From f61c658c61336761cf0c41239fd8378d282b135e Mon Sep 17 00:00:00 2001 From: B1ackSand Date: Wed, 4 Oct 2023 13:32:00 +0800 Subject: [PATCH] add sqlite support. format xaml code. --- LiaoTian_Cup/Dictionary/I18n/Lang.Designer.cs | 2 +- LiaoTian_Cup/Dictionary/I18n/Lang.resx | 2 +- LiaoTian_Cup/Dictionary/I18n/Lang.zh.resx | 2 +- LiaoTian_Cup/Helper/CSVKit.cs | 3 +- LiaoTian_Cup/Helper/DbHelper.cs | 62 ++++ LiaoTian_Cup/Helper/FileData.cs | 80 +++-- LiaoTian_Cup/Helper/MyImage.cs | 39 --- LiaoTian_Cup/Helper/RandomKit.cs | 3 - LiaoTian_Cup/Helper/RelayCommand.cs | 67 ---- LiaoTian_Cup/Helper/RelayNoCommand.cs | 67 ---- LiaoTian_Cup/LiaoTian_Cup.csproj | 28 +- LiaoTian_Cup/MainPage.xaml.cs | 12 - LiaoTian_Cup/MainWindow.xaml | 36 ++- LiaoTian_Cup/MainWindow.xaml.cs | 19 +- LiaoTian_Cup/Mode/DoublesModeWindow.xaml.cs | 77 ++--- LiaoTian_Cup/Mode/NegativeFactorWindow.xaml | 271 ++++++++++------ .../Mode/NegativeFactorWindow.xaml.cs | 80 +++-- LiaoTian_Cup/Mode/RandomMutationWindow.xaml | 216 ++++++++----- .../Mode/RandomMutationWindow.xaml.cs | 33 +- LiaoTian_Cup/Mode/SingleModeWindow.xaml | 300 +++++++++++------- LiaoTian_Cup/Mode/SingleModeWindow.xaml.cs | 49 ++- LiaoTian_Cup/Mode/USuckModeWindow.xaml.cs | 89 +++--- .../Overview/ShowDoublesDetail.xaml.cs | 14 +- LiaoTian_Cup/Overview/ShowNegativeDetail.xaml | 189 ++++++++--- .../Overview/ShowNegativeDetail.xaml.cs | 15 +- LiaoTian_Cup/Overview/ShowRMDetail.xaml | 269 +++++++++++++--- LiaoTian_Cup/Overview/ShowRMDetail.xaml.cs | 14 +- LiaoTian_Cup/Overview/ShowSingleDetail.xaml | 196 +++++++++--- .../Overview/ShowSingleDetail.xaml.cs | 14 +- LiaoTian_Cup/Overview/ShowUSuckDetail.xaml.cs | 14 +- ...0\345\237\272\347\241\200\345\272\223.csv" | 7 - ...0\345\255\220\345\210\227\350\241\250.csv" | 51 --- ...0\345\237\272\347\241\200\345\272\223.csv" | 14 - LiaoTian_Cup/Resources/database.db | Bin 0 -> 27648 bytes LiaoTian_Cup/Resources/factor/desktop.ini | 2 - ...7\345\221\275\346\261\262\345\217\226.png" | Bin 6723 -> 6382 bytes ...2\351\207\215\347\224\237\350\200\205.png" | Bin 9397 -> 11171 bytes .../Resources/group_FactorList_Score.csv | 48 --- ...5\345\256\230\345\210\227\350\241\250.csv" | 10 - ...5\345\256\230\345\210\227\350\241\250.csv" | 8 - ...0\345\237\272\347\241\200\345\272\223.csv" | 5 - ...0\346\234\211\345\234\260\345\233\276.csv" | 12 - ...2\345\233\240\345\255\220\345\272\223.csv" | 14 - .../Resources/\347\224\265\350\204\221AI.csv" | 19 -- ...0\345\255\220\345\210\227\350\241\250.csv" | 48 --- ...0\345\237\272\347\241\200\345\272\223.csv" | 6 - ...1\345\217\230\345\210\227\350\241\250.csv" | 120 ------- README.md | 4 +- README_ZH.md | 2 + 49 files changed, 1314 insertions(+), 1318 deletions(-) create mode 100644 LiaoTian_Cup/Helper/DbHelper.cs delete mode 100644 LiaoTian_Cup/Helper/MyImage.cs delete mode 100644 LiaoTian_Cup/Helper/RelayCommand.cs delete mode 100644 LiaoTian_Cup/Helper/RelayNoCommand.cs delete mode 100644 "LiaoTian_Cup/Resources/USuck\345\244\232\347\272\277\345\233\240\345\255\220\345\237\272\347\241\200\345\272\223.csv" delete mode 100644 "LiaoTian_Cup/Resources/USuck\347\252\201\345\217\230\345\233\240\345\255\220\345\210\227\350\241\250.csv" delete mode 100644 "LiaoTian_Cup/Resources/USuck\347\272\257\346\255\243\351\235\242\345\233\240\345\255\220\345\237\272\347\241\200\345\272\223.csv" create mode 100644 LiaoTian_Cup/Resources/database.db delete mode 100644 LiaoTian_Cup/Resources/factor/desktop.ini delete mode 100644 LiaoTian_Cup/Resources/group_FactorList_Score.csv delete mode 100644 "LiaoTian_Cup/Resources/\345\205\210\345\207\272\346\214\207\346\214\245\345\256\230\345\210\227\350\241\250.csv" delete mode 100644 "LiaoTian_Cup/Resources/\345\220\216\345\207\272\346\214\207\346\214\245\345\256\230\345\210\227\350\241\250.csv" delete mode 100644 "LiaoTian_Cup/Resources/\345\244\232\347\272\277\345\233\240\345\255\220\345\237\272\347\241\200\345\272\223.csv" delete mode 100644 "LiaoTian_Cup/Resources/\346\211\200\346\234\211\345\234\260\345\233\276.csv" delete mode 100644 "LiaoTian_Cup/Resources/\346\255\243\351\235\242\345\233\240\345\255\220\345\272\223.csv" delete mode 100644 "LiaoTian_Cup/Resources/\347\224\265\350\204\221AI.csv" delete mode 100644 "LiaoTian_Cup/Resources/\347\252\201\345\217\230\345\233\240\345\255\220\345\210\227\350\241\250.csv" delete mode 100644 "LiaoTian_Cup/Resources/\347\272\257\346\255\243\351\235\242\345\233\240\345\255\220\345\237\272\347\241\200\345\272\223.csv" delete mode 100644 "LiaoTian_Cup/Resources/\350\207\252\351\200\211\347\252\201\345\217\230\345\210\227\350\241\250.csv" diff --git a/LiaoTian_Cup/Dictionary/I18n/Lang.Designer.cs b/LiaoTian_Cup/Dictionary/I18n/Lang.Designer.cs index c9c74dd..f5779d8 100644 --- a/LiaoTian_Cup/Dictionary/I18n/Lang.Designer.cs +++ b/LiaoTian_Cup/Dictionary/I18n/Lang.Designer.cs @@ -286,7 +286,7 @@ public static string LangBtn { } /// - /// 查找类似 聊天杯 LiaoTian_Cup v0.2.2 - Programmed by B1ackSand 的本地化字符串。 + /// 查找类似 聊天杯 LiaoTian_Cup v0.2.3 - Programmed by B1ackSand 的本地化字符串。 /// public static string MainWindowTitle { get { diff --git a/LiaoTian_Cup/Dictionary/I18n/Lang.resx b/LiaoTian_Cup/Dictionary/I18n/Lang.resx index 77a0800..5c67d56 100644 --- a/LiaoTian_Cup/Dictionary/I18n/Lang.resx +++ b/LiaoTian_Cup/Dictionary/I18n/Lang.resx @@ -196,7 +196,7 @@ you need to pick commander - 聊天杯 LiaoTian_Cup v0.2.2 - Programmed by B1ackSand + 聊天杯 LiaoTian_Cup v0.2.3 - Programmed by B1ackSand 3 mutators mode diff --git a/LiaoTian_Cup/Dictionary/I18n/Lang.zh.resx b/LiaoTian_Cup/Dictionary/I18n/Lang.zh.resx index 107e67b..adc7b77 100644 --- a/LiaoTian_Cup/Dictionary/I18n/Lang.zh.resx +++ b/LiaoTian_Cup/Dictionary/I18n/Lang.zh.resx @@ -196,7 +196,7 @@ 未选择指挥官 - 聊天杯 LiaoTian_Cup v0.2.2 - Programmed by B1ackSand + 聊天杯 LiaoTian_Cup v0.2.3 - Programmed by B1ackSand 3因子模式 diff --git a/LiaoTian_Cup/Helper/CSVKit.cs b/LiaoTian_Cup/Helper/CSVKit.cs index f96c08e..8d02173 100644 --- a/LiaoTian_Cup/Helper/CSVKit.cs +++ b/LiaoTian_Cup/Helper/CSVKit.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Data; using System.IO; using System.Text; @@ -8,7 +7,7 @@ namespace LiaoTian_Cup.Helper { class CSVKit { - // TODO 读写锁的问题存在 + // 已废弃使用 //两个实现 public static List Csv2Dt(string filePath, List list) { diff --git a/LiaoTian_Cup/Helper/DbHelper.cs b/LiaoTian_Cup/Helper/DbHelper.cs new file mode 100644 index 0000000..ab19911 --- /dev/null +++ b/LiaoTian_Cup/Helper/DbHelper.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Data.SQLite; + +namespace LiaoTian_Cup.Helper; + +public class DbHelper +{ + private const string ConnectionString = @"Data Source=./Resources/database.db;"; + + private static readonly SQLiteConnection Conn = new SQLiteConnection(ConnectionString); + + public static List GetColumnData(string tableName, List list) + { + Conn.Open(); + try + { + using SQLiteCommand cmd = new SQLiteCommand(Conn); + cmd.CommandText = $"SELECT * FROM {tableName}"; + using SQLiteDataReader reader = cmd.ExecuteReader(); + while (reader.Read()) + { + var str = Convert.ToString(reader[0]); + list.Add(str); + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + Conn.Close(); + return list; + } + + public static List GetListData(string tableName,int columnCount, List list) + { + Conn.Open(); + try + { + using SQLiteCommand cmd = new SQLiteCommand(Conn); + cmd.CommandText = $"SELECT * FROM {tableName}"; + using SQLiteDataReader reader = cmd.ExecuteReader(); + while (reader.Read()) + { + string[] rowStrings = new string[columnCount]; + for (int i = 0; i < columnCount; i++) + { + rowStrings[i] = Convert.ToString(reader[i]); + } + list.Add(rowStrings); + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + Conn.Close(); + return list; + } +} \ No newline at end of file diff --git a/LiaoTian_Cup/Helper/FileData.cs b/LiaoTian_Cup/Helper/FileData.cs index cad7490..055c55d 100644 --- a/LiaoTian_Cup/Helper/FileData.cs +++ b/LiaoTian_Cup/Helper/FileData.cs @@ -12,57 +12,79 @@ public class FileData { //公共信息提取 //存放从自选突变CSV中得到的数据 - public List mutationList = new List(); + public static List mutationList = new List(); //存放从突变因子CSV中得到的数据 - public List mutationFactorList = new List(); + public static List mutationFactorList = new List(); //存放先出指挥官CSV中得到的数据 - public List beforeCommanderInfo = new List(); + public static List beforeCommanderInfo = new List(); //存放后出指挥官CSV中得到的数据 - public List afterCommanderInfo = new List(); + public static List afterCommanderInfo = new List(); //存放所有的人机CSV中得到的数据 - public List botInfo = new List(); + public static List botInfo = new List(); //存放因子库CSV中得到的数据 - public List baseNegativeFactorInfo = new List(); - public List baseMultiFactorInfo = new List(); - public List negativeFactorInfo = new List(); - public List scoreFactorList = new List(); + public static List baseNegativeFactorInfo = new List(); + public static List baseMultiFactorInfo = new List(); + public static List negativeFactorInfo = new List(); + public static List scoreFactorList = new List(); //存放USuck模式的CSV数据 - public List usuckNegativeFactorInfo = new List(); - public List usuckMultiFactorInfo = new List(); - public List usuckFactorList = new List(); + public static List usuckNegativeFactorInfo = new List(); + public static List usuckMultiFactorInfo = new List(); + public static List usuckFactorList = new List(); //存放地图数据 - public List mapsInfo = new List(); + public static List mapsInfo = new List(); public FileData() { - ReadCsv(); + ReadDataBase(); } //读取csv - private void ReadCsv() + //private void ReadCsv() + //{ + // //初始化窗口时即拿数据 + // CSVKit.Csv2Dt(Dictionary.FilePath.mutationFilePath, mutationList); + // CSVKit.Csv2Dt(Dictionary.FilePath.scoreFactorPath, scoreFactorList); + // CSVKit.Csv2Dt(Dictionary.FilePath.mutationFactorPath, mutationFactorList); + // CSVKit.Csv2Dt(Dictionary.FilePath.beforeCommanderFilePath, beforeCommanderInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.afterCommanderFilePath, afterCommanderInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.aIFilePath, botInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.baseNegativeFactorFilePath, baseNegativeFactorInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.baseMultiFactorFilePath, baseMultiFactorInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.mapsFilePath, mapsInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.negativeFactorFilePath, negativeFactorInfo); + + // //USuck + // CSVKit.Csv2Dt(Dictionary.FilePath.usuckFactorPath, usuckFactorList); + // CSVKit.Csv2Dt(Dictionary.FilePath.usuckMultiPath, usuckMultiFactorInfo); + // CSVKit.Csv2Dt(Dictionary.FilePath.usuckNegativePath, usuckNegativeFactorInfo); + //} + + //读取数据库 + private void ReadDataBase() { - //初始化窗口时即拿数据 - CSVKit.Csv2Dt(Dictionary.FilePath.mutationFilePath, mutationList); - CSVKit.Csv2Dt(Dictionary.FilePath.mutationFactorPath, mutationFactorList); - CSVKit.Csv2Dt(Dictionary.FilePath.beforeCommanderFilePath, beforeCommanderInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.afterCommanderFilePath, afterCommanderInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.aIFilePath, botInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.baseNegativeFactorFilePath, baseNegativeFactorInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.baseMultiFactorFilePath, baseMultiFactorInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.mapsFilePath, mapsInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.negativeFactorFilePath, negativeFactorInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.scoreFactorPath, scoreFactorList); + DbHelper.GetListData("global_weeklymutations", 5, mutationList); + DbHelper.GetListData("group_MutatorList_Cost", 3, scoreFactorList); + + DbHelper.GetColumnData("global_mutatorlist", mutationFactorList); + DbHelper.GetColumnData("global_cmdroldlist", beforeCommanderInfo); + DbHelper.GetColumnData("global_cmdrnewlist", afterCommanderInfo); + DbHelper.GetColumnData("ai_table", botInfo); + DbHelper.GetColumnData("doubles_negativelist", baseNegativeFactorInfo); + DbHelper.GetColumnData("doubles_multilist", baseMultiFactorInfo); + DbHelper.GetColumnData("global_maplist", mapsInfo); + DbHelper.GetColumnData("global_negativelist", negativeFactorInfo); //USuck - CSVKit.Csv2Dt(Dictionary.FilePath.usuckFactorPath, usuckFactorList); - CSVKit.Csv2Dt(Dictionary.FilePath.usuckMultiPath, usuckMultiFactorInfo); - CSVKit.Csv2Dt(Dictionary.FilePath.usuckNegativePath, usuckNegativeFactorInfo); + DbHelper.GetColumnData("usuck_mutatorlist", usuckFactorList); + DbHelper.GetColumnData("usuck_multilist", usuckMultiFactorInfo); + DbHelper.GetColumnData("usuck_negativelist", usuckNegativeFactorInfo); + } } } diff --git a/LiaoTian_Cup/Helper/MyImage.cs b/LiaoTian_Cup/Helper/MyImage.cs deleted file mode 100644 index 8d69199..0000000 --- a/LiaoTian_Cup/Helper/MyImage.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Media; - -namespace LiaoTian_Cup.Helper -{ - public partial class MyImage : System.Windows.Controls.Image - { - public MyImage() - { - } - public bool IsSelect;//是否选中 - /// - /// 重绘 - /// - protected override void OnRender(DrawingContext dc) - { - base.OnRender(dc); - - if (IsSelect) - { - try - { - //绘制边框 - Rect rect = new Rect(0, 0, this.ActualWidth, this.ActualHeight); - Pen p = new Pen(new SolidColorBrush(Colors.Red), 2); - p.DashStyle = DashStyles.Dot; - p.StartLineCap = PenLineCap.Triangle; - dc.DrawRectangle(Brushes.Transparent, p, rect); - } - catch { } - } - } - } -} diff --git a/LiaoTian_Cup/Helper/RandomKit.cs b/LiaoTian_Cup/Helper/RandomKit.cs index 584ea87..7f507c9 100644 --- a/LiaoTian_Cup/Helper/RandomKit.cs +++ b/LiaoTian_Cup/Helper/RandomKit.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace LiaoTian_Cup.Helper { diff --git a/LiaoTian_Cup/Helper/RelayCommand.cs b/LiaoTian_Cup/Helper/RelayCommand.cs deleted file mode 100644 index 966d41b..0000000 --- a/LiaoTian_Cup/Helper/RelayCommand.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; - -namespace LiaoTian_Cup.Helper -{ - //命令绑定类 - public class RelayCommand : ICommand - { - /// - /// 命令是否能够执行 - /// - readonly Func _canExecute; - - /// - /// 命令需要执行的方法 - /// - readonly Action _execute; - - /// - /// 构造函数 - /// - /// - /// - public RelayCommand(Action action, Func canExecute) - { - _execute = action; - _canExecute = canExecute; - } - - - public bool CanExecute(object parameter) - { - if(_canExecute == null) - { - return true; - } - return _canExecute(); - } - - public void Execute(object parameter) - { - _execute(parameter); - } - - public event EventHandler CanExecuteChanged - { - add - { - if(_canExecute != null) - { - CommandManager.RequerySuggested += value; - } - } - remove - { - if (_canExecute != null) - { - CommandManager.RequerySuggested -= value; - } - } - } - } -} diff --git a/LiaoTian_Cup/Helper/RelayNoCommand.cs b/LiaoTian_Cup/Helper/RelayNoCommand.cs deleted file mode 100644 index 048fefa..0000000 --- a/LiaoTian_Cup/Helper/RelayNoCommand.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; - -namespace LiaoTian_Cup.Helper -{ - //命令绑定类 - public class RelayNoCommand : ICommand - { - /// - /// 命令是否能够执行 - /// - readonly Func _canExecute; - - /// - /// 命令需要执行的方法 - /// - readonly Action _execute; - - /// - /// 构造函数 - /// - /// - /// - public RelayNoCommand(Action action, Func canExecute) - { - _execute = action; - _canExecute = canExecute; - } - - - public bool CanExecute(object parameter) - { - if (_canExecute == null) - { - return true; - } - return _canExecute(); - } - - public void Execute(object parameter) - { - _execute(); - } - - public event EventHandler CanExecuteChanged - { - add - { - if (_canExecute != null) - { - CommandManager.RequerySuggested += value; - } - } - remove - { - if (_canExecute != null) - { - CommandManager.RequerySuggested -= value; - } - } - } - } -} diff --git a/LiaoTian_Cup/LiaoTian_Cup.csproj b/LiaoTian_Cup/LiaoTian_Cup.csproj index dfd6442..a45fdff 100644 --- a/LiaoTian_Cup/LiaoTian_Cup.csproj +++ b/LiaoTian_Cup/LiaoTian_Cup.csproj @@ -9,7 +9,7 @@ win-x64 true Resources\Logo\icon.ico - 0.2.2 + 0.2.3 B1ackSand app.manifest README.md @@ -51,6 +51,7 @@ + @@ -193,6 +194,9 @@ + + Always + Always @@ -235,9 +239,6 @@ Always - - Always - Always @@ -246,6 +247,7 @@ + @@ -600,24 +602,6 @@ Always - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - diff --git a/LiaoTian_Cup/MainPage.xaml.cs b/LiaoTian_Cup/MainPage.xaml.cs index 66220de..ee50fd1 100644 --- a/LiaoTian_Cup/MainPage.xaml.cs +++ b/LiaoTian_Cup/MainPage.xaml.cs @@ -1,20 +1,8 @@ using LiaoTian_Cup.Dictionary.I18n; -using LiaoTian_Cup.Helper; using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace LiaoTian_Cup { diff --git a/LiaoTian_Cup/MainWindow.xaml b/LiaoTian_Cup/MainWindow.xaml index f2a3c28..5a1192f 100644 --- a/LiaoTian_Cup/MainWindow.xaml +++ b/LiaoTian_Cup/MainWindow.xaml @@ -1,20 +1,28 @@ - + - + - + diff --git a/LiaoTian_Cup/MainWindow.xaml.cs b/LiaoTian_Cup/MainWindow.xaml.cs index 483dc6c..0607db7 100644 --- a/LiaoTian_Cup/MainWindow.xaml.cs +++ b/LiaoTian_Cup/MainWindow.xaml.cs @@ -1,18 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Interop; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using System.Windows; +using LiaoTian_Cup.Helper; namespace LiaoTian_Cup { @@ -23,6 +10,8 @@ public partial class MainWindow : Window { public MainWindow() { + // 初始化数据库读取 + _ = new FileData(); InitializeComponent(); this.Height = SystemParameters.PrimaryScreenHeight * (910d / 1080); this.Width = SystemParameters.PrimaryScreenWidth * (1180d / 1920); diff --git a/LiaoTian_Cup/Mode/DoublesModeWindow.xaml.cs b/LiaoTian_Cup/Mode/DoublesModeWindow.xaml.cs index 01b5015..871101d 100644 --- a/LiaoTian_Cup/Mode/DoublesModeWindow.xaml.cs +++ b/LiaoTian_Cup/Mode/DoublesModeWindow.xaml.cs @@ -3,18 +3,10 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace LiaoTian_Cup { @@ -33,7 +25,6 @@ public partial class DoublesModeWindow : Page, INotifyPropertyChanged //初始化工具 - readonly FileData fd = new FileData(); readonly RandomKit rk = new RandomKit(); string factorDir = Dictionary.FilePath.factorDir; string mapDir = Dictionary.FilePath.mapDir; @@ -88,8 +79,8 @@ private string IsRandAIFunc() if (isRandAI) { Random rand = new Random(); - int number = rand.Next(0, fd.botInfo.Count); - return Dictionary.I18n.Lang.ResourceManager.GetString(fd.botInfo[number]); + int number = rand.Next(0, FileData.botInfo.Count); + return Dictionary.I18n.Lang.ResourceManager.GetString(FileData.botInfo[number]); } else { @@ -156,13 +147,13 @@ private void ShowRandomMaps() { hasSelectMap = new Image(); FlashHasSelectMap(); - List randNums = rk.GenerateXRandomNum(3, fd.mapsInfo.Count); - MapImg1.Source = new BitmapImage(new Uri(mapDir + fd.mapsInfo[randNums[0]] + ".png", UriKind.Relative)); - MapImg2.Source = new BitmapImage(new Uri(mapDir + fd.mapsInfo[randNums[1]] + ".png", UriKind.Relative)); - MapImg3.Source = new BitmapImage(new Uri(mapDir + fd.mapsInfo[randNums[2]] + ".png", UriKind.Relative)); - MapName1.Text = Dictionary.I18n.Lang.ResourceManager.GetString(fd.mapsInfo[randNums[0]]); - MapName2.Text = Dictionary.I18n.Lang.ResourceManager.GetString(fd.mapsInfo[randNums[1]]); - MapName3.Text = Dictionary.I18n.Lang.ResourceManager.GetString(fd.mapsInfo[randNums[2]]); + List randNums = rk.GenerateXRandomNum(3, FileData.mapsInfo.Count); + MapImg1.Source = new BitmapImage(new Uri(mapDir + FileData.mapsInfo[randNums[0]] + ".png", UriKind.Relative)); + MapImg2.Source = new BitmapImage(new Uri(mapDir + FileData.mapsInfo[randNums[1]] + ".png", UriKind.Relative)); + MapImg3.Source = new BitmapImage(new Uri(mapDir + FileData.mapsInfo[randNums[2]] + ".png", UriKind.Relative)); + MapName1.Text = Dictionary.I18n.Lang.ResourceManager.GetString(FileData.mapsInfo[randNums[0]]); + MapName2.Text = Dictionary.I18n.Lang.ResourceManager.GetString(FileData.mapsInfo[randNums[1]]); + MapName3.Text = Dictionary.I18n.Lang.ResourceManager.GetString(FileData.mapsInfo[randNums[2]]); } //点击地图图片事件响应 @@ -227,22 +218,22 @@ private void Button_MapConfirm_Click(object sender, RoutedEventArgs e) private void ShowBaseNegativeFactor() { //相对路径URI指定因子图片来源 - NegativeFactor1.Source = new BitmapImage(new Uri(factorDir + fd.baseNegativeFactorInfo[0] + ".png", UriKind.Relative)); - NegativeFactor2.Source = new BitmapImage(new Uri(factorDir + fd.baseNegativeFactorInfo[1] + ".png", UriKind.Relative)); - NegativeFactor3.Source = new BitmapImage(new Uri(factorDir + fd.baseNegativeFactorInfo[2] + ".png", UriKind.Relative)); - NegativeFactor4.Source = new BitmapImage(new Uri(factorDir + fd.baseNegativeFactorInfo[3] + ".png", UriKind.Relative)); - NegativeFactor5.Source = new BitmapImage(new Uri(factorDir + fd.baseNegativeFactorInfo[4] + ".png", UriKind.Relative)); - NegativeFactor6.Source = new BitmapImage(new Uri(factorDir + fd.baseNegativeFactorInfo[5] + ".png", UriKind.Relative)); + NegativeFactor1.Source = new BitmapImage(new Uri(factorDir + FileData.baseNegativeFactorInfo[0] + ".png", UriKind.Relative)); + NegativeFactor2.Source = new BitmapImage(new Uri(factorDir + FileData.baseNegativeFactorInfo[1] + ".png", UriKind.Relative)); + NegativeFactor3.Source = new BitmapImage(new Uri(factorDir + FileData.baseNegativeFactorInfo[2] + ".png", UriKind.Relative)); + NegativeFactor4.Source = new BitmapImage(new Uri(factorDir + FileData.baseNegativeFactorInfo[3] + ".png", UriKind.Relative)); + NegativeFactor5.Source = new BitmapImage(new Uri(factorDir + FileData.baseNegativeFactorInfo[4] + ".png", UriKind.Relative)); + NegativeFactor6.Source = new BitmapImage(new Uri(factorDir + FileData.baseNegativeFactorInfo[5] + ".png", UriKind.Relative)); } //多线因子显示 private void ShowBaseMultiFactor() { - MultiFactor1.Source = new BitmapImage(new Uri(factorDir + fd.baseMultiFactorInfo[0] + ".png", UriKind.Relative)); - MultiFactor2.Source = new BitmapImage(new Uri(factorDir + fd.baseMultiFactorInfo[1] + ".png", UriKind.Relative)); - MultiFactor3.Source = new BitmapImage(new Uri(factorDir + fd.baseMultiFactorInfo[2] + ".png", UriKind.Relative)); - MultiFactor4.Source = new BitmapImage(new Uri(factorDir + fd.baseMultiFactorInfo[3] + ".png", UriKind.Relative)); - MultiFactor5.Source = new BitmapImage(new Uri(factorDir + fd.baseMultiFactorInfo[4] + ".png", UriKind.Relative)); + MultiFactor1.Source = new BitmapImage(new Uri(factorDir + FileData.baseMultiFactorInfo[0] + ".png", UriKind.Relative)); + MultiFactor2.Source = new BitmapImage(new Uri(factorDir + FileData.baseMultiFactorInfo[1] + ".png", UriKind.Relative)); + MultiFactor3.Source = new BitmapImage(new Uri(factorDir + FileData.baseMultiFactorInfo[2] + ".png", UriKind.Relative)); + MultiFactor4.Source = new BitmapImage(new Uri(factorDir + FileData.baseMultiFactorInfo[3] + ".png", UriKind.Relative)); + MultiFactor5.Source = new BitmapImage(new Uri(factorDir + FileData.baseMultiFactorInfo[4] + ".png", UriKind.Relative)); } //点击基础因子(正面和多面)图片事件响应 @@ -324,7 +315,7 @@ private void FlashSelectBase() //显示最多8个随机选择因子 private void ShowRandomFactor() { - var factorListClone = fd.mutationFactorList.DeepClone(); + var factorListClone = FileData.mutationFactorList.DeepClone(); for (int i = 0; i < hasSelectBase.Count; i++) { @@ -430,21 +421,21 @@ private void FlashHasSelectFactor() //随机先出和后出指挥官处理逻辑 private void RandomCommanderInfo() { - List beforeRandNum = rk.GenerateXRandomNum(6, fd.beforeCommanderInfo.Count); - List afterRandNum = rk.GenerateXRandomNum(4, fd.afterCommanderInfo.Count); + List beforeRandNum = rk.GenerateXRandomNum(6, FileData.beforeCommanderInfo.Count); + List afterRandNum = rk.GenerateXRandomNum(4, FileData.afterCommanderInfo.Count); //相对路径URI指定指挥官图片来源 - BeforeCommander1.Source = new BitmapImage(new Uri(commanderDir + fd.beforeCommanderInfo[beforeRandNum[0]] + ".png", UriKind.Relative)); - BeforeCommander2.Source = new BitmapImage(new Uri(commanderDir + fd.beforeCommanderInfo[beforeRandNum[1]] + ".png", UriKind.Relative)); - BeforeCommander3.Source = new BitmapImage(new Uri(commanderDir + fd.beforeCommanderInfo[beforeRandNum[2]] + ".png", UriKind.Relative)); - BeforeCommander4.Source = new BitmapImage(new Uri(commanderDir + fd.beforeCommanderInfo[beforeRandNum[3]] + ".png", UriKind.Relative)); - BeforeCommander5.Source = new BitmapImage(new Uri(commanderDir + fd.beforeCommanderInfo[beforeRandNum[4]] + ".png", UriKind.Relative)); - BeforeCommander6.Source = new BitmapImage(new Uri(commanderDir + fd.beforeCommanderInfo[beforeRandNum[5]] + ".png", UriKind.Relative)); - - AfterCommander1.Source = new BitmapImage(new Uri(commanderDir + fd.afterCommanderInfo[afterRandNum[0]] + ".png", UriKind.Relative)); - AfterCommander2.Source = new BitmapImage(new Uri(commanderDir + fd.afterCommanderInfo[afterRandNum[1]] + ".png", UriKind.Relative)); - AfterCommander3.Source = new BitmapImage(new Uri(commanderDir + fd.afterCommanderInfo[afterRandNum[2]] + ".png", UriKind.Relative)); - AfterCommander4.Source = new BitmapImage(new Uri(commanderDir + fd.afterCommanderInfo[afterRandNum[3]] + ".png", UriKind.Relative)); + BeforeCommander1.Source = new BitmapImage(new Uri(commanderDir + FileData.beforeCommanderInfo[beforeRandNum[0]] + ".png", UriKind.Relative)); + BeforeCommander2.Source = new BitmapImage(new Uri(commanderDir + FileData.beforeCommanderInfo[beforeRandNum[1]] + ".png", UriKind.Relative)); + BeforeCommander3.Source = new BitmapImage(new Uri(commanderDir + FileData.beforeCommanderInfo[beforeRandNum[2]] + ".png", UriKind.Relative)); + BeforeCommander4.Source = new BitmapImage(new Uri(commanderDir + FileData.beforeCommanderInfo[beforeRandNum[3]] + ".png", UriKind.Relative)); + BeforeCommander5.Source = new BitmapImage(new Uri(commanderDir + FileData.beforeCommanderInfo[beforeRandNum[4]] + ".png", UriKind.Relative)); + BeforeCommander6.Source = new BitmapImage(new Uri(commanderDir + FileData.beforeCommanderInfo[beforeRandNum[5]] + ".png", UriKind.Relative)); + + AfterCommander1.Source = new BitmapImage(new Uri(commanderDir + FileData.afterCommanderInfo[afterRandNum[0]] + ".png", UriKind.Relative)); + AfterCommander2.Source = new BitmapImage(new Uri(commanderDir + FileData.afterCommanderInfo[afterRandNum[1]] + ".png", UriKind.Relative)); + AfterCommander3.Source = new BitmapImage(new Uri(commanderDir + FileData.afterCommanderInfo[afterRandNum[2]] + ".png", UriKind.Relative)); + AfterCommander4.Source = new BitmapImage(new Uri(commanderDir + FileData.afterCommanderInfo[afterRandNum[3]] + ".png", UriKind.Relative)); } //点击自选指挥官事件响应 diff --git a/LiaoTian_Cup/Mode/NegativeFactorWindow.xaml b/LiaoTian_Cup/Mode/NegativeFactorWindow.xaml index 486e6c3..df98520 100644 --- a/LiaoTian_Cup/Mode/NegativeFactorWindow.xaml +++ b/LiaoTian_Cup/Mode/NegativeFactorWindow.xaml @@ -1,18 +1,20 @@ - + - - -