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; using System.Xml; using System.Xml.Linq; namespace OTSPartA_STDEditor { public partial class Form_MaxEDSRules : Form { //国际化 Language lan; System.Collections.Hashtable table; string STDDBAddress = Application.StartupPath + "\\Config\\SysData\\" + "OTSCleanlinesSTD.db"; //string STDDBAddress_backup = Application.StartupPath + "\\Config\\SysData\\LibBackup\\" + "OTSCleanlinesSTD_backup.db"; string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\"; //元素周期表 Form_PeriodicTable form_PeriodicTable=null; public Form_MaxEDSRules(string DBAddress) { InitializeComponent(); STDDBAddress = DBAddress; //X = this.Width; //Y = this.Height; //setTag(this); } private void Form_MaxEDSRules_Load(object sender, EventArgs e) { //初始化comboBox this.comboBox_Elem1.Items.Add("first_elem"); this.comboBox_Elem1.Items.Add("second_elem"); this.comboBox_Elem1.Items.Add("third_elem"); this.comboBox_Elem1.Items.Add("forth_elem"); this.comboBox_Elem1.Items.Add("fifth_elem"); this.comboBox_Elem1.Items.Add("sixth_elem"); this.comboBox_Elem1.Items.Add("seventh_elem"); this.comboBox_Elem1.Items.Add("eighth_elem"); this.comboBox_Elem1.Items.Add("ninth_elem"); this.comboBox_Elem1.Items.Add("tenth_elem"); comboBox_Elem1.SelectedIndex = comboBox_Elem1.Items.IndexOf("first_elem"); this.comboBox_Elem.Items.Add("Element#1"); this.comboBox_Elem.Items.Add("Element#2"); this.comboBox_Elem.Items.Add("Element#3"); this.comboBox_Elem.Items.Add("Element#4"); this.comboBox_Elem.Items.Add("Element#5"); this.comboBox_Elem.Items.Add("Element#6"); this.comboBox_Elem.Items.Add("Element#7"); this.comboBox_Elem.Items.Add("Element#8"); this.comboBox_Elem.Items.Add("Element#9"); this.comboBox_Elem.Items.Add("Element#10"); comboBox_Elem.SelectedIndex = comboBox_Elem.Items.IndexOf("Element#1"); this.comboBox_ImgProperty.Items.Add("Dmax"); this.comboBox_ImgProperty.Items.Add("Dmin"); this.comboBox_ImgProperty.Items.Add("Aspect"); this.comboBox_ImgProperty.Items.Add("Dperp"); this.comboBox_ImgProperty.Items.Add("Dmean"); this.comboBox_ImgProperty.Items.Add("Area"); this.comboBox_ImgProperty.Items.Add("Dferet"); this.comboBox_ImgProperty.Items.Add("With"); this.comboBox_ImgProperty.Items.Add("Height"); this.comboBox_ImgProperty.Items.Add("Perimeter"); this.comboBox_ImgProperty.Items.Add("Dinscr"); this.comboBox_ImgProperty.Items.Add("Orientation"); this.comboBox_ImgProperty.Items.Add("Delong"); this.comboBox_ImgProperty.Items.Add("Aspectelong"); this.comboBox_ImgProperty.Items.Add("Dequalcircle"); this.comboBox_ImgProperty.Items.Add("Vedio"); comboBox_ImgProperty.SelectedIndex = comboBox_ImgProperty.Items.IndexOf("Dmax"); string[] PeriodicTable = { "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hq", "TI", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Mc", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Unb" }; comboBox_PeriodicTable.Items.AddRange(PeriodicTable); AutoCompleteStringCollection sc = new AutoCompleteStringCollection(); sc.AddRange(PeriodicTable); this.comboBox_PeriodicTable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.comboBox_PeriodicTable.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource; this.comboBox_PeriodicTable.AutoCompleteCustomSource = sc; LoadMaxEDSRulesToTreeControl(STDDBAddress, XmlTree_MaxEDSRules.Nodes); LoadConstants(STDDBAddress); this.textbox_STDEditor.Text = ""; lan = new Language(this); table = lan.GetNameTable("Form_MaxEDSRules"); if (table["language"].ToString() == "EN") { //panel_OTSPeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_EN; PeriodicTableSwitch.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.STDEditoName; PeriodicTableSwitch.Text = ""; } else { //panel_OTSPeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_ZH; PeriodicTableSwitch.Text = "元素周期表"; } //panel_OTSPeriodicTable.Visible = true; //this.Width = this.Width - panel_OTSPeriodicTable.Width - 5; Size size = Screen.PrimaryScreen.WorkingArea.Size; Left = (size.Width - Width) / 2; Top = (size.Height - Height) / 2; WindowState = FormWindowState.Normal; //groupBox_XmlTree_MaxEDSRules.Focus(); this.XmlTree_MaxEDSRules.HideSelection = false;//失去焦点后不隐藏选中节点 XmlTree_MaxEDSRules.Focus(); if (XmlTree_MaxEDSRules.Nodes.Count > 0) { XmlTree_MaxEDSRules.SelectedNode = XmlTree_MaxEDSRules.Nodes[0]; XmlTree_MaxEDSRules_AfterSelect(XmlTree_MaxEDSRules, new TreeViewEventArgs(XmlTree_MaxEDSRules.SelectedNode)); } } //XmlTree_MaxEDSRules void LoadXmlToTreeControl(XmlDocument xml,TreeNodeCollection XmlTree_MaxEDSRules) { XmlNode root = xml.SelectSingleNode("XMLData"); XmlNodeList root2 = root.SelectNodes("Collection"); for (int j = 0; j < root2.Count; j++) { if (root2[j].Attributes["RegName"].Value.ToString() == "MaxEDSRules") { XmlNodeList childlist = root2[j].ChildNodes; if (childlist.Count != 0) { for (int i = 0; i < childlist.Count; i++) { TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象 //new_child.Name = childlist[i].Attributes["MaxEDSTime"].Value; new_child.Tag = childlist[i].Attributes["Expression"].Value; new_child.Text = "Rule" + i.ToString(); XmlTree_MaxEDSRules.Add(new_child); } if (childlist[0].Attributes["MaxEDSTime"] != null) { textBox_MaxEDSTime.Text = childlist[0].Attributes["MaxEDSTime"].Value; } } } } XmlNode root3 = root.SelectSingleNode("Member"); string ConstantsStr = root3.Attributes["value"].Value; ConstantsStr = ConstantsStr.Replace(" ", ""); string[] ConstantsStr2 = ConstantsStr.Split(','); this.comboBox_Constants.Items.Clear(); this.comboBox_Constants.Items.AddRange(ConstantsStr2); } void LoadMaxEDSRulesToTreeControl(string DBAddress, TreeNodeCollection XmlTree_MaxEDSRules) { try { System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'"); m_dbConnection.Open(); System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from MaxEDSRules", m_dbConnection); DataSet ds = new DataSet(); m_dataAdapter.Fill(ds); DataTable dt = ds.Tables[0]; if (dt != null) { if (dt.Rows.Count > 0) { int i = 1; foreach (DataRow item in dt.Rows) { TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象 new_child.Tag = item["Expression"].ToString(); new_child.Text = "Rule" + i.ToString(); XmlTree_MaxEDSRules.Add(new_child); i++; } if (dt.Rows[0]["MaxEDSTime"] != null) { textBox_MaxEDSTime.Text = dt.Rows[0]["MaxEDSTime"].ToString(); } } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } } void LoadConstants(string STDDBAddress) { try { System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'"); m_dbConnection.Open(); System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from Constants", m_dbConnection); DataSet ds = new DataSet(); m_dataAdapter.Fill(ds); DataTable dt = ds.Tables[0]; string ConstantsStr = ""; if (dt.Rows.Count > 0) { ConstantsStr = dt.Rows[0][0].ToString(); } ConstantsStr = ConstantsStr.Replace(" ", ""); string[] ConstantsStr2 = ConstantsStr.Split(','); comboBox_Constants.Items.Clear(); comboBox_Constants.Items.AddRange(ConstantsStr2); m_dbConnection.Close(); } catch (Exception ee) { MessageBox.Show(ee.ToString()); } } private void comboBox_Elem1_SelectedIndexChanged(object sender, EventArgs e) { string newStr = comboBox_Elem1.SelectedItem.ToString(); int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + newStr.Length, 0); textbox_STDEditor.ScrollToCaret(); } private void comboBox_Elem2_SelectedIndexChanged(object sender, EventArgs e) { string newStr = comboBox_Elem.SelectedItem.ToString(); int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + newStr.Length, 0); textbox_STDEditor.ScrollToCaret(); } private void comboBox_ImgProperty_SelectedIndexChanged(object sender, EventArgs e) { string newStr = comboBox_ImgProperty.SelectedItem.ToString(); int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + newStr.Length, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Plus_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "+"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index+1,0); textbox_STDEditor.ScrollToCaret(); } private void button_Subtract_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "-"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Multiply_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "*"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Divide_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "/"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); ; } private void button_More_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, ">"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Less_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "<"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_LeftParenthesis_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "("); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_RightParenthesis_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, ")"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Equal_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "="); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } //除选中点以外其它节点前景色置灰 private void SetGrayExceptSelectedNode(TreeView Tree, TreeNode SelectedNode) { foreach (TreeNode node in Tree.Nodes) { if (node != SelectedNode) { node.ForeColor = Color.Gray; } } } //恢复所有节点颜色为可用 private void SetBlackAllNodes(TreeView Tree) { foreach (TreeNode node in Tree.Nodes) { node.ForeColor = Color.Black; } } //删除 private void DeleteTreeNode_Click(object sender, EventArgs e) { try { TreeView XmlTree = (TreeView)XmlTreeMenuStrip.SourceControl; if (XmlTree.SelectedNode != null) { if (XmlTree != null) { if (XmlTree.SelectedNode.NextNode != null) { TreeNode Temp = XmlTree.SelectedNode.NextNode; XmlTree.SelectedNode.Remove(); XmlTree.SelectedNode = Temp; } else if (XmlTree.SelectedNode.PrevNode != null) { TreeNode Temp = XmlTree.SelectedNode.PrevNode; XmlTree.SelectedNode.Remove(); XmlTree.SelectedNode = Temp; } else { XmlTree.SelectedNode.Remove(); XmlTree.SelectedNode = null; if (XmlTree.Name == "XmlTree_MaxEDSRules") { textbox_STDEditor.Text = ""; textBox_MaxEDSTime.Text = ""; } } } } else { MessageBox.Show("No nodes are selected!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Tip"); } } //新建 private void AddTreeNode_Click(object sender, EventArgs e) { try { if (XmlTree_MaxEDSRules.SelectedNode != null) { //判断MaxEDSTime double dMaxEDSTime = 0; if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0) { MessageBox.Show("The MaxEDSTime of current selected node input error, please enter the correct format!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //判断textbox_STDEditor if (!Checktextbox_STDEditor()) { return; } XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text; } TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象 TreeView XmlTree = (TreeView)XmlTreeMenuStrip.SourceControl; if (XmlTreeMenuStrip.SourceControl.Name == "XmlTree_MaxEDSRules") { int Number = XmlTree.Nodes.Count; for (int num = 0; num < XmlTree.Nodes.Count; num++) { string aa = XmlTree.Nodes[num].Text.ToString().Substring(XmlTree.Nodes[num].Text.Length - 1, 1); int tp = int.Parse(XmlTree.Nodes[num].Text.ToString().Substring(XmlTree.Nodes[num].Text.Length - 1, 1)); if (Number < tp) Number = tp; } new_child.Text = "Rule" + Number.ToString(); new_child.Tag = "NewRules"; textbox_STDEditor.Text = "NewRules"; } XmlTree.Nodes.Add(new_child); XmlTree.SelectedNode = null; XmlTree.SelectedNode = new_child; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Tip"); } } void SaveXmlTreeDataToMaxEDSRules(string DBAddress) { System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'"); m_dbConnection.Open(); System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand(); cmm.CommandText = "delete from MaxEDSRules"; try { cmm.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from MaxEDSRules", m_dbConnection); System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter); DataSet ds = new DataSet(); m_dataAdapter.Fill(ds, "MaxEDSRules"); DataTable dt = ds.Tables["MaxEDSRules"]; dt.Clear(); for (int num = 0; num < XmlTree_MaxEDSRules.Nodes.Count; num++) { string UsingElementList = ""; string UsingImgPropertyList = ""; string UsingOtherPropertyList = ""; List UsingElementL = new List(); List UsingImgPropertyL = new List(); List UsingOtherPropertyL = new List(); string str_RemoveBlank = ""; //forth_elem干扰or分隔符,故先行去掉 if (XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Contains("forth_elem")) { str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", ""); UsingOtherPropertyList = "forth_elem,"; } str_RemoveBlank = XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Replace(" ", ""); string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None); List str_Removeandor = new List(); for (int i = 0; i < str_Removeand.Length; i++) { str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None)); } List list_all = new List(); for (int i = 0; i < str_Removeandor.Count; i++) { list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' })); } for (int i = 0; i < list_all.Count; i++) { //周期元素? if (this.comboBox_PeriodicTable.Items.Contains(list_all[i])) { if (!UsingElementL.Contains(list_all[i])) { UsingElementL.Add(list_all[i]); } } //first_elem? if (this.comboBox_Elem1.Items.Contains(list_all[i])) { if (!UsingOtherPropertyL.Contains(list_all[i])) { UsingOtherPropertyL.Add(list_all[i]); } } //Element1? if (this.comboBox_Elem.Items.Contains(list_all[i])) { if (!UsingOtherPropertyL.Contains(list_all[i])) { UsingOtherPropertyL.Add(list_all[i]); } } //其它元素? if (this.comboBox_ImgProperty.Items.Contains(list_all[i])) { if (!UsingImgPropertyL.Contains(list_all[i])) { UsingImgPropertyL.Add(list_all[i]); } } } if (UsingElementL.Count > 0) { for (int i = 0; i < UsingElementL.Count - 1; i++) { UsingElementList += UsingElementL[i] + ","; } UsingElementList += UsingElementL[UsingElementL.Count - 1]; } if (UsingImgPropertyL.Count > 0) { for (int i = 0; i < UsingImgPropertyL.Count - 1; i++) { UsingImgPropertyList += UsingImgPropertyL[i] + ","; } UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1]; } if (UsingOtherPropertyL.Count > 0) { for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++) { UsingOtherPropertyList += UsingOtherPropertyL[i] + ","; } UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1]; } DataRow newRow = dt.NewRow(); newRow["MaxEDSTime"] = int.Parse(textBox_MaxEDSTime.Text); newRow["UsingElementList"] = UsingElementList; newRow["UsingImgPropertyList"] = UsingImgPropertyList; newRow["UsingOtherPropertyList"] = UsingOtherPropertyList; newRow["Expression"] = XmlTree_MaxEDSRules.Nodes[num].Tag; dt.Rows.Add(newRow); } m_dataAdapter.Update(ds, "MaxEDSRules"); m_dbConnection.Close(); MessageBox.Show("Save successful!", "Tip"); } //元素周期表开关 private void PeriodicTableSwitch_Click(object sender, EventArgs e) { //if (PeriodicTableSwitch.BackColor == SystemColors.Control) //{ // //this.Resize -= new System.EventHandler(this.Form_MaxEDSRules_Resize); // panel_OTSPeriodicTable.Visible = false; // this.Width = this.Width - panel_OTSPeriodicTable.Width; // //this.Resize += new System.EventHandler(this.Form_MaxEDSRules_Resize); // PeriodicTableSwitch.BackColor = SystemColors.ControlDark; // //if (Language == "English") // //{ // // PeriodicTableSwitch.Text = "Close PeriodicTable"; // //} // //else if(Language == "Chinese") // //{ // // PeriodicTableSwitch.Text = "关闭元素周期表"; // //} //} //else if (PeriodicTableSwitch.BackColor == SystemColors.ControlDark) //{ // //this.Resize -= new System.EventHandler(this.Form_MaxEDSRules_Resize); // //this.Width = this.Width + panel_OTSPeriodicTable.Width + 5; // panel_OTSPeriodicTable.Visible = true; // //this.Resize += new System.EventHandler(this.Form_MaxEDSRules_Resize); // PeriodicTableSwitch.BackColor = SystemColors.Control; // //if (Language == "English") // //{ // // PeriodicTableSwitch.Text = "Open PeriodicTable"; // //} // //else if (Language == "Chinese") // //{ // // PeriodicTableSwitch.Text = "打开元素周期表"; // //} // //textbox_STDEditor.Focus(); // groupBox_CalculatingSymbols.Focus(); //} if (form_PeriodicTable == null) { form_PeriodicTable = new Form_PeriodicTable(); form_PeriodicTable.Show(); form_PeriodicTable.Location = new Point(this.Location.X + this.Width - 14, this.Location.Y); } else { if (form_PeriodicTable.IsDisposed) { form_PeriodicTable = new Form_PeriodicTable(); form_PeriodicTable.Show(); form_PeriodicTable.Location = new Point(this.Location.X + this.Width - 14, this.Location.Y); } else { form_PeriodicTable.Activate(); } } } private void button_Ok_Click(object sender, EventArgs e) { if (XmlTree_MaxEDSRules.SelectedNode != null) { //判断MaxEDSTime double dMaxEDSTime = 0; if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0) { textBox_MaxEDSTime.Focus(); textBox_MaxEDSTime.SelectAll(); MessageBox.Show("The Item of MaxEDSTime input error, please enter the correct format!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //判断textbox_STDEditor if (!Checktextbox_STDEditor()) { return; } XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text; //XmlTree_MaxEDSRules.SelectedNode.Name = textBox_MaxEDSTime.Text; } SaveXmlTreeDataToMaxEDSRules(STDDBAddress); this.Close(); } private void button_Cancel_Click(object sender, EventArgs e) { this.Close(); } //元素下拉选择输入 private void comboBox_PeriodicTable_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_PeriodicTable.Text != null && comboBox_PeriodicTable.SelectedItem != null) { string newStr = comboBox_PeriodicTable.SelectedItem.ToString(); comboBox_PeriodicTable.Text = null; int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + newStr.Length, 0); textbox_STDEditor.ScrollToCaret(); } } //元素自身text按回车键输入 private void comboBox_PeriodicTable_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { if (comboBox_PeriodicTable.Text != null && comboBox_PeriodicTable.Text != "") { this.textbox_STDEditor.Text += comboBox_PeriodicTable.Text.ToString(); comboBox_PeriodicTable.Text = null; } } } //表达式规则检查 private bool Checktextbox_STDEditor() { if (textbox_STDEditor.Text == "" || textbox_STDEditor.Text == null) { textBox_MaxEDSTime.Focus(); MessageBox.Show("The content of Standard library cannot be empty!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", ""); str_RemoveBlank = str_RemoveBlank.Replace("\r\n", ""); //分割符号检验 string[] Symbol = { "and", "or", "+", "-", "*", "/", "=", ">", "<" }; for (int i = 0; i < Symbol.Length; i++) { for (int j = 0; j < Symbol.Length; j++) { if ((Symbol[i] + Symbol[j]) != ">=" && (Symbol[i] + Symbol[j]) != "<=") { if (str_RemoveBlank.Contains(Symbol[i] + Symbol[j])) { MessageBox.Show("Invalid string exists:" + Symbol[i] + Symbol[j], "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } } if (str_RemoveBlank.Contains(Symbol[i] + ")") || str_RemoveBlank.Contains("(" + Symbol[i])) { MessageBox.Show("Invalid string exists:" + Symbol[i] + ")", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } if (str_RemoveBlank.Contains("(" + Symbol[i])) { MessageBox.Show("Invalid string exists:" + "(" + Symbol[i], "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } if ((str_RemoveBlank != null) && (str_RemoveBlank != "")) { //左右括号匹配检验 int BracketsNum = 0; for (int i = 0; i < str_RemoveBlank.Length; i++) { if (str_RemoveBlank[i] == '(') BracketsNum++; if (str_RemoveBlank[i] == ')') BracketsNum--; } if (BracketsNum != 0) { MessageBox.Show("Number of left and right parentheses does not match!", "Tip", MessageBoxButtons.OK,MessageBoxIcon.Information); return false; } //首字符检测 if ((str_RemoveBlank[0] == '+') || (str_RemoveBlank[0] == '-') || (str_RemoveBlank[0] == '*') || (str_RemoveBlank[0] == '/') || (str_RemoveBlank[0] == '>') || (str_RemoveBlank[0] == '<') || (str_RemoveBlank[0] == '=') || (str_RemoveBlank[0] == ')') || (str_RemoveBlank[str_RemoveBlank.Length - 1] == '(')) { MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } if (str_RemoveBlank.Length >= 3) { if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end")) { MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } } //forth_elem干扰or分隔符,故先行去掉 str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", ""); string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None); List str_Removeandor = new List(); for (int i = 0; i < str_Removeand.Length; i++) { str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None)); } List list_all = new List(); for (int i = 0; i < str_Removeandor.Count; i++) { list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' })); } //常量 List Constantslist = new List(); for (int j = 0; j < comboBox_Constants.Items.Count; j++) { Constantslist.Add(comboBox_Constants.Items[j].ToString().Split('=')[0]); } for (int i = 0; i < list_all.Count; i++) { //周期元素? if (this.comboBox_PeriodicTable.Items.Contains(list_all[i])) { continue; } //first_elem? if (this.comboBox_Elem1.Items.Contains(list_all[i])) { continue; } //Element1? if (this.comboBox_Elem.Items.Contains(list_all[i])) { continue; } //其它元素? if (this.comboBox_ImgProperty.Items.Contains(list_all[i])) { continue; } //常量? if (Constantslist.Contains(list_all[i])) { continue; } //数字? double DNum = 0; if (double.TryParse(list_all[i], out DNum)) { continue; } //>=? <=?等其它情况 if (list_all[i] == "") { continue; } //true false? if ((list_all[i] == "true") || (list_all[i] == "false")) { continue; } MessageBox.Show("Please check whether the input rules are correct, error characters:" + list_all[i], "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //检测是否有<>= true,false if (!textbox_STDEditor.Text.ToString().Contains("<") && !textbox_STDEditor.Text.ToString().Contains(">") && !textbox_STDEditor.Text.ToString().Contains("=")&& textbox_STDEditor.Text.ToString()!="true"&& textbox_STDEditor.Text.ToString() != "false") { MessageBox.Show("Expressions have no effect!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } return true; } private void button_And_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "and"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 3, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Or_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "or"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 2, 0); textbox_STDEditor.ScrollToCaret(); } private void comboBox_Constants_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_Constants.SelectedItem != null) { string newStr = comboBox_Constants.SelectedItem.ToString().Split('=')[0]; int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + newStr.Length, 0); textbox_STDEditor.ScrollToCaret(); } } private void button_Recover_Click(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); try { //System.IO.File.Copy(Address_backup, Address, true); //doc.Load(Address_backup); //LoadXmlToTreeControl(doc, XmlTree_MaxEDSRules.Nodes); XmlTree_MaxEDSRules.Nodes.Clear(); string STDDBAddress_backup = ""; string[] files = System.IO.Directory.GetFiles(STDDBAddress_backupDirectory);//得到文件 foreach (var file in files) { if (".db".IndexOf(file.Substring(file.LastIndexOf(".") + 1)) > -1) { STDDBAddress_backup = file; } } LoadMaxEDSRulesToTreeControl(STDDBAddress_backup, XmlTree_MaxEDSRules.Nodes); XmlTree_MaxEDSRules.Focus(); if (XmlTree_MaxEDSRules.Nodes.Count > 0) { XmlTree_MaxEDSRules.SelectedNode = XmlTree_MaxEDSRules.Nodes[0]; XmlTree_MaxEDSRules_AfterSelect(XmlTree_MaxEDSRules, new TreeViewEventArgs(XmlTree_MaxEDSRules.SelectedNode)); } else { textbox_STDEditor.Text = ""; textBox_MaxEDSTime.Text = ""; } } catch(Exception ex) { MessageBox.Show("Recovery failed!" + "\n"+ex.Message.ToString(), "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private bool CheckConstants(string ConstantName) { for (int num = 0; num < XmlTree_MaxEDSRules.Nodes.Count; num++) { if (XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Contains(ConstantName)) { XmlTree_MaxEDSRules.SelectedNode = XmlTree_MaxEDSRules.Nodes[num]; SetGrayExceptSelectedNode(XmlTree_MaxEDSRules, XmlTree_MaxEDSRules.SelectedNode); DialogResult result = MessageBox.Show("Closing failed," + XmlTree_MaxEDSRules.Nodes[num].Text + table["message28"].ToString(), "Tip", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } } return true; } private void XmlTree_MaxEDSRules_AfterSelect(object sender, TreeViewEventArgs e) { SetBlackAllNodes(XmlTree_MaxEDSRules); this.textbox_STDEditor.Text = XmlTree_MaxEDSRules.SelectedNode.Tag.ToString(); } private void XmlTree_MaxEDSRules_BeforeSelect(object sender, TreeViewCancelEventArgs e) { if (XmlTree_MaxEDSRules.SelectedNode != null) { if (!Checktextbox_STDEditor()) { SetGrayExceptSelectedNode(XmlTree_MaxEDSRules, XmlTree_MaxEDSRules.SelectedNode); e.Cancel = true; return; } XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text; } } private void textbox_STDEditor_Leave(object sender, EventArgs e) { XmlTree_MaxEDSRules.Focus(); } #region 为配合textbox_STDEditor_Leave时事件,点击其它groupbox组件时使焦点转移 private void Form_ConstantsEditor_Click(object sender, EventArgs e) { groupBox_XmlTree_MaxEDSRules.Focus(); } private void groupBox_Data_Click(object sender, EventArgs e) { groupBox_Data.Focus(); } private void groupBox_ChemicalElement_Click(object sender, EventArgs e) { groupBox_ChemicalElement.Focus(); } private void groupBox_OtherCommonlyUsedSymbols_Click(object sender, EventArgs e) { groupBox_OtherCommonlyUsedSymbols.Focus(); } private void groupBox_CalculatingSymbols_Click(object sender, EventArgs e) { groupBox_CalculatingSymbols.Focus(); } private void groupBox_XmlTree_MaxEDSRules_Click(object sender, EventArgs e) { groupBox_XmlTree_MaxEDSRules.Focus(); } #endregion private void button_1_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "1"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_2_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "2"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_3_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "3"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_4_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "4"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_5_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "5"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_6_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "6"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_7_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "7"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_8_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "8"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_9_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "9"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } private void button_0_Click(object sender, EventArgs e) { int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "0"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 1, 0); textbox_STDEditor.ScrollToCaret(); } //private float X = 1; //private float Y = 1; //float AmplificationFactor = 1; private void Form_MaxEDSRules_Resize(object sender, EventArgs e) { //float newx = this.Width / X; //float newy = this.Height / Y; //AmplificationFactor = newy; //setControls(newx, newy, this); //this.Resize -= new System.EventHandler(this.Form_MaxEDSRules_Resize); //if (panel_OTSPeriodicTable.Visible == false) //{ // int w = this.Width - panel_OTSPeriodicTable.Width; // this.Width = w; //} //this.Resize += new System.EventHandler(this.Form_MaxEDSRules_Resize); ////if (WindowState == FormWindowState.Maximized) ////{ //// panel_OTSPeriodicTable.Visible = true; //// PeriodicTableSwitch.Enabled = false; ////} } private void setTag(Control cons) { foreach (Control con in cons.Controls) { con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; if (con.Controls.Count > 0) setTag(con); } } private void setControls(float newx, float newy, Control cons) { foreach (Control con in cons.Controls) { if (false) { } else { string[] mytag = con.Tag.ToString().Split(':'); float a = Convert.ToSingle(mytag[0]) * newx; con.Width = (int)a; a = Convert.ToSingle(mytag[1]) * newy; con.Height = (int)(a); a = Convert.ToSingle(mytag[2]) * newx; con.Left = (int)(a); a = Convert.ToSingle(mytag[3]) * newy; con.Top = (int)(a); Single currentSize; if (con.GetType().ToString() == "System.Windows.Forms.Label") { currentSize = Convert.ToSingle(mytag[4]) * ((newx + newy) / 2); //currentSize = 6f; } else { if (Math.Max(newx, newy) < 1) { currentSize = Convert.ToSingle(mytag[4]) * 1; } else { currentSize = Convert.ToSingle(mytag[4]) * Math.Max(newx, newy); } } con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); if (con.Controls.Count > 0) { setControls(newx, newy, con); } } } } #region //XmlDocument doc = new XmlDocument(); //doc.Load(Address); //LoadXmlToTreeControl(doc,XmlTree_MaxEDSRules.Nodes); //public string Language = "English"; //string Address_backup = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD_backup.xml"; //string Address = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD.xml"; //保存xmltree内容到xml文件 //void SaveXmlTreeDataToXml(string Address) //{ // XDocument xdoc = XDocument.Load(Address); // IEnumerable elements = from ele in xdoc.Descendants("XMLData") select ele; // var item = (from ele1 in elements.Elements("Collection") // where ele1.Attribute("RegName").Value.Equals("MaxEDSRules") // select ele1).FirstOrDefault(); // if (item != null) // { // item.Remove(); // } // XElement MaxEDS = new XElement("Collection"); // MaxEDS.SetAttributeValue("RegName", "MaxEDSRules"); // elements.ElementAt(0).Add(MaxEDS); // for (int num = 0; num < XmlTree_MaxEDSRules.Nodes.Count; num++) // { // string UsingElementList = ""; // string UsingImgPropertyList = ""; // string UsingOtherPropertyList = ""; // List UsingElementL = new List(); // List UsingImgPropertyL = new List(); // List UsingOtherPropertyL = new List(); // string str_RemoveBlank = ""; // //forth_elem干扰or分隔符,故先行去掉 // if (XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Contains("forth_elem")) // { // str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", ""); // UsingOtherPropertyList = "forth_elem,"; // } // str_RemoveBlank = XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Replace(" ", ""); // string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None); // List str_Removeandor = new List(); // for (int i = 0; i < str_Removeand.Length; i++) // { // str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None)); // } // List list_all = new List(); // for (int i = 0; i < str_Removeandor.Count; i++) // { // list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' })); // } // for (int i = 0; i < list_all.Count; i++) // { // //周期元素? // if (this.comboBox_PeriodicTable.Items.Contains(list_all[i])) // { // if (!UsingElementL.Contains(list_all[i])) // { // UsingElementL.Add(list_all[i]); // } // } // //first_elem? // if (this.comboBox_Elem1.Items.Contains(list_all[i])) // { // if (!UsingOtherPropertyL.Contains(list_all[i])) // { // UsingOtherPropertyL.Add(list_all[i]); // } // } // //Element1? // if (this.comboBox_Elem.Items.Contains(list_all[i])) // { // if (!UsingOtherPropertyL.Contains(list_all[i])) // { // UsingOtherPropertyL.Add(list_all[i]); // } // } // //其它元素? // if (this.comboBox_ImgProperty.Items.Contains(list_all[i])) // { // if (!UsingImgPropertyL.Contains(list_all[i])) // { // UsingImgPropertyL.Add(list_all[i]); // } // } // } // if (UsingElementL.Count > 0) // { // for (int i = 0; i < UsingElementL.Count - 1; i++) // { // UsingElementList += UsingElementL[i] + ","; // } // UsingElementList += UsingElementL[UsingElementL.Count - 1]; // } // if (UsingImgPropertyL.Count > 0) // { // for (int i = 0; i < UsingImgPropertyL.Count - 1; i++) // { // UsingImgPropertyList += UsingImgPropertyL[i] + ","; // } // UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1]; // } // if (UsingOtherPropertyL.Count > 0) // { // for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++) // { // UsingOtherPropertyList += UsingOtherPropertyL[i] + ","; // } // UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1]; // } // XElement EleName = new XElement("Member"); // //EleName.SetAttributeValue("MaxEDSTime", XmlTree_MaxEDSRules.Nodes[num].Name); // EleName.SetAttributeValue("MaxEDSTime", textBox_MaxEDSTime.Text); // EleName.SetAttributeValue("UsingElementList", UsingElementList); // EleName.SetAttributeValue("UsingImgPropertyList", UsingImgPropertyList); // EleName.SetAttributeValue("UsingOtherPropertyList", UsingOtherPropertyList); // EleName.SetAttributeValue("Expression", XmlTree_MaxEDSRules.Nodes[num].Tag); // MaxEDS.Add(EleName); // } // xdoc.Save(Address); //} //private void button_Backup_Click(object sender, EventArgs e) //{ // if (XmlTree_MaxEDSRules.SelectedNode != null) // { // //判断MaxEDSTime // double dMaxEDSTime = 0; // if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0) // { // textBox_MaxEDSTime.Focus(); // textBox_MaxEDSTime.SelectAll(); // MessageBox.Show(table["message16"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information); // return; // } // //判断textbox_STDEditor // if (!Checktextbox_STDEditor()) // { // return; // } // XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text; // //XmlTree_MaxEDSRules.SelectedNode.Name = textBox_MaxEDSTime.Text; // } // try // { // SaveFileDialog saveFile = new SaveFileDialog(); // saveFile.Title = table["message23"].ToString(); // saveFile.Filter = table["message24"].ToString(); // saveFile.OverwritePrompt = true; //是否覆盖当前文件 // saveFile.RestoreDirectory = true; //还原上次目录 // if (saveFile.ShowDialog() == DialogResult.OK) // { // System.IO.File.Copy(Address, saveFile.FileName, true); // SaveXmlTreeDataToXml(saveFile.FileName); // MessageBox.Show(table["message25"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information); // } // else // { // return; // } // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } //} #endregion private void Form_MaxEDSRules_FormClosing(object sender, FormClosingEventArgs e) { if (form_PeriodicTable != null) { form_PeriodicTable.Close(); } } } }