diff --git a/BallanceTASEditor/App.xaml b/BallanceTASEditor/App.xaml
index 0a66cf4..949af02 100644
--- a/BallanceTASEditor/App.xaml
+++ b/BallanceTASEditor/App.xaml
@@ -4,6 +4,11 @@
xmlns:local="clr-namespace:BallanceTASEditor"
StartupUri="MainWindow.xaml">
-
+
+
+
+
+
+
diff --git a/BallanceTASEditor/App.xaml.cs b/BallanceTASEditor/App.xaml.cs
index cf4f60b..4d2bd46 100644
--- a/BallanceTASEditor/App.xaml.cs
+++ b/BallanceTASEditor/App.xaml.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
@@ -25,6 +26,17 @@ namespace BallanceTASEditor {
}
};
#endif
+
+ // init configure manager
+ GlobalVariable.configManager = new Core.ConfigManager("ballance-tas-editor.cfg", new Dictionary() {
+ {"Language", CultureInfo.CurrentCulture.ThreeLetterWindowsLanguageName},
+ {"ItemCount", "15"},
+ {"IsHorizonLayout", "True"}
+ });
+
+ // init i18n
+ Core.I18NProcessor.ChangeLanguage(GlobalVariable.configManager.Configuration["Language"]);
+
}
private void UncatchedErrorHandle(string message, string stackTrace) {
@@ -50,7 +62,10 @@ namespace BallanceTASEditor {
;//skip
}
- MessageBox.Show("A fatal error occurs. The application should exit. Please send the error log, reproduce step and corresponding TAS file(is possible) to use to help fixing this problem.", "Ballance TAS Editor", MessageBoxButton.OK, MessageBoxImage.Error);
+ MessageBox.Show("A fatal error occurs. The application should exit. Please send the error log, reproduce step and corresponding TAS file(if possible) to developer to help fixing this problem.",
+ "Ballance TAS Editor",
+ MessageBoxButton.OK, MessageBoxImage.Error
+ );
App.Current.Shutdown();
}
diff --git a/BallanceTASEditor/BallanceTASEditor.csproj b/BallanceTASEditor/BallanceTASEditor.csproj
index 47518ce..b6c04f6 100644
--- a/BallanceTASEditor/BallanceTASEditor.csproj
+++ b/BallanceTASEditor/BallanceTASEditor.csproj
@@ -38,6 +38,9 @@
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
@@ -61,9 +64,12 @@
Designer
+
+
+
AddItem.xaml
@@ -75,6 +81,14 @@
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
@@ -126,5 +140,6 @@
Settings.Designer.cs
+
\ No newline at end of file
diff --git a/BallanceTASEditor/Core/ConfigManager.cs b/BallanceTASEditor/Core/ConfigManager.cs
new file mode 100644
index 0000000..1d26303
--- /dev/null
+++ b/BallanceTASEditor/Core/ConfigManager.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+using Newtonsoft.Json;
+
+namespace BallanceTASEditor.Core {
+ public class ConfigManager {
+
+ public ConfigManager(string fileName, Dictionary defaultValue) {
+ _fileName = fileName;
+ _defaultValue = JsonConvert.SerializeObject(defaultValue);
+
+ Configuration = Read();
+ }
+
+ string _fileName;
+ string _defaultValue;
+ public Dictionary Configuration;
+
+ Dictionary Read() {
+ if (!File.Exists(Path.Combine(Environment.CurrentDirectory, _fileName)))
+ Init();
+
+ Dictionary data;
+ using (StreamReader fs = new StreamReader(Path.Combine(Environment.CurrentDirectory, _fileName), Encoding.UTF8)) {
+ data = JsonConvert.DeserializeObject>(fs.ReadToEnd());
+ fs.Close();
+ }
+
+ return data;
+ }
+
+ void Init() {
+ using (StreamWriter fs = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _fileName), false, Encoding.UTF8)) {
+ fs.Write(_defaultValue);
+ fs.Close();
+ }
+ }
+
+ public void Save() {
+ using (StreamWriter fs = new StreamWriter(Path.Combine(Environment.CurrentDirectory, _fileName), false, Encoding.UTF8)) {
+ fs.Write(JsonConvert.SerializeObject(this.Configuration));
+ fs.Close();
+ }
+ }
+
+ }
+
+}
diff --git a/BallanceTASEditor/Core/I18NProcessor.cs b/BallanceTASEditor/Core/I18NProcessor.cs
new file mode 100644
index 0000000..24d756c
--- /dev/null
+++ b/BallanceTASEditor/Core/I18NProcessor.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+
+namespace BallanceTASEditor.Core {
+ public static class I18NProcessor {
+
+ public static string GetI18N(string key, params string[] parameters) {
+ try {
+ var cache = (string)(App.Current.Resources[key]);
+ return string.Format(cache, parameters);
+ } catch (Exception) {
+ return "";
+ }
+ }
+
+ public static void ChangeLanguage(string target) {
+ ResourceDictionary langRd = null;
+ try {
+ langRd =
+ Application.LoadComponent(
+ new Uri(@"Language/" + target + ".xaml", UriKind.Relative))
+ as ResourceDictionary;
+ } catch {
+ ;
+ }
+
+ if (langRd != null) {
+ if (App.Current.Resources.MergedDictionaries.Count > 0) {
+ App.Current.Resources.MergedDictionaries.Clear();
+ }
+ App.Current.Resources.MergedDictionaries.Add(langRd);
+ }
+
+ }
+
+ }
+}
diff --git a/BallanceTASEditor/GlobalVariable.cs b/BallanceTASEditor/GlobalVariable.cs
new file mode 100644
index 0000000..6373825
--- /dev/null
+++ b/BallanceTASEditor/GlobalVariable.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BallanceTASEditor {
+ public class GlobalVariable {
+
+ public static Core.ConfigManager configManager;
+
+ }
+}
diff --git a/BallanceTASEditor/Language/CHS.xaml b/BallanceTASEditor/Language/CHS.xaml
new file mode 100644
index 0000000..79e8b19
--- /dev/null
+++ b/BallanceTASEditor/Language/CHS.xaml
@@ -0,0 +1,55 @@
+
+
+ Ballance TAS 编辑器
+
+ 文件
+ 打开
+ 保存
+ 另存为...
+ 关闭
+
+ 编辑
+ 撤销
+ 重做
+ 项个数
+ 覆盖式粘贴
+
+ 帮助
+ 汇报漏洞
+ 关于
+
+ 打开一个 TAS 文件以编辑
+
+ 选择模式
+ 填充模式
+ 画笔模式
+
+ 选择模式
+ 填充模式
+ 画笔模式
+ 已选择:
+
+
+ 帧
+ 间隔时间
+
+ 设置
+ 不设置
+ 剪切
+ 复制
+ 粘贴于后方
+ 粘贴于前方
+ 删除
+ 向后删除
+ 向前删除
+ 在后方添加新项
+ 在前方添加新项
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BallanceTASEditor/Language/DefaultLanguage.xaml b/BallanceTASEditor/Language/DefaultLanguage.xaml
new file mode 100644
index 0000000..67689fa
--- /dev/null
+++ b/BallanceTASEditor/Language/DefaultLanguage.xaml
@@ -0,0 +1,55 @@
+
+
+ Ballance TAS Editor
+
+ File
+ Open
+ Save
+ Save As ...
+ Close
+
+ Edit
+ Undo
+ Redo
+ Item Count
+ Overwritten Paste
+
+ Help
+ Report Bugs
+ About
+
+ Open a TAS file for editing
+
+ Select mode
+ Fill mode
+ Draw mode
+
+ Select mode
+ Fill mode
+ Draw mode
+ Selected:
+
+
+ Frame
+ Delta Time
+
+ Set
+ Unset
+ Cut
+ Copy
+ Paste after this
+ Paste before this
+ Delete
+ Delete next frame
+ Delete last frame
+ Add blank item after this
+ Add blank item before this
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BallanceTASEditor/MainWindow.xaml b/BallanceTASEditor/MainWindow.xaml
index 2087581..9caa619 100644
--- a/BallanceTASEditor/MainWindow.xaml
+++ b/BallanceTASEditor/MainWindow.xaml
@@ -7,7 +7,7 @@
xmlns:controls="clr-namespace:BallanceTASEditor.UI"
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"
mc:Ignorable="d"
- Title="Ballance TAS Editor" Height="500" Width="800" KeyUp="funcWindow_KeyUp"
+ Title="{DynamicResource ui_MainWindow_Title}" Height="500" Width="800" KeyUp="funcWindow_KeyUp"
input:InputMethod.IsInputMethodEnabled="False">
@@ -18,25 +18,25 @@
-
+
@@ -53,7 +53,7 @@
-
+
@@ -133,11 +133,11 @@
-
-
-
+
+
+
-
+
diff --git a/BallanceTASEditor/UI/OperationEnum.cs b/BallanceTASEditor/UI/OperationEnum.cs
index c554ed5..bdb3474 100644
--- a/BallanceTASEditor/UI/OperationEnum.cs
+++ b/BallanceTASEditor/UI/OperationEnum.cs
@@ -7,6 +7,7 @@ namespace BallanceTASEditor.UI {
public enum OperationEnum {
Set,
Unset,
+ Cut,
Copy,
PasteAfter,
PasteBefore,
diff --git a/BallanceTASEditor/UI/TASFlow.xaml b/BallanceTASEditor/UI/TASFlow.xaml
index 4e25737..9868791 100644
--- a/BallanceTASEditor/UI/TASFlow.xaml
+++ b/BallanceTASEditor/UI/TASFlow.xaml
@@ -9,19 +9,20 @@
-
-
+
+
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
@@ -44,8 +45,8 @@
-
-
+
+
diff --git a/BallanceTASEditor/UI/TASFlow.xaml.cs b/BallanceTASEditor/UI/TASFlow.xaml.cs
index 0a82be7..9ce173b 100644
--- a/BallanceTASEditor/UI/TASFlow.xaml.cs
+++ b/BallanceTASEditor/UI/TASFlow.xaml.cs
@@ -88,6 +88,7 @@ namespace BallanceTASEditor.UI {
uiDataMenu_Set.IsEnabled = showFill;
uiDataMenu_Unset.IsEnabled = showFill;
+ uiDataMenu_Cut.IsEnabled = showCursorCopyDelete;
uiDataMenu_Copy.IsEnabled = showCursorCopyDelete;
uiDataMenu_Delete.IsEnabled = showCursorCopyDelete;
uiDataMenu_DeleteAfter.IsEnabled = showCursorPasteAddDeleteOne;
@@ -180,6 +181,10 @@ namespace BallanceTASEditor.UI {
NewOperation?.Invoke(OperationEnum.Unset);
}
+ private void uiDataMenu_Cut_Click(object sender, RoutedEventArgs e) {
+ NewOperation?.Invoke(OperationEnum.Cut);
+ }
+
private void uiDataMenu_Copy_Click(object sender, RoutedEventArgs e) {
NewOperation?.Invoke(OperationEnum.Copy);
}
diff --git a/BallanceTASEditor/UI/TASViewer.cs b/BallanceTASEditor/UI/TASViewer.cs
index 73eaf17..46cd6e4 100644
--- a/BallanceTASEditor/UI/TASViewer.cs
+++ b/BallanceTASEditor/UI/TASViewer.cs
@@ -161,6 +161,25 @@ namespace BallanceTASEditor.UI {
RefreshDisplay();
}
break;
+ case OperationEnum.Cut: {
+ // cut is a hybrid operation, first, do copy
+ // then delete selected item
+ // due to copy is not affect TASFile and only delete oper affect it
+ // so this is a revocable oper
+ var data = new LinkedList();
+ mFile.Copy(mSelectionHelp.GetRange(), data);
+ if (!ClipboardUtil.SetFrameData(data)) {
+ MessageBox.Show("Fail to cut due to unknow reason!");
+ break; // if fail to cut, do not delete selected items.
+ }
+
+ // do delete
+ mFile.Remove(mSelectionHelp.GetRange());
+ mSelectionHelp.Reset();
+ updateSliderRange();
+ RefreshDisplay();
+ }
+ break;
case OperationEnum.Copy: {
var data = new LinkedList();
mFile.Copy(mSelectionHelp.GetRange(), data);
diff --git a/BallanceTASEditor/packages.config b/BallanceTASEditor/packages.config
index ea2c82d..83372d1 100644
--- a/BallanceTASEditor/packages.config
+++ b/BallanceTASEditor/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file