Browse Source

Whether to modify the comparison when resuming closure

cxs 3 days ago
parent
commit
4b7735be5d

+ 1 - 3
OTSPartA_STDEditor/BaseClass/STDInfo.cs

@@ -32,8 +32,8 @@ namespace OTSPartA_STDEditor.BaseClass
             if (!aa)
             {
                 STDDictionary=null;
-                STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
             }
+            STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
             aa = LoadGroupDataFromDb();
             if (!aa)
             {
@@ -48,7 +48,6 @@ namespace OTSPartA_STDEditor.BaseClass
         {
             try
             {
-                STDDictionaryInitial.Clear();
                 STDDictionary.Clear();
                 System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + _DBAddress + "'");
                 m_dbConnection.Open();
@@ -101,7 +100,6 @@ namespace OTSPartA_STDEditor.BaseClass
                                 }
                             }
                             STDDictionary.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
-                            STDDictionaryInitial.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
                         }
                     }
                 }

+ 0 - 1
OTSPartA_STDEditor/BaseClass/STDdata.cs

@@ -153,7 +153,6 @@ namespace OTSPartA_STDEditor
               (UsingOtherPropertyList == a_oSource.UsingOtherPropertyList) &&
               (Expression == a_oSource.Expression) &&
               (GroupId == a_oSource.GroupId) &&
-              (ListNum == a_oSource.ListNum) &&
               (IfElementAnalysis == a_oSource.IfElementAnalysis);
         }
 

+ 4 - 19
OTSPartA_STDEditor/UI/Attributes.cs

@@ -1,12 +1,7 @@
 using OTS.WinFormsUI.Docking;
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
 using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace OTSPartA_STDEditor
@@ -73,20 +68,6 @@ namespace OTSPartA_STDEditor
             
             m_MainForm.ChangeSTDRuleName(Convert.ToString( Grid_Attributes[context.Position.Row, context.Position.Column].Value));
         }
-
-
-
-
-
-
-
-
-
-
-
-
-        
-        
         private class MyHeader : SourceGrid.Cells.ColumnHeader
         {
             public MyHeader(object value) : base(value)
@@ -102,6 +83,10 @@ namespace OTSPartA_STDEditor
             }
         }
 
+
+
+
+
         public Attributes(Form_Main mainForm)
         {
             InitializeComponent();

+ 99 - 115
OTSPartA_STDEditor/UI/Form_Main.cs

@@ -25,7 +25,6 @@ namespace OTSPartA_STDEditor
         public Language lan;
         Hashtable table;
         //是否做出过更改
-        public bool IsModified { set; get; }
         public static readonly string[] ColorGroup = { "#FFB6C1", "#FFC0CB", "#DC143C", "#FFF0F5", "#DB7093", "#FF69B4", "#FF1493", "#C71585", "#DA70D6", "#D8BFD8", "#DDA0DD", "#EE82EE", "#FF00FF", "#8B008B", "#800080", "#BA55D3", "#9400D3", "#9932CC", "#4B0082", "#8A2BE2", "#9370DB","#7B68EE", "#6A5ACD", "#483D8B", "#E6E6FA", "#F8F8FF", "#0000FF", "#0000CD", "#191970", "#00008B", "#000080", "#4169E1" , "#6495ED", "#B0C4DE", "#778899", "#708090", "#1E90FF", "#F0F8FF", "#00FFFF" };
         public Form_Main()
         {
@@ -54,18 +53,6 @@ namespace OTSPartA_STDEditor
             {
                 InitForms(STDDBAddress);
                 this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
-                IsModified = false;
-
-                //if (ImportArgs.Count > 1)
-                //{
-                //    ImportStandardLibraryTypeSelection m_importStandardLibraryTypeSelection = new ImportStandardLibraryTypeSelection();
-                //    var result = m_importStandardLibraryTypeSelection.ShowDialog();
-                //    if (m_importStandardLibraryTypeSelection.SelectEvent == "expression")
-                //    {
-                //        int STDId = _sTDEditor.AddSTDDictionaryItem();
-                //        m_STDRuleslist.AddNewRow(STDId, "NewClassify", Attributes.colorHx16toRGB(ddata.Color));
-                //    }
-                //}
             }
         }
 
@@ -74,18 +61,6 @@ namespace OTSPartA_STDEditor
             m_SubMidWindow.ChangeText_textbox_STDEditor(ddata);
             m_Attributes.SetDatatoGrid_Attributes(ddata);
         }
