|
@@ -1,4342 +0,0 @@
|
|
|
-using OTSCLRINTERFACE;
|
|
|
-using System;
|
|
|
-using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Data;
|
|
|
-using System.Drawing;
|
|
|
-using System.IO;
|
|
|
-using System.Linq;
|
|
|
-using System.Runtime.InteropServices;
|
|
|
-using System.Text;
|
|
|
-using System.Text.RegularExpressions;
|
|
|
-using System.Windows.Forms;
|
|
|
-using System.Xml;
|
|
|
-using System.Xml.Linq;
|
|
|
-
|
|
|
-namespace OTSPartA_STDEditor
|
|
|
-{
|
|
|
- public partial class Form_STDConstantsEditor : Form
|
|
|
- {
|
|
|
- //readonly string[] PeriodicTable = {"H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hq","TI","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Mc","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Unb"};
|
|
|
- //readonly string[] OtherSymbol = { "first_elem" , "second_elem" , "third_elem" , "forth_elem", "fifth_elem", "sixth_elem", "seventh_elem","eighth_elem","ninth_elem", "tenth_elem", "Element1", "Element2" };
|
|
|
- public Form_STDConstantsEditor()
|
|
|
- {
|
|
|
- InitializeComponent();
|
|
|
- m_sc = new SqlLiteClass();
|
|
|
- }
|
|
|
- #region 全局变量
|
|
|
- //数据库操作对象
|
|
|
- private SqlLiteClass m_sc = null;
|
|
|
- // 电镜设置对象
|
|
|
- COTSControlFunExport m_cfun = null;
|
|
|
- //Xray图谱用户控件
|
|
|
- UXrayControl XrayControl = null;
|
|
|
- //全局Xray 用于存储当前选择行的Xray信息
|
|
|
- byte[] xrayByteData = null;
|
|
|
- // 连接状态
|
|
|
- bool m_bConnectionState = false;
|
|
|
- //标准Xray信息列表
|
|
|
- List<STDXray> m_STDXrayList = null;
|
|
|
- #endregion
|
|
|
-
|
|
|
- //国际化
|
|
|
- Language lan;
|
|
|
- Hashtable table;
|
|
|
- //public string Language = "English";
|
|
|
- string Address_backup = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD_backup.xml";
|
|
|
- string Address = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
-
|
|
|
- private void Form_ConstantsEditor_Load(object sender, EventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- //初始化comboBox
|
|
|
- this.comboBox_Elem1.Items.Add("first_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("second_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("third_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("forth_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("fifth_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("sixth_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("seventh_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("eighth_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("ninth_elem");
|
|
|
- this.comboBox_Elem1.Items.Add("tenth_elem");
|
|
|
- comboBox_Elem1.SelectedIndex = comboBox_Elem1.Items.IndexOf("first_elem");
|
|
|
-
|
|
|
- this.comboBox_Elem.Items.Add("Element#1");
|
|
|
- this.comboBox_Elem.Items.Add("Element#2");
|
|
|
- this.comboBox_Elem.Items.Add("Element#3");
|
|
|
- this.comboBox_Elem.Items.Add("Element#4");
|
|
|
- this.comboBox_Elem.Items.Add("Element#5");
|
|
|
- this.comboBox_Elem.Items.Add("Element#6");
|
|
|
- this.comboBox_Elem.Items.Add("Element#7");
|
|
|
- this.comboBox_Elem.Items.Add("Element#8");
|
|
|
- this.comboBox_Elem.Items.Add("Element#9");
|
|
|
- this.comboBox_Elem.Items.Add("Element#10");
|
|
|
- comboBox_Elem.SelectedIndex = comboBox_Elem.Items.IndexOf("Element#1");
|
|
|
-
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dmax");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dmin");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Aspect");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dperp");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dmean");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Area");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dferet");
|
|
|
- this.comboBox_ImgProperty.Items.Add("With");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Height");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Perimeter");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dinscr");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Orientation");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Delong");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Aspectelong");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Dequalcircle");
|
|
|
- this.comboBox_ImgProperty.Items.Add("Vedio");
|
|
|
-
|
|
|
- comboBox_ImgProperty.SelectedIndex = comboBox_ImgProperty.Items.IndexOf("Dmax");
|
|
|
-
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#0");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#1");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#2");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#3");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#4");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#5");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#6");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#7");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#8");
|
|
|
- //this.comboBox_Constants.Items.Add("MAC#9");
|
|
|
- //comboBox_Constants.SelectedIndex = comboBox_Constants.Items.IndexOf("MAC#1");
|
|
|
-
|
|
|
- string[] PeriodicTable = { "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hq", "TI", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Mc", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Unb" };
|
|
|
- comboBox_PeriodicTable.Items.AddRange(PeriodicTable);
|
|
|
- AutoCompleteStringCollection sc = new AutoCompleteStringCollection();
|
|
|
- sc.AddRange(PeriodicTable);
|
|
|
- this.comboBox_PeriodicTable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
|
|
|
- this.comboBox_PeriodicTable.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
|
|
|
- this.comboBox_PeriodicTable.AutoCompleteCustomSource = sc;
|
|
|
-
|
|
|
- checkBox_0.Checked = false;
|
|
|
- checkBox_1.Checked = false;
|
|
|
- checkBox_2.Checked = false;
|
|
|
- checkBox_3.Checked = false;
|
|
|
- checkBox_4.Checked = false;
|
|
|
- checkBox_5.Checked = false;
|
|
|
- checkBox_6.Checked = false;
|
|
|
- checkBox_7.Checked = false;
|
|
|
- checkBox_8.Checked = false;
|
|
|
- checkBox_9.Checked = false;
|
|
|
- textBox_0.ReadOnly = true;
|
|
|
- textBox_1.ReadOnly = true;
|
|
|
- textBox_2.ReadOnly = true;
|
|
|
- textBox_3.ReadOnly = true;
|
|
|
- textBox_4.ReadOnly = true;
|
|
|
- textBox_5.ReadOnly = true;
|
|
|
- textBox_6.ReadOnly = true;
|
|
|
- textBox_7.ReadOnly = true;
|
|
|
- textBox_8.ReadOnly = true;
|
|
|
- textBox_9.ReadOnly = true;
|
|
|
-
|
|
|
- textBox_Density.ReadOnly = false;
|
|
|
- textBox_Electrical_conductivity.ReadOnly = false;
|
|
|
- textBox_BSEValue.ReadOnly = false;
|
|
|
- textBox_Formula.ReadOnly = false;
|
|
|
- textBox_Element.ReadOnly = false;
|
|
|
- textBox_Hardness.ReadOnly = false;
|
|
|
- btn_dbs.Enabled = true;
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_KeyElements.RowHeadersVisible = false;
|
|
|
- dataGridView_KeyElements.ColumnHeadersVisible = false;
|
|
|
- dataGridView_KeyElements.AllowUserToAddRows = false;
|
|
|
- dataGridView_KeyElements.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
|
|
-
|
|
|
- dataGridView_SubElements.RowHeadersVisible = false;
|
|
|
- dataGridView_SubElements.ColumnHeadersVisible = false;
|
|
|
- dataGridView_SubElements.AllowUserToAddRows = false;
|
|
|
- dataGridView_SubElements.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
|
|
-
|
|
|
-
|
|
|
- XmlDocument doc = new XmlDocument();
|
|
|
- //string Address = Application.StartupPath.Substring(0, Application.StartupPath.Length-35) + "\\Opton\\OTSPartA\\OTS\\Bin\\Win32\\Debug\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- //string Address = ".\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- doc.Load(Address);
|
|
|
- LoadXmlToTreeControl(doc, XmlTree_STDlist.Nodes, XmlTree_MaxEDSRules.Nodes, XmlTree_ZeroElementRules.Nodes);
|
|
|
-
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- textBox_MaxEDSTime.ReadOnly = true;
|
|
|
- this.textbox_STDEditor.Text = "";
|
|
|
- //this.XmlTree.TabStop = false;
|
|
|
- panel_OTSPeriodicTable.Visible = false;
|
|
|
- //修改窗体宽度
|
|
|
- //this.Width = this.Width - panel_OTSPeriodicTable.Width - 5;
|
|
|
-
|
|
|
- //if (XmlTree.GetNodeCount(true) != 0)
|
|
|
- //{
|
|
|
- // this.XmlTree.SelectedNode = XmlTree.Nodes[0];
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- lan = new Language(this);
|
|
|
- table = lan.GetNameTable(this.Name);
|
|
|
-
|
|
|
- if (table["language"].ToString() == "EN")
|
|
|
- {
|
|
|
- panel_OTSPeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_EN;
|
|
|
- PeriodicTableSwitch.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.STDEditoName;
|
|
|
- PeriodicTableSwitch.Text = "";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- panel_OTSPeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_ZH;
|
|
|
- PeriodicTableSwitch.Text = "元素周期表";
|
|
|
- }
|
|
|
-
|
|
|
- panel_OTSPeriodicTable.Visible = false;
|
|
|
- this.Width = this.Width - panel_OTSPeriodicTable.Width - 5;
|
|
|
-
|
|
|
- Size size = Screen.PrimaryScreen.WorkingArea.Size; Left = (size.Width - Width) / 2;
|
|
|
- Top = (size.Height - Height) / 2;
|
|
|
- WindowState = FormWindowState.Normal;
|
|
|
-
|
|
|
- //groupBox_XmlTree_MaxEDSRules.Focus();
|
|
|
- this.XmlTree_STDlist.HideSelection = false;//失去焦点后不隐藏选中节点
|
|
|
- XmlTree_STDlist.Focus();
|
|
|
- if (XmlTree_STDlist.Nodes.Count > 0)
|
|
|
- {
|
|
|
- XmlTree_STDlist.SelectedNode = XmlTree_STDlist.Nodes[0];
|
|
|
- XmlTree_STDlist_AfterSelect(XmlTree_STDlist, new TreeViewEventArgs(XmlTree_STDlist.SelectedNode));
|
|
|
- }
|
|
|
-
|
|
|
- //添加Xray用户控件
|
|
|
- XrayControl = new UXrayControl();
|
|
|
- plXray.Controls.Add(XrayControl);
|
|
|
- XrayControl.Dock = DockStyle.Fill;
|
|
|
- //绑定数据库中的STDXray
|
|
|
- m_STDXrayList = new List<STDXray>();
|
|
|
- BindSTDXray();
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// [颜色:16进制转成RGB]
|
|
|
- /// </summary>
|
|
|
- /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static System.Drawing.Color colorHx16toRGB(string strHxColor)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (strHxColor.Length == 0)
|
|
|
- {//如果为空
|
|
|
- return System.Drawing.Color.FromArgb(255, 255, 204);//设为白色
|
|
|
- }
|
|
|
- else
|
|
|
- {//转换颜色
|
|
|
- return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
|
|
|
- }
|
|
|
- }
|
|
|
- catch
|
|
|
- {//设为白色
|
|
|
- return System.Drawing.Color.FromArgb(255, 255, 204);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <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));
|
|
|
- }
|
|
|
-
|
|
|
- //XmlTree_STDlist、XmlTree_MaxEDSRules、XmlTree_ZeroElementRules和 ConstantsPage页
|
|
|
- void LoadXmlToTreeControl(XmlDocument xml, TreeNodeCollection XmlTree_STDlist, TreeNodeCollection XmlTree_MaxEDSRules, TreeNodeCollection XmlTree_ZeroElementRules)
|
|
|
- {
|
|
|
- XmlNode root = xml.SelectSingleNode("XMLData");
|
|
|
- XmlNodeList root2 = root.SelectNodes("Collection");
|
|
|
- for (int j = 0; j < root2.Count; j++)
|
|
|
- {
|
|
|
- if (root2[j].Attributes["RegName"].Value.ToString() == "STDList")
|
|
|
- {
|
|
|
- XmlNodeList childlist = root2[j].ChildNodes;
|
|
|
- for (int i = 0; i < childlist.Count; i++)
|
|
|
- {
|
|
|
- TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
|
|
|
- //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;
|
|
|
- }
|
|
|
- new_child.Name = childlist[i].Attributes["Hardness"].Value + "_" + childlist[i].Attributes["Density"].Value + "_" + childlist[i].Attributes["Electrical_conductivity"].Value + "_" + strBseValue + "_" + strFormula + "_" + strElement + "$" + childlist[i].Attributes["KeyElementList"].Value + "$" + childlist[i].Attributes["SubElementList"].Value;
|
|
|
- new_child.Text = childlist[i].Attributes["StrName"].Value;
|
|
|
- new_child.Tag = childlist[i].Attributes["Expression"].Value;
|
|
|
- new_child.ToolTipText = childlist[i].Attributes["STDId"].Value;
|
|
|
- new_child.BackColor = colorHx16toRGB(childlist[i].Attributes["Color"].Value);
|
|
|
- XmlTree_STDlist.Add(new_child);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (root2[j].Attributes["RegName"].Value.ToString() == "ZeroElementRules")
|
|
|
- {
|
|
|
- XmlNodeList childlist = root2[j].ChildNodes;
|
|
|
- for (int i = 0; i < childlist.Count; i++)
|
|
|
- {
|
|
|
- TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
|
|
|
- new_child.Text = childlist[i].Attributes["ZeroElement"].Value+"=0";
|
|
|
- new_child.Tag = childlist[i].Attributes["Expression"].Value;
|
|
|
- XmlTree_ZeroElementRules.Add(new_child);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (root2[j].Attributes["RegName"].Value.ToString() == "MaxEDSRules")
|
|
|
- {
|
|
|
- XmlNodeList childlist = root2[j].ChildNodes;
|
|
|
- if (childlist.Count != 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < childlist.Count; i++)
|
|
|
- {
|
|
|
- TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
|
|
|
- //new_child.Name = childlist[i].Attributes["MaxEDSTime"].Value;
|
|
|
- new_child.Tag = childlist[i].Attributes["Expression"].Value;
|
|
|
- new_child.Text = "Rule" + i.ToString();
|
|
|
- XmlTree_MaxEDSRules.Add(new_child);
|
|
|
- }
|
|
|
- if (childlist[0].Attributes["MaxEDSTime"] != null)
|
|
|
- {
|
|
|
- textBox_MaxEDSTime.Text = childlist[0].Attributes["MaxEDSTime"].Value;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- XmlNode root3 = root.SelectSingleNode("Member");
|
|
|
- string ConstantsStr = root3.Attributes["value"].Value;
|
|
|
- ConstantsStr = ConstantsStr.Replace(" ", "");
|
|
|
- string[] ConstantsStr2 = ConstantsStr.Split(',');
|
|
|
- this.comboBox_Constants.Items.Clear();
|
|
|
- this.comboBox_Constants.Items.AddRange(ConstantsStr2);
|
|
|
- List<string> Constantslist = new List<string>();
|
|
|
- for (int i = 0; i < ConstantsStr2.Length; i++)
|
|
|
- {
|
|
|
- Constantslist.AddRange(ConstantsStr2[i].Split('='));
|
|
|
- }
|
|
|
- for (int i = 0; i < Constantslist.Count; i += 2)
|
|
|
- {
|
|
|
- if (Constantslist[i].Contains("MAC#0"))
|
|
|
- {
|
|
|
- this.checkBox_0.Checked = true;
|
|
|
- this.textBox_0.ReadOnly = false;
|
|
|
- this.textBox_0.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#1"))
|
|
|
- {
|
|
|
- this.checkBox_1.Checked = true;
|
|
|
- this.textBox_1.ReadOnly = false;
|
|
|
- this.textBox_1.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#2"))
|
|
|
- {
|
|
|
- this.checkBox_2.Checked = true;
|
|
|
- this.textBox_2.ReadOnly = false;
|
|
|
- this.textBox_2.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#3"))
|
|
|
- {
|
|
|
- this.checkBox_3.Checked = true;
|
|
|
- this.textBox_3.ReadOnly = false;
|
|
|
- this.textBox_3.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#4"))
|
|
|
- {
|
|
|
- this.checkBox_4.Checked = true;
|
|
|
- this.textBox_4.ReadOnly = false;
|
|
|
- this.textBox_4.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#5"))
|
|
|
- {
|
|
|
- this.checkBox_5.Checked = true;
|
|
|
- this.textBox_5.ReadOnly = false;
|
|
|
- this.textBox_5.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#6"))
|
|
|
- {
|
|
|
- this.checkBox_6.Checked = true;
|
|
|
- this.textBox_6.ReadOnly = false;
|
|
|
- this.textBox_6.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#7"))
|
|
|
- {
|
|
|
- this.checkBox_7.Checked = true;
|
|
|
- this.textBox_7.ReadOnly = false;
|
|
|
- this.textBox_7.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#8"))
|
|
|
- {
|
|
|
- this.checkBox_8.Checked = true;
|
|
|
- this.textBox_8.ReadOnly = false;
|
|
|
- this.textBox_8.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- else if (Constantslist[i].Contains("MAC#9"))
|
|
|
- {
|
|
|
- this.checkBox_9.Checked = true;
|
|
|
- this.textBox_9.ReadOnly = false;
|
|
|
- this.textBox_9.Text = Constantslist[i + 1];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void comboBox_Elem1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- string newStr = comboBox_Elem1.SelectedItem.ToString();
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr);
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + newStr.Length, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void comboBox_Elem2_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- string newStr = comboBox_Elem.SelectedItem.ToString();
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr);
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + newStr.Length, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void comboBox_ImgProperty_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- string newStr = comboBox_ImgProperty.SelectedItem.ToString();
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr);
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + newStr.Length, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Plus_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "+");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index+1,0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Subtract_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "-");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Multiply_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "*");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Divide_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "/");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret(); ;
|
|
|
- }
|
|
|
-
|
|
|
- private void button_More_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, ">");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Less_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "<");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_LeftParenthesis_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "(");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_RightParenthesis_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, ")");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Equal_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "=");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- //除选中点以外其它节点前景色置灰
|
|
|
- private void SetGrayExceptSelectedNode(TreeView Tree, TreeNode SelectedNode)
|
|
|
- {
|
|
|
- foreach (TreeNode node in Tree.Nodes)
|
|
|
- {
|
|
|
- if (node != SelectedNode)
|
|
|
- {
|
|
|
- node.ForeColor = Color.Gray;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //恢复所有节点颜色为可用
|
|
|
- private void SetBlackAllNodes(TreeView Tree)
|
|
|
- {
|
|
|
- foreach (TreeNode node in Tree.Nodes)
|
|
|
- {
|
|
|
- node.ForeColor = Color.Black;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //点击节点
|
|
|
- private void XmlTree_STDlist_MouseClick(object sender, MouseEventArgs e)
|
|
|
- {
|
|
|
- //if (e.Button == MouseButtons.Left)
|
|
|
- //{
|
|
|
- // Point ClickPoint = new Point(e.X, e.Y);
|
|
|
- // TreeNode CurrentNode = XmlTree_STDlist.GetNodeAt(ClickPoint);
|
|
|
- // if (CurrentNode != null)//判断你点的是不是一个节点
|
|
|
- // {
|
|
|
- // if (XmlTree_STDlist.SelectedNode != null&& XmlTree_STDlist.SelectedNode != CurrentNode)
|
|
|
- // {
|
|
|
- // //判断Hardness、Density、Electrical_conductivity
|
|
|
- // double dHardness = 0, dDensity = 0, dElectrical_conductivity = 0;
|
|
|
- // if (!double.TryParse(textBox_Hardness.Text, out dHardness))
|
|
|
- // {
|
|
|
- // MessageBox.Show("硬度输入错误,请输入数字!");
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // if (!double.TryParse(textBox_Density.Text, out dDensity))
|
|
|
- // {
|
|
|
- // MessageBox.Show("密度输入错误,请输入数字!");
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // if (!double.TryParse(textBox_Electrical_conductivity.Text, out dElectrical_conductivity))
|
|
|
- // {
|
|
|
- // MessageBox.Show("导电性输入错误,请输入数字!");
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
- // //判断textbox_STDEditor
|
|
|
- // if (!Checktextbox_STDEditor())
|
|
|
- // {
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // XmlTree_STDlist_SaveBeforeMouseClick(e);
|
|
|
-
|
|
|
- // }
|
|
|
- // SetBlackAllNodes(XmlTree_STDlist);
|
|
|
- // XmlTree_STDlist.SelectedNode = CurrentNode;
|
|
|
- // XmlTree_STDlist.LabelEdit = true;
|
|
|
- // this.textbox_STDEditor.Text = XmlTree_STDlist.SelectedNode.Tag.ToString();
|
|
|
- // btn_dbs.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
-
|
|
|
- // string[] strOther = XmlTree_STDlist.SelectedNode.Name.Split('_');
|
|
|
- // textBox_Hardness.Text = strOther[0];
|
|
|
- // textBox_Density.Text = strOther[1];
|
|
|
- // textBox_Electrical_conductivity.Text = strOther[2];
|
|
|
-
|
|
|
- // if (UpOrder.Enabled == false)
|
|
|
- // {
|
|
|
- // UpOrder.Enabled = true;
|
|
|
- // }
|
|
|
- // if (DownOrder.Enabled == false)
|
|
|
- // {
|
|
|
- // DownOrder.Enabled = true;
|
|
|
- // }
|
|
|
- // if (XmlTree_STDlist.SelectedNode.PrevNode == null)
|
|
|
- // {
|
|
|
- // UpOrder.Enabled = false;
|
|
|
- // }
|
|
|
- // else if (XmlTree_STDlist.SelectedNode.NextNode == null)
|
|
|
- // {
|
|
|
- // DownOrder.Enabled = false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //if (e.Button == MouseButtons.Right)
|
|
|
- //{
|
|
|
- // Point ClickPoint = new Point(e.X, e.Y);
|
|
|
- // TreeNode CurrentNode = XmlTree.GetNodeAt(ClickPoint);
|
|
|
- // if (CurrentNode != null)//判断你点的是不是一个节点
|
|
|
- // {
|
|
|
- // XmlTree.SelectedNode = CurrentNode;//选中这个节点
|
|
|
- // XmlTree.LabelEdit = true;
|
|
|
- // this.textbox_STDEditor.Text = XmlTree.SelectedNode.Tag.ToString();
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //XmlTree_STDlist点击节点前保存数据-Hardness、Density、Electrical_conductivity、textbox_STDEditor
|
|
|
- void XmlTree_STDlist_BeforeMouseClick(MouseEventArgs e)
|
|
|
- {
|
|
|
- if ((this.textbox_STDEditor.Text != null) && (XmlTree_STDlist.SelectedNode != null))
|
|
|
- {
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- XmlTree_STDlist.SelectedNode.Name = textBox_Hardness.Text + "_" + textBox_Density.Text + "_" + textBox_Electrical_conductivity.Text + "_" + textBox_BSEValue.Text + "_" + textBox_Formula.Text + "_" + textBox_Element.Text; ;
|
|
|
-
|
|
|
- string sKeyElements = "";
|
|
|
- for (int i = 0; i < dataGridView_KeyElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sKeyElements += 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 < dataGridView_SubElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sSubElements += dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
|
|
|
- }
|
|
|
- if (sSubElements.Length > 0)
|
|
|
- {
|
|
|
- sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name += "$" + sKeyElements + "$" + sSubElements;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //删除
|
|
|
- private void DeleteTreeNode_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- TreeView XmlTree = (TreeView)XmlTreeMenuStrip.SourceControl;
|
|
|
- if (XmlTree.SelectedNode != null)
|
|
|
- {
|
|
|
- if (XmlTree != null)
|
|
|
- {
|
|
|
- if (XmlTree.SelectedNode.NextNode != null)
|
|
|
- {
|
|
|
- TreeNode Temp = XmlTree.SelectedNode.NextNode;
|
|
|
- XmlTree.SelectedNode.Remove();
|
|
|
- XmlTree.SelectedNode = Temp;
|
|
|
- }
|
|
|
- else if (XmlTree.SelectedNode.PrevNode != null)
|
|
|
- {
|
|
|
- TreeNode Temp = XmlTree.SelectedNode.PrevNode;
|
|
|
- XmlTree.SelectedNode.Remove();
|
|
|
- XmlTree.SelectedNode = Temp;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- XmlTree.SelectedNode.Remove();
|
|
|
- XmlTree.SelectedNode = null;
|
|
|
- if (XmlTree.Name == "XmlTree_STDlist")
|
|
|
- {
|
|
|
- textbox_STDEditor.Text = "";
|
|
|
- textBox_Density.Text = "";
|
|
|
- textBox_Electrical_conductivity.Text = "";
|
|
|
- textBox_BSEValue.Text = "";
|
|
|
- textBox_Formula.Text = "";
|
|
|
- textBox_Element.Text = "";
|
|
|
- textBox_Hardness.Text = "";
|
|
|
- btn_dbs.BackColor = Color.White;
|
|
|
- }
|
|
|
- if (XmlTree.Name == "XmlTree_MaxEDSRules")
|
|
|
- {
|
|
|
- textbox_STDEditor.Text = "";
|
|
|
- textBox_MaxEDSTime.Text = "";
|
|
|
- }
|
|
|
- if (XmlTree.Name == "XmlTree_ZeroElementRules")
|
|
|
- {
|
|
|
- textbox_STDEditor.Text = "";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(table["message1"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.ToString(), table["message32"].ToString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //新建
|
|
|
- private void AddTreeNode_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (tabControl_Rules.SelectedIndex == 0)
|
|
|
- {
|
|
|
- //保存节点当前数据
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- //判断Hardness、Density、Electrical_conductivity
|
|
|
- double dHardness = 0, dDensity = 0, dElectrical_conductivity = 0;
|
|
|
- if (!double.TryParse(textBox_Hardness.Text, out dHardness) || (double.Parse(textBox_Hardness.Text) <= 0))
|
|
|
- {
|
|
|
- textBox_Hardness.Focus();
|
|
|
- textBox_Hardness.SelectAll();
|
|
|
- MessageBox.Show(table["message2"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Density.Text, out dDensity)||double.Parse(textBox_Density.Text)<=0)
|
|
|
- {
|
|
|
- textBox_Density.Focus();
|
|
|
- textBox_Density.SelectAll();
|
|
|
- MessageBox.Show(table["message3"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Electrical_conductivity.Text, out dElectrical_conductivity)||double.Parse(textBox_Electrical_conductivity.Text)<=0)
|
|
|
- {
|
|
|
- textBox_Electrical_conductivity.Focus();
|
|
|
- textBox_Electrical_conductivity.SelectAll();
|
|
|
- MessageBox.Show(table["message4"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_BSEValue.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message5"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Formula.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message6"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Formula.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Element.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message7"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Element.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- XmlTree_STDlist.SelectedNode.Name = textBox_Hardness.Text + "_" + textBox_Density.Text + "_" + textBox_Electrical_conductivity.Text + "_" + textBox_BSEValue.Text + "_" + textBox_Formula.Text + "_" + textBox_Element.Text; ;
|
|
|
-
|
|
|
- string sKeyElements = "";
|
|
|
- for (int i = 0; i < dataGridView_KeyElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sKeyElements += 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 < dataGridView_SubElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sSubElements += dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
|
|
|
- }
|
|
|
- if (sSubElements.Length > 0)
|
|
|
- {
|
|
|
- sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name += "$" + sKeyElements + "$" + sSubElements;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 1)
|
|
|
- {
|
|
|
- if (XmlTree_MaxEDSRules.SelectedNode != null)
|
|
|
- {
|
|
|
-
|
|
|
- //判断MaxEDSTime
|
|
|
- double dMaxEDSTime = 0;
|
|
|
- if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message8"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode.Name = textBox_MaxEDSTime.Text;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 2)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode != null)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
|
|
|
- {
|
|
|
- if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- TreeNode new_child = new TreeNode();//定义一个TreeNode节点对象
|
|
|
- TreeView XmlTree = (TreeView)XmlTreeMenuStrip.SourceControl;
|
|
|
- if (XmlTreeMenuStrip.SourceControl.Name == "XmlTree_STDlist")
|
|
|
- {
|
|
|
- new_child.Name = "1_1_1$$";
|
|
|
- new_child.Text = "new strName";
|
|
|
- new_child.Tag = "NewRules";
|
|
|
- textbox_STDEditor.Text = "NewRules";
|
|
|
- textBox_Density.Text = "1";
|
|
|
- textBox_Electrical_conductivity.Text = "1";
|
|
|
- textBox_Hardness.Text = "1";
|
|
|
- new_child.BackColor = Color.White;
|
|
|
-
|
|
|
- int STDId = 1;
|
|
|
- for (int i = 0; i < XmlTree_STDlist.Nodes.Count; i++)
|
|
|
- {
|
|
|
- if (STDId < int.Parse(XmlTree_STDlist.Nodes[i].ToolTipText))
|
|
|
- {
|
|
|
- STDId = int.Parse(XmlTree_STDlist.Nodes[i].ToolTipText);
|
|
|
- }
|
|
|
- }
|
|
|
- new_child.ToolTipText = (STDId+1).ToString();
|
|
|
- }
|
|
|
- if (XmlTreeMenuStrip.SourceControl.Name == "XmlTree_MaxEDSRules")
|
|
|
- {
|
|
|
- int Number = XmlTree.Nodes.Count;
|
|
|
- for (int num = 0; num < XmlTree.Nodes.Count; num++)
|
|
|
- {
|
|
|
- string aa = XmlTree.Nodes[num].Text.ToString().Substring(XmlTree.Nodes[num].Text.Length - 1, 1);
|
|
|
- int tp = int.Parse(XmlTree.Nodes[num].Text.ToString().Substring(XmlTree.Nodes[num].Text.Length - 1, 1));
|
|
|
- if (Number < tp) Number = tp;
|
|
|
- }
|
|
|
- new_child.Text = "Rule" + Number.ToString();
|
|
|
- new_child.Tag = "NewRules";
|
|
|
- textbox_STDEditor.Text = "NewRules";
|
|
|
- }
|
|
|
- if (XmlTreeMenuStrip.SourceControl.Name == "XmlTree_ZeroElementRules")
|
|
|
- {
|
|
|
- new_child.Text = "NewElement=0";
|
|
|
- new_child.Tag = "NewRules";
|
|
|
- textbox_STDEditor.Text = "NewRules";
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree.Nodes.Add(new_child);
|
|
|
- XmlTree.SelectedNode = null;
|
|
|
- XmlTree.SelectedNode = new_child;
|
|
|
- //添加STDXray信息
|
|
|
- AddSTDXray(XmlTree.SelectedNode, xrayByteData);
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.ToString(), table["message32"].ToString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //双击节点
|
|
|
- private void XmlTree_STDlist_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
- {
|
|
|
- if (e.Button == MouseButtons.Left)
|
|
|
- {
|
|
|
- Point ClickPoint = new Point(e.X, e.Y);
|
|
|
- TreeNode CurrentNode = XmlTree_STDlist.GetNodeAt(ClickPoint);
|
|
|
- if (CurrentNode != null)//判断你点的是不是一个节点
|
|
|
- {
|
|
|
- XmlTree_STDlist.SelectedNode = CurrentNode;//选中这个节点
|
|
|
- XmlTree_STDlist.LabelEdit = true;
|
|
|
- XmlTree_STDlist.SelectedNode.BeginEdit();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //保存xmltree内容到xml文件
|
|
|
- void SaveXmlTreeDataToXml(string Address)
|
|
|
- {
|
|
|
- XDocument xdoc = XDocument.Load(Address);
|
|
|
- IEnumerable<XElement> elements = from ele in xdoc.Descendants("XMLData") select ele;
|
|
|
- foreach (var ele in elements)
|
|
|
- {
|
|
|
- if (ele != null)
|
|
|
- {
|
|
|
- ele.RemoveAll();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- string value = "";
|
|
|
- foreach (var str in comboBox_Constants.Items)
|
|
|
- {
|
|
|
- value += str + ",";
|
|
|
- }
|
|
|
- if (value != "")
|
|
|
- {
|
|
|
- value = value.Substring(0, value.Length - 1);
|
|
|
- }
|
|
|
- XElement Constant = new XElement("Member");
|
|
|
- Constant.SetAttributeValue("RegName", "Constants");
|
|
|
- Constant.SetAttributeValue("value", value);
|
|
|
- elements.ElementAt(0).Add(Constant);
|
|
|
-
|
|
|
- XElement ZeroElement = new XElement("Collection");
|
|
|
- ZeroElement.SetAttributeValue("RegName", "ZeroElementRules");
|
|
|
- elements.ElementAt(0).Add(ZeroElement);
|
|
|
-
|
|
|
- for (int num = 0; num < XmlTree_ZeroElementRules.Nodes.Count; num++)
|
|
|
- {
|
|
|
- string UsingElementList = "";
|
|
|
- string UsingImgPropertyList = "";
|
|
|
- string UsingOtherPropertyList = "";
|
|
|
- List<string> UsingElementL = new List<string>();
|
|
|
- List<string> UsingImgPropertyL = new List<string>();
|
|
|
- List<string> UsingOtherPropertyL = new List<string>();
|
|
|
-
|
|
|
- string str_RemoveBlank = "";
|
|
|
- //forth_elem干扰or分隔符,故先行去掉
|
|
|
- if (XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Contains("forth_elem"))
|
|
|
- {
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
|
|
|
- UsingOtherPropertyL.Add("forth_elem");
|
|
|
- }
|
|
|
-
|
|
|
- str_RemoveBlank = XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Replace(" ", "");
|
|
|
- string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
- List<string> str_Removeandor = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
- {
|
|
|
- str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
- }
|
|
|
- List<string> list_all = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
- {
|
|
|
- list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
- }
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (this.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (this.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (this.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingImgPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingImgPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingElementL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingElementList += UsingElementL[i] + ",";
|
|
|
- }
|
|
|
- UsingElementList += UsingElementL[UsingElementL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingImgPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingOtherPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- XElement EleName = new XElement("Member");
|
|
|
- EleName.SetAttributeValue("ZeroElement", XmlTree_ZeroElementRules.Nodes[num].Text.Split('=')[0]);
|
|
|
- EleName.SetAttributeValue("UsingElementList", UsingElementList);
|
|
|
- EleName.SetAttributeValue("UsingImgPropertyList", UsingImgPropertyList);
|
|
|
- EleName.SetAttributeValue("UsingOtherPropertyList", UsingOtherPropertyList);
|
|
|
- EleName.SetAttributeValue("Expression", XmlTree_ZeroElementRules.Nodes[num].Tag);
|
|
|
- ZeroElement.Add(EleName);
|
|
|
- }
|
|
|
-
|
|
|
- XElement MaxEDS = new XElement("Collection");
|
|
|
- MaxEDS.SetAttributeValue("RegName", "MaxEDSRules");
|
|
|
- elements.ElementAt(0).Add(MaxEDS);
|
|
|
- for (int num = 0; num < XmlTree_MaxEDSRules.Nodes.Count; num++)
|
|
|
- {
|
|
|
- string UsingElementList = "";
|
|
|
- string UsingImgPropertyList = "";
|
|
|
- string UsingOtherPropertyList = "";
|
|
|
- List<string> UsingElementL = new List<string>();
|
|
|
- List<string> UsingImgPropertyL = new List<string>();
|
|
|
- List<string> UsingOtherPropertyL = new List<string>();
|
|
|
-
|
|
|
- string str_RemoveBlank = "";
|
|
|
- //forth_elem干扰or分隔符,故先行去掉
|
|
|
- if (XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Contains("forth_elem"))
|
|
|
- {
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
|
|
|
- UsingOtherPropertyList = "forth_elem,";
|
|
|
- }
|
|
|
-
|
|
|
- str_RemoveBlank = XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Replace(" ", "");
|
|
|
- string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
- List<string> str_Removeandor = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
- {
|
|
|
- str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
- }
|
|
|
- List<string> list_all = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
- {
|
|
|
- list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
- }
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (this.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (this.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (this.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingImgPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingImgPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingElementL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingElementList += UsingElementL[i] + ",";
|
|
|
- }
|
|
|
- UsingElementList += UsingElementL[UsingElementL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingImgPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingOtherPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- XElement EleName = new XElement("Member");
|
|
|
- //EleName.SetAttributeValue("MaxEDSTime", XmlTree_MaxEDSRules.Nodes[num].Name);
|
|
|
- EleName.SetAttributeValue("MaxEDSTime", textBox_MaxEDSTime.Text);
|
|
|
- EleName.SetAttributeValue("UsingElementList", UsingElementList);
|
|
|
- EleName.SetAttributeValue("UsingImgPropertyList", UsingImgPropertyList);
|
|
|
- EleName.SetAttributeValue("UsingOtherPropertyList", UsingOtherPropertyList);
|
|
|
- EleName.SetAttributeValue("Expression", XmlTree_MaxEDSRules.Nodes[num].Tag);
|
|
|
-
|
|
|
- MaxEDS.Add(EleName);
|
|
|
- }
|
|
|
-
|
|
|
- XElement STD = new XElement("Collection");
|
|
|
- STD.SetAttributeValue("RegName", "STDList");
|
|
|
- elements.ElementAt(0).Add(STD);
|
|
|
-
|
|
|
- for (int num = 0; num < XmlTree_STDlist.Nodes.Count; num++)
|
|
|
- {
|
|
|
- string UsingElementList = "";
|
|
|
- string UsingImgPropertyList = "";
|
|
|
- string UsingOtherPropertyList = "";
|
|
|
- List<string> UsingElementL = new List<string>();
|
|
|
- List<string> UsingImgPropertyL = new List<string>();
|
|
|
- List<string> UsingOtherPropertyL = new List<string>();
|
|
|
-
|
|
|
- string str_RemoveBlank = "";
|
|
|
- //forth_elem干扰or分隔符,故先行去掉
|
|
|
- if (XmlTree_STDlist.Nodes[num].Tag.ToString().Contains("forth_elem"))
|
|
|
- {
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("forth_elem", "");
|
|
|
- UsingOtherPropertyList = "forth_elem,";
|
|
|
- }
|
|
|
-
|
|
|
- str_RemoveBlank = XmlTree_STDlist.Nodes[num].Tag.ToString().Replace(" ", "");
|
|
|
- string[] str_Removeand = System.Text.RegularExpressions.Regex.Split(str_RemoveBlank, "and", System.Text.RegularExpressions.RegexOptions.None);
|
|
|
- List<string> str_Removeandor = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeand.Length; i++)
|
|
|
- {
|
|
|
- str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None));
|
|
|
- }
|
|
|
- List<string> list_all = new List<string>();
|
|
|
- for (int i = 0; i < str_Removeandor.Count; i++)
|
|
|
- {
|
|
|
- list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' }));
|
|
|
- }
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (this.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (this.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingOtherPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingOtherPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (this.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingImgPropertyL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingImgPropertyL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingElementL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingElementList += UsingElementL[i] + ",";
|
|
|
- }
|
|
|
- UsingElementList += UsingElementL[UsingElementL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingImgPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingImgPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingImgPropertyList += UsingImgPropertyL[UsingImgPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- if (UsingOtherPropertyL.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingOtherPropertyL.Count - 1; i++)
|
|
|
- {
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[i] + ",";
|
|
|
- }
|
|
|
- UsingOtherPropertyList += UsingOtherPropertyL[UsingOtherPropertyL.Count - 1];
|
|
|
- }
|
|
|
-
|
|
|
- string[] str = XmlTree_STDlist.Nodes[num].Name.Split('$');
|
|
|
- string[] strOther = str[0].Split('_');
|
|
|
-
|
|
|
- XElement EleName = new XElement("Member");
|
|
|
- EleName.SetAttributeValue("STDId", XmlTree_STDlist.Nodes[num].ToolTipText);
|
|
|
- EleName.SetAttributeValue("StrName", XmlTree_STDlist.Nodes[num].Text);
|
|
|
- EleName.SetAttributeValue("Color", colorRGBtoHx16(XmlTree_STDlist.Nodes[num].BackColor.R, XmlTree_STDlist.Nodes[num].BackColor.G, XmlTree_STDlist.Nodes[num].BackColor.B));
|
|
|
- //EleName.SetAttributeValue("UsingElementList", UsingElementList);
|
|
|
- EleName.SetAttributeValue("KeyElementList", str[1]);
|
|
|
- EleName.SetAttributeValue("SubElementList", str[2]);
|
|
|
- EleName.SetAttributeValue("UsingImgPropertyList", UsingImgPropertyList);
|
|
|
- EleName.SetAttributeValue("UsingOtherPropertyList", UsingOtherPropertyList);
|
|
|
- EleName.SetAttributeValue("Expression", XmlTree_STDlist.Nodes[num].Tag);
|
|
|
- EleName.SetAttributeValue("Hardness", strOther[0]);
|
|
|
- EleName.SetAttributeValue("Density", strOther[1]);
|
|
|
- EleName.SetAttributeValue("Electrical_conductivity", strOther[2]);
|
|
|
- if (strOther.Length > 3)
|
|
|
- {
|
|
|
- EleName.SetAttributeValue("BSE", strOther[3]);
|
|
|
- EleName.SetAttributeValue("Formula", strOther[4]);
|
|
|
- EleName.SetAttributeValue("Element", strOther[5]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- EleName.SetAttributeValue("BSE", "");
|
|
|
- EleName.SetAttributeValue("Formula", "");
|
|
|
- EleName.SetAttributeValue("Element", "");
|
|
|
- }
|
|
|
- STD.Add(EleName);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- xdoc.Save(Address);
|
|
|
- }
|
|
|
- //元素周期表开关
|
|
|
- private void PeriodicTableSwitch_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (PeriodicTableSwitch.BackColor == SystemColors.Control)
|
|
|
- {
|
|
|
- panel_OTSPeriodicTable.Visible = true;
|
|
|
- this.Width = this.Width + panel_OTSPeriodicTable.Width + 5;
|
|
|
- PeriodicTableSwitch.BackColor = SystemColors.ControlDark;
|
|
|
- //if (Language == "English")
|
|
|
- //{
|
|
|
- // PeriodicTableSwitch.Text = "Close PeriodicTable";
|
|
|
- //}
|
|
|
- //else if(Language == "Chinese")
|
|
|
- //{
|
|
|
- // PeriodicTableSwitch.Text = "关闭元素周期表";
|
|
|
- //}
|
|
|
- }
|
|
|
- else if (PeriodicTableSwitch.BackColor == SystemColors.ControlDark)
|
|
|
- {
|
|
|
- panel_OTSPeriodicTable.Visible = false;
|
|
|
- this.Width = this.Width - panel_OTSPeriodicTable.Width - 5;
|
|
|
- PeriodicTableSwitch.BackColor = SystemColors.Control;
|
|
|
- //if (Language == "English")
|
|
|
- //{
|
|
|
- // PeriodicTableSwitch.Text = "Open PeriodicTable";
|
|
|
- //}
|
|
|
- //else if (Language == "Chinese")
|
|
|
- //{
|
|
|
- // PeriodicTableSwitch.Text = "打开元素周期表";
|
|
|
- //}
|
|
|
-
|
|
|
- //textbox_STDEditor.Focus();
|
|
|
- groupBox_XmlTree_MaxEDSRules.Focus();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Ok_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (tabControl_Rules.SelectedIndex == 0)
|
|
|
- {
|
|
|
- //保存节点当前数据
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- //判断Hardness、Density、Electrical_conductivity
|
|
|
- double dHardness = 0, dDensity = 0, dElectrical_conductivity = 0;
|
|
|
- if (!double.TryParse(textBox_Hardness.Text, out dHardness) || (double.Parse(textBox_Hardness.Text) <= 0))
|
|
|
- {
|
|
|
- textBox_Hardness.Focus();
|
|
|
- textBox_Hardness.SelectAll();
|
|
|
- MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Density.Text, out dDensity) || double.Parse(textBox_Density.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_Density.Focus();
|
|
|
- textBox_Density.SelectAll();
|
|
|
- MessageBox.Show(table["message11"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Electrical_conductivity.Text, out dElectrical_conductivity) || double.Parse(textBox_Electrical_conductivity.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_Electrical_conductivity.Focus();
|
|
|
- textBox_Electrical_conductivity.SelectAll();
|
|
|
- MessageBox.Show(table["message12"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_BSEValue.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- textBox_BSEValue.SelectAll();
|
|
|
- MessageBox.Show(table["message13"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Formula.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_Formula.Focus();
|
|
|
- textBox_Formula.SelectAll();
|
|
|
- MessageBox.Show(table["message14"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Formula.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Element.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_Element.Focus();
|
|
|
- textBox_Element.SelectAll();
|
|
|
- MessageBox.Show(table["message15"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Element.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- XmlTree_STDlist.SelectedNode.Name = textBox_Hardness.Text + "_" + textBox_Density.Text + "_" + textBox_Electrical_conductivity.Text + "_" + textBox_BSEValue.Text + "_" + textBox_Formula.Text + "_" + textBox_Element.Text;
|
|
|
-
|
|
|
- string sKeyElements = "";
|
|
|
- for (int i = 0; i < dataGridView_KeyElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sKeyElements += 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 < dataGridView_SubElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sSubElements += dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
|
|
|
- }
|
|
|
- if (sSubElements.Length > 0)
|
|
|
- {
|
|
|
- sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name += "$" + sKeyElements + "$" + sSubElements;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 1)
|
|
|
- {
|
|
|
- if (XmlTree_MaxEDSRules.SelectedNode != null)
|
|
|
- {
|
|
|
-
|
|
|
- //判断MaxEDSTime
|
|
|
- double dMaxEDSTime = 0;
|
|
|
- if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_MaxEDSTime.Focus();
|
|
|
- textBox_MaxEDSTime.SelectAll();
|
|
|
- MessageBox.Show(table["message16"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode.Name = textBox_MaxEDSTime.Text;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 2)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode != null)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
|
|
|
- {
|
|
|
- if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- string value = "";
|
|
|
- foreach (var str in comboBox_Constants.Items)
|
|
|
- {
|
|
|
- value += str + ",";
|
|
|
- }
|
|
|
- if (value != "")
|
|
|
- {
|
|
|
- value = value.Substring(0, value.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //string Address = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- //string Address = ".\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- SaveXmlTreeDataToXml(Address);
|
|
|
- //保存STDXray信息至数据库
|
|
|
- SaveSTDXray();
|
|
|
- this.Close();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Cancel_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- this.Close();
|
|
|
- }
|
|
|
-
|
|
|
- //元素下拉选择输入
|
|
|
- private void comboBox_PeriodicTable_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (comboBox_PeriodicTable.Text != null && comboBox_PeriodicTable.SelectedItem != null)
|
|
|
- {
|
|
|
-
|
|
|
- string newStr = comboBox_PeriodicTable.SelectedItem.ToString();
|
|
|
- comboBox_PeriodicTable.Text = null;
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr);
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + newStr.Length, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //元素自身text按回车键输入
|
|
|
- private void comboBox_PeriodicTable_KeyDown(object sender, KeyEventArgs e)
|
|
|
- {
|
|
|
- if (e.KeyValue == 13)
|
|
|
- {
|
|
|
- if (comboBox_PeriodicTable.Text != null && comboBox_PeriodicTable.Text != "")
|
|
|
- {
|
|
|
- this.textbox_STDEditor.Text += comboBox_PeriodicTable.Text.ToString();
|
|
|
- comboBox_PeriodicTable.Text = null;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //表达式规则检查
|
|
|
- private bool Checktextbox_STDEditor()
|
|
|
- {
|
|
|
- if (textbox_STDEditor.Text == "" || textbox_STDEditor.Text == null)
|
|
|
- {
|
|
|
- textBox_MaxEDSTime.Focus();
|
|
|
- MessageBox.Show(table["message17"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
- //分割符号检验
|
|
|
- string[] Symbol = { "and", "or", "+", "-", "*", "/", "=", ">", "<" };
|
|
|
- for (int i = 0; i < Symbol.Length; i++)
|
|
|
- {
|
|
|
- for (int j = 0; j < Symbol.Length; j++)
|
|
|
- {
|
|
|
- if ((Symbol[i] + Symbol[j]) != ">=" && (Symbol[i] + Symbol[j]) != "<=")
|
|
|
- {
|
|
|
- if (str_RemoveBlank.Contains(Symbol[i] + Symbol[j]))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message18"].ToString() + Symbol[i] + Symbol[j], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (str_RemoveBlank.Contains(Symbol[i] + ")") || str_RemoveBlank.Contains("(" + Symbol[i]))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message18"].ToString() + Symbol[i] + ")", table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (str_RemoveBlank.Contains("(" + Symbol[i]))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message18"].ToString() + "(" + Symbol[i], table["message32"].ToString(), 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(table["message19"].ToString(),table["message32"].ToString(),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(table["message20"].ToString(), table["message32"].ToString(), 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(table["message20"].ToString(), table["message32"].ToString(), 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 < comboBox_Constants.Items.Count; j++)
|
|
|
- {
|
|
|
- Constantslist.Add(comboBox_Constants.Items[j].ToString().Split('=')[0]);
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- //周期元素?
|
|
|
- if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //first_elem?
|
|
|
- if (this.comboBox_Elem1.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //Element1?
|
|
|
- if (this.comboBox_Elem.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //其它元素?
|
|
|
- if (this.comboBox_ImgProperty.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //常量?
|
|
|
- if (Constantslist.Contains(list_all[i]))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //数字?
|
|
|
- double DNum = 0;
|
|
|
- if (double.TryParse(list_all[i], out DNum))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //>=? <=?等其它情况
|
|
|
- if (list_all[i] == "")
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- //true false?
|
|
|
- if ((list_all[i] == "true") || (list_all[i] == "false"))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- MessageBox.Show(table["message21"].ToString() + list_all[i], table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- //检测是否有<>= true,false
|
|
|
- if (!textbox_STDEditor.Text.ToString().Contains("<") && !textbox_STDEditor.Text.ToString().Contains(">") && !textbox_STDEditor.Text.ToString().Contains("=") && textbox_STDEditor.Text.ToString() != "true" && textbox_STDEditor.Text.ToString() != "false")
|
|
|
- {
|
|
|
- MessageBox.Show(table["message22"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- private void btn_dbs_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- ColorDialog cd = new ColorDialog();
|
|
|
- cd.FullOpen = true;//自定义颜色界面打开
|
|
|
- DialogResult result = cd.ShowDialog();
|
|
|
- if (result == DialogResult.OK)
|
|
|
- {
|
|
|
- btn_dbs.BackColor = cd.Color;
|
|
|
- int color = Convert.ToInt32(ParseRGB(cd.Color));
|
|
|
- ShowXrayAtlas(color, xrayByteData);
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- XmlTree_STDlist.SelectedNode.BackColor = cd.Color;
|
|
|
- }
|
|
|
- }
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- //如果不是白色了,就把文字去掉吧,显得好看
|
|
|
- if (btn_dbs.BackColor != Color.White)
|
|
|
- {
|
|
|
- btn_dbs.Text = "";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void button_And_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "and");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 3, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Or_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "or");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 2, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void comboBox_Constants_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //if (Flag_comboBox_Constants)
|
|
|
- //{
|
|
|
- if (comboBox_Constants.SelectedItem != null)
|
|
|
- {
|
|
|
- //this.textbox_STDEditor.Text += comboBox_Constants.SelectedItem.ToString().Split('=')[0];
|
|
|
- ////comboBox_Constants.Text = null;
|
|
|
- //textbox_STDEditor.Focus();
|
|
|
- //textbox_STDEditor.SelectionStart = textbox_STDEditor.Text.Length;
|
|
|
- //textbox_STDEditor.ScrollToCaret();
|
|
|
-
|
|
|
- string newStr = comboBox_Constants.SelectedItem.ToString().Split('=')[0];
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr);
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + newStr.Length, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
- //}
|
|
|
- //Flag_comboBox_Constants = true;
|
|
|
- }
|
|
|
-
|
|
|
- bool Flag_SelStatus = true; //XML切换成功失败状态
|
|
|
-
|
|
|
- private void button_UpOrder_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (XmlTree_STDlist.SelectedNode.PrevNode != null)
|
|
|
- {
|
|
|
- //object tag = XmlTree_STDlist.SelectedNode.PrevNode.Tag;
|
|
|
- //string name = XmlTree_STDlist.SelectedNode.PrevNode.Name;
|
|
|
- //string text = XmlTree_STDlist.SelectedNode.PrevNode.Text;
|
|
|
- //Color backcolor=XmlTree_STDlist.SelectedNode.PrevNode.BackColor;
|
|
|
- //string STDId = XmlTree_STDlist.SelectedNode.PrevNode.ToolTipText;
|
|
|
-
|
|
|
- //XmlTree_STDlist.SelectedNode.PrevNode.Tag = XmlTree_STDlist.SelectedNode.Tag;
|
|
|
- //XmlTree_STDlist.SelectedNode.PrevNode.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
- //XmlTree_STDlist.SelectedNode.PrevNode.Name = XmlTree_STDlist.SelectedNode.Name;
|
|
|
- //XmlTree_STDlist.SelectedNode.PrevNode.Text = XmlTree_STDlist.SelectedNode.Text;
|
|
|
- //XmlTree_STDlist.SelectedNode.PrevNode.ToolTipText = XmlTree_STDlist.SelectedNode.ToolTipText;
|
|
|
-
|
|
|
- //XmlTree_STDlist.SelectedNode.Tag = tag;
|
|
|
- //XmlTree_STDlist.SelectedNode.BackColor = backcolor;
|
|
|
- //XmlTree_STDlist.SelectedNode.Name = name;
|
|
|
- //XmlTree_STDlist.SelectedNode.Text = text;
|
|
|
- //XmlTree_STDlist.SelectedNode.ToolTipText = STDId;
|
|
|
-
|
|
|
- //this.textbox_STDEditor.Text = XmlTree_STDlist.SelectedNode.Tag.ToString();
|
|
|
- //btn_dbs.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
-
|
|
|
- //string[] strOther = XmlTree_STDlist.SelectedNode.Name.Split('$');
|
|
|
-
|
|
|
- //string[] strOther2 = strOther[0].Split('_');
|
|
|
- //textBox_Hardness.Text = strOther2[0];
|
|
|
- //textBox_Density.Text = strOther2[1];
|
|
|
- //textBox_Electrical_conductivity.Text = strOther2[2];
|
|
|
-
|
|
|
-
|
|
|
- //dataGridView_KeyElements.Rows.Clear();
|
|
|
- //dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- //string[] KeyElement = strOther[1].Split(',');
|
|
|
- //for (int i = 0; i < KeyElement.Length; i++)
|
|
|
- //{
|
|
|
- // if (KeyElement[0] != "")
|
|
|
- // {
|
|
|
- // DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- // dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- // dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- // if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- // {
|
|
|
- // DataGridViewRow row = new DataGridViewRow();
|
|
|
- // dataGridView_KeyElements.Rows.Add(row);
|
|
|
- // }
|
|
|
- // dataGridView_KeyElements.Rows[0].Cells[i].Value = KeyElement[i];
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- //dataGridView_SubElements.Rows.Clear();
|
|
|
- //dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- //string[] SubElement = strOther[2].Split(',');
|
|
|
- //for (int i = 0; i < SubElement.Length; i++)
|
|
|
- //{
|
|
|
- // if (SubElement[i] != "")
|
|
|
- // {
|
|
|
- // DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- // dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- // dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- // if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- // {
|
|
|
- // DataGridViewRow row = new DataGridViewRow();
|
|
|
- // dataGridView_SubElements.Rows.Add(row);
|
|
|
- // }
|
|
|
- // dataGridView_SubElements.Rows[0].Cells[i].Value = SubElement[i];
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //this.XmlTree_STDlist.Focus();
|
|
|
- //XmlTree_STDlist.SelectedNode = XmlTree_STDlist.SelectedNode.PrevNode;
|
|
|
- //if (XmlTree_STDlist.SelectedNode.PrevNode == null)
|
|
|
- //{
|
|
|
- // UpOrder.Enabled = false;
|
|
|
- //}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode = XmlTree_STDlist.SelectedNode.PrevNode;
|
|
|
- if (Flag_SelStatus)
|
|
|
- {
|
|
|
- object tag = XmlTree_STDlist.SelectedNode.NextNode.Tag;
|
|
|
- string name = XmlTree_STDlist.SelectedNode.NextNode.Name;
|
|
|
- string text = XmlTree_STDlist.SelectedNode.NextNode.Text;
|
|
|
- Color backcolor = XmlTree_STDlist.SelectedNode.NextNode.BackColor;
|
|
|
- string STDId = XmlTree_STDlist.SelectedNode.NextNode.ToolTipText;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.NextNode.Tag = XmlTree_STDlist.SelectedNode.Tag;
|
|
|
- XmlTree_STDlist.SelectedNode.NextNode.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
- XmlTree_STDlist.SelectedNode.NextNode.Name = XmlTree_STDlist.SelectedNode.Name;
|
|
|
- XmlTree_STDlist.SelectedNode.NextNode.Text = XmlTree_STDlist.SelectedNode.Text;
|
|
|
- XmlTree_STDlist.SelectedNode.NextNode.ToolTipText = XmlTree_STDlist.SelectedNode.ToolTipText;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = tag;
|
|
|
- XmlTree_STDlist.SelectedNode.BackColor = backcolor;
|
|
|
- XmlTree_STDlist.SelectedNode.Name = name;
|
|
|
- XmlTree_STDlist.SelectedNode.Text = text;
|
|
|
- XmlTree_STDlist.SelectedNode.ToolTipText = STDId;
|
|
|
-
|
|
|
- this.textbox_STDEditor.Text = XmlTree_STDlist.SelectedNode.Tag.ToString();
|
|
|
- btn_dbs.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
-
|
|
|
- string[] strOther = XmlTree_STDlist.SelectedNode.Name.Split('$');
|
|
|
-
|
|
|
- string[] strOther2 = strOther[0].Split('_');
|
|
|
- textBox_Hardness.Text = strOther2[0];
|
|
|
- textBox_Density.Text = strOther2[1];
|
|
|
- textBox_Electrical_conductivity.Text = strOther2[2];
|
|
|
- if (strOther2.Length > 3)
|
|
|
- {
|
|
|
- textBox_BSEValue.Text = strOther2[3];
|
|
|
- textBox_Formula.Text = strOther2[4];
|
|
|
- textBox_Element.Text = strOther2[5];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_BSEValue.Text = "";
|
|
|
- textBox_Formula.Text = "";
|
|
|
- textBox_Element.Text = "";
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- string[] KeyElement = strOther[1].Split(',');
|
|
|
- for (int i = 0; i < KeyElement.Length; i++)
|
|
|
- {
|
|
|
- if (KeyElement[0] != "")
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[i].Value = KeyElement[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- string[] SubElement = strOther[2].Split(',');
|
|
|
- for (int i = 0; i < SubElement.Length; i++)
|
|
|
- {
|
|
|
- if (SubElement[i] != "")
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_SubElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_SubElements.Rows[0].Cells[i].Value = SubElement[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.XmlTree_STDlist.Focus();
|
|
|
- if (XmlTree_STDlist.SelectedNode.PrevNode == null)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
-
|
|
|
- dataGridView_KeyElements.ClearSelection();
|
|
|
- dataGridView_SubElements.ClearSelection();
|
|
|
-
|
|
|
- }
|
|
|
- this.XmlTree_STDlist.Focus();
|
|
|
- Flag_SelStatus = true;
|
|
|
- }
|
|
|
-
|
|
|
- private void button_DownOrder_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (XmlTree_STDlist.SelectedNode.NextNode != null)
|
|
|
- {
|
|
|
- //object tag = XmlTree_STDlist.SelectedNode.NextNode.Tag;
|
|
|
- //string name = XmlTree_STDlist.SelectedNode.NextNode.Name;
|
|
|
- //string text = XmlTree_STDlist.SelectedNode.NextNode.Text;
|
|
|
- //Color backcolor = XmlTree_STDlist.SelectedNode.NextNode.BackColor;
|
|
|
- //string STDId = XmlTree_STDlist.SelectedNode.NextNode.ToolTipText;
|
|
|
-
|
|
|
- //XmlTree_STDlist.SelectedNode.NextNode.Tag = XmlTree_STDlist.SelectedNode.Tag;
|
|
|
- //XmlTree_STDlist.SelectedNode.NextNode.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
- //XmlTree_STDlist.SelectedNode.NextNode.Name = XmlTree_STDlist.SelectedNode.Name;
|
|
|
- //XmlTree_STDlist.SelectedNode.NextNode.Text = XmlTree_STDlist.SelectedNode.Text;
|
|
|
- //XmlTree_STDlist.SelectedNode.NextNode.ToolTipText = XmlTree_STDlist.SelectedNode.ToolTipText;
|
|
|
-
|
|
|
- //XmlTree_STDlist.SelectedNode.Tag = tag;
|
|
|
- //XmlTree_STDlist.SelectedNode.BackColor = backcolor;
|
|
|
- //XmlTree_STDlist.SelectedNode.Name = name;
|
|
|
- //XmlTree_STDlist.SelectedNode.Text = text;
|
|
|
- //XmlTree_STDlist.SelectedNode.ToolTipText = STDId;
|
|
|
-
|
|
|
- //this.textbox_STDEditor.Text = XmlTree_STDlist.SelectedNode.Tag.ToString();
|
|
|
- //btn_dbs.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
-
|
|
|
- //string[] strOther = XmlTree_STDlist.SelectedNode.Name.Split('$');
|
|
|
-
|
|
|
- //string[] strOther2 = strOther[0].Split('_');
|
|
|
- //textBox_Hardness.Text = strOther2[0];
|
|
|
- //textBox_Density.Text = strOther2[1];
|
|
|
- //textBox_Electrical_conductivity.Text = strOther2[2];
|
|
|
-
|
|
|
-
|
|
|
- //dataGridView_KeyElements.Rows.Clear();
|
|
|
- //dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- //string[] KeyElement = strOther[1].Split(',');
|
|
|
- //for (int i = 0; i < KeyElement.Length; i++)
|
|
|
- //{
|
|
|
- // if (KeyElement[0] != "")
|
|
|
- // {
|
|
|
- // DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- // dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- // dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- // if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- // {
|
|
|
- // DataGridViewRow row = new DataGridViewRow();
|
|
|
- // dataGridView_KeyElements.Rows.Add(row);
|
|
|
- // }
|
|
|
- // dataGridView_KeyElements.Rows[0].Cells[i].Value = KeyElement[i];
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- //dataGridView_SubElements.Rows.Clear();
|
|
|
- //dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- //string[] SubElement = strOther[2].Split(',');
|
|
|
- //for (int i = 0; i < SubElement.Length; i++)
|
|
|
- //{
|
|
|
- // if (SubElement[i] != "")
|
|
|
- // {
|
|
|
- // DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- // dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- // dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- // if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- // {
|
|
|
- // DataGridViewRow row = new DataGridViewRow();
|
|
|
- // dataGridView_SubElements.Rows.Add(row);
|
|
|
- // }
|
|
|
- // dataGridView_SubElements.Rows[0].Cells[i].Value = SubElement[i];
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- //this.XmlTree_STDlist.Focus();
|
|
|
- //XmlTree_STDlist.SelectedNode = XmlTree_STDlist.SelectedNode.NextNode;
|
|
|
- //if (XmlTree_STDlist.SelectedNode.NextNode == null)
|
|
|
- //{
|
|
|
- // DownOrder.Enabled = false;
|
|
|
- //}
|
|
|
-
|
|
|
- }
|
|
|
- XmlTree_STDlist.SelectedNode = XmlTree_STDlist.SelectedNode.NextNode;
|
|
|
- if (Flag_SelStatus)
|
|
|
- {
|
|
|
- object tag = XmlTree_STDlist.SelectedNode.PrevNode.Tag;
|
|
|
- string name = XmlTree_STDlist.SelectedNode.PrevNode.Name;
|
|
|
- string text = XmlTree_STDlist.SelectedNode.PrevNode.Text;
|
|
|
- Color backcolor = XmlTree_STDlist.SelectedNode.PrevNode.BackColor;
|
|
|
- string STDId = XmlTree_STDlist.SelectedNode.PrevNode.ToolTipText;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.PrevNode.Tag = XmlTree_STDlist.SelectedNode.Tag;
|
|
|
- XmlTree_STDlist.SelectedNode.PrevNode.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
- XmlTree_STDlist.SelectedNode.PrevNode.Name = XmlTree_STDlist.SelectedNode.Name;
|
|
|
- XmlTree_STDlist.SelectedNode.PrevNode.Text = XmlTree_STDlist.SelectedNode.Text;
|
|
|
- XmlTree_STDlist.SelectedNode.PrevNode.ToolTipText = XmlTree_STDlist.SelectedNode.ToolTipText;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = tag;
|
|
|
- XmlTree_STDlist.SelectedNode.BackColor = backcolor;
|
|
|
- XmlTree_STDlist.SelectedNode.Name = name;
|
|
|
- XmlTree_STDlist.SelectedNode.Text = text;
|
|
|
- XmlTree_STDlist.SelectedNode.ToolTipText = STDId;
|
|
|
-
|
|
|
- this.textbox_STDEditor.Text = XmlTree_STDlist.SelectedNode.Tag.ToString();
|
|
|
- btn_dbs.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
-
|
|
|
- string[] strOther = XmlTree_STDlist.SelectedNode.Name.Split('$');
|
|
|
-
|
|
|
- string[] strOther2 = strOther[0].Split('_');
|
|
|
- textBox_Hardness.Text = strOther2[0];
|
|
|
- textBox_Density.Text = strOther2[1];
|
|
|
- textBox_Electrical_conductivity.Text = strOther2[2];
|
|
|
- if (strOther2.Length > 3)
|
|
|
- {
|
|
|
- textBox_BSEValue.Text = strOther2[3];
|
|
|
- textBox_Formula.Text = strOther2[4];
|
|
|
- textBox_Element.Text = strOther2[5];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_BSEValue.Text = "";
|
|
|
- textBox_Formula.Text = "";
|
|
|
- textBox_Element.Text = "";
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- string[] KeyElement = strOther[1].Split(',');
|
|
|
- for (int i = 0; i < KeyElement.Length; i++)
|
|
|
- {
|
|
|
- if (KeyElement[0] != "")
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[i].Value = KeyElement[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- string[] SubElement = strOther[2].Split(',');
|
|
|
- for (int i = 0; i < SubElement.Length; i++)
|
|
|
- {
|
|
|
- if (SubElement[i] != "")
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_SubElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_SubElements.Rows[0].Cells[i].Value = SubElement[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.XmlTree_STDlist.Focus();
|
|
|
-
|
|
|
- if (XmlTree_STDlist.SelectedNode.PrevNode == null)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
-
|
|
|
- dataGridView_KeyElements.ClearSelection();
|
|
|
- dataGridView_SubElements.ClearSelection();
|
|
|
- }
|
|
|
-
|
|
|
- this.XmlTree_STDlist.Focus();
|
|
|
- Flag_SelStatus = true;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Backup_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (tabControl_Rules.SelectedIndex == 0)
|
|
|
- {
|
|
|
- //保存节点当前数据
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- //判断Hardness、Density、Electrical_conductivity
|
|
|
- double dHardness = 0, dDensity = 0, dElectrical_conductivity = 0;
|
|
|
- if (!double.TryParse(textBox_Hardness.Text, out dHardness) || (double.Parse(textBox_Hardness.Text) <= 0))
|
|
|
- {
|
|
|
- textBox_Hardness.Focus();
|
|
|
- textBox_Hardness.SelectAll();
|
|
|
- MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Density.Text, out dDensity) || double.Parse(textBox_Density.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_Density.Focus();
|
|
|
- textBox_Density.SelectAll();
|
|
|
- MessageBox.Show(table["message11"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Electrical_conductivity.Text, out dElectrical_conductivity) || double.Parse(textBox_Electrical_conductivity.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_Electrical_conductivity.Focus();
|
|
|
- textBox_Electrical_conductivity.SelectAll();
|
|
|
- MessageBox.Show(table["message12"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_BSEValue.Text.LastIndexOf("_")>0)
|
|
|
- {
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- textBox_BSEValue.SelectAll();
|
|
|
- MessageBox.Show(table["message13"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Formula.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_Formula.Focus();
|
|
|
- textBox_Formula.SelectAll();
|
|
|
- MessageBox.Show(table["message14"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Formula.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Element.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_Element.Focus();
|
|
|
- textBox_Element.SelectAll();
|
|
|
- MessageBox.Show(table["message15"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Element.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- XmlTree_STDlist.SelectedNode.Name = textBox_Hardness.Text + "_" + textBox_Density.Text + "_" + textBox_Electrical_conductivity.Text + "_" + textBox_BSEValue.Text + "_" + textBox_Formula.Text + "_" + textBox_Element.Text; ;
|
|
|
-
|
|
|
- string sKeyElements = "";
|
|
|
- for (int i = 0; i < dataGridView_KeyElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sKeyElements += 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 < dataGridView_SubElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sSubElements += dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
|
|
|
- }
|
|
|
- if (sSubElements.Length > 0)
|
|
|
- {
|
|
|
- sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name += "$" + sKeyElements + "$" + sSubElements;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 1)
|
|
|
- {
|
|
|
- if (XmlTree_MaxEDSRules.SelectedNode != null)
|
|
|
- {
|
|
|
-
|
|
|
- //判断MaxEDSTime
|
|
|
- double dMaxEDSTime = 0;
|
|
|
- if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_MaxEDSTime.Focus();
|
|
|
- textBox_MaxEDSTime.SelectAll();
|
|
|
- MessageBox.Show(table["message16"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode.Name = textBox_MaxEDSTime.Text;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 2)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode != null)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
|
|
|
- {
|
|
|
- if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- SaveFileDialog saveFile = new SaveFileDialog();
|
|
|
- saveFile.Title = table["message23"].ToString();
|
|
|
- saveFile.Filter = table["message24"].ToString();
|
|
|
- saveFile.OverwritePrompt = true; //是否覆盖当前文件
|
|
|
- saveFile.RestoreDirectory = true; //还原上次目录
|
|
|
- if (saveFile.ShowDialog() == DialogResult.OK)
|
|
|
- {
|
|
|
- //string Address = Application.StartupPath.Substring(0, Application.StartupPath.Length - 35) + "\\Opton\\OTSPartA\\OTS\\Bin\\Win32\\Debug\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- //string Address = ".\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- System.IO.File.Copy(Address, saveFile.FileName, true);
|
|
|
- SaveXmlTreeDataToXml(saveFile.FileName);
|
|
|
- MessageBox.Show(table["message25"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(ex.Message);
|
|
|
- }
|
|
|
- //string Address_backup = Application.StartupPath.Substring(0, Application.StartupPath.Length-35) + "\\Bin\\Win32\\Debug\\Config\\SysData\\OTSParticleSTD_backup.xml";
|
|
|
- //string Address_backup = ".\\Config\\SysData\\OTSParticleSTD_backup.xml";
|
|
|
- //SaveXmlTreeDataToXml(Address_backup);
|
|
|
-
|
|
|
-
|
|
|
- //MessageBox.Show("备份成功!", "提示");
|
|
|
- }
|
|
|
-
|
|
|
- private void button_Recover_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- XmlDocument doc = new XmlDocument();
|
|
|
- //string Address_backup = ".\\Config\\SysData\\OTSParticleSTD_backup.xml";
|
|
|
- //string Address = ".\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- //string Address_backup = Application.StartupPath + "\\Config\\SysData\\\\OTSParticleSTD_backup.xml";
|
|
|
- //string Address = Application.StartupPath + "\\Config\\SysData\\OTSParticleSTD.xml";
|
|
|
- try
|
|
|
- {
|
|
|
- System.IO.File.Copy(Address_backup, Address, true);
|
|
|
- doc.Load(Address_backup);
|
|
|
-
|
|
|
- XmlTree_STDlist.Nodes.Clear();
|
|
|
- XmlTree_MaxEDSRules.Nodes.Clear();
|
|
|
- XmlTree_ZeroElementRules.Nodes.Clear();
|
|
|
-
|
|
|
- checkBox_0.Checked = false;
|
|
|
- checkBox_1.Checked = false;
|
|
|
- checkBox_2.Checked = false;
|
|
|
- checkBox_3.Checked = false;
|
|
|
- checkBox_4.Checked = false;
|
|
|
- checkBox_5.Checked = false;
|
|
|
- checkBox_6.Checked = false;
|
|
|
- checkBox_7.Checked = false;
|
|
|
- checkBox_8.Checked = false;
|
|
|
- checkBox_9.Checked = false;
|
|
|
- textBox_0.ReadOnly = true;
|
|
|
- textBox_1.ReadOnly = true;
|
|
|
- textBox_2.ReadOnly = true;
|
|
|
- textBox_3.ReadOnly = true;
|
|
|
- textBox_4.ReadOnly = true;
|
|
|
- textBox_5.ReadOnly = true;
|
|
|
- textBox_6.ReadOnly = true;
|
|
|
- textBox_7.ReadOnly = true;
|
|
|
- textBox_8.ReadOnly = true;
|
|
|
- textBox_9.ReadOnly = true;
|
|
|
-
|
|
|
- LoadXmlToTreeControl(doc, XmlTree_STDlist.Nodes, XmlTree_MaxEDSRules.Nodes, XmlTree_ZeroElementRules.Nodes);
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode = null;
|
|
|
- XmlTree_MaxEDSRules.SelectedNode = null;
|
|
|
- XmlTree_ZeroElementRules.SelectedNode = null;
|
|
|
- textbox_STDEditor.Text = "";
|
|
|
- textBox_Density.Text = "";
|
|
|
- textBox_Electrical_conductivity.Text = "";
|
|
|
- textBox_BSEValue.Text = "";
|
|
|
- textBox_Formula.Text = "";
|
|
|
- textBox_Element.Text = "";
|
|
|
- textBox_Hardness.Text = "";
|
|
|
- //textBox_MaxEDSTime.Text = "";
|
|
|
- btn_dbs.BackColor = Color.White;
|
|
|
-
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
- //重新绑定STDXray信息
|
|
|
- BindSTDXray();
|
|
|
-
|
|
|
- }
|
|
|
- catch(Exception ex)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message26"].ToString() + "\n"+ex.Message.ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void tabControl_Rules_DrawItem(object sender, DrawItemEventArgs e)
|
|
|
- {
|
|
|
- //SolidBrush _Brush = new SolidBrush(Color.Black);//单色画刷
|
|
|
- //RectangleF _TabTextArea = (RectangleF)tabControl_Rules.GetTabRect(e.Index);//绘制区域
|
|
|
- //StringFormat _sf = new StringFormat();//封装文本布局格式信息
|
|
|
- //_sf.LineAlignment = StringAlignment.Center;
|
|
|
- //_sf.Alignment = StringAlignment.Center;
|
|
|
- //e.Graphics.DrawString(tabControl_Rules.Controls[e.Index].Text, SystemInformation.MenuFont, _Brush, _TabTextArea, _sf);
|
|
|
-
|
|
|
- //RectangleF tabArea = tabControl_Rules.GetTabRect(e.Index);
|
|
|
- //RectangleF tabTextArea = tabArea;
|
|
|
- //Graphics g = e.Graphics;
|
|
|
- //StringFormat sf = new StringFormat();
|
|
|
- //sf.LineAlignment = StringAlignment.Center;
|
|
|
- //sf.Alignment = StringAlignment.Center;
|
|
|
- //Font font = this.tabControl_Rules.Font;
|
|
|
- //SolidBrush brush = new SolidBrush(Color.Black);
|
|
|
- //g.DrawString(((TabControl)(sender)).TabPages[e.Index].Text, font, brush, tabTextArea, sf);
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_ZeroElementRules_MouseClick(object sender, MouseEventArgs e)
|
|
|
- {
|
|
|
- //if (e.Button == MouseButtons.Left)
|
|
|
- //{
|
|
|
- // Point ClickPoint = new Point(e.X, e.Y);
|
|
|
- // TreeNode CurrentNode = XmlTree_ZeroElementRules.GetNodeAt(ClickPoint);
|
|
|
- // if (CurrentNode != null)//判断你点的是不是一个节点
|
|
|
- // {
|
|
|
- // if (XmlTree_ZeroElementRules.SelectedNode != null&& XmlTree_ZeroElementRules.SelectedNode != CurrentNode)
|
|
|
- // {
|
|
|
- // if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
|
|
|
- // {
|
|
|
- // if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
|
|
|
- // {
|
|
|
- // MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "项,名称格式填写错误,正确格式为:元素名=0");
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + "项,名称格式填写错误,正确格式为:元素名=0");
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // if (!Checktextbox_STDEditor())
|
|
|
- // {
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // SetBlackAllNodes(XmlTree_ZeroElementRules);
|
|
|
- // XmlTree_ZeroElementRules.SelectedNode = CurrentNode;
|
|
|
- // this.textbox_STDEditor.Text = XmlTree_ZeroElementRules.SelectedNode.Tag.ToString();
|
|
|
-
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_ZeroElementRules_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
- {
|
|
|
- if (e.Button == MouseButtons.Left)
|
|
|
- {
|
|
|
- Point ClickPoint = new Point(e.X, e.Y);
|
|
|
- TreeNode CurrentNode = XmlTree_ZeroElementRules.GetNodeAt(ClickPoint);
|
|
|
- if (CurrentNode != null)//判断你点的是不是一个节点
|
|
|
- {
|
|
|
- XmlTree_ZeroElementRules.SelectedNode = CurrentNode;//选中这个节点
|
|
|
- //this.textbox_STDEditor.Text = XmlTree_ZeroElementRules.SelectedNode.Tag.ToString();
|
|
|
- XmlTree_ZeroElementRules.LabelEdit = true;
|
|
|
- XmlTree_ZeroElementRules.SelectedNode.BeginEdit();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_MaxEDSRules_MouseClick(object sender, MouseEventArgs e)
|
|
|
- {
|
|
|
- //if (e.Button == MouseButtons.Left)
|
|
|
- //{
|
|
|
- // Point ClickPoint = new Point(e.X, e.Y);
|
|
|
- // TreeNode CurrentNode = XmlTree_MaxEDSRules.GetNodeAt(ClickPoint);
|
|
|
- // if (CurrentNode != null)//判断你点的是不是一个节点
|
|
|
- // {
|
|
|
- // if (XmlTree_MaxEDSRules.SelectedNode != null&& XmlTree_MaxEDSRules.SelectedNode!= CurrentNode)
|
|
|
- // {
|
|
|
- // if (!Checktextbox_STDEditor())
|
|
|
- // {
|
|
|
- // SetGrayExceptSelectedNode(XmlTree_MaxEDSRules, XmlTree_MaxEDSRules.SelectedNode);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // //double dMaxEDSTime = 0;
|
|
|
- // //if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime)||double.Parse(textBox_MaxEDSTime.Text)<=0)
|
|
|
- // //{
|
|
|
- // // MessageBox.Show("MaxEDSTime请填写数字!", "提示");
|
|
|
- // //}
|
|
|
-
|
|
|
- // XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- // //XmlTree_MaxEDSRules.SelectedNode.Name = this.textBox_MaxEDSTime.Text;
|
|
|
-
|
|
|
- // }
|
|
|
- // SetBlackAllNodes(XmlTree_MaxEDSRules);
|
|
|
- // XmlTree_MaxEDSRules.SelectedNode = CurrentNode;
|
|
|
- // this.textbox_STDEditor.Text = XmlTree_MaxEDSRules.SelectedNode.Tag.ToString();
|
|
|
- // //textBox_MaxEDSTime.Text = XmlTree_MaxEDSRules.SelectedNode.Name;
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void checkBox_0_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_0.Checked)
|
|
|
- {
|
|
|
- textBox_0.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_0.Text))
|
|
|
- {
|
|
|
- checkBox_0.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_0.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_1_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_1.Checked)
|
|
|
- {
|
|
|
- textBox_1.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_1.Text))
|
|
|
- {
|
|
|
- checkBox_1.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_1.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_2_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_2.Checked)
|
|
|
- {
|
|
|
- textBox_2.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_2.Text))
|
|
|
- {
|
|
|
- checkBox_2.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_2.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_3_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_3.Checked)
|
|
|
- {
|
|
|
- textBox_3.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_3.Text))
|
|
|
- {
|
|
|
- checkBox_3.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_3.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_4_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_4.Checked)
|
|
|
- {
|
|
|
- textBox_4.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_4.Text))
|
|
|
- {
|
|
|
- checkBox_4.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_4.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_5_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_5.Checked)
|
|
|
- {
|
|
|
- textBox_5.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_5.Text))
|
|
|
- {
|
|
|
- checkBox_5.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_5.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_6_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_6.Checked)
|
|
|
- {
|
|
|
- textBox_6.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_6.Text))
|
|
|
- {
|
|
|
- checkBox_6.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_6.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_7_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_7.Checked)
|
|
|
- {
|
|
|
- textBox_7.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_7.Text))
|
|
|
- {
|
|
|
- checkBox_7.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_7.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_8_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_8.Checked)
|
|
|
- {
|
|
|
- textBox_8.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_8.Text))
|
|
|
- {
|
|
|
- checkBox_8.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_8.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void checkBox_9_CheckedChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (checkBox_9.Checked)
|
|
|
- {
|
|
|
- textBox_9.ReadOnly = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!CheckConstants(checkBox_9.Text))
|
|
|
- {
|
|
|
- checkBox_9.Checked = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textBox_9.ReadOnly = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- private bool CheckConstants(string ConstantName)
|
|
|
- {
|
|
|
- for (int num = 0; num < XmlTree_STDlist.Nodes.Count; num++)
|
|
|
- {
|
|
|
- if (XmlTree_STDlist.Nodes[num].Tag.ToString().Contains(ConstantName))
|
|
|
- {
|
|
|
- tabControl_Rules.SelectedIndex = 0;
|
|
|
- XmlTree_STDlist.SelectedNode = XmlTree_STDlist.Nodes[num];
|
|
|
- SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- DialogResult result = MessageBox.Show(table["message27"].ToString() + XmlTree_STDlist.Nodes[num].Text + table["message28"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- for (int num = 0; num < XmlTree_MaxEDSRules.Nodes.Count; num++)
|
|
|
- {
|
|
|
- if (XmlTree_MaxEDSRules.Nodes[num].Tag.ToString().Contains(ConstantName))
|
|
|
- {
|
|
|
- tabControl_Rules.SelectedIndex = 1;
|
|
|
- XmlTree_MaxEDSRules.SelectedNode = XmlTree_MaxEDSRules.Nodes[num];
|
|
|
- SetGrayExceptSelectedNode(XmlTree_MaxEDSRules, XmlTree_MaxEDSRules.SelectedNode);
|
|
|
- DialogResult result = MessageBox.Show(table["message27"].ToString() + XmlTree_MaxEDSRules.Nodes[num].Text + table["message28"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- for (int num = 0; num < XmlTree_ZeroElementRules.Nodes.Count; num++)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.Nodes[num].Tag.ToString().Contains(ConstantName))
|
|
|
- {
|
|
|
- tabControl_Rules.SelectedIndex = 2;
|
|
|
- XmlTree_ZeroElementRules.SelectedNode = XmlTree_ZeroElementRules.Nodes[num];
|
|
|
- SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- DialogResult result = MessageBox.Show(table["message27"].ToString() + XmlTree_ZeroElementRules.Nodes[num].Text + table["message28"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- private void button_UpdateConstants_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- this.comboBox_Constants.Items.Clear();
|
|
|
- for (int i = 0; i < 10; i++)
|
|
|
- {
|
|
|
- CheckBox checkBox = (CheckBox)this.tabControl_Rules.TabPages[3].Controls.Find("checkBox_" + i.ToString(), false)[0];
|
|
|
- if (checkBox.Checked)
|
|
|
- {
|
|
|
- TextBox tBox = (TextBox)this.tabControl_Rules.TabPages[3].Controls.Find("textBox_" + i.ToString(), false)[0];
|
|
|
- double DoubleTry = 0;
|
|
|
- if (double.TryParse(tBox.Text, out DoubleTry))
|
|
|
- {
|
|
|
- this.comboBox_Constants.Items.Add(checkBox.Text + "=" + tBox.Text);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(table["message29"].ToString() + checkBox.Name + table["message30"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<string> Constantslist = new List<string>();
|
|
|
- Constantslist.Add("MAC#0");
|
|
|
- Constantslist.Add("MAC#1");
|
|
|
- Constantslist.Add("MAC#2");
|
|
|
- Constantslist.Add("MAC#3");
|
|
|
- Constantslist.Add("MAC#4");
|
|
|
- Constantslist.Add("MAC#5");
|
|
|
- Constantslist.Add("MAC#6");
|
|
|
- Constantslist.Add("MAC#7");
|
|
|
- Constantslist.Add("MAC#8");
|
|
|
- Constantslist.Add("MAC#9");
|
|
|
- foreach (var item in comboBox_Constants.Items)
|
|
|
- {
|
|
|
- Constantslist.Remove(item.ToString().Split('=')[0]);
|
|
|
- }
|
|
|
-
|
|
|
- MessageBox.Show(table["message31"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- }
|
|
|
- //tabpage切换开关
|
|
|
- bool Flag_TabControlChange = true;
|
|
|
- private void tabControl_Rules_Deselecting(object sender, TabControlCancelEventArgs e)
|
|
|
- {
|
|
|
- if (tabControl_Rules.SelectedIndex == 0)
|
|
|
- {
|
|
|
- //保存节点当前数据
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- //判断Hardness、Density、Electrical_conductivity
|
|
|
- double dHardness = 0, dDensity = 0, dElectrical_conductivity = 0;
|
|
|
- if (!double.TryParse(textBox_Hardness.Text, out dHardness) || (double.Parse(textBox_Hardness.Text) <= 0))
|
|
|
- {
|
|
|
- textBox_Hardness.Focus();
|
|
|
- textBox_Hardness.SelectAll();
|
|
|
- MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Density.Text, out dDensity) || double.Parse(textBox_Density.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_Density.Focus();
|
|
|
- textBox_Density.SelectAll();
|
|
|
- MessageBox.Show(table["message11"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Electrical_conductivity.Text, out dElectrical_conductivity) || double.Parse(textBox_Electrical_conductivity.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_Electrical_conductivity.Focus();
|
|
|
- textBox_Electrical_conductivity.SelectAll();
|
|
|
- MessageBox.Show(table["message12"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_BSEValue.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- textBox_BSEValue.SelectAll();
|
|
|
- MessageBox.Show(table["message13"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Formula.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_Formula.Focus();
|
|
|
- textBox_Formula.SelectAll();
|
|
|
- MessageBox.Show(table["message14"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Formula.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Element.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- textBox_Element.Focus();
|
|
|
- textBox_Element.SelectAll();
|
|
|
- MessageBox.Show(table["message15"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Element.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Flag_TabControlChange = true;
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name = textBox_Hardness.Text + "_" + textBox_Density.Text + "_" + textBox_Electrical_conductivity.Text + "_" + textBox_BSEValue.Text + "_" + textBox_Formula.Text + "_" + textBox_Element.Text; ;
|
|
|
-
|
|
|
- string sKeyElements = "";
|
|
|
- for (int i = 0; i < dataGridView_KeyElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sKeyElements += 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 < dataGridView_SubElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sSubElements += dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
|
|
|
- }
|
|
|
- if (sSubElements.Length > 0)
|
|
|
- {
|
|
|
- sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name += "$" + sKeyElements + "$" + sSubElements;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.BackColor = btn_dbs.BackColor;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 1)
|
|
|
- {
|
|
|
- if (XmlTree_MaxEDSRules.SelectedNode != null)
|
|
|
- {
|
|
|
- //判断MaxEDSTime
|
|
|
- double dMaxEDSTime = 0;
|
|
|
- if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime) || double.Parse(textBox_MaxEDSTime.Text) <= 0)
|
|
|
- {
|
|
|
- textBox_MaxEDSTime.Focus();
|
|
|
- textBox_MaxEDSTime.SelectAll();
|
|
|
- MessageBox.Show(table["message16"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- Flag_TabControlChange = true;
|
|
|
- XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode.Name = textBox_MaxEDSTime.Text;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 2)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode != null)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
|
|
|
- {
|
|
|
- if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- Flag_TabControlChange = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- Flag_TabControlChange = true;
|
|
|
- XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- }
|
|
|
- }
|
|
|
- //XmlTree_STDlist.SelectedNode = null;
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode = null;
|
|
|
- //XmlTree_ZeroElementRules.SelectedNode = null;
|
|
|
- //textbox_STDEditor.Text = "";
|
|
|
- //textBox_Density.Text = "";
|
|
|
- //textBox_Electrical_conductivity.Text = "";
|
|
|
- //textBox_Hardness.Text = "";
|
|
|
- //textBox_MaxEDSTime.Text = "";
|
|
|
- //btn_dbs.BackColor = Color.White;
|
|
|
- }
|
|
|
-
|
|
|
- private void tabControl_Rules_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (tabControl_Rules.SelectedIndex == 0)
|
|
|
- {
|
|
|
- //XmlTree_STDlist.SelectedNode = null;
|
|
|
- XmlTree_STDlist.Focus();
|
|
|
- XmlTree_STDlist_AfterSelect(XmlTree_STDlist, new TreeViewEventArgs(XmlTree_STDlist.SelectedNode));
|
|
|
-
|
|
|
- textBox_Density.ReadOnly = false;
|
|
|
- textBox_Electrical_conductivity.ReadOnly = false;
|
|
|
- textBox_Hardness.ReadOnly = false;
|
|
|
- textBox_BSEValue.ReadOnly = false;
|
|
|
- textBox_Formula.ReadOnly = false;
|
|
|
- textBox_Element.ReadOnly = false;
|
|
|
- btn_dbs.Enabled = true;
|
|
|
- textBox_MaxEDSTime.ReadOnly = true;
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 1)
|
|
|
- {
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode = null;
|
|
|
- XmlTree_MaxEDSRules.Focus();
|
|
|
- XmlTree_MaxEDSRules_AfterSelect(XmlTree_MaxEDSRules, new TreeViewEventArgs(XmlTree_MaxEDSRules.SelectedNode));
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- btn_dbs.BackColor = SystemColors.Control;
|
|
|
- textBox_Density.Text = "";
|
|
|
- textBox_Electrical_conductivity.Text = "";
|
|
|
- textBox_Hardness.Text = "";
|
|
|
-
|
|
|
- textBox_Density.ReadOnly = true;
|
|
|
- textBox_Electrical_conductivity.ReadOnly = true;
|
|
|
- textBox_Hardness.ReadOnly = true;
|
|
|
- textBox_BSEValue.ReadOnly = true;
|
|
|
- textBox_Formula.ReadOnly = true;
|
|
|
- textBox_Element.ReadOnly = true;
|
|
|
- btn_dbs.Enabled = false;
|
|
|
- textBox_MaxEDSTime.ReadOnly = false;
|
|
|
-
|
|
|
- tabSTDStandrad.SelectedIndex = 0;
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 2)
|
|
|
- {
|
|
|
- //XmlTree_ZeroElementRules.SelectedNode = null;
|
|
|
- XmlTree_ZeroElementRules.Focus();
|
|
|
- XmlTree_ZeroElementRules_AfterSelect(XmlTree_MaxEDSRules, new TreeViewEventArgs(XmlTree_ZeroElementRules.SelectedNode));
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- btn_dbs.BackColor = SystemColors.Control;
|
|
|
- textBox_Density.Text = "";
|
|
|
- textBox_Electrical_conductivity.Text = "";
|
|
|
- textBox_Hardness.Text = "";
|
|
|
-
|
|
|
- textBox_Density.ReadOnly = true;
|
|
|
- textBox_Electrical_conductivity.ReadOnly = true;
|
|
|
- textBox_BSEValue.ReadOnly = true;
|
|
|
- textBox_Formula.ReadOnly = true;
|
|
|
- textBox_Element.ReadOnly = true;
|
|
|
- textBox_Hardness.ReadOnly = true;
|
|
|
- btn_dbs.Enabled = false;
|
|
|
- textBox_MaxEDSTime.ReadOnly = true;
|
|
|
- tabSTDStandrad.SelectedIndex = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- textbox_STDEditor.Text = "";
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- btn_dbs.BackColor = SystemColors.Control;
|
|
|
- textBox_Density.Text = "";
|
|
|
- textBox_Electrical_conductivity.Text = "";
|
|
|
- textBox_Hardness.Text = "";
|
|
|
-
|
|
|
- textBox_Density.ReadOnly = true;
|
|
|
- textBox_Electrical_conductivity.ReadOnly = true;
|
|
|
- textBox_BSEValue.ReadOnly = true;
|
|
|
- textBox_Formula.ReadOnly = true;
|
|
|
- textBox_Element.ReadOnly = true;
|
|
|
- textBox_Hardness.ReadOnly = true;
|
|
|
- btn_dbs.Enabled = false;
|
|
|
- textBox_MaxEDSTime.ReadOnly = true;
|
|
|
- }
|
|
|
-
|
|
|
- //textbox_STDEditor.Text = "";
|
|
|
- //dataGridView_KeyElements.Rows.Clear();
|
|
|
- //dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- //dataGridView_SubElements.Rows.Clear();
|
|
|
- //dataGridView_SubElements.Columns.Clear();
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_ZeroElementRules_BeforeSelect(object sender, TreeViewCancelEventArgs e)
|
|
|
- {
|
|
|
- //if (e.Node != null)
|
|
|
- //{
|
|
|
- // if (e.Node.ForeColor == Color.Gray)
|
|
|
- // {
|
|
|
- // e.Cancel = true; //不让选中禁用节点
|
|
|
- // return;
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode != null)
|
|
|
- {
|
|
|
- if (XmlTree_ZeroElementRules.SelectedNode.Text.Contains("="))
|
|
|
- {
|
|
|
- if (!comboBox_PeriodicTable.Items.Contains(XmlTree_ZeroElementRules.SelectedNode.Text.Split('=')[0]))
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show(XmlTree_ZeroElementRules.SelectedNode.Text + table["message9"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- SetGrayExceptSelectedNode(XmlTree_ZeroElementRules, XmlTree_ZeroElementRules.SelectedNode);
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- XmlTree_ZeroElementRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void tabControl_Rules_Selecting(object sender, TabControlCancelEventArgs e)
|
|
|
- {
|
|
|
- if (!Flag_TabControlChange)
|
|
|
- {
|
|
|
- e.Cancel = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_ZeroElementRules_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
- {
|
|
|
- SetBlackAllNodes(XmlTree_ZeroElementRules);
|
|
|
- this.textbox_STDEditor.Text = XmlTree_ZeroElementRules.SelectedNode.Tag.ToString();
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_STDlist_BeforeSelect(object sender, TreeViewCancelEventArgs e)
|
|
|
- {
|
|
|
- if (XmlTree_STDlist.SelectedNode != null)
|
|
|
- {
|
|
|
- //判断Hardness、Density、Electrical_conductivity
|
|
|
- double dHardness = 0, dDensity = 0, dElectrical_conductivity = 0;
|
|
|
- if (!double.TryParse(textBox_Hardness.Text, out dHardness) || (double.Parse(textBox_Hardness.Text) <= 0))
|
|
|
- {
|
|
|
- MessageBox.Show(table["message10"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- Flag_SelStatus = false;
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Density.Text, out dDensity) || double.Parse(textBox_Density.Text) <= 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message11"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- Flag_SelStatus = false;
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!double.TryParse(textBox_Electrical_conductivity.Text, out dElectrical_conductivity) || double.Parse(textBox_Electrical_conductivity.Text) <= 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message12"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- Flag_SelStatus = false;
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_BSEValue.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message13"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_BSEValue.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Formula.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message14"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Formula.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (textBox_Element.Text.LastIndexOf("_") > 0)
|
|
|
- {
|
|
|
- MessageBox.Show(table["message15"].ToString(), table["message32"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
- textBox_Element.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- //判断textbox_STDEditor
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- SetGrayExceptSelectedNode(XmlTree_STDlist, XmlTree_STDlist.SelectedNode);
|
|
|
- Flag_SelStatus = false;
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
-
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0 && dataGridView_SubElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
- 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> UsingElementL = new List<string>();
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- for (int i = 0; i < UsingElementL.Count; i++)
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[i].Value = UsingElementL[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name = textBox_Hardness.Text + "_" + textBox_Density.Text + "_" + textBox_Electrical_conductivity.Text + "_" + textBox_BSEValue.Text + "_" + textBox_Formula.Text + "_" + textBox_Element.Text; ;
|
|
|
-
|
|
|
- string sKeyElements = "";
|
|
|
- for (int i = 0; i < dataGridView_KeyElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sKeyElements += 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 < dataGridView_SubElements.Columns.Count; i++)
|
|
|
- {
|
|
|
- sSubElements += dataGridView_SubElements.Rows[0].Cells[i].Value.ToString() + ",";
|
|
|
- }
|
|
|
- if (sSubElements.Length > 0)
|
|
|
- {
|
|
|
- sSubElements = sSubElements.Substring(0, sSubElements.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.Name += "$" + sKeyElements + "$" + sSubElements;
|
|
|
-
|
|
|
- XmlTree_STDlist.SelectedNode.BackColor = btn_dbs.BackColor;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_MaxEDSRules_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
- {
|
|
|
- SetBlackAllNodes(XmlTree_MaxEDSRules);
|
|
|
- this.textbox_STDEditor.Text = XmlTree_MaxEDSRules.SelectedNode.Tag.ToString();
|
|
|
- //textBox_MaxEDSTime.Text = XmlTree_MaxEDSRules.SelectedNode.Name;
|
|
|
- }
|
|
|
-
|
|
|
- private void XmlTree_MaxEDSRules_BeforeSelect(object sender, TreeViewCancelEventArgs e)
|
|
|
- {
|
|
|
- if (XmlTree_MaxEDSRules.SelectedNode != null)
|
|
|
- {
|
|
|
- if (!Checktextbox_STDEditor())
|
|
|
- {
|
|
|
- SetGrayExceptSelectedNode(XmlTree_MaxEDSRules, XmlTree_MaxEDSRules.SelectedNode);
|
|
|
- e.Cancel = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- //double dMaxEDSTime = 0;
|
|
|
- //if (!double.TryParse(textBox_MaxEDSTime.Text, out dMaxEDSTime)||double.Parse(textBox_MaxEDSTime.Text)<=0)
|
|
|
- //{
|
|
|
- // MessageBox.Show("MaxEDSTime请填写数字!", "提示");
|
|
|
- // e.Cancel = true;
|
|
|
- //}
|
|
|
-
|
|
|
- XmlTree_MaxEDSRules.SelectedNode.Tag = this.textbox_STDEditor.Text;
|
|
|
- //XmlTree_MaxEDSRules.SelectedNode.Name = this.textBox_MaxEDSTime.Text;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- string ElementKeyOrSub = "";
|
|
|
-
|
|
|
- private void dataGridView_KeyElements_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
- {
|
|
|
- ElementKeyOrSub = dataGridView_KeyElements.CurrentCell.Value.ToString();
|
|
|
- dataGridView_KeyElements.Columns.RemoveAt(e.ColumnIndex);
|
|
|
-
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_SubElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_SubElements.Rows[0].Cells[dataGridView_SubElements.Columns.Count - 1].Value = ElementKeyOrSub;
|
|
|
- dataGridView_SubElements.ClearSelection();
|
|
|
- dataGridView_KeyElements.ClearSelection();
|
|
|
- XmlTree_STDlist.Focus();
|
|
|
- }
|
|
|
-
|
|
|
- private void dataGridView_SubElements_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
- {
|
|
|
- ElementKeyOrSub = dataGridView_SubElements.CurrentCell.Value.ToString();
|
|
|
- dataGridView_SubElements.Columns.RemoveAt(e.ColumnIndex);
|
|
|
-
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[dataGridView_KeyElements.Columns.Count - 1].Value = ElementKeyOrSub;
|
|
|
- dataGridView_KeyElements.ClearSelection();
|
|
|
- dataGridView_SubElements.ClearSelection();
|
|
|
- XmlTree_STDlist.Focus();
|
|
|
- }
|
|
|
-
|
|
|
- private void textbox_STDEditor_TextChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- //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> UsingElementL = new List<string>();
|
|
|
- //for (int i = 0; i < list_all.Count; i++)
|
|
|
- //{
|
|
|
- // if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- // {
|
|
|
- // if (!UsingElementL.Contains(list_all[i]))
|
|
|
- // {
|
|
|
- // UsingElementL.Add(list_all[i]);
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //for (int i = 0; i < UsingElementL.Count; i++)
|
|
|
- //{
|
|
|
- // DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- // dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
|
|
|
- // dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- // if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- // {
|
|
|
- // DataGridViewRow row = new DataGridViewRow();
|
|
|
- // dataGridView_KeyElements.Rows.Add(row);
|
|
|
- // }
|
|
|
- // dataGridView_KeyElements.Rows[0].Cells[i].Value = UsingElementL[i];
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
- private void textbox_STDEditor_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
- {
|
|
|
- //if (e.KeyChar == '\r')
|
|
|
- //{
|
|
|
- // dataGridView_KeyElements.Rows.Clear();
|
|
|
- // dataGridView_KeyElements.Columns.Clear();
|
|
|
- // dataGridView_SubElements.Rows.Clear();
|
|
|
- // dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- // string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- // str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
- // 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> UsingElementL = new List<string>();
|
|
|
- // for (int i = 0; i < list_all.Count; i++)
|
|
|
- // {
|
|
|
- // if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- // {
|
|
|
- // if (!UsingElementL.Contains(list_all[i]))
|
|
|
- // {
|
|
|
- // UsingElementL.Add(list_all[i]);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // for (int i = 0; i < UsingElementL.Count; i++)
|
|
|
- // {
|
|
|
- // DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- // dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
|
|
|
- // dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- // if(dataGridView_KeyElements.Rows.Count==0)
|
|
|
- // {
|
|
|
- // DataGridViewRow row = new DataGridViewRow();
|
|
|
- // dataGridView_KeyElements.Rows.Add(row);
|
|
|
- // }
|
|
|
- // dataGridView_KeyElements.Rows[0].Cells[i].Value = UsingElementL[i];
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
- private void textbox_STDEditor_Leave(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (tabControl_Rules.SelectedIndex == 0)
|
|
|
- {
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
-
|
|
|
- string str_RemoveBlank = textbox_STDEditor.Text.ToString().Replace(" ", "");
|
|
|
- str_RemoveBlank = str_RemoveBlank.Replace("\r\n", "");
|
|
|
- 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> UsingElementL = new List<string>();
|
|
|
- for (int i = 0; i < list_all.Count; i++)
|
|
|
- {
|
|
|
- if (this.comboBox_PeriodicTable.Items.Contains(list_all[i]))
|
|
|
- {
|
|
|
- if (!UsingElementL.Contains(list_all[i]))
|
|
|
- {
|
|
|
- UsingElementL.Add(list_all[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<string> SubElements = new List<string>();
|
|
|
- for (int i = 0; i < dataGridView_SubElements.ColumnCount; i++)
|
|
|
- {
|
|
|
- if (UsingElementL.Contains(dataGridView_SubElements.Rows[0].Cells[i].Value))
|
|
|
- {
|
|
|
- SubElements.Add(dataGridView_SubElements.Rows[0].Cells[i].Value.ToString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- for (int i = 0; i < SubElements.Count; i++)
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_SubElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_SubElements.Rows[0].Cells[dataGridView_SubElements.ColumnCount - 1].Value = SubElements[i];
|
|
|
- }
|
|
|
-
|
|
|
- if (SubElements.Count > 0)
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count; i++)
|
|
|
- {
|
|
|
- if (!SubElements.Contains(UsingElementL[i]))
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[dataGridView_KeyElements.ColumnCount - 1].Value = UsingElementL[i];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- for (int i = 0; i < UsingElementL.Count; i++)
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_KeyElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[i].Value = UsingElementL[i];
|
|
|
- }
|
|
|
- }
|
|
|
- dataGridView_KeyElements.ClearSelection();
|
|
|
- dataGridView_SubElements.ClearSelection();
|
|
|
- XmlTree_STDlist.Focus();
|
|
|
- }
|
|
|
- else if(tabControl_Rules.SelectedIndex == 1)
|
|
|
- {
|
|
|
- XmlTree_MaxEDSRules.Focus();
|
|
|
- }
|
|
|
- else if (tabControl_Rules.SelectedIndex == 2)
|
|
|
- {
|
|
|
- XmlTree_ZeroElementRules.Focus();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #region 为配合textbox_STDEditor_Leave时事件,点击其它groupbox组件时使焦点转移
|
|
|
- private void Form_ConstantsEditor_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_XmlTree_MaxEDSRules.Focus();
|
|
|
- }
|
|
|
- private void groupBox_Data_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_Data.Focus();
|
|
|
- }
|
|
|
-
|
|
|
- private void groupBox_ChemicalElement_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_ChemicalElement.Focus();
|
|
|
- }
|
|
|
- private void groupBox_OtherCommonlyUsedSymbols_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_OtherCommonlyUsedSymbols.Focus();
|
|
|
- }
|
|
|
- private void groupBox_XmlTree_STDlist1_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_XmlTree_STDlist1.Focus();
|
|
|
- }
|
|
|
- private void groupBox_CalculatingSymbols_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_CalculatingSymbols.Focus();
|
|
|
- }
|
|
|
- private void groupBox_XmlTree_MaxEDSRules_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- groupBox_XmlTree_MaxEDSRules.Focus();
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 采集Xray 按钮事件
|
|
|
- private void btnCollectXray_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- string strTime = txtCollectTime.Text.Trim();
|
|
|
- if (txtCollectTime.Equals(""))
|
|
|
- {
|
|
|
- showMessage(table["message33"].ToString());
|
|
|
- txtCollectTime.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!IsMatch(strTime, 1))
|
|
|
- {
|
|
|
- showMessage(table["message34"].ToString());
|
|
|
- txtCollectTime.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (Convert.ToInt32(strTime) < 100)
|
|
|
- {
|
|
|
- showMessage(table["message35"].ToString());
|
|
|
- txtCollectTime.Focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- //显示Xray
|
|
|
- xrayByteData = IntArrToByteArr(GetCollectXray(strTime));
|
|
|
- int color = Convert.ToInt32(ParseRGB(btn_dbs.BackColor));
|
|
|
- //根据树节点修改对应的Xray信息
|
|
|
- UpdateSTDXray(XmlTree_STDlist.SelectedNode, xrayByteData);
|
|
|
- ShowXrayAtlas(color, xrayByteData);
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 获取采集当前的Xray信息
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- protected uint[] GetCollectXray(string strTime)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- if (null == m_cfun)
|
|
|
- {
|
|
|
- m_cfun = COTSControlFunExport.GetControllerInstance("Bruker");
|
|
|
- }
|
|
|
- if (ConnectionSem(connectionEnumType.EDSOnlyPointXRay))
|
|
|
- {
|
|
|
- if (EDSInit())
|
|
|
- {
|
|
|
- int iSize = 2000;
|
|
|
- uint[] iXrayData = new uint[iSize];
|
|
|
- //采集XRay数据
|
|
|
- if (m_cfun.CollectSpectrum(uint.Parse(strTime), ref iXrayData))
|
|
|
- {
|
|
|
- return iXrayData;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
- catch /*(Exception ex)*/
|
|
|
- {
|
|
|
- return null;
|
|
|
- }
|
|
|
- finally
|
|
|
- {
|
|
|
- //EDS过程结束
|
|
|
- //m_cfun.EDSFinishedInstance();
|
|
|
-
|
|
|
- //关闭连接
|
|
|
- DisConnectSem(connectionEnumType.EDSOnlyPointXRay);
|
|
|
- }
|
|
|
- }
|
|
|
- private void btnReadXray_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- OpenFileDialog fileSel = new OpenFileDialog();
|
|
|
- fileSel.Filter = "|*.txt";
|
|
|
- if (DialogResult.OK == fileSel.ShowDialog())
|
|
|
- {
|
|
|
- String str = "";
|
|
|
- //读取Xray文件
|
|
|
- using (StreamReader sr = new StreamReader(fileSel.FileName))
|
|
|
- {
|
|
|
- while (!sr.EndOfStream)
|
|
|
- {
|
|
|
- str += sr.ReadLine() + ",";
|
|
|
- }
|
|
|
- str = str.Substring(0, str.Length - 1);
|
|
|
- string[] xrayData = str.Split(',');
|
|
|
- if (xrayData.Length != 2000)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- uint[] data = new uint[xrayData.Length];
|
|
|
- for (int i = 0; i < xrayData.Length; i++)
|
|
|
- {
|
|
|
- data[i] = Convert.ToUInt32(xrayData[i]);
|
|
|
- }
|
|
|
- //Xray数据
|
|
|
- xrayByteData = IntArrToByteArr(data);
|
|
|
- int color = Convert.ToInt32(ParseRGB(btn_dbs.BackColor));
|
|
|
- //根据树节点修改对应的Xray信息
|
|
|
- UpdateSTDXray(XmlTree_STDlist.SelectedNode, xrayByteData);
|
|
|
- ShowXrayAtlas(color, xrayByteData);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 将int[] 转换为 byte[]
|
|
|
- /// </summary>
|
|
|
- /// <param name="intArr"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public static byte[] IntArrToByteArr(uint[] intArr)
|
|
|
- {
|
|
|
- int intSize = sizeof(int) * intArr.Length;
|
|
|
- byte[] bytArr = new byte[intSize];
|
|
|
-
|
|
|
- //申请一块非托管内存
|
|
|
- //IntPtr ptr = Marshal.AllocHGlobal(intSize);
|
|
|
- //复制int数组到该内存块
|
|
|
- //Marshal.Copy(intArr, 0, ptr, intArr.Length);
|
|
|
- ////复制回byte数组
|
|
|
- //Marshal.Copy(ptr, bytArr, 0, bytArr.Length);
|
|
|
- ////释放申请的非托管内存
|
|
|
- //Marshal.FreeHGlobal(ptr);
|
|
|
- for (int i = 0; i < intSize; i++)
|
|
|
- {
|
|
|
- byte[] c1 = BitConverter.GetBytes(intArr[i]);
|
|
|
- c1.CopyTo(bytArr, i * intSize);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return bytArr;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 将颜色对象转换为uint
|
|
|
- /// </summary>
|
|
|
- /// <param name="color"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public uint ParseRGB(Color color)
|
|
|
- {
|
|
|
- return (uint)(((uint)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R));
|
|
|
- }
|
|
|
-
|
|
|
- #region 显示Xray图谱
|
|
|
- /// <summary>
|
|
|
- /// 显示Xray图谱
|
|
|
- /// </summary>
|
|
|
- protected void ShowXrayAtlas(int colorValue = 0, byte[] XrayData = null)
|
|
|
- {
|
|
|
- DataTable dt = new DataTable();
|
|
|
- dt.Columns.Add("Color", typeof(int));
|
|
|
- dt.Columns.Add("SPEC", typeof(byte[]));
|
|
|
- DataRow dRow = dt.NewRow();
|
|
|
- dRow["Color"] = colorValue;
|
|
|
- if (XrayData != null)
|
|
|
- {
|
|
|
- dRow["SPEC"] = XrayData;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- dRow["SPEC"] = new byte[8000];
|
|
|
- }
|
|
|
- //将选择行的数据传递给Xray控件
|
|
|
- XrayControl.Dr = dRow;
|
|
|
- XrayControl.Refresh();
|
|
|
- XrayData = null;
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 常用数据验证的封装,数字字符的验证
|
|
|
- /// <summary>
|
|
|
- /// 常用数据验证的封装,数字字符的验证
|
|
|
- /// </summary>
|
|
|
- /// <param name="inputVal">需要验证的数值【字符串,或者数字】</param>
|
|
|
- /// <param name="type">类型为哪一个验证</param>
|
|
|
- /// <returns>如果验证成功则返回True,否则返回false</returns>
|
|
|
- public bool IsMatch(string inputVal, int type)
|
|
|
- {
|
|
|
- switch (type)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- return Regex.IsMatch(inputVal, @"^[1-9]d*$"); //匹配正整数
|
|
|
- case 1:
|
|
|
- return Regex.IsMatch(inputVal, @"^-?\d+$"); //匹配整数
|
|
|
- case 2:
|
|
|
- return Regex.IsMatch(inputVal, @"^[A-Za-z0-9]+$"); //匹配由数字和26个英文字母组成的字符串
|
|
|
- case 3:
|
|
|
- return Regex.IsMatch(inputVal, @"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"); //匹配正浮点数
|
|
|
- case 4:
|
|
|
- return Regex.IsMatch(inputVal, @"^[\u4e00-\u9fa5]{0,}$"); //匹配汉字
|
|
|
- case 5:
|
|
|
- return Regex.IsMatch(inputVal, @"^[0-9]+(.[0-9]{1,3})?$"); //匹配1~3位小数的正实数
|
|
|
- case 6:
|
|
|
- return Regex.IsMatch(inputVal, @"^[A-Za-z]+$"); //匹配英文字符
|
|
|
- default:
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 弹出提示
|
|
|
- /// <summary>
|
|
|
- /// 弹出提示
|
|
|
- /// </summary>
|
|
|
- /// <param name="strContent"></param>
|
|
|
- protected void showMessage(string strContent)
|
|
|
- {
|
|
|
- MessageBox.Show(strContent, table["message32"].ToString());
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 连接与关闭设备
|
|
|
- public bool ConnectionSem(connectionEnumType connectionType)
|
|
|
- {
|
|
|
- //获取连接电镜类型
|
|
|
- string connTypeStr = GetConnectionType(connectionType);
|
|
|
- //连接电镜标识
|
|
|
- bool bDisConnResult = false;
|
|
|
- //判断连接状态
|
|
|
- if (!m_bConnectionState)
|
|
|
- {
|
|
|
- //连接电镜设置
|
|
|
- bDisConnResult = m_cfun.ConncetSem();
|
|
|
- }
|
|
|
- if (bDisConnResult)
|
|
|
- {
|
|
|
- m_bConnectionState = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_bConnectionState = false;
|
|
|
- }
|
|
|
- return bDisConnResult;
|
|
|
- }
|
|
|
-
|
|
|
- public bool DisConnectSem(connectionEnumType disConnectType)
|
|
|
- {
|
|
|
- //获取关闭电镜类型
|
|
|
- string connTypeStr = GetConnectionType(disConnectType);
|
|
|
- bool bDisConnResult = false;
|
|
|
- if (m_bConnectionState)
|
|
|
- {
|
|
|
- //bDisConnResult = m_cfun.DisConnectSem();
|
|
|
- }
|
|
|
- if (bDisConnResult)
|
|
|
- {
|
|
|
- m_bConnectionState = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_bConnectionState = true;
|
|
|
- }
|
|
|
- return bDisConnResult;
|
|
|
- }
|
|
|
-
|
|
|
- private string GetConnectionType(connectionEnumType connectionType)
|
|
|
- {
|
|
|
- string connString = string.Empty;
|
|
|
- switch (connectionType)
|
|
|
- {
|
|
|
- //设置单点采集文字内容
|
|
|
- case connectionEnumType.EDSOnlyPointXRay:
|
|
|
- connString = "OnlyPointXRay";
|
|
|
- break;
|
|
|
- //设置多点采集文字内容
|
|
|
- case connectionEnumType.EDSMultiPointXRay:
|
|
|
- connString = "MultiPointXRay";
|
|
|
- break;
|
|
|
- //设置面采集文字内容
|
|
|
- case connectionEnumType.EDSAreaXRay:
|
|
|
- connString = "AreaXRay";
|
|
|
- break;
|
|
|
- //设置图片
|
|
|
- case connectionEnumType.ScanImage:
|
|
|
- connString = "Image";
|
|
|
- break;
|
|
|
- default: break;
|
|
|
- }
|
|
|
- return connString;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// EDS初始化
|
|
|
- /// </summary>
|
|
|
- public bool EDSInit()
|
|
|
- {
|
|
|
- bool bResult = false;
|
|
|
- //线程调用 加载
|
|
|
- bResult = m_cfun.EDSInit();
|
|
|
- return bResult;
|
|
|
- }
|
|
|
- public enum connectionEnumType
|
|
|
- {
|
|
|
- EDSOnlyPointXRay = 0,
|
|
|
- EDSMultiPointXRay = 1,
|
|
|
- EDSAreaXRay = 2,
|
|
|
- ScanImage = 3
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 标准Xray状态
|
|
|
- /// </summary>
|
|
|
- public enum STDXrayInfoState
|
|
|
- {
|
|
|
- Add = 0,
|
|
|
- Modify = 1,
|
|
|
- Delete = 2
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 记录修改后的标准中的Xray信息
|
|
|
- /// </summary>
|
|
|
- public class STDXray
|
|
|
- {
|
|
|
- /// <summary>
|
|
|
- /// 标准编号
|
|
|
- /// </summary>
|
|
|
- private string stdID;
|
|
|
- /// <summary>
|
|
|
- /// Xray数据
|
|
|
- /// </summary>
|
|
|
- private byte[] xrayData;
|
|
|
- /// <summary>
|
|
|
- /// 状态
|
|
|
- /// </summary>
|
|
|
- private int infoState=-1;
|
|
|
-
|
|
|
- public string StdID { get => stdID; set => stdID = value; }
|
|
|
- public byte[] XrayData { get => xrayData; set => xrayData = value; }
|
|
|
- public int InfoState { get => infoState; set => infoState = value; }
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region Xray 与 STDDB数据操作
|
|
|
- /// <summary>
|
|
|
- /// 绑定数据库中已存在的Xray信息
|
|
|
- /// </summary>
|
|
|
- protected void BindSTDXray()
|
|
|
- {
|
|
|
- //清空STDXray列表中的集合
|
|
|
- m_STDXrayList.Clear();
|
|
|
- //查询
|
|
|
- DataTable dt = m_sc.GetDTFormSysSTDBySQLString("select Id,SPEC from STDMinerals");
|
|
|
- if (dt != null)
|
|
|
- {
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- foreach (DataRow item in dt.Rows)
|
|
|
- {
|
|
|
- STDXray sXray = new STDXray();
|
|
|
- sXray.StdID = item["Id"].ToString();
|
|
|
- sXray.XrayData = (byte[])item["SPEC"];
|
|
|
- m_STDXrayList.Add(sXray);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 保存STDXray至数据库
|
|
|
- /// </summary>
|
|
|
- protected void SaveSTDXray()
|
|
|
- {
|
|
|
- ArrayList delArrayList = new ArrayList();
|
|
|
- if (m_STDXrayList != null)
|
|
|
- {
|
|
|
- //if (m_STDXrayList.Count > 0)
|
|
|
- //{
|
|
|
- foreach (STDXray item in m_STDXrayList)
|
|
|
- {
|
|
|
- int infoState = item.InfoState;
|
|
|
- //添加状态 根据Xray信息当前只能按照一条操作
|
|
|
- if (infoState == (int)STDXrayInfoState.Add)
|
|
|
- {
|
|
|
- if (item.XrayData == null)
|
|
|
- {
|
|
|
- item.XrayData = new byte[8000];
|
|
|
- }
|
|
|
- string strvaluename = "@data";
|
|
|
- //编辑添加语句
|
|
|
- StringBuilder strSqlAdd = new StringBuilder();
|
|
|
- strSqlAdd.Append("insert into STDMinerals(Id,SPEC) values(" + item.StdID + "," + strvaluename + ");");
|
|
|
- bool addResult = m_sc.ExecuteBlob(strSqlAdd.ToString(), strvaluename, (byte[])item.XrayData, ((byte[])item.XrayData).Length);
|
|
|
- if (!addResult)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- //修改状态
|
|
|
- else if (infoState == (int)STDXrayInfoState.Modify)
|
|
|
- {
|
|
|
- //判断STDID在数据库中是否存在
|
|
|
- bool selResult = SelSTDDBBySTDId(item.StdID);
|
|
|
- if (selResult)
|
|
|
- {
|
|
|
- UpdateSTDDB(item.StdID, xrayByteData);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- AddSTDDB(item.StdID, xrayByteData);
|
|
|
- }
|
|
|
- }
|
|
|
- //删除状态 编辑批量删除语句
|
|
|
- else if (infoState == (int)STDXrayInfoState.Delete)
|
|
|
- {
|
|
|
- //编辑删除语句
|
|
|
- delArrayList.Add("delete from STDMinerals where id=" + item.StdID + ";");
|
|
|
- }
|
|
|
- }
|
|
|
- //批量删除
|
|
|
- if (delArrayList.Count>0)
|
|
|
- {
|
|
|
- bool delResult = m_sc.DelSTDInfo(delArrayList);
|
|
|
- }
|
|
|
- //}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 添加STD信息至数据库
|
|
|
- /// </summary>
|
|
|
- protected bool AddSTDDB(string stdID,byte[] XrayData)
|
|
|
- {
|
|
|
- if (XrayData == null)
|
|
|
- {
|
|
|
- XrayData = new byte[8000];
|
|
|
- }
|
|
|
- string strvaluename = "@data";
|
|
|
- StringBuilder sqlStrAdd = new StringBuilder();
|
|
|
- sqlStrAdd.Append("insert into STDMinerals(Id,SPEC) values(" + stdID + "," + strvaluename + ");");
|
|
|
- bool addResult = m_sc.ExecuteBlob(sqlStrAdd.ToString(), strvaluename, (byte[])XrayData, ((byte[])XrayData).Length);
|
|
|
- return addResult;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 修改STD信息至数据库
|
|
|
- /// </summary>
|
|
|
- protected bool UpdateSTDDB(string stdID, byte[] XrayData)
|
|
|
- {
|
|
|
- if (XrayData == null)
|
|
|
- {
|
|
|
- XrayData = new byte[8000];
|
|
|
- }
|
|
|
- string strValueName = "@data";
|
|
|
- StringBuilder sqlStrUpdate = new StringBuilder();
|
|
|
- sqlStrUpdate.Append("update STDMinerals set SPEC=" + strValueName + " where id=" + stdID + ";");
|
|
|
- bool updateResult = m_sc.ExecuteBlob(sqlStrUpdate.ToString(), strValueName, (byte[])XrayData, ((byte[])XrayData).Length);
|
|
|
- return updateResult;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 查询是否存在标准编号
|
|
|
- /// </summary>
|
|
|
- /// <param name="stdID"></param>
|
|
|
- protected bool SelSTDDBBySTDId(string stdID)
|
|
|
- {
|
|
|
- bool selResult = false;
|
|
|
- //编辑查询语句
|
|
|
- StringBuilder sqlStr = new StringBuilder();
|
|
|
- sqlStr.Append("select * from STDMinerals where id=" + stdID + "");
|
|
|
- DataTable dt = m_sc.GetDTFormSysSTDBySQLString(sqlStr.ToString());
|
|
|
- if (dt != null)
|
|
|
- {
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- //已存在状态
|
|
|
- selResult = true;
|
|
|
- }
|
|
|
- }
|
|
|
- return selResult;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 根据选择树节点显示对应的Xray信息
|
|
|
- /// </summary>
|
|
|
- protected void SelSTDXray(TreeNode tn)
|
|
|
- {
|
|
|
- if (tn == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (m_STDXrayList != null)
|
|
|
- {
|
|
|
- if (m_STDXrayList.Count > 0)
|
|
|
- {
|
|
|
- bool isExists = false;
|
|
|
- foreach (STDXray item in m_STDXrayList)
|
|
|
- {
|
|
|
- //修改XrayData信息
|
|
|
- if (item.StdID == tn.ToolTipText.ToString())
|
|
|
- {
|
|
|
- string selColor = ParseRGB(tn.BackColor).ToString();
|
|
|
- int colorValue = Convert.ToInt32(selColor);
|
|
|
- //显示Xray信息
|
|
|
- if (item.XrayData != null)
|
|
|
- {
|
|
|
- isExists = true;
|
|
|
- ShowXrayAtlas(colorValue, item.XrayData);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isExists)
|
|
|
- {
|
|
|
- ShowXrayAtlas();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 根据树节点修改对应的Xray信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="tn"></param>
|
|
|
- protected void UpdateSTDXray(TreeNode tn,byte[] xrayData)
|
|
|
- {
|
|
|
- if (tn == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (m_STDXrayList != null)
|
|
|
- {
|
|
|
- //if (m_STDXrayList.Count > 0)
|
|
|
- //{
|
|
|
- bool isExists = false;
|
|
|
- foreach (STDXray item in m_STDXrayList)
|
|
|
- {
|
|
|
- //修改XrayData信息
|
|
|
- if (item.StdID == tn.ToolTipText.ToString())
|
|
|
- {
|
|
|
- item.XrayData = xrayData;
|
|
|
- item.InfoState = (int)STDXrayInfoState.Modify;
|
|
|
- isExists = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isExists)
|
|
|
- {
|
|
|
- if (!tn.ToolTipText.ToString().Equals(""))
|
|
|
- {
|
|
|
- //添加STD XrayData信息
|
|
|
- STDXray stdXray = new STDXray();
|
|
|
- stdXray.StdID = tn.ToolTipText.ToString();
|
|
|
- stdXray.XrayData = xrayData;
|
|
|
- stdXray.InfoState = (int)STDXrayInfoState.Add;
|
|
|
- m_STDXrayList.Add(stdXray);
|
|
|
- }
|
|
|
- }
|
|
|
- //}
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 添加STDXray信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="tn">所选树节点</param>
|
|
|
- /// <param name="xrayData">Xray信息</param>
|
|
|
- /// <returns></returns>
|
|
|
- protected bool AddSTDXray(TreeNode tn, byte[] xrayData)
|
|
|
- {
|
|
|
- bool addResult = false;
|
|
|
- if (tn == null)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (m_STDXrayList != null)
|
|
|
- {
|
|
|
- if (m_STDXrayList.Count > 0)
|
|
|
- {
|
|
|
- if (!tn.ToolTipText.ToString().Equals(""))
|
|
|
- {
|
|
|
- //添加STD XrayData信息
|
|
|
- STDXray stdXray = new STDXray();
|
|
|
- stdXray.StdID = tn.ToolTipText.ToString();
|
|
|
- stdXray.XrayData = xrayData;
|
|
|
- stdXray.InfoState = (int)STDXrayInfoState.Add;
|
|
|
- m_STDXrayList.Add(stdXray);
|
|
|
- addResult = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return addResult;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 删除STDXray信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="tn">所选要删除的树节点</param>
|
|
|
- /// <returns></returns>
|
|
|
- protected bool DelSTDXray(TreeNode tn)
|
|
|
- {
|
|
|
- bool delResult = false;
|
|
|
- if (tn == null)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (m_STDXrayList != null)
|
|
|
- {
|
|
|
- if (m_STDXrayList.Count > 0)
|
|
|
- {
|
|
|
- if (!tn.ToolTipText.ToString().Equals(""))
|
|
|
- {
|
|
|
- foreach (STDXray item in m_STDXrayList)
|
|
|
- {
|
|
|
- //修改XrayData信息
|
|
|
- if (item.StdID == tn.ToolTipText.ToString())
|
|
|
- {
|
|
|
- item.InfoState = (int)STDXrayInfoState.Delete;
|
|
|
- delResult = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return delResult;
|
|
|
- }
|
|
|
- #endregion
|
|
|
- #region 控制BSE、化学式、元素本文框中不能输入下划线
|
|
|
- /// <summary>
|
|
|
- /// 控件不能输入下划线
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void textBox_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
- {
|
|
|
- if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z') ||
|
|
|
- (e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar == 8) || !(e.KeyChar == '_'))
|
|
|
- {
|
|
|
- e.Handled = false;
|
|
|
- }
|
|
|
-
|
|
|
- else
|
|
|
- {
|
|
|
- e.Handled = true;
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- private void button_1_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "1");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_2_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "2");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_3_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "3");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_4_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "4");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_5_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "5");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_6_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "6");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_7_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "7");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_8_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "8");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_9_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //textbox_STDEditor 中的光标
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "9");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void button_0_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- int index = textbox_STDEditor.SelectionStart;
|
|
|
- textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "0");
|
|
|
-
|
|
|
- textbox_STDEditor.Focus();
|
|
|
- textbox_STDEditor.Select(index + 1, 0);
|
|
|
- textbox_STDEditor.ScrollToCaret();
|
|
|
- }
|
|
|
-
|
|
|
- private void tabSTDStandrad_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- if (tabSTDStandrad.SelectedIndex == 1)
|
|
|
- {
|
|
|
- tabControl_Rules.SelectedIndex = 0;
|
|
|
- XmlTree_STDlist.Focus();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void btnTest_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- XrayContrastForm xrayContrastForm = new XrayContrastForm();
|
|
|
- //xrayContrastForm.XmlTree_STDlist = XmlTree_STDlist.Nodes;
|
|
|
- xrayContrastForm.ShowDialog();
|
|
|
- }
|
|
|
- private void XmlTree_STDlist_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
- {
|
|
|
- SetBlackAllNodes(XmlTree_STDlist);
|
|
|
-
|
|
|
- this.textbox_STDEditor.Text = XmlTree_STDlist.SelectedNode.Tag.ToString();
|
|
|
- btn_dbs.BackColor = XmlTree_STDlist.SelectedNode.BackColor;
|
|
|
-
|
|
|
-
|
|
|
- string[] strOther = XmlTree_STDlist.SelectedNode.Name.Split('$');
|
|
|
-
|
|
|
- string[] strOther2 = strOther[0].Split('_');
|
|
|
- textBox_Hardness.Text = strOther2[0];
|
|
|
- textBox_Density.Text = strOther2[1];
|
|
|
- textBox_Electrical_conductivity.Text = strOther2[2];
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_KeyElements.Rows.Clear();
|
|
|
- dataGridView_KeyElements.Columns.Clear();
|
|
|
-
|
|
|
- string[] KeyElement = strOther[1].Split(',');
|
|
|
- for (int i = 0; i < KeyElement.Length; i++)
|
|
|
- {
|
|
|
- if (KeyElement[0] != "")
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_KeyElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_KeyElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_KeyElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_KeyElements.Rows[0].Cells[i].Value = KeyElement[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- dataGridView_SubElements.Rows.Clear();
|
|
|
- dataGridView_SubElements.Columns.Clear();
|
|
|
-
|
|
|
- string[] SubElement = strOther[2].Split(',');
|
|
|
- for (int i = 0; i < SubElement.Length; i++)
|
|
|
- {
|
|
|
- if (SubElement[i] != "")
|
|
|
- {
|
|
|
- DataGridViewButtonColumn dataGridViewButtonColumn = new DataGridViewButtonColumn();
|
|
|
- dataGridViewButtonColumn.Name = dataGridView_SubElements.Columns.Count.ToString();
|
|
|
- dataGridView_SubElements.Columns.Add(dataGridViewButtonColumn);
|
|
|
- if (dataGridView_SubElements.Rows.Count == 0)
|
|
|
- {
|
|
|
- DataGridViewRow row = new DataGridViewRow();
|
|
|
- dataGridView_SubElements.Rows.Add(row);
|
|
|
- }
|
|
|
- dataGridView_SubElements.Rows[0].Cells[i].Value = SubElement[i];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (button_UpOrder.Enabled == false)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (button_DownOrder.Enabled == false)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = true;
|
|
|
- }
|
|
|
- if (XmlTree_STDlist.SelectedNode.PrevNode == null)
|
|
|
- {
|
|
|
- button_UpOrder.Enabled = false;
|
|
|
- }
|
|
|
- else if (XmlTree_STDlist.SelectedNode.NextNode == null)
|
|
|
- {
|
|
|
- button_DownOrder.Enabled = false;
|
|
|
- }
|
|
|
-
|
|
|
- dataGridView_KeyElements.ClearSelection();
|
|
|
- dataGridView_SubElements.ClearSelection();
|
|
|
- ShowEditContent(XmlTree_STDlist.SelectedNode);
|
|
|
- SelSTDXray(XmlTree_STDlist.SelectedNode);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- protected void ShowEditContent(TreeNode tn)
|
|
|
- {
|
|
|
- if (m_STDXrayList != null)
|
|
|
- {
|
|
|
- for (int i = 0; i < m_STDXrayList.Count; i++)
|
|
|
- {
|
|
|
- if (m_STDXrayList[i].StdID == tn.ToolTipText.ToString())
|
|
|
- {
|
|
|
-
|
|
|
- //获取修改行的信息
|
|
|
- xrayByteData = (byte[])m_STDXrayList[i].XrayData;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|