|  | @@ -1,1733 +0,0 @@
 | 
	
		
			
				|  |  | -using SourceGrid;
 | 
	
		
			
				|  |  | -using System;
 | 
	
		
			
				|  |  | -using System.Collections;
 | 
	
		
			
				|  |  | -using System.Collections.Generic;
 | 
	
		
			
				|  |  | -using System.ComponentModel;
 | 
	
		
			
				|  |  | -using System.Data;
 | 
	
		
			
				|  |  | -using System.Drawing;
 | 
	
		
			
				|  |  | -using System.Linq;
 | 
	
		
			
				|  |  | -using System.Text;
 | 
	
		
			
				|  |  | -using System.Threading.Tasks;
 | 
	
		
			
				|  |  | -using System.Windows.Forms;
 | 
	
		
			
				|  |  | -using System.Xml;
 | 
	
		
			
				|  |  | -using System.Xml.Linq;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -namespace OTSPartA_STDEditor
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -    public partial class Form_ConstantsEditor2 : Form
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | -        OTSDockWindow m_DockWindow = null;
 | 
	
		
			
				|  |  | -        public STDRuleslist m_STDRuleslist = null;
 | 
	
		
			
				|  |  | -        public Attributes m_Attributes = null;
 | 
	
		
			
				|  |  | -        public SubMidWindow m_SubMidWindow = null;
 | 
	
		
			
				|  |  | -        public Dictionary<int, STDdata> STDDictionary = new Dictionary<int, STDdata>();
 | 
	
		
			
				|  |  | -        private Dictionary<int, STDdata> STDDictionaryInitial=new Dictionary<int, STDdata>();
 | 
	
		
			
				|  |  | -        public Dictionary<int,string> GroupIdDictionaryFromId = new Dictionary<int,string>();
 | 
	
		
			
				|  |  | -        public Dictionary<string, int> GroupIdDictionaryFromName = new Dictionary<string, int>();
 | 
	
		
			
				|  |  | -        string STDDBAddress_backupDirectory = Application.StartupPath + "\\Config\\SysData\\LibBackup\\";
 | 
	
		
			
				|  |  | -        public string STDDBAddress = "";
 | 
	
		
			
				|  |  | -        /// <summary>
 | 
	
		
			
				|  |  | -        /// 0:正在打开的标准库路径;1:所增加标准的颗粒所在结果库位置;2:所增加标准的颗粒FieldId;3:所增加标准的颗粒ParticleId;4:所增加标准的颗粒XRayId
 | 
	
		
			
				|  |  | -        /// </summary>
 | 
	
		
			
				|  |  | -        List<string> ImportArgs = new List<string>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //国际化
 | 
	
		
			
				|  |  | -        public Language lan;
 | 
	
		
			
				|  |  | -        Hashtable table;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //是否做出过更改
 | 
	
		
			
				|  |  | -        public bool IsModified { set; get; }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public Form_ConstantsEditor2()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            InitializeComponent();
 | 
	
		
			
				|  |  | -            m_STDRuleslist = new STDRuleslist(this);
 | 
	
		
			
				|  |  | -            m_Attributes = new Attributes(this);
 | 
	
		
			
				|  |  | -            m_SubMidWindow = new SubMidWindow(this);
 | 
	
		
			
				|  |  | -            m_DockWindow = new OTSDockWindow(this);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public Form_ConstantsEditor2(string[] ImportStandardLibraryArgs)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            InitializeComponent();
 | 
	
		
			
				|  |  | -            m_STDRuleslist = new STDRuleslist(this);
 | 
	
		
			
				|  |  | -            m_Attributes = new Attributes(this);
 | 
	
		
			
				|  |  | -            m_SubMidWindow = new SubMidWindow(this);
 | 
	
		
			
				|  |  | -            m_DockWindow = new OTSDockWindow(this);
 | 
	
		
			
				|  |  | -            foreach (var it in ImportStandardLibraryArgs)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                ImportArgs.Add(it);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void Form_ConstantsEditor2_Load(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            lan = new Language(this);
 | 
	
		
			
				|  |  | -            table = lan.GetNameTable("Form_ConstantsEditor2");
 | 
	
		
			
				|  |  | -            if (STDDBAddress != "")
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                InitForms(STDDBAddress);
 | 
	
		
			
				|  |  | -                this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
 | 
	
		
			
				|  |  | -                IsModified = false;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                if (ImportArgs.Count > 1)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    ImportStandardLibraryTypeSelection m_importStandardLibraryTypeSelection = new ImportStandardLibraryTypeSelection();
 | 
	
		
			
				|  |  | -                    var result = m_importStandardLibraryTypeSelection.ShowDialog();
 | 
	
		
			
				|  |  | -                    if (m_importStandardLibraryTypeSelection.SelectEvent == "xray")
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + ImportArgs[1] + "'");
 | 
	
		
			
				|  |  | -                        m_dbConnection.Open();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        string sqlp = @"select xraydata from xraydata where fieldid=" + ImportArgs[2] + " and xrayindex=" + ImportArgs[4];
 | 
	
		
			
				|  |  | -                        System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter(sqlp, m_dbConnection);
 | 
	
		
			
				|  |  | -                        DataSet ds = new DataSet();
 | 
	
		
			
				|  |  | -                        m_dataAdapter.Fill(ds);
 | 
	
		
			
				|  |  | -                        DataTable dt = ds.Tables[0];
 | 
	
		
			
				|  |  | -                        if (dt.Rows.Count > 0)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            int STDId = AddSTDDictionaryItem();
 | 
	
		
			
				|  |  | -                            if (dt != null)
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                if (dt.Rows.Count > 0)
 | 
	
		
			
				|  |  | -                                {
 | 
	
		
			
				|  |  | -                                    STDEditor.STDXray tDXray = new STDEditor.STDXray();
 | 
	
		
			
				|  |  | -                                    tDXray.StdID = STDId.ToString();
 | 
	
		
			
				|  |  | -                                    tDXray.XrayData = (byte[])dt.Rows[0]["XrayData"];
 | 
	
		
			
				|  |  | -                                    tDXray.InfoState = (int)STDEditor.STDXrayInfoState.Add;
 | 
	
		
			
				|  |  | -                                    m_SubMidWindow.m_STDEditor.m_STDXrayList.Add(tDXray);
 | 
	
		
			
				|  |  | -                                    m_STDRuleslist.AddNewRow(STDId, "NewClassify", Color.Gray);
 | 
	
		
			
				|  |  | -                                    m_SubMidWindow.m_STDEditor.ShowTabXray();
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        m_dbConnection.Close();
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else if (m_importStandardLibraryTypeSelection.SelectEvent == "expression")
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        int STDId = AddSTDDictionaryItem();
 | 
	
		
			
				|  |  | -                        m_STDRuleslist.AddNewRow(STDId, "NewClassify", Color.Gray);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        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];
 | 
	
		
			
				|  |  | -                if (dt.Rows.Count > 0)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    string ConstantsStr = dt.Rows[0][0].ToString();
 | 
	
		
			
				|  |  | -                    ConstantsStr = ConstantsStr.Replace(" ", "");
 | 
	
		
			
				|  |  | -                    string[] ConstantsStr2 = ConstantsStr.Split(',');
 | 
	
		
			
				|  |  | -                    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
 | 
	
		
			
				|  |  | -                    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                m_dbConnection.Close();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (Exception ee)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                MessageBox.Show(ee.ToString());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -       bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            try
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                //STDDictionaryInitial.Clear();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                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 ClassifySTD order by ListNum", 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)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            STDdata new_STDdata = new STDdata();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                            new_STDdata.Hardness = item["Hardness"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.Density = item["Density"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.Electrical_conductivity = item["Electrical_conductivity"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.BSE = item["BSE"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.Formula = item["Formula"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.Element = item["Element"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.StrName = item["StrName"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.Expression = item["Expression"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.Color = item["Color"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.KeyElementList = item["KeyElementList"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.SubElementList = item["SubElementList"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.GroupId = item["GroupId"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.ListNum= item["ListNum"].ToString();
 | 
	
		
			
				|  |  | -                            new_STDdata.GroupId = item["GroupId"].ToString();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                            STDDictionary.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                return true;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch /*(Exception ee)*/
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                MessageBox.Show("The selected standard library is formatted incorrectly, please open the correct standard library!", "Tip");
 | 
	
		
			
				|  |  | -                return false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void ChangeSTDEditorAndGrid_Attributes(int STDId)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            m_SubMidWindow.ChangeText_textbox_STDEditor(STDId);
 | 
	
		
			
				|  |  | -            m_SubMidWindow.SelSTDXray(STDId, STDDictionary[STDId]);
 | 
	
		
			
				|  |  | -            m_Attributes.SetDatatoGrid_Attributes(STDId);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbBackup_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row >= 0)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                //if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
 | 
	
		
			
				|  |  | -                //{
 | 
	
		
			
				|  |  | -                    if (CheckAttributes())
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                            try
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                            SaveFileDialog saveFile = new SaveFileDialog();
 | 
	
		
			
				|  |  | -                            saveFile.Title = "Please select the path which to save the file";
 | 
	
		
			
				|  |  | -                            saveFile.Filter = "Database File(*.db)|*.db";
 | 
	
		
			
				|  |  | -                            saveFile.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
 | 
	
		
			
				|  |  | -                            saveFile.OverwritePrompt = true;  //是否覆盖当前文件
 | 
	
		
			
				|  |  | -                                                              //saveFile.RestoreDirectory = true;  //还原上次目录
 | 
	
		
			
				|  |  | -                            if (saveFile.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
 | 
	
		
			
				|  |  | -                                bool result = SaveDictionaryToClassify(saveFile.FileName);
 | 
	
		
			
				|  |  | -                                STDDBAddress = saveFile.FileName;
 | 
	
		
			
				|  |  | -                                this.Text = this.Text.Split(' ')[0] + "   " + saveFile.FileName;
 | 
	
		
			
				|  |  | -                                //if (result)
 | 
	
		
			
				|  |  | -                                //{
 | 
	
		
			
				|  |  | -                                //    MessageBox.Show("Export file successful!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                                //}
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                return;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                            catch (Exception ex)
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                MessageBox.Show(ex.Message);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    //}
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show("The name of rulecannot be empty!", "Tip");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    SaveFileDialog saveFile = new SaveFileDialog();
 | 
	
		
			
				|  |  | -                    saveFile.Title = "Please select the path which to save the file";
 | 
	
		
			
				|  |  | -                    saveFile.Filter = "Database File(*.db)|*.db";
 | 
	
		
			
				|  |  | -                    saveFile.OverwritePrompt = true;  //是否覆盖当前文件
 | 
	
		
			
				|  |  | -                    saveFile.RestoreDirectory = true;  //还原上次目录
 | 
	
		
			
				|  |  | -                    if (saveFile.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        System.IO.File.Copy(STDDBAddress, saveFile.FileName, true);
 | 
	
		
			
				|  |  | -                        bool result = SaveDictionaryToClassify(saveFile.FileName);
 | 
	
		
			
				|  |  | -                        if (result)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            MessageBox.Show("Export file successful!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (Exception ex)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ex.Message);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public bool ClearDb(string DBAddress, string DBTableName)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            try
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
 | 
	
		
			
				|  |  | -                m_dbConnection.Open();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
 | 
	
		
			
				|  |  | -                cmm.CommandText = "delete from " + DBTableName;
 | 
	
		
			
				|  |  | -                cmm.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                m_dbConnection.Close();
 | 
	
		
			
				|  |  | -                return true;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (Exception ex)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                return false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbRecover_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        object Clone(Dictionary<int, STDdata> STDDictionary)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            Dictionary<int, STDdata> STDDictionaryInitial = new Dictionary<int, STDdata>();
 | 
	
		
			
				|  |  | -            foreach (var key in STDDictionary.Keys)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDdata tDdata = new STDdata();
 | 
	
		
			
				|  |  | -                tDdata = tDdata.Clone(STDDictionary[key]) as STDdata;
 | 
	
		
			
				|  |  | -                STDDictionaryInitial.Add(key, tDdata);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            return STDDictionaryInitial;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbSave_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row > 0)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (CheckAttributes())
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                FormForWaiting forWaiting = new FormForWaiting();
 | 
	
		
			
				|  |  | -                                forWaiting.Show();
 | 
	
		
			
				|  |  | -                                SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
 | 
	
		
			
				|  |  | -                                // SaveXmlTreeDataToXml(Address);
 | 
	
		
			
				|  |  | -                                bool result = SaveDictionaryToClassify(STDDBAddress);
 | 
	
		
			
				|  |  | -                                if (result)
 | 
	
		
			
				|  |  | -                                {
 | 
	
		
			
				|  |  | -                                    m_SubMidWindow.m_STDEditor.SaveSTDXray();
 | 
	
		
			
				|  |  | -                                    STDDictionaryInitial.Clear();
 | 
	
		
			
				|  |  | -                                    STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
 | 
	
		
			
				|  |  | -                                    forWaiting.Close();
 | 
	
		
			
				|  |  | -                                    IsModified = false;
 | 
	
		
			
				|  |  | -                                    //MessageBox.Show("Save successful!", "Tip");
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                else
 | 
	
		
			
				|  |  | -                                {
 | 
	
		
			
				|  |  | -                                    forWaiting.Close();
 | 
	
		
			
				|  |  | -                                    MessageBox.Show("Save failed!", "Tip");
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    Position pos = new Position(1, 0);
 | 
	
		
			
				|  |  | -                    m_STDRuleslist.Grid_Minerals[1, 0].Grid.Select();
 | 
	
		
			
				|  |  | -                    if (m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "")
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (CheckAttributes())
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                FormForWaiting forWaiting = new FormForWaiting();
 | 
	
		
			
				|  |  | -                                forWaiting.Show();
 | 
	
		
			
				|  |  | -                                SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
 | 
	
		
			
				|  |  | -                                //SaveXmlTreeDataToXml(Address);
 | 
	
		
			
				|  |  | -                                bool result = SaveDictionaryToClassify(STDDBAddress);
 | 
	
		
			
				|  |  | -                                if (result)
 | 
	
		
			
				|  |  | -                                {
 | 
	
		
			
				|  |  | -                                    m_SubMidWindow.m_STDEditor.SaveSTDXray();
 | 
	
		
			
				|  |  | -                                    STDDictionaryInitial.Clear();
 | 
	
		
			
				|  |  | -                                    STDDictionaryInitial = new Dictionary<int, STDdata>(STDDictionary);
 | 
	
		
			
				|  |  | -                                    forWaiting.Close();
 | 
	
		
			
				|  |  | -                                    IsModified = false;
 | 
	
		
			
				|  |  | -                                    MessageBox.Show("Save successful!", "Tip");
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                else
 | 
	
		
			
				|  |  | -                                {
 | 
	
		
			
				|  |  | -                                    forWaiting.Close();
 | 
	
		
			
				|  |  | -                                    MessageBox.Show("Save failed!", "Tip");
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        /// <summary>
 | 
	
		
			
				|  |  | -        /// [颜色:RGB转成16进制]
 | 
	
		
			
				|  |  | -        /// </summary>
 | 
	
		
			
				|  |  | -        /// <param name="R">红 int</param>
 | 
	
		
			
				|  |  | -        /// <param name="G">绿 int</param>
 | 
	
		
			
				|  |  | -        /// <param name="B">蓝 int</param>
 | 
	
		
			
				|  |  | -        /// <returns></returns>
 | 
	
		
			
				|  |  | -        public static string colorRGBtoHx16(int R, int G, int B)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            return System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(R, G, B));
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        //表达式规则检查
 | 
	
		
			
				|  |  | -        public bool Checktextbox_STDEditor()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            string str_RemoveBlank = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Replace(" ", "");
 | 
	
		
			
				|  |  | -            if (str_RemoveBlank != "")
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
 | 
	
		
			
				|  |  | -                //分割符号检验
 | 
	
		
			
				|  |  | -                string[] Symbol = { "and", "or", "+", "-", "*", "/", "=", ">", "<" };
 | 
	
		
			
				|  |  | -                for (int i = 0; i < Symbol.Length; i++)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    for (int j = 0; j < Symbol.Length; j++)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if ((Symbol[i] + Symbol[j]) != ">=" && (Symbol[i] + Symbol[j]) != "<=")
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (str_RemoveBlank.Contains(Symbol[i] + Symbol[j]))
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                MessageBox.Show("Invalid string exists:" + Symbol[i] + Symbol[j], "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                                return false;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    if (str_RemoveBlank.Contains(Symbol[i] + ")") || str_RemoveBlank.Contains("(" + Symbol[i]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show("Invalid string exists:" + Symbol[i] + ")", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        return false;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    if (str_RemoveBlank.Contains("(" + Symbol[i]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show("Invalid string exists:" + "(" + Symbol[i], "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        return false;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if ((str_RemoveBlank != null) && (str_RemoveBlank != ""))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    //左右括号匹配检验
 | 
	
		
			
				|  |  | -                    int BracketsNum = 0;
 | 
	
		
			
				|  |  | -                    for (int i = 0; i < str_RemoveBlank.Length; i++)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (str_RemoveBlank[i] == '(') BracketsNum++;
 | 
	
		
			
				|  |  | -                        if (str_RemoveBlank[i] == ')') BracketsNum--;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    if (BracketsNum != 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show("Number of left and right parentheses does not match!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        return false;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    //首字符检测
 | 
	
		
			
				|  |  | -                    if ((str_RemoveBlank[0] == '+') || (str_RemoveBlank[0] == '-') || (str_RemoveBlank[0] == '*') || (str_RemoveBlank[0] == '/') || (str_RemoveBlank[0] == '>') || (str_RemoveBlank[0] == '<') || (str_RemoveBlank[0] == '=') || (str_RemoveBlank[0] == ')') || (str_RemoveBlank[str_RemoveBlank.Length - 1] == '('))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                        return false;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    if (str_RemoveBlank.Length >= 3)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                            return false;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                //forth_elem干扰or分隔符,故先行去掉
 | 
	
		
			
				|  |  | -                str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
 | 
	
		
			
				|  |  | -                List<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 < m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Count; j++)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    Constantslist.Add(m_SubMidWindow.m_STDEditor.comboBox_Constants.Items[j].ToString().Split('=')[0]);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                for (int i = 0; i < list_all.Count; i++)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    //周期元素?
 | 
	
		
			
				|  |  | -                    if (this.m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        continue;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    //first_elem?
 | 
	
		
			
				|  |  | -                    if (this.m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        continue;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    //Element1?
 | 
	
		
			
				|  |  | -                    if (this.m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        continue;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    //其它元素?
 | 
	
		
			
				|  |  | -                    if (this.m_SubMidWindow.m_STDEditor.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 (!m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains("<") && !m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains(">") && !m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString().Contains("=") && m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString() != "true" && m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString() != "false")
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show("Expressions have no effect!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                    return false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                var XrayInfo = m_SubMidWindow.m_STDEditor.m_STDXrayList.Find(STDXray => STDXray.StdID == m_STDRuleslist.Grid_Minerals[m_STDRuleslist.PreRow, 0].Tag.ToString());
 | 
	
		
			
				|  |  | -                if (XrayInfo==null||XrayInfo.XrayData==null)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show("Expressions cannot be empty!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                    return false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            return true;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //属性检测
 | 
	
		
			
				|  |  | -        public bool CheckAttributes()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //if (double.Parse(m_Attributes.Grid_Attributes[4, 1].Value.ToString()) <= 0)
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    Position pos = new Position(4, 1);
 | 
	
		
			
				|  |  | -            //    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            //    MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            //    return false;
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -            //if (double.Parse(m_Attributes.Grid_Attributes[5, 1].Value.ToString()) <= 0)
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    Position pos = new Position(5, 1);
 | 
	
		
			
				|  |  | -            //    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            //    MessageBox.Show(table["message11"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            //    return false;
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -            //if (double.Parse(m_Attributes.Grid_Attributes[6, 1].Value.ToString()) <= 0)
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    Position pos = new Position(6, 1);
 | 
	
		
			
				|  |  | -            //    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            //    MessageBox.Show(table["message12"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            //    return false;
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -            //if (int.Parse(m_Attributes.Grid_Attributes[7, 1].Value.ToString()) <= 0)
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    Position pos = new Position(7, 1);
 | 
	
		
			
				|  |  | -            //    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            //    MessageBox.Show(table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            //    return false;
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -            if (m_Attributes.Grid_Attributes[10, 1].Value != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (!GroupIdDictionaryFromName.ContainsKey(m_Attributes.Grid_Attributes[10, 1].Value.ToString()))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    Position pos = new Position(10, 1);
 | 
	
		
			
				|  |  | -                    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -                    MessageBox.Show("This group name is not included, please fill in again!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -                    return false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            #region 化学式和元素暂无限制
 | 
	
		
			
				|  |  | -            //if (m_Attributes.Grid_Attributes[7, 1].Value.ToString())
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    Position pos = new Position(7, 1);
 | 
	
		
			
				|  |  | -            //    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            //    MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            //    return false;
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //if (m_Attributes.Grid_Attributes[8, 1].Value.ToString())
 | 
	
		
			
				|  |  | -            //{
 | 
	
		
			
				|  |  | -            //    Position pos = new Position(8, 1);
 | 
	
		
			
				|  |  | -            //    m_Attributes.Grid_Attributes.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            //    MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 | 
	
		
			
				|  |  | -            //    return false;
 | 
	
		
			
				|  |  | -            //}
 | 
	
		
			
				|  |  | -            #endregion
 | 
	
		
			
				|  |  | -            return true;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void SaveDataOfSelRule(int PreRow, int PreColumn)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].StrName = m_Attributes.Grid_Attributes[2, 1].Value.ToString();
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Color = colorRGBtoHx16(m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Hardness = m_Attributes.Grid_Attributes[4, 1].Value.ToString();
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Density = m_Attributes.Grid_Attributes[5, 1].Value.ToString();
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Electrical_conductivity = m_Attributes.Grid_Attributes[6, 1].Value.ToString();
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].BSE = m_Attributes.Grid_Attributes[7, 1].Value.ToString();  
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (m_Attributes.Grid_Attributes[8, 1].Value!= null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = m_Attributes.Grid_Attributes[8, 1].Value.ToString();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Formula = "";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (m_Attributes.Grid_Attributes[9, 1].Value != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = m_Attributes.Grid_Attributes[9, 1].Value.ToString();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Element = "";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (m_Attributes.Grid_Attributes[10, 1].Value != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId =  GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[10, 1].Value.ToString()].ToString();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].GroupId = "0";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].Expression = m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text.ToString();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            string sKeyElements = "";
 | 
	
		
			
				|  |  | -            for (int i = 0; i < m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Columns.Count; i++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                sKeyElements += m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Rows[0].Cells[i].Value.ToString() + ",";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (sKeyElements.Length > 0)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                sKeyElements = sKeyElements.Substring(0, sKeyElements.Length - 1);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            string sSubElements = "";
 | 
	
		
			
				|  |  | -            for (int i = 0; i < m_SubMidWindow.m_STDEditor.dataGridView_SubElements.Columns.Count; i++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                sSubElements += m_SubMidWindow.m_STDEditor.dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (sSubElements.Length > 0)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].KeyElementList = sKeyElements;
 | 
	
		
			
				|  |  | -            STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[PreRow, 0].Tag.ToString())].SubElementList = sSubElements;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        /// <summary>
 | 
	
		
			
				|  |  | -        /// 保存ClassifySTD库和MineralElements库
 | 
	
		
			
				|  |  | -        /// </summary>
 | 
	
		
			
				|  |  | -        /// <param name="DBAddress"></param>
 | 
	
		
			
				|  |  | -        /// <returns></returns>
 | 
	
		
			
				|  |  | -        bool SaveDictionaryToClassify(string DBAddress)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //保存列表顺序
 | 
	
		
			
				|  |  | -           for(int i=1;i<m_STDRuleslist.Grid_Minerals.RowsCount;i++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                STDDictionary[(int)m_STDRuleslist.Grid_Minerals[i,0].Tag].ListNum = i.ToString();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            try
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
 | 
	
		
			
				|  |  | -                m_dbConnection.Open();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
 | 
	
		
			
				|  |  | -                cmm.CommandText = "delete from ClassifySTD";
 | 
	
		
			
				|  |  | -                //cmm.CommandText = "delete from ClassifySTD_Backup";
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    cmm.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (Exception ex)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                    return false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD", m_dbConnection);
 | 
	
		
			
				|  |  | -                //System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD_Backup", m_dbConnection);
 | 
	
		
			
				|  |  | -                System.Data.SQLite.SQLiteCommandBuilder qLiteCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(m_dataAdapter);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                DataSet ds = new DataSet();
 | 
	
		
			
				|  |  | -                m_dataAdapter.Fill(ds, "ClassifySTD");
 | 
	
		
			
				|  |  | -                DataTable dt = ds.Tables["ClassifySTD"];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                //m_dataAdapter.Fill(ds, "ClassifySTD_Backup");
 | 
	
		
			
				|  |  | -                //DataTable dt = ds.Tables["ClassifySTD_Backup"];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                dt.Clear();
 | 
	
		
			
				|  |  | -                foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    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 = kv.Value.Expression;
 | 
	
		
			
				|  |  | -                    //forth_elem干扰or分隔符,故先行去掉
 | 
	
		
			
				|  |  | -                    if (str_RemoveBlank.Contains("forth_elem"))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
 | 
	
		
			
				|  |  | -                        UsingOtherPropertyList = "forth_elem,";
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    str_RemoveBlank = str_RemoveBlank.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 (m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (!UsingElementL.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                UsingElementL.Add(list_all[i]);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        //first_elem?
 | 
	
		
			
				|  |  | -                        if (m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (!UsingOtherPropertyL.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                UsingOtherPropertyL.Add(list_all[i]);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        //Element1?
 | 
	
		
			
				|  |  | -                        if (m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (!UsingOtherPropertyL.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                UsingOtherPropertyL.Add(list_all[i]);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        //其它元素?
 | 
	
		
			
				|  |  | -                        if (m_SubMidWindow.m_STDEditor.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["STDId"] = kv.Key;
 | 
	
		
			
				|  |  | -                    newRow["StrName"] = kv.Value.StrName;
 | 
	
		
			
				|  |  | -                    newRow["Color"] = kv.Value.Color;
 | 
	
		
			
				|  |  | -                    newRow["KeyElementList"] = kv.Value.KeyElementList;
 | 
	
		
			
				|  |  | -                    newRow["SubElementList"] = kv.Value.SubElementList;
 | 
	
		
			
				|  |  | -                    newRow["UsingImgPropertyList"] = UsingImgPropertyList;
 | 
	
		
			
				|  |  | -                    newRow["UsingOtherPropertyList"] = UsingOtherPropertyList;
 | 
	
		
			
				|  |  | -                    newRow["Expression"] = kv.Value.Expression;
 | 
	
		
			
				|  |  | -                    newRow["Hardness"] = kv.Value.Hardness;
 | 
	
		
			
				|  |  | -                    newRow["Density"] = kv.Value.Density;
 | 
	
		
			
				|  |  | -                    newRow["Electrical_conductivity"] = kv.Value.Electrical_conductivity;
 | 
	
		
			
				|  |  | -                    newRow["BSE"] = int.Parse(kv.Value.BSE);
 | 
	
		
			
				|  |  | -                    newRow["Formula"] = kv.Value.Formula;
 | 
	
		
			
				|  |  | -                    newRow["Element"] = kv.Value.Element;
 | 
	
		
			
				|  |  | -                    newRow["GroupId"] = int.Parse(kv.Value.GroupId);
 | 
	
		
			
				|  |  | -                    newRow["ListNum"] = kv.Value.ListNum;
 | 
	
		
			
				|  |  | -                    dt.Rows.Add(newRow);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                m_dataAdapter.Update(ds,"ClassifySTD");
 | 
	
		
			
				|  |  | -                m_dbConnection.Close();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (Exception ex)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                return false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            return true;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public int AddSTDDictionaryItem()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            STDdata new_STDdata = new STDdata();//定义一个TreeNode节点对象
 | 
	
		
			
				|  |  | -            new_STDdata.Hardness = "1";
 | 
	
		
			
				|  |  | -            new_STDdata.Density = "1";
 | 
	
		
			
				|  |  | -            new_STDdata.Electrical_conductivity = "1";
 | 
	
		
			
				|  |  | -            new_STDdata.BSE = "1";
 | 
	
		
			
				|  |  | -            new_STDdata.Formula = "1";
 | 
	
		
			
				|  |  | -            new_STDdata.Element = "1";
 | 
	
		
			
				|  |  | -            new_STDdata.StrName = "NewRuleName";
 | 
	
		
			
				|  |  | -            //new_STDdata.Expression = "NewRules";
 | 
	
		
			
				|  |  | -            new_STDdata.Expression = "";
 | 
	
		
			
				|  |  | -            new_STDdata.KeyElementList = "";
 | 
	
		
			
				|  |  | -            new_STDdata.SubElementList = "";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            new_STDdata.Color = colorRGBtoHx16(Color.Gray.R, Color.Gray.G, Color.Gray.B);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            int STDId = 40000;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (STDId < kv.Key)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    STDId = kv.Key;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            STDDictionary.Add(STDId + 1, new_STDdata);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            return STDId + 1;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void RemoveSTDDictionaryItem(int STDId)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            STDDictionary.Remove(STDId);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void ChangeStrName(int RowNum, string NewStrName)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            STDDictionary[(int)m_STDRuleslist.Grid_Minerals[RowNum, 0].Tag].StrName = NewStrName;
 | 
	
		
			
				|  |  | -            m_Attributes.Grid_Attributes[2, 1].Value = NewStrName;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void ChangeSTDRulesLISTBackColor()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            int stdid=m_STDRuleslist.ChangeSTDRulesLISTBackColor();
 | 
	
		
			
				|  |  | -            if (stdid != -1)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                m_SubMidWindow.m_STDEditor.SelSTDXray(stdid, STDDictionary[stdid]);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        public void ChangeSTDRuleName(String RuleName)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value = RuleName;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void SetNull()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
 | 
	
		
			
				|  |  | -            for (int i = 1; i<m_Attributes.Grid_Attributes.RowsCount-1; i++)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                m_Attributes.Grid_Attributes[i, 1].Value = "";
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
 | 
	
		
			
				|  |  | -            view.BackColor = Color.White;
 | 
	
		
			
				|  |  | -            m_Attributes.Grid_Attributes[2, 1].View= view;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Rows.Clear();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.dataGridView_KeyElements.Columns.Clear();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.dataGridView_SubElements.Rows.Clear();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.dataGridView_SubElements.Columns.Clear();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void ribbon_ESDMaxRules_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            Form_MaxEDSRules form_MaxEDSRules = new Form_MaxEDSRules(STDDBAddress);
 | 
	
		
			
				|  |  | -            form_MaxEDSRules.Show();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void ribbon_ZeroRules_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            Form_ZeroElementRules form_ZeroElementRules = new Form_ZeroElementRules(STDDBAddress);
 | 
	
		
			
				|  |  | -            form_ZeroElementRules.Show();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void ribbon_UserConstants_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            Form_UserConstants form_UserConstants = new Form_UserConstants(STDDBAddress);
 | 
	
		
			
				|  |  | -            DialogResult dialogResult=form_UserConstants.ShowDialog();
 | 
	
		
			
				|  |  | -            if (dialogResult == DialogResult.Yes)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                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 value from Constants", m_dbConnection);
 | 
	
		
			
				|  |  | -                    DataSet ds = new DataSet();
 | 
	
		
			
				|  |  | -                    m_dataAdapter.Fill(ds);
 | 
	
		
			
				|  |  | -                    DataTable dt = ds.Tables[0];
 | 
	
		
			
				|  |  | -                    string ConstantsStr = dt.Rows[0][0].ToString();
 | 
	
		
			
				|  |  | -                    ConstantsStr = ConstantsStr.Replace(" ", "");
 | 
	
		
			
				|  |  | -                    string[] ConstantsStr2 = ConstantsStr.Split(',');
 | 
	
		
			
				|  |  | -                    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
 | 
	
		
			
				|  |  | -                    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
 | 
	
		
			
				|  |  | -                    m_dbConnection.Close();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (Exception ee)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ee.ToString());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public void AddSTDGroupsToAttribute()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            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 name,id from STDGroups order by iorder", m_dbConnection);
 | 
	
		
			
				|  |  | -                DataSet ds = new DataSet();
 | 
	
		
			
				|  |  | -                m_dataAdapter.Fill(ds);
 | 
	
		
			
				|  |  | -                DataTable dt = ds.Tables[0];
 | 
	
		
			
				|  |  | -                if (dt != null)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (dt.Rows.Count >= 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        GroupIdDictionaryFromId.Clear();
 | 
	
		
			
				|  |  | -                        GroupIdDictionaryFromName.Clear();
 | 
	
		
			
				|  |  | -                        if (dt.Select("id='0'").Length==0)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            GroupIdDictionaryFromId.Add(0, "Default");
 | 
	
		
			
				|  |  | -                            GroupIdDictionaryFromName.Add("Default", 0);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        List<string> ss = new List<string>();
 | 
	
		
			
				|  |  | -                        foreach (DataRow item in dt.Rows)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            ss.Add(item["name"].ToString());
 | 
	
		
			
				|  |  | -                            GroupIdDictionaryFromName.Add(item["name"].ToString(), int.Parse(item["id"].ToString()));
 | 
	
		
			
				|  |  | -                            GroupIdDictionaryFromId.Add(int.Parse(item["id"].ToString()),item["name"].ToString());
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        SourceGrid.Cells.Editors.ComboBox GroupIdCBBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
 | 
	
		
			
				|  |  | -                        GroupIdCBBox.StandardValues = ss;
 | 
	
		
			
				|  |  | -                        GroupIdCBBox.EditableMode = SourceGrid.EditableMode.SingleClick| SourceGrid.EditableMode.Focus;
 | 
	
		
			
				|  |  | -                        m_Attributes.Grid_Attributes[10, 1] = new SourceGrid.Cells.Cell("Default", GroupIdCBBox);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                //string ConstantsStr = dt.Rows[0][0].ToString();
 | 
	
		
			
				|  |  | -                m_dbConnection.Close();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (Exception ee)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                MessageBox.Show(ee.ToString());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        void SetNonexistentGroupsToDefault()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if(!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    kv.Value.GroupId = "0";
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            m_Attributes.Grid_Attributes.Refresh();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        private void ribbon_GroupNameMaintenance_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            //STDDictionary[int.Parse(m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Tag.ToString())].GroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[10, 1].Value.ToString()].ToString();
 | 
	
		
			
				|  |  | -            int selGroupId = GroupIdDictionaryFromName[m_Attributes.Grid_Attributes[10, 1].Value.ToString()];
 | 
	
		
			
				|  |  | -            Form_GroupId form_GroupId = new Form_GroupId(STDDBAddress,this);
 | 
	
		
			
				|  |  | -            DialogResult dialogResult = form_GroupId.ShowDialog();
 | 
	
		
			
				|  |  | -            if (dialogResult == DialogResult.Yes)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                AddSTDGroupsToAttribute();
 | 
	
		
			
				|  |  | -                //SetNonexistentGroupsToDefault();
 | 
	
		
			
				|  |  | -                m_Attributes.Grid_Attributes[10, 1].Value = GroupIdDictionaryFromId[selGroupId];
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void ribbon_Exit_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            this.Close();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        #region XML文档部分代码
 | 
	
		
			
				|  |  | -        //string Address = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD.xml";
 | 
	
		
			
				|  |  | -        //string Address_backup = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD_backup.xml";
 | 
	
		
			
				|  |  | -        //private void Form_ConstantsEditor2_Load(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    //XmlDocument doc = new XmlDocument();
 | 
	
		
			
				|  |  | -        //    //doc.Load(Address);
 | 
	
		
			
				|  |  | -        //    //doc.Load(Address_backup);
 | 
	
		
			
				|  |  | -        //    //LoadXmlToDictionary(doc, ref STDDictionary);
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -        //private void rbRecover_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    try
 | 
	
		
			
				|  |  | -        //    {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //        //System.IO.File.Copy(Address_backup, Address, true);
 | 
	
		
			
				|  |  | -        //        //XmlDocument doc = new XmlDocument();
 | 
	
		
			
				|  |  | -        //        //doc.Load(Address);
 | 
	
		
			
				|  |  | -        //        //LoadXmlToDictionary(doc, ref STDDictionary);
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -        //void LoadXmlToDictionary(XmlDocument xml, ref Dictionary<int, STDdata> STDDictionary)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    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() == "STDList")
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            XmlNodeList childlist = root2[j].ChildNodes;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //            for (int i = 0; i < childlist.Count; i++)
 | 
	
		
			
				|  |  | -        //            {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //                //BSE、化学式、元素
 | 
	
		
			
				|  |  | -        //                string strBseValue = string.Empty;
 | 
	
		
			
				|  |  | -        //                string strFormula = string.Empty;
 | 
	
		
			
				|  |  | -        //                string strElement = string.Empty;
 | 
	
		
			
				|  |  | -        //                if (childlist[i].Attributes["BSE"] != null)
 | 
	
		
			
				|  |  | -        //                {
 | 
	
		
			
				|  |  | -        //                    strBseValue = childlist[i].Attributes["BSE"].Value;
 | 
	
		
			
				|  |  | -        //                }
 | 
	
		
			
				|  |  | -        //                if (childlist[i].Attributes["Formula"] != null)
 | 
	
		
			
				|  |  | -        //                {
 | 
	
		
			
				|  |  | -        //                    strFormula = childlist[i].Attributes["Formula"].Value;
 | 
	
		
			
				|  |  | -        //                }
 | 
	
		
			
				|  |  | -        //                if (childlist[i].Attributes["Element"] != null)
 | 
	
		
			
				|  |  | -        //                {
 | 
	
		
			
				|  |  | -        //                    strElement = childlist[i].Attributes["Element"].Value;
 | 
	
		
			
				|  |  | -        //                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //                STDdata new_STDdata = new STDdata();//定义一个TreeNode节点对象
 | 
	
		
			
				|  |  | -        //                new_STDdata.Hardness = childlist[i].Attributes["Hardness"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.Density = childlist[i].Attributes["Density"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.Electrical_conductivity = childlist[i].Attributes["Electrical_conductivity"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.BSE = strBseValue;
 | 
	
		
			
				|  |  | -        //                new_STDdata.Formula = strFormula;
 | 
	
		
			
				|  |  | -        //                new_STDdata.Element = strElement;
 | 
	
		
			
				|  |  | -        //                new_STDdata.StrName = childlist[i].Attributes["StrName"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.Expression = childlist[i].Attributes["Expression"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.STDId = childlist[i].Attributes["STDId"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.Color = childlist[i].Attributes["Color"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.KeyElementList = childlist[i].Attributes["KeyElementList"].Value;
 | 
	
		
			
				|  |  | -        //                new_STDdata.SubElementList = childlist[i].Attributes["SubElementList"].Value;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //                STDDictionary.Add(int.Parse(childlist[i].Attributes["STDId"].Value), new_STDdata);
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    XmlNode root3 = root.SelectSingleNode("Member");
 | 
	
		
			
				|  |  | -        //    string ConstantsStr = root3.Attributes["value"].Value;
 | 
	
		
			
				|  |  | -        //    ConstantsStr = ConstantsStr.Replace(" ", "");
 | 
	
		
			
				|  |  | -        //    string[] ConstantsStr2 = ConstantsStr.Split(',');
 | 
	
		
			
				|  |  | -        //    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.Clear();
 | 
	
		
			
				|  |  | -        //    m_SubMidWindow.m_STDEditor.comboBox_Constants.Items.AddRange(ConstantsStr2);
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        ////保存xmltree内容到xml文件
 | 
	
		
			
				|  |  | -        //void SaveXmlTreeDataToXml(string Address)
 | 
	
		
			
				|  |  | -        //{
 | 
	
		
			
				|  |  | -        //    #region text
 | 
	
		
			
				|  |  | -        //    //XElement xele = XElement.Load(Address);
 | 
	
		
			
				|  |  | -        //    //var item = (from ele1 in xele.Elements("Collection")
 | 
	
		
			
				|  |  | -        //    //            where ele1.Attribute("RegName").Value.Equals("STDList")
 | 
	
		
			
				|  |  | -        //    //            select ele1).FirstOrDefault();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    //if (item != null)
 | 
	
		
			
				|  |  | -        //    //{
 | 
	
		
			
				|  |  | -        //    //    item.Remove();
 | 
	
		
			
				|  |  | -        //    //}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    //xele.Save(Address);
 | 
	
		
			
				|  |  | -        //    #endregion
 | 
	
		
			
				|  |  | -        //    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("STDList")
 | 
	
		
			
				|  |  | -        //                select ele1).FirstOrDefault();
 | 
	
		
			
				|  |  | -        //    if (item != null)
 | 
	
		
			
				|  |  | -        //    {
 | 
	
		
			
				|  |  | -        //        item.Remove();
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    XElement STD = new XElement("Collection");
 | 
	
		
			
				|  |  | -        //    STD.SetAttributeValue("RegName", "STDList");
 | 
	
		
			
				|  |  | -        //    elements.ElementAt(0).Add(STD);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //    foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
 | 
	
		
			
				|  |  | -        //    {
 | 
	
		
			
				|  |  | -        //        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 = kv.Value.Expression;
 | 
	
		
			
				|  |  | -        //        //forth_elem干扰or分隔符,故先行去掉
 | 
	
		
			
				|  |  | -        //        if (str_RemoveBlank.Contains("forth_elem"))
 | 
	
		
			
				|  |  | -        //        {
 | 
	
		
			
				|  |  | -        //            str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
 | 
	
		
			
				|  |  | -        //            UsingOtherPropertyList = "forth_elem,";
 | 
	
		
			
				|  |  | -        //        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //        str_RemoveBlank = str_RemoveBlank.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 (m_SubMidWindow.m_STDEditor.comboBox_PeriodicTable.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -        //            {
 | 
	
		
			
				|  |  | -        //                if (!UsingElementL.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -        //                {
 | 
	
		
			
				|  |  | -        //                    UsingElementL.Add(list_all[i]);
 | 
	
		
			
				|  |  | -        //                }
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //            //first_elem?
 | 
	
		
			
				|  |  | -        //            if (m_SubMidWindow.m_STDEditor.comboBox_Elem1.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -        //            {
 | 
	
		
			
				|  |  | -        //                if (!UsingOtherPropertyL.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -        //                {
 | 
	
		
			
				|  |  | -        //                    UsingOtherPropertyL.Add(list_all[i]);
 | 
	
		
			
				|  |  | -        //                }
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //            //Element1?
 | 
	
		
			
				|  |  | -        //            if (m_SubMidWindow.m_STDEditor.comboBox_Elem.Items.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -        //            {
 | 
	
		
			
				|  |  | -        //                if (!UsingOtherPropertyL.Contains(list_all[i]))
 | 
	
		
			
				|  |  | -        //                {
 | 
	
		
			
				|  |  | -        //                    UsingOtherPropertyL.Add(list_all[i]);
 | 
	
		
			
				|  |  | -        //                }
 | 
	
		
			
				|  |  | -        //            }
 | 
	
		
			
				|  |  | -        //            //其它元素?
 | 
	
		
			
				|  |  | -        //            if (m_SubMidWindow.m_STDEditor.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("STDId", kv.Key);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("StrName", kv.Value.StrName);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Color", kv.Value.Color);
 | 
	
		
			
				|  |  | -        //        //EleName.SetAttributeValue("UsingElementList", UsingElementList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("KeyElementList", kv.Value.KeyElementList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("SubElementList", kv.Value.SubElementList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("UsingImgPropertyList", UsingImgPropertyList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("UsingOtherPropertyList", UsingOtherPropertyList);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Expression", kv.Value.Expression);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Hardness", kv.Value.Hardness);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Density", kv.Value.Density);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Electrical_conductivity", kv.Value.Electrical_conductivity);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("BSE", kv.Value.BSE);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Formula", kv.Value.Formula);
 | 
	
		
			
				|  |  | -        //        EleName.SetAttributeValue("Element", kv.Value.Element);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //        STD.Add(EleName);
 | 
	
		
			
				|  |  | -        //    }
 | 
	
		
			
				|  |  | -        //    xdoc.Save(Address);
 | 
	
		
			
				|  |  | -        //}
 | 
	
		
			
				|  |  | -        #endregion
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbClose_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {            
 | 
	
		
			
				|  |  | -            if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary) || IsModified)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                DialogResult dr = MessageBox.Show("Whether to save the current modification?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | 
	
		
			
				|  |  | -                if (dr == DialogResult.Yes)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if ((m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "") && CheckAttributes() && Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        else
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            return;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        STDDictionaryInitial.Clear();
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    FormForWaiting forWaiting = new FormForWaiting();
 | 
	
		
			
				|  |  | -                    forWaiting.Show();
 | 
	
		
			
				|  |  | -                    bool result = SaveDictionaryToClassify(STDDBAddress);
 | 
	
		
			
				|  |  | -                    if (result)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        m_SubMidWindow.m_STDEditor.SaveSTDXray();
 | 
	
		
			
				|  |  | -                        forWaiting.Close();
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        forWaiting.Close();
 | 
	
		
			
				|  |  | -                        MessageBox.Show("Save failed!", "Tip");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            m_Attributes.Close();
 | 
	
		
			
				|  |  | -            m_STDRuleslist.Close();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.Close();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_ComparativeLibrary.Close();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.Close();
 | 
	
		
			
				|  |  | -            ButtonStatusClose();
 | 
	
		
			
				|  |  | -            if (this.Text.Split(' ').Count() != 0)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                this.Text = this.Text.Split(' ')[0];
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbOpen_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            OpenFileDialog openFileDialog = new OpenFileDialog();
 | 
	
		
			
				|  |  | -            openFileDialog.Filter = "(*.db)|*.db";
 | 
	
		
			
				|  |  | -            openFileDialog.RestoreDirectory = true;
 | 
	
		
			
				|  |  | -            openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
 | 
	
		
			
				|  |  | -            openFileDialog.FilterIndex = 1;
 | 
	
		
			
				|  |  | -            if (openFileDialog.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    STDDBAddress = openFileDialog.FileName;
 | 
	
		
			
				|  |  | -                    InitForms(STDDBAddress);
 | 
	
		
			
				|  |  | -                    this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
 | 
	
		
			
				|  |  | -                    IsModified = false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show("The selected standard library is formatted incorrectly, please open the correct standard library!", "Tip");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        void ButtonStatusOpen()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            rbOpen.Enabled = false;
 | 
	
		
			
				|  |  | -            rbClose.Enabled = true;
 | 
	
		
			
				|  |  | -            //rbRecover.Enabled = true;
 | 
	
		
			
				|  |  | -            rbBackup.Enabled = true;
 | 
	
		
			
				|  |  | -            rbSave.Enabled = true;
 | 
	
		
			
				|  |  | -            rbNew.Enabled = false;
 | 
	
		
			
				|  |  | -            ribbon_ZeroRules.Enabled = true;
 | 
	
		
			
				|  |  | -            ribbon_ESDMaxRules.Enabled = true;
 | 
	
		
			
				|  |  | -            ribbon_UserConstants.Enabled = true;
 | 
	
		
			
				|  |  | -            ribbon_GroupNameMaintenance.Enabled = true;
 | 
	
		
			
				|  |  | -            ribbon_BulkImport.Enabled = true;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        void ButtonStatusClose()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            rbOpen.Enabled = true;
 | 
	
		
			
				|  |  | -            rbClose.Enabled = false;
 | 
	
		
			
				|  |  | -            //rbRecover.Enabled = false;
 | 
	
		
			
				|  |  | -            rbBackup.Enabled = false;
 | 
	
		
			
				|  |  | -            rbSave.Enabled = false;
 | 
	
		
			
				|  |  | -            rbNew.Enabled = true;
 | 
	
		
			
				|  |  | -            ribbon_ZeroRules.Enabled = false;
 | 
	
		
			
				|  |  | -            ribbon_ESDMaxRules.Enabled = false;
 | 
	
		
			
				|  |  | -            ribbon_UserConstants.Enabled = false;
 | 
	
		
			
				|  |  | -            ribbon_GroupNameMaintenance.Enabled = false;
 | 
	
		
			
				|  |  | -            ribbon_BulkImport.Enabled = false;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        void InitForms(string DBAddress)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            STDDictionary.Clear();
 | 
	
		
			
				|  |  | -            bool ret = LoadClassifyToDictionary(DBAddress, ref STDDictionary);
 | 
	
		
			
				|  |  | -            STDDictionaryInitial = Clone(STDDictionary) as Dictionary<int, STDdata>;
 | 
	
		
			
				|  |  | -            if (!ret)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            ButtonStatusOpen();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            m_STDRuleslist = new STDRuleslist(this);
 | 
	
		
			
				|  |  | -            m_Attributes = new Attributes(this);
 | 
	
		
			
				|  |  | -            m_SubMidWindow = new SubMidWindow(this);
 | 
	
		
			
				|  |  | -            m_DockWindow = new OTSDockWindow(this);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            m_DockWindow.CreateMainWindow();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (m_SubMidWindow.m_STDEditor.m_sc != null)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                m_SubMidWindow.m_STDEditor.m_sc.CloseDB();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.m_sc = new SqlLiteClass(DBAddress);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            LoadConstants(DBAddress);
 | 
	
		
			
				|  |  | -            AddSTDGroupsToAttribute();
 | 
	
		
			
				|  |  | -            m_SubMidWindow.m_STDEditor.textbox_STDEditor.Text = "";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                m_STDRuleslist.button_UpOrder.Enabled = false;
 | 
	
		
			
				|  |  | -                if (m_STDRuleslist.Grid_Minerals.RowsCount == 2)       //就一条时向下按钮置灰
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    m_STDRuleslist.button_DownOrder.Enabled = false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                ChangeSTDEditorAndGrid_Attributes(int.Parse(m_STDRuleslist.Grid_Minerals[1, 0].Tag.ToString()));
 | 
	
		
			
				|  |  | -                Position pos = new Position(1, 0);
 | 
	
		
			
				|  |  | -                m_STDRuleslist.Grid_Minerals[1, 0].Grid.Select();
 | 
	
		
			
				|  |  | -                m_STDRuleslist.Grid_Minerals.Selection.Focus(pos, true);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void ribbon_BulkImport_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            OpenFileDialog openFileDialog = new OpenFileDialog();
 | 
	
		
			
				|  |  | -            openFileDialog.Filter = "(*.db)|*.db";
 | 
	
		
			
				|  |  | -            openFileDialog.RestoreDirectory = true;
 | 
	
		
			
				|  |  | -            openFileDialog.FilterIndex = 1;
 | 
	
		
			
				|  |  | -            openFileDialog.Title = "Please open a database!";
 | 
	
		
			
				|  |  | -            if (openFileDialog.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + openFileDialog.FileName + "'");
 | 
	
		
			
				|  |  | -                    m_dbConnection.Open();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    if(STDDictionary.Count==0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show(table["message27"].ToString(), "Tip");
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    string STDId = m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row,m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column].Tag.ToString();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    bool ret = false;//搜索结果
 | 
	
		
			
				|  |  | -                    for(int i=0;i< STDDictionary.Count;i++)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        STDEditor.Result result = m_SubMidWindow.m_STDEditor.ImportFromResult(STDDictionary.Keys.ElementAt(i).ToString(), m_dbConnection);
 | 
	
		
			
				|  |  | -                        if (result == STDEditor.Result.Success)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            ret = true;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        else if(result == STDEditor.Result.Fail)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            return;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    if (!ret)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        MessageBox.Show("No matching energy spectrum data was found", "Tip");
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    int color = Convert.ToInt32(m_SubMidWindow.m_STDEditor.ParseRGB(STDRuleslist.colorHx16toRGB(STDDictionary[int.Parse(STDId)].Color)).ToString());
 | 
	
		
			
				|  |  | -                    for (int j = 0; j < m_SubMidWindow.m_STDEditor.m_STDXrayList.Count; j++)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (m_SubMidWindow.m_STDEditor.m_STDXrayList[j].StdID == STDId)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            m_SubMidWindow.m_STDEditor.ShowXrayAtlas(color, m_SubMidWindow.m_STDEditor.m_STDXrayList[j].XrayData);
 | 
	
		
			
				|  |  | -                            break;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    m_dbConnection.Close();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch(Exception ex)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        bool EqualsBetweenDictionary(Dictionary<int, STDdata> STDDictionaryInitial, Dictionary<int, STDdata> STDDictionary)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -           if(STDDictionaryInitial.Count!= STDDictionary.Count)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                return false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -           
 | 
	
		
			
				|  |  | -           foreach(var key in STDDictionaryInitial.Keys)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (STDDictionary.Keys.Contains(key))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    if(!STDDictionaryInitial[key].Equals(STDDictionary[key]))
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return false;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    return false;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            return true;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void Form_ConstantsEditor2_FormClosing(object sender, FormClosingEventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (m_STDRuleslist.Text != "")
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                if (!EqualsBetweenDictionary(STDDictionaryInitial, STDDictionary)|| IsModified)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    DialogResult dr = MessageBox.Show("Whether to save the current modification", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | 
	
		
			
				|  |  | -                    if (dr == DialogResult.Yes)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (m_STDRuleslist.Grid_Minerals.RowsCount > 1)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if ((m_STDRuleslist.Grid_Minerals[m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0].Value.ToString().Replace(" ", "").Trim() != "") && CheckAttributes() && Checktextbox_STDEditor())
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                SaveDataOfSelRule(m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row, 0);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                e.Cancel = true;
 | 
	
		
			
				|  |  | -                                return;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        else
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            STDDictionaryInitial.Clear();
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        FormForWaiting forWaiting = new FormForWaiting();
 | 
	
		
			
				|  |  | -                        forWaiting.Show();
 | 
	
		
			
				|  |  | -                        bool result = SaveDictionaryToClassify(STDDBAddress);
 | 
	
		
			
				|  |  | -                        if (result)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            m_SubMidWindow.m_STDEditor.SaveSTDXray();
 | 
	
		
			
				|  |  | -                            forWaiting.Close();
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        else
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            forWaiting.Close();
 | 
	
		
			
				|  |  | -                            MessageBox.Show("Save failed!", "Tip");
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        foreach (KeyValuePair<int, STDdata> kv in STDDictionary)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (!GroupIdDictionaryFromId.Keys.Contains(int.Parse(kv.Value.GroupId)))
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                MessageBox.Show("There is non-existent grouping informations in the classification, please adjust!");
 | 
	
		
			
				|  |  | -                                e.Cancel = true;
 | 
	
		
			
				|  |  | -                                return;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void ribbon_ConvertOreDatabaseToOtsDatabase_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            DataTable OreDatabasedt = new DataTable();
 | 
	
		
			
				|  |  | -            OpenFileDialog openFileDialog = new OpenFileDialog();
 | 
	
		
			
				|  |  | -            openFileDialog.Title= "Please select the database you want to convert";
 | 
	
		
			
				|  |  | -            openFileDialog.Filter = "(*.db)|*.db";
 | 
	
		
			
				|  |  | -            openFileDialog.RestoreDirectory = true;
 | 
	
		
			
				|  |  | -            openFileDialog.FilterIndex = 1;
 | 
	
		
			
				|  |  | -            if (openFileDialog.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    string OreDatabaseAddress = openFileDialog.FileName;
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteConnection m_OreDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + OreDatabaseAddress + "'");
 | 
	
		
			
				|  |  | -                    m_OreDatabaseConnection.Open();
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteDataAdapter m_OreDatabasedataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDMinerals", m_OreDatabaseConnection);
 | 
	
		
			
				|  |  | -                    DataSet OreDatabaseds = new DataSet();
 | 
	
		
			
				|  |  | -                    m_OreDatabasedataAdapter.Fill(OreDatabaseds);
 | 
	
		
			
				|  |  | -                    OreDatabasedt = OreDatabaseds.Tables[0];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    int listnum = 1;
 | 
	
		
			
				|  |  | -                    SaveFileDialog saveFile = new SaveFileDialog();
 | 
	
		
			
				|  |  | -                    saveFile.Title = table["message23"].ToString();
 | 
	
		
			
				|  |  | -                    saveFile.Filter = table["message36"].ToString();
 | 
	
		
			
				|  |  | -                    saveFile.OverwritePrompt = true;  //是否覆盖当前文件
 | 
	
		
			
				|  |  | -                    saveFile.RestoreDirectory = true;  //还原上次目录
 | 
	
		
			
				|  |  | -                    if (saveFile.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        System.Data.SQLite.SQLiteConnection.CreateFile(saveFile.FileName);
 | 
	
		
			
				|  |  | -                        System.Data.SQLite.SQLiteConnection m_OtsDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + saveFile.FileName + "'");
 | 
	
		
			
				|  |  | -                        m_OtsDatabaseConnection.Open();
 | 
	
		
			
				|  |  | -                        System.Data.SQLite.SQLiteCommand OtsDatabaseCommand = m_OtsDatabaseConnection.CreateCommand();
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.CommandText = "CREATE TABLE ClassifySTD (STDId INTEGER,StrName TEXT, Color TEXT,KeyElementList TEXT,SubElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT,Hardness TEXT,Density TEXT,Electrical_conductivity TEXT,BSE INTEGER,Formula TEXT,Element TEXT,ListNum INT,GroupId INT)";
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.CommandText = "CREATE TABLE Constants (value TEXT)";
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.CommandText = "CREATE TABLE MaxEDSRules (MaxEDSTime INT,UsingElementList TEXT, UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT)";
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.CommandText = "CREATE TABLE STDGroups (id INTEGER,name TEXT, color TEXT,iorder INTEGER)";
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.CommandText = "CREATE TABLE STDMinerals (id INTEGER,SPEC BLOB)";
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT, UsingImgPropertyList TEXT,Expression TEXT)";
 | 
	
		
			
				|  |  | -                        OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        foreach (DataRow item in OreDatabasedt.Rows)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            int n = 0;
 | 
	
		
			
				|  |  | -                            string STRcolor = "#0";
 | 
	
		
			
				|  |  | -                            if(int.TryParse(item["color"].ToString(),out n))
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                STRcolor = "#"+n.ToString("X6");
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            int idaAdd10 = 0;
 | 
	
		
			
				|  |  | -                            idaAdd10 = int.Parse(item["id"].ToString()) + 10;
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.CommandText = "insert into ClassifySTD (Density,BSE,Formula,StrName,Color,STDId,ListNum,GroupId,KeyElementList,SubElementList,UsingImgPropertyList,UsingOtherPropertyList,Expression,Hardness,Electrical_conductivity,Element) values ( '" + item["density"].ToString() + "','" + item["BSEValue"].ToString() + "','" + item["formula"].ToString() + "','" + item["name"].ToString() + "','" + STRcolor + "'," + idaAdd10.ToString() + "," + listnum.ToString() + @",0,' ',' ',' ',' ',' ',' ',' ',' ')";
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                            listnum++;
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.CommandText = "insert into STDMinerals (id,SPEC) values (@id,@SPEC)";
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.Parameters.Add("id", DbType.Int32).Value = idaAdd10;
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.Parameters.Add("SPEC", DbType.Binary).Value = item["SPEC"];
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        trans.Commit();
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch(Exception ex)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbMatchescorrespondingelement_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            DataTable OreDatabasedt = new DataTable();
 | 
	
		
			
				|  |  | -            OpenFileDialog openFileDialog = new OpenFileDialog();
 | 
	
		
			
				|  |  | -            openFileDialog.Title = "Please select the database you want to math:";
 | 
	
		
			
				|  |  | -            openFileDialog.Filter = "(*.db)|*.db";
 | 
	
		
			
				|  |  | -            openFileDialog.RestoreDirectory = true;
 | 
	
		
			
				|  |  | -            openFileDialog.FilterIndex = 1;
 | 
	
		
			
				|  |  | -            if (openFileDialog.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    string OreDatabaseAddress = openFileDialog.FileName;
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteConnection m_OreDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + OreDatabaseAddress + "'");
 | 
	
		
			
				|  |  | -                    m_OreDatabaseConnection.Open();
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteDataAdapter m_OreDatabasedataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from MineralElements", m_OreDatabaseConnection);
 | 
	
		
			
				|  |  | -                    DataSet OreDatabaseds = new DataSet();
 | 
	
		
			
				|  |  | -                    m_OreDatabasedataAdapter.Fill(OreDatabaseds);
 | 
	
		
			
				|  |  | -                    OreDatabasedt = OreDatabaseds.Tables[0];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteConnection m_OtsDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
 | 
	
		
			
				|  |  | -                    m_OtsDatabaseConnection.Open();
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteCommand OtsDatabaseCommand = m_OtsDatabaseConnection.CreateCommand();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE MineralElements (mineralID INTEGER,elementID INTEGER,elementPercentage FLOAT)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteDataAdapter m_OtsDatabasedataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select id from STDMinerals", m_OtsDatabaseConnection);
 | 
	
		
			
				|  |  | -                    DataSet OtsDatabaseds = new DataSet();
 | 
	
		
			
				|  |  | -                    m_OtsDatabasedataAdapter.Fill(OtsDatabaseds);
 | 
	
		
			
				|  |  | -                    var OtsDatabasedt = OtsDatabaseds.Tables[0];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    List<int> IdG = new List<int>();
 | 
	
		
			
				|  |  | -                    foreach (DataRow item in OtsDatabasedt.Rows)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        IdG.Add(int.Parse(item["id"].ToString()) - 10);
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    int n = 0;
 | 
	
		
			
				|  |  | -                    foreach (DataRow item in OreDatabasedt.Rows)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        if (!int.TryParse(item["mineralID"].ToString(), out n))
 | 
	
		
			
				|  |  | -                        { continue; }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        if (IdG.Contains(n))
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.CommandText = "insert into MineralElements (mineralID,elementID,elementPercentage) values (@mineralID,@elementID,@elementPercentage)";
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.Parameters.Add("mineralID", DbType.Int32).Value = (n+10);
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.Parameters.Add("elementID", DbType.Int32).Value = item["elementID"];
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.Parameters.Add("elementPercentage", DbType.Double).Value = item["elementPercentage"];
 | 
	
		
			
				|  |  | -                            OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    trans.Commit();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch (Exception ex)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void rbNew_Click(object sender, EventArgs e)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            SaveFileDialog saveFile = new SaveFileDialog();
 | 
	
		
			
				|  |  | -            saveFile.Title = table["message23"].ToString();
 | 
	
		
			
				|  |  | -            saveFile.Filter = table["message36"].ToString();
 | 
	
		
			
				|  |  | -            saveFile.OverwritePrompt = true;  //是否覆盖当前文件
 | 
	
		
			
				|  |  | -            saveFile.RestoreDirectory = true;  //还原上次目录
 | 
	
		
			
				|  |  | -            if (saveFile.ShowDialog() == DialogResult.OK)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                try
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteConnection.CreateFile(saveFile.FileName);
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteConnection m_OtsDatabaseConnection = new System.Data.SQLite.SQLiteConnection("data source='" + saveFile.FileName + "'");
 | 
	
		
			
				|  |  | -                    m_OtsDatabaseConnection.Open();
 | 
	
		
			
				|  |  | -                    System.Data.SQLite.SQLiteCommand OtsDatabaseCommand = m_OtsDatabaseConnection.CreateCommand();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE ClassifySTD (STDId INTEGER,StrName TEXT, Color TEXT,KeyElementList TEXT,SubElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT,Hardness TEXT,Density TEXT,Electrical_conductivity TEXT,BSE INTEGER,Formula TEXT,Element TEXT,ListNum INT,GroupId INT)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE Constants (value TEXT)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE MaxEDSRules (MaxEDSTime INT,UsingElementList TEXT, UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,Expression TEXT)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE STDGroups (id INTEGER,name TEXT, color TEXT,iorder INTEGER)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE STDMinerals (id INTEGER,SPEC BLOB)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT, UsingImgPropertyList TEXT,Expression TEXT)";
 | 
	
		
			
				|  |  | -                    OtsDatabaseCommand.ExecuteNonQuery();
 | 
	
		
			
				|  |  | -                    System.Data.Common.DbTransaction trans = m_OtsDatabaseConnection.BeginTransaction();
 | 
	
		
			
				|  |  | -                    trans.Commit();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                catch(Exception ex)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    MessageBox.Show(ex.ToString());
 | 
	
		
			
				|  |  | -                    return;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                STDDBAddress = saveFile.FileName;
 | 
	
		
			
				|  |  | -                InitForms(STDDBAddress);
 | 
	
		
			
				|  |  | -                this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
 | 
	
		
			
				|  |  | -                IsModified = false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                return;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -}
 |