-
-
-
-
-
-
-
-
-
-
-
-        
         private void rbBackup_Click(object sender, EventArgs e)
         {
             if (m_STDRuleslist.treeView_G.SelectedNode != null && m_STDRuleslist.treeView_G.SelectedNode.Level == 1)
@@ -106,6 +81,13 @@ namespace OTSPartA_STDEditor
                 saveFile.OverwritePrompt = false;  //是否覆盖当前文件
                 if (saveFile.ShowDialog() == DialogResult.OK)
                 {
+                    
+                    
+                    
+                    
+                    
+                    
+                    
                     if (STDDBAddress == saveFile.FileName)
                     {
                         MessageBox.Show("Cannot save as same name!", "Tip");
@@ -114,16 +96,23 @@ namespace OTSPartA_STDEditor
                     FormForWaiting forWaiting = new FormForWaiting();
                     forWaiting.Show();
                     this.Refresh();
-                    System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
-                    bool result = _sTDEditor.SaveAsDictionaryToClassify(saveFile.FileName);
-                    if (result)
+                    if (Ruleformatcheck())
                     {
-                        _sTDEditor.UpdateSTDDictionaryInitial();
-                        STDDBAddress = saveFile.FileName;
-                        this.Text = this.Text.Split(' ')[0] + "   " + saveFile.FileName;
-                        IsModified = false;
-                        forWaiting.Close();
-                        MessageBox.Show("Save successful!", "Tip");
+                        System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
+                        bool result = _sTDEditor.SaveAsDictionaryToClassify(saveFile.FileName);
+                        if (result)
+                        {
+                            _sTDEditor.UpdateSTDDictionaryInitial();
+                            STDDBAddress = saveFile.FileName;
+                            this.Text = this.Text.Split(' ')[0] + "   " + saveFile.FileName;
+                            forWaiting.Close();
+                            MessageBox.Show("Save successful!", "Tip");
+                        }
+                        else
+                        {
+                            forWaiting.Close();
+                            MessageBox.Show("Save failed!", "Tip");
+                        }
                     }
                     else
                     {
@@ -142,10 +131,6 @@ namespace OTSPartA_STDEditor
             }
         }
 
-
-
-
-
         private void rbSave_Click(object sender, EventArgs e)
         {
             if (m_STDRuleslist.treeView_G.SelectedNode != null && m_STDRuleslist.treeView_G.SelectedNode.Level == 1)
@@ -157,30 +142,7 @@ namespace OTSPartA_STDEditor
                 }
             }
             m_STDRuleslist.ConvertToRuleViewDic();
-            if (Ruleformatcheck())
-            {
-                FormForWaiting forWaiting = new FormForWaiting();
-                forWaiting.Show();
-
-                this.Refresh();
-                bool result = _sTDEditor.SaveDictionaryToClassify();
-                if (result)
-                {
-                    _sTDEditor.UpdateSTDDictionaryInitial();
-                    forWaiting.Close();
-                    IsModified = false;
-                    MessageBox.Show("Save successful!", "Tip");
-                }
-                else
-                {
-                    forWaiting.Close();
-                    MessageBox.Show("Save failed!", "Tip");
-                }
-            }
-            else
-            {
-                return;
-            }
+            Save();
         }
         bool Ruleformatcheck()
         {
@@ -210,6 +172,48 @@ namespace OTSPartA_STDEditor
             return true;
         }
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+        public bool Save()
+        {
+            if (Ruleformatcheck())
+            {
+                FormForWaiting forWaiting = new FormForWaiting();
+                forWaiting.Show();
+                this.Refresh();
+                bool result = _sTDEditor.SaveDictionaryToClassify();
+                if (result)
+                {
+                    _sTDEditor.UpdateSTDDictionaryInitial();
+                    MessageBox.Show("Save successful!", "Tip");
+                }
+                else
+                {
+                    MessageBox.Show("Save failed!", "Tip");
+                }
+                forWaiting.Close();
+                return result;
+            }
+            else
+            {
+                return false;
+            }
+        }
         /// <summary>
         /// [颜色:RGB转成16进制]
         /// </summary>
@@ -469,6 +473,7 @@ namespace OTSPartA_STDEditor
                         ddata.SubElementList = sSubElements;
 
                         //ddata.ListNum = "0";   
+                        break;
                     }
                 }
             }
@@ -610,48 +615,30 @@ namespace OTSPartA_STDEditor
         }
         private void rbClose_Click(object sender, EventArgs e)
         {
+            bool expressionright = true;
             if (!_sTDEditor.Isoldversion)
             {
-                if (!EqualsBetweenDictionary() || IsModified)
+                if (!EqualsBetweenDictionary())
                 {
                     DialogResult dr = MessageBox.Show("Whether to save the current modification?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dr == DialogResult.Yes)
                     {
-                        if (m_STDRuleslist.Predata != null)
-                        {
-                            int id = m_STDRuleslist.Predata.STDId;
-                            SaveDataOfSelRule(id);
-                        }
-                    }
-                    else
-                    {
-                        return;
-                    }
-                    FormForWaiting forWaiting = new FormForWaiting();
-                    forWaiting.Show();
-
-
-                    bool result = _sTDEditor.SaveDictionaryToClassify();
-                    if (result)
-                    {
-                        forWaiting.Close();
-                    }
-                    else
-                    {
-                        forWaiting.Close();
-                        MessageBox.Show("Save failed!", "Tip");
+                        expressionright = Save();
                     }
                 }
             }
-            m_Attributes.Close();
-            m_STDRuleslist.Close();
-            m_SubMidWindow.m_STDEditor.Close();
-            m_SubMidWindow.m_ComparativeLibrary.Close();
-            m_SubMidWindow.Close();
-            ButtonStatusClose();
-            if (this.Text.Split(' ').Count() != 0)
+            if (expressionright)
             {
-                this.Text = this.Text.Split(' ')[0];
+                m_Attributes.Close();
+                m_STDRuleslist.Close();
+                m_SubMidWindow.m_STDEditor.Close();
+                m_SubMidWindow.m_ComparativeLibrary.Close();
+                m_SubMidWindow.Close();
+                ButtonStatusClose();
+                if (this.Text.Split(' ').Count() != 0)
+                {
+                    this.Text = this.Text.Split(' ')[0];
+                }
             }
         }
 
@@ -669,7 +656,6 @@ namespace OTSPartA_STDEditor
                     STDDBAddress = openFileDialog.FileName;
                     InitForms(STDDBAddress);
                     this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
-                    IsModified = false;
                     CheckAccuracyofZeroRules();
                 }
                 catch(Exception ex)
