diff --git a/ConfigureTool/TabControlDemo.xaml b/ConfigureTool/TabControlDemo.xaml index b414058..7ccb49e 100644 --- a/ConfigureTool/TabControlDemo.xaml +++ b/ConfigureTool/TabControlDemo.xaml @@ -135,15 +135,30 @@ + - - + + + + + + - + diff --git a/ConfigureTool/TabControlDemo.xaml.cs b/ConfigureTool/TabControlDemo.xaml.cs index 9fbf671..715504c 100644 --- a/ConfigureTool/TabControlDemo.xaml.cs +++ b/ConfigureTool/TabControlDemo.xaml.cs @@ -235,4 +235,59 @@ public partial class TabControlDemo : Window File.WriteAllText("./test.json", content); FileEncrypterDecrypter.EncryptFile("./test.json", filename, "000000"); } + + private void ImportButton_Click(object sender, RoutedEventArgs e) + { + Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); + openFileDialog.Filter = "Text files (*.enc)|*.enc|All files (*.*)|*.*"; + string content = null; + if (openFileDialog.ShowDialog() == true) + { + string filename = openFileDialog.FileName; + if (File.Exists(filename)) + { + content = FileEncrypterDecrypter.DecryptFile(filename, "000000"); + } + } + JsonEntity info = JsonConvert.DeserializeObject(content); + if (info != null) + { + SHAPE_NAME.Text = info.SHAPE_NAME; + SHAPE_EN_NAME.Text = info.SHAPE_EN_NAME; + RULE_NAME.Text = info.RULE_NAME; + RULE_EN_NAME.Text = info.RULE_EN_NAME; + GradeContent.GradeList.ItemsSource = info.gradeInfos; + GradeConfigContent.StandardList.ItemsSource = info.standardInfos; + } + } + + private void RULE_EN_NAME_TextChanged(object sender, TextChangedEventArgs e) + { + string ShapeId = SHAPE_EN_NAME.Text.Replace(" ", "_").ToUpper(); + string RuleId = RULE_EN_NAME.Text.Replace(" ", "_").ToUpper(); + GradeIdP = ShapeId + RuleId; + string oldGradeP = ""; + List list = GradeContent.GradeList.ItemsSource as List; + if (list != null) + { + oldGradeP = list[0].GRADE_ID.Substring(0,list[0].GRADE_ID.Length-2); + foreach (GradeInfo info in list) + { + info.GRADE_ID = info.GRADE_ID.Replace(oldGradeP, GradeIdP); + } + } + GradeContent.GradeList.ItemsSource = new List(); + GradeContent.GradeList.ItemsSource = list; + List standardInfoList = GradeConfigContent.StandardList.ItemsSource as List; + if (standardInfoList != null) + { + foreach (StandardInfo info in standardInfoList) + { + info.GRADE_ID = info.GRADE_ID.Replace(oldGradeP, GradeIdP); + info.STANDARD_ID = info.STANDARD_ID.Replace(oldGradeP, GradeIdP); + } + } + GradeConfigContent.StandardList.ItemsSource = new List(); + GradeConfigContent.StandardList.ItemsSource = standardInfoList; + } } \ No newline at end of file