|  | @@ -1,1424 +0,0 @@
 | 
	
		
			
				|  |  | -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 SpectrumSTDEditor
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -    public partial class Form_ZeroElementRules : 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_ZeroElementRules(string DBAddress)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            InitializeComponent();
 | 
	
		
			
				|  |  | -            STDDBAddress = DBAddress;
 | 
	
		
			
				|  |  | -                                                                                                                                                                            
 | 
	
		
			
				|  |  | -            X = this.Width;
 | 
	
		
			
				|  |  | -            Y = this.Height;
 | 
	
		
			
				|  |  | -            setTag(this);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void Form_ZeroElementRules_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("fourth_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;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            LoadZeroElementRulesToTreeControl(STDDBAddress, XmlTree_ZeroElementRules.Nodes);
 | 
	
		
			
				|  |  | -            LoadConstants(STDDBAddress);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            this.textbox_STDEditor.Text = "";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            lan = new Language(this);
 | 
	
		
			
				|  |  | -            table = lan.GetNameTable("Form_ZeroElementRules");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (table["language"].ToString() == "EN")
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                //panel_OTSPeriodicTable.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.PeriodicTable_EN;
 | 
	
		
			
				|  |  | -                PeriodicTableSwitch.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.STDEditoName;
 | 
	
		
			
				|  |  | -                PeriodicTableSwitch.Text = "";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                //panel_OTSPeriodicTable.BackgroundImage = global::SpectrumSTDEditor.Properties.Resources.PeriodicTable_ZH;
 | 
	
		
			
				|  |  | -                PeriodicTableSwitch.Text = "元素周期表";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            Size size = Screen.PrimaryScreen.WorkingArea.Size;
 | 
	
		
			
				|  |  | -            Left = (size.Width - Width) / 2;
 | 
	
		
			
				|  |  | -            Top = (size.Height - Height) / 2;
 | 
	
		
			
				|  |  | -            WindowState = FormWindowState.Normal;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -           
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //panel_OTSPeriodicTable.Visible = true;
 | 
	
		
			
				|  |  | -            //this.Width = this.Width - panel_OTSPeriodicTable.Width - 5;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            this.XmlTree_ZeroElementRules.HideSelection = false;//失去焦点后不隐藏选中节点
 | 
	
		
			
				|  |  | -            XmlTree_ZeroElementRules.Focus();
 | 
	
		
			
				|  |  | -            if (XmlTree_ZeroElementRules.Nodes.Count > 0)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                XmlTree_ZeroElementRules.SelectedNode = XmlTree_ZeroElementRules.Nodes[0];
 | 
	
		
			
				|  |  | -                XmlTree_ZeroElementRules_AfterSelect(XmlTree_ZeroElementRules, new TreeViewEventArgs(XmlTree_ZeroElementRules.SelectedNode));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -          
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        void LoadZeroElementRulesToTreeControl(string DBAddress, TreeNodeCollection XmlTree_ZeroElementRules)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            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 ZeroElementRules", m_dbConnection);
 | 
	
		
			
				|  |  | -                DataSet ds = new DataSet();
 | 
	
		
			
				|  |  | -                m_dataAdapter.Fill(ds);
 | 
	
		
			
				|  |  | -                DataTable dt = ds.Tables[0];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                if (dt != null)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (dt.Rows.Count > 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        foreach (DataRow item in dt.Rows)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
 | 
	
		
			
				|  |  | -                            new_child.Text = item["ZeroElement"].ToString() + "=0";
 | 
	
		
			
				|  |  | -                            new_child.Tag = item["Expression"];
 | 
	
		
			
				|  |  | -                            XmlTree_ZeroElementRules.Add(new_child);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //textbox_STDEditor 中的光标
 | 
	
		
			
				|  |  | -            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;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                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_ZeroElementRules.SelectedNode != null)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "Item,It`s format of name is error, The correct format is : element name =0", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                            return;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "Item,It`s format of name is error, The correct format is : element name =0", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    //判断textbox_STDEditor
 | 
	
		
			
				|  |  | -                    if (!Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
 | 
	
		
			
				|  |  | -                TreeView XmlTree = (TreeView)XmlTreeMenuStrip.SourceControl;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                if (XmlTreeMenuStrip.SourceControl.Name == "XmlTree_ZeroElementRules")
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    new_child.Text = "NewElement=0";
 | 
	
		
			
				|  |  | -                    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 SaveXmlTreeDataToZeroElementRules(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 = "drop table ZeroElementRules";
 | 
	
		
			
				|  |  | -            cmm.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            cmm.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT, UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT)";
 | 
	
		
			
				|  |  | -            cmm.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ZeroElementRules", m_dbConnection);
 | 
	
		
			
				|  |  | -            System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            DataSet ds = new DataSet();
 | 
	
		
			
				|  |  | -            m_dataAdapter.Fill(ds, "ZeroElementRules");
 | 
	
		
			
				|  |  | -            DataTable dt = ds.Tables["ZeroElementRules"];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            for (int num = 0; num < XmlTree_ZeroElementRules.Nodes.Count; num++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                string UsingElementList = "";
 | 
	
		
			
				|  |  | -                string UsingImgPropertyList = "";
 | 
	
		
			
				|  |  | -                string UsingOtherPropertyList = "";
 | 
	
		
			
				|  |  | -                List<string> UsingElementL = new List<string>();
 | 
	
		
			
				|  |  | -                List<string> UsingImgPropertyL = new List<string>();
 | 
	
		
			
				|  |  | -                List<string> UsingOtherPropertyL = new List<string>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                string str_RemoveBlank = "";
 | 
	
		
			
				|  |  | -                str_RemoveBlank = XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Replace(" ", "");
 | 
	
		
			
				|  |  | -                string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
 | 
	
		
			
				|  |  | -                List<string> str_Removeandor = new List<string>();
 | 
	
		
			
				|  |  | -                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<string> list_all = new List<string>();
 | 
	
		
			
				|  |  | -                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["ZeroElement"] = XmlTree_ZeroElementRules.Nodes[num].Text.Split('=')[0];
 | 
	
		
			
				|  |  | -                newRow["UsingElementList"] = UsingElementList;
 | 
	
		
			
				|  |  | -                newRow["UsingImgPropertyList"] = UsingImgPropertyList;
 | 
	
		
			
				|  |  | -                newRow["UsingOtherPropertyList"] = UsingOtherPropertyList;
 | 
	
		
			
				|  |  | -                newRow["Expression"] = XmlTree_ZeroElementRules.Nodes[num].Tag;
 | 
	
		
			
				|  |  | -                dt.Rows.Add(newRow);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            m_dataAdapter.Update(ds, "ZeroElementRules");
 | 
	
		
			
				|  |  | -            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_ZeroElementRules_Resize);
 | 
	
		
			
				|  |  | -            //    //panel_OTSPeriodicTable.Visible = false;
 | 
	
		
			
				|  |  | -            //    //this.Width = this.Width - panel_OTSPeriodicTable.Width;
 | 
	
		
			
				|  |  | -            //    ////this.Resize += new System.EventHandler(this.Form_ZeroElementRules_Resize);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //    //PeriodicTableSwitch.BackColor = SystemColors.ControlDark;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //    ////if (Language == "English")
 | 
	
		
			
				|  |  | -            //    ////{
 | 
	
		
			
				|  |  | -            //    ////    PeriodicTableSwitch.Text = "Close PeriodicTable";
 | 
	
		
			
				|  |  | -            //    ////}
 | 
	
		
			
				|  |  | -            //    ////else if(Language == "Chinese")
 | 
	
		
			
				|  |  | -            //    ////{
 | 
	
		
			
				|  |  | -            //    ////    PeriodicTableSwitch.Text = "关闭元素周期表";
 | 
	
		
			
				|  |  | -            //    ////}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //    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();
 | 
	
		
			
				|  |  | -            //        }
 | 
	
		
			
				|  |  | -            //    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -            //else if (PeriodicTableSwitch.BackColor == SystemColors.ControlDark)
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    //this.Resize -= new System.EventHandler(this.Form_ZeroElementRules_Resize);
 | 
	
		
			
				|  |  | -            //    //this.Width = this.Width + panel_OTSPeriodicTable.Width + 5;
 | 
	
		
			
				|  |  | -            //    panel_OTSPeriodicTable.Visible = true;
 | 
	
		
			
				|  |  | -            //    //this.Resize += new System.EventHandler(this.Form_ZeroElementRules_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_ZeroElementRules.SelectedNode != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "Item,It`s format of name is error, The correct format is : element name =0", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "Item,It`s format of name is error, The correct format is : element name =0", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                    return;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                //判断textbox_STDEditor
 | 
	
		
			
				|  |  | -                if (!Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    return;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //SaveXmlTreeDataToXml(Address);
 | 
	
		
			
				|  |  | -            SaveXmlTreeDataToZeroElementRules(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_STDEditor.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("fourth_elem", "");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
 | 
	
		
			
				|  |  | -            List<string> str_Removeandor = new List<string>();
 | 
	
		
			
				|  |  | -            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<string> list_all = new List<string>();
 | 
	
		
			
				|  |  | -            for (int i = 0; i < str_Removeandor.Count; i++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //常量
 | 
	
		
			
				|  |  | -            List<string> Constantslist = new List<string>();
 | 
	
		
			
				|  |  | -            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);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                XmlTree_ZeroElementRules.Nodes.Clear();
 | 
	
		
			
				|  |  | -                //LoadXmlToTreeControl(doc,XmlTree_ZeroElementRules.Nodes);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                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;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                LoadZeroElementRulesToTreeControl(STDDBAddress_backup, XmlTree_ZeroElementRules.Nodes);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                XmlTree_ZeroElementRules.Focus();
 | 
	
		
			
				|  |  | -                if (XmlTree_ZeroElementRules.Nodes.Count > 0)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules.SelectedNode = XmlTree_ZeroElementRules.Nodes[0];
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules_AfterSelect(XmlTree_ZeroElementRules, new TreeViewEventArgs(XmlTree_ZeroElementRules.SelectedNode));
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    textbox_STDEditor.Text = "";
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (Exception ex)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                MessageBox.Show("Recovery failed!" + "\n" + ex.Message.ToString(), "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void XmlTree_ZeroElementRules_MouseDoubleClick(object sender, MouseEventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (e.Button == MouseButtons.Left)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                Point ClickPoint = new Point(e.X, e.Y);
 | 
	
		
			
				|  |  | -                TreeNode CurrentNode = XmlTree_ZeroElementRules.GetNodeAt(ClickPoint);
 | 
	
		
			
				|  |  | -                if (CurrentNode != null)//判断你点的是不是一个节点
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules.SelectedNode = CurrentNode;//选中这个节点
 | 
	
		
			
				|  |  | -                    //this.textbox_STDEditor.Text = XmlTree_ZeroElementRules.SelectedNode.Tag.ToString();
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules.LabelEdit = true;
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules.SelectedNode.BeginEdit();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private bool CheckConstants(string ConstantName)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            for (int num = 0; num < XmlTree_ZeroElementRules.Nodes.Count; num++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Contains(ConstantName))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    XmlTree_ZeroElementRules.SelectedNode = XmlTree_ZeroElementRules.Nodes[num];
 | 
	
		
			
				|  |  | -                    SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
 | 
	
		
			
				|  |  | -                    DialogResult result = MessageBox.Show("Closing failed," + XmlTree_ZeroElementRules.Nodes[num].Text + "Item ,it`s rule input contains this constant!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 | 
	
		
			
				|  |  | -                    return false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            return true;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void XmlTree_ZeroElementRules_BeforeSelect(object sender, TreeViewCancelEventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (XmlTree_ZeroElementRules.SelectedNode != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "Item,It`s format of name is error, The correct format is : element name =0", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
 | 
	
		
			
				|  |  | -                        e.Cancel = true;
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "Item,It`s format of name is error, The correct format is : element name =0", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                    SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
 | 
	
		
			
				|  |  | -                    e.Cancel = true;
 | 
	
		
			
				|  |  | -                    return;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (!Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
 | 
	
		
			
				|  |  | -                    e.Cancel = true;
 | 
	
		
			
				|  |  | -                    return;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void XmlTree_ZeroElementRules_AfterSelect(object sender, TreeViewEventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            SetBlackAllNodes(XmlTree_ZeroElementRules);
 | 
	
		
			
				|  |  | -            this.textbox_STDEditor.Text = XmlTree_ZeroElementRules.SelectedNode.Tag.ToString();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void textbox_STDEditor_Leave(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            XmlTree_ZeroElementRules.Focus();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        #region  为配合textbox_STDEditor_Leave时事件,点击其它groupbox组件时使焦点转移
 | 
	
		
			
				|  |  | -        private void Form_ConstantsEditor_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            groupBox_CalculatingSymbols.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();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        #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_ZeroElementRules_Resize(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        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(con.Name== "Form_ZeroElementRules")
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    continue;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                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
 | 
	
		
			
				|  |  | -        //string Address_backup = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD_backup.xml";
 | 
	
		
			
				|  |  | -        //string Address = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD.xml";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //private void Form_ZeroElementRules_Load(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    XmlDocument doc = new XmlDocument();
 | 
	
		
			
				|  |  | -        //    doc.Load(Address);
 | 
	
		
			
				|  |  | -        //    LoadXmlToTreeControl(doc, XmlTree_ZeroElementRules.Nodes);
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -        //保存xmltree内容到xml文件
 | 
	
		
			
				|  |  | -        //void SaveXmlTreeDataToXml(string Address)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    XDocument xdoc = XDocument.Load(Address);
 | 
	
		
			
				|  |  | -        //    IEnumerable<XElement> elements = from ele in xdoc.Descendants("XMLData") select ele;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    var item = (from ele1 in elements.Elements("Collection")
 | 
	
		
			
				|  |  | -        //                where ele1.Attribute("RegName").Value.Equals("ZeroElementRules")
 | 
	
		
			
				|  |  | -        //                select ele1).FirstOrDefault();
 | 
	
		
			
				|  |  | -        //    if (item != null)
 | 
	
		
			
				|  |  | -        //    {
 | 
	
		
			
				|  |  | -        //        item.Remove();
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    XElement ZeroElement = new XElement("Collection");
 | 
	
		
			
				|  |  | -        //    ZeroElement.SetAttributeValue("RegName", "ZeroElementRules");
 | 
	
		
			
				|  |  | -        //    elements.ElementAt(0).Add(ZeroElement);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    for (int num = 0; num < XmlTree_ZeroElementRules.Nodes.Count; num++)
 | 
	
		
			
				|  |  | -        //    {
 | 
	
		
			
				|  |  | -        //        string UsingElementList = "";
 | 
	
		
			
				|  |  | -        //        string UsingImgPropertyList = "";
 | 
	
		
			
				|  |  | -        //        string UsingOtherPropertyList = "";
 | 
	
		
			
				|  |  | -        //        List<string> UsingElementL = new List<string>();
 | 
	
		
			
				|  |  | -        //        List<string> UsingImgPropertyL = new List<string>();
 | 
	
		
			
				|  |  | -        //        List<string> UsingOtherPropertyL = new List<string>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //        string str_RemoveBlank = "";
 | 
	
		
			
				|  |  | -        //        //forth_elem干扰or分隔符,故先行去掉
 | 
	
		
			
				|  |  | -        //        if (XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Contains("forth_elem"))
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
 | 
	
		
			
				|  |  | -        //            UsingOtherPropertyL.Add("forth_elem");
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //        str_RemoveBlank = XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Replace(" ", "");
 | 
	
		
			
				|  |  | -        //        string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
 | 
	
		
			
				|  |  | -        //        List<string> str_Removeandor = new List<string>();
 | 
	
		
			
				|  |  | -        //        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<string> list_all = new List<string>();
 | 
	
		
			
				|  |  | -        //        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("ZeroElement", XmlTree_ZeroElementRules.Nodes[num].Text.Split('=')[0]);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("UsingElementList", UsingElementList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("UsingImgPropertyList", UsingImgPropertyList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("UsingOtherPropertyList", UsingOtherPropertyList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Expression", XmlTree_ZeroElementRules.Nodes[num].Tag);
 | 
	
		
			
				|  |  | -        //        ZeroElement.Add(EleName);
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -        //    xdoc.Save(Address);
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -        //XmlTree_ZeroElementRules
 | 
	
		
			
				|  |  | -        //void LoadXmlToTreeControl(XmlDocument xml, TreeNodeCollection XmlTree_ZeroElementRules)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    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() == "ZeroElementRules")
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            XmlNodeList childlist = root2[j].ChildNodes;
 | 
	
		
			
				|  |  | -        //            for (int i = 0; i < childlist.Count; i++)
 | 
	
		
			
				|  |  | -        //            {
 | 
	
		
			
				|  |  | -        //                TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
 | 
	
		
			
				|  |  | -        //                new_child.Text = childlist[i].Attributes["ZeroElement"].Value + "=0";
 | 
	
		
			
				|  |  | -        //                new_child.Tag = childlist[i].Attributes["Expression"].Value;
 | 
	
		
			
				|  |  | -        //                XmlTree_ZeroElementRules.Add(new_child);
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -        //    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);
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -        //private void button_Backup_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    if (XmlTree_ZeroElementRules.SelectedNode != null)
 | 
	
		
			
				|  |  | -        //    {
 | 
	
		
			
				|  |  | -        //        if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
 | 
	
		
			
				|  |  | -        //            {
 | 
	
		
			
				|  |  | -        //                MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -        //                return;
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -        //        else
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -        //            return;
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -        //        //判断textbox_STDEditor
 | 
	
		
			
				|  |  | -        //        if (!Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            return;
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -        //        XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.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_ZeroElementRules_FormClosing(object sender, FormClosingEventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (form_PeriodicTable != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                form_PeriodicTable.Close();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -}
 |