@@ -744,37 +730,34 @@ namespace OTSPartA_STDEditor
             }
             if (m_STDRuleslist.Text != "")
             {
-                if (!EqualsBetweenDictionary() || IsModified)
+                bool expressionright = true;
+                if (!EqualsBetweenDictionary())
                 {
                     DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (dr == DialogResult.Yes)
                     {
-                        if (m_STDRuleslist.Predata!=null)
-                        {
-                            int id = m_STDRuleslist.Predata.STDId;
-                            SaveDataOfSelRule(id);
-                        }
-                        FormForWaiting forWaiting = new FormForWaiting();
-                        forWaiting.Show();
-                        bool result = _sTDEditor.SaveDictionaryToClassify();
-                        if (result)
-                        {
-                            forWaiting.Close();
-                        }
-                        else
-                        {
-                            forWaiting.Close();
-                            MessageBox.Show("Save failed!", "Tip");
-                        }
+                        expressionright = Save();
+                       
+                        
+                        if (!expressionright)
+                        { e.Cancel = true; return; }
                     }
                 }
             }
         }
         bool EqualsBetweenDictionary()
         {
+            if (m_STDRuleslist.treeView_G.SelectedNode != null && m_STDRuleslist.treeView_G.SelectedNode.Level == 1)
+            {
+                STDdata sTDdata = (STDdata)m_STDRuleslist.treeView_G.SelectedNode.Tag;
+                if (sTDdata != null)
+                {
+                    SaveDataOfSelRule(sTDdata.STDId);
+                }
+            }
+            m_STDRuleslist.ConvertToRuleViewDic();
             return _sTDEditor.EqualsBetweenDictionary();
         }
-
         private void rbNew_Click(object sender, EventArgs e)
         {
             SaveFileDialog saveFile = new SaveFileDialog();
@@ -814,7 +797,6 @@ namespace OTSPartA_STDEditor
                 STDDBAddress = saveFile.FileName;
                 InitForms(STDDBAddress);
                 this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
-                IsModified = false;
             }
             else
             {
@@ -840,6 +822,8 @@ namespace OTSPartA_STDEditor
                     
                     cmm.CommandText = "CREATE TABLE sqlitestudio_temp_table AS SELECT * FROM ZeroElementRules";
                     cmm.ExecuteNonQuery();
+
+
                     cmm.CommandText = "DROP TABLE ZeroElementRules";
                     cmm.ExecuteNonQuery();
                     cmm.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT)";

+ 5 - 16
OTSPartA_STDEditor/UI/STDRuleslist.cs

@@ -160,23 +160,7 @@ namespace OTSPartA_STDEditor
                 m_MainForm._sTDEditor.GroupIdDictionaryFromName.Add(tDGroups.name.ToString(), int.Parse(tDGroups.id.ToString()));
                 m_MainForm._sTDEditor.GroupIdDictionaryFromId.Add(int.Parse(tDGroups.id.ToString()), tDGroups.name.ToString());
             }
-            if (treeView_G.SelectedNode == null){return;}
-            if (treeView_G.SelectedNode.Level == 1)
-            {
-                m_MainForm.SaveDataOfSelRule(((STDdata)treeView_G.SelectedNode.Tag).STDId);
-            }
         }
-
-
-
-
-
-
-
-
-
-
-
         private void ToolStripMenuItem_NewGroup_Click(object sender, EventArgs e)
         {
             STDGroups group = new STDGroups();
@@ -198,6 +182,11 @@ namespace OTSPartA_STDEditor
             m_MainForm._sTDEditor.GroupIdDictionaryFromId.Add(id, group.name);
             m_MainForm._sTDEditor.GroupIdDictionaryFromName.Add(group.name, group.id);
             InitGroupView();
+
+
+
+
+
             foreach (TreeNode treeNode in treeView_G.Nodes)
             {
                 if (((STDGroups)treeNode.Tag).id == id)