using OTS.WinFormsUI.Docking; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; using System.Collections; using System.Text.RegularExpressions; namespace OTSPartA_STDEditor { public partial class STDEditor : DockContent { #region 全局变量 public SubMidWindow m_SubMidWindow = null; public int STDId = -1; Hashtable table_STDEditor; //数据库操作对象 public SqlLiteClass m_sc = null; #endregion public enum Result { NoMatched = 0, Success = 1, Fail = 2 } public STDEditor(SubMidWindow SubMidWindow) { InitializeComponent(); m_sc = new SqlLiteClass(); m_SubMidWindow = SubMidWindow; X = this.Width; Y = this.Height; setTag(this); } public STDEditor(SubMidWindow SubMidWindow, string STDDBaddress) { InitializeComponent(); m_sc = new SqlLiteClass(STDDBaddress); m_SubMidWindow = SubMidWindow; X = this.Width; Y = this.Height; setTag(this); } private void STDEditor_Load(object sender, EventArgs e) { m_SubMidWindow.m_MainForm.lan = new Language(this); table_STDEditor = m_SubMidWindow.m_MainForm.lan.GetNameTable("STDEditor"); //初始化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"); //与Dmax垂直直径; this.comboBox_ImgProperty.Items.Add("Dmean"); //平均内接圆直径; this.comboBox_ImgProperty.Items.Add("Area"); //面积; this.comboBox_ImgProperty.Items.Add("Dferet"); //费雷特直径; this.comboBox_ImgProperty.Items.Add("Width"); //宽度(直上直下那种); 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"); //BSE灰度平均值 comboBox_ImgProperty.SelectedIndex = comboBox_ImgProperty.Items.IndexOf("Dmax"); string[] PeriodicTable = { "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hq", "TI", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Mc", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Unb" }; comboBox_PeriodicTable.Items.AddRange(PeriodicTable); AutoCompleteStringCollection sc = new AutoCompleteStringCollection(); sc.AddRange(PeriodicTable); this.comboBox_PeriodicTable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.comboBox_PeriodicTable.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource; this.comboBox_PeriodicTable.AutoCompleteCustomSource = sc; 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; } /// /// [颜色:16进制转成RGB] /// /// 设置16进制颜色 [返回RGB] /// 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); } } float AmplificationFactor = 1; //private void button_Extend_Click(object sender, EventArgs e) //{ // if (button_Extend.BackColor == SystemColors.ControlDarkDark) // { // //groupBox_Data.Visible = true; // textbox_STDEditor.Height = (int)Math.Round(150 * AmplificationFactor); // button_Extend.BackColor = SystemColors.ControlDark; // } // else // { // button_Extend.BackColor = SystemColors.ControlDarkDark; // textbox_STDEditor.Height = (int)Math.Round(300* AmplificationFactor); // } //} 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 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(); } } private void button_And_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "and"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 3, 0); textbox_STDEditor.ScrollToCaret(); } private void button_Or_Click(object sender, EventArgs e) { //textbox_STDEditor 中的光标 int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, "or"); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + 2, 0); textbox_STDEditor.ScrollToCaret(); } private void comboBox_Constants_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_Constants.SelectedItem != null) { string newStr = comboBox_Constants.SelectedItem.ToString().Split('=')[0]; int index = textbox_STDEditor.SelectionStart; textbox_STDEditor.Text = textbox_STDEditor.Text.Insert(index, newStr); textbox_STDEditor.Focus(); textbox_STDEditor.Select(index + newStr.Length, 0); textbox_STDEditor.ScrollToCaret(); } } private void button_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(); } //元素自身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; } } } /// /// 将颜色对象转换为uint /// /// /// public uint ParseRGB(Color color) { return (uint)(((uint)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R)); } #region 常用数据验证的封装,数字字符的验证 /// /// 常用数据验证的封装,数字字符的验证 /// /// 需要验证的数值【字符串,或者数字】 /// 类型为哪一个验证 /// 如果验证成功则返回True,否则返回false 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 弹出提示 /// /// 弹出提示 /// /// protected void showMessage(string strContent) { MessageBox.Show(strContent, "Tip"); } #endregion #region 控制BSE、化学式、元素本文框中不能输入下划线 /// /// 控件不能输入下划线 /// /// /// 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 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(); } 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(); } private float X = 1; private float Y = 1; private void STDEditor_Resize(object sender, EventArgs e) { float newx = (this.Width) / X; float newy = this.Height / Y; AmplificationFactor = newy; setControls(newx, newy, this.tabSTDStandrad.TabPages[0]); //button_Extend.BackColor = SystemColors.ControlDarkDark; } private void setTag(Control cons) { foreach (Control con in cons.Controls) { con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; if (con.Controls.Count > 0) setTag(con); } } private void setControls(float newx, float newy, Control cons) { foreach (Control con in cons.Controls) { if (false) { } else { string[] mytag = con.Tag.ToString().Split(':'); float a = Convert.ToSingle(mytag[0]) * newx; con.Width = (int)a; a = Convert.ToSingle(mytag[1]) * newy; con.Height = (int)(a); a = Convert.ToSingle(mytag[2]) * newx; con.Left = (int)(a); a = Convert.ToSingle(mytag[3]) * newy; con.Top = (int)(a); Single currentSize; if (con.Name == "button_Extend") { currentSize = 6f; } else { if (Math.Max(newx, newy) < 1) { currentSize = Convert.ToSingle(mytag[4]) * 1; } else { currentSize = Convert.ToSingle(mytag[4]) * Math.Max(newx, newy); } } con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); if (con.Controls.Count > 0) { setControls(newx, newy, con); } } } } Form_PeriodicTable form_PeriodicTable; private void button_PeriodicTableSwitch_Click(object sender, EventArgs e) { if (form_PeriodicTable == null) //如果子窗体为空则创造实例 并显示 { form_PeriodicTable = new Form_PeriodicTable(); if (table_STDEditor["language"].ToString() == "EN") { form_PeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_EN; } else { form_PeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_ZH; } form_PeriodicTable.Show(); } else { if (form_PeriodicTable.IsDisposed) //若子窗体关闭 则打开新子窗体 并显示 { form_PeriodicTable = new Form_PeriodicTable(); if (table_STDEditor["language"].ToString() == "EN") { form_PeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_EN; } else { form_PeriodicTable.BackgroundImage = global::OTSPartA_STDEditor.Properties.Resources.PeriodicTable_ZH; } form_PeriodicTable.Show(); } else { form_PeriodicTable.Activate(); //使子窗体获得焦点 } } } private void textbox_STDEditor_MouseLeave(object sender, EventArgs e) { 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 str_Removeandor = new List(); for (int i = 0; i < str_Removeand.Length; i++) { str_Removeandor.AddRange(System.Text.RegularExpressions.Regex.Split(str_Removeand[i], "or", System.Text.RegularExpressions.RegexOptions.None)); } List list_all = new List(); for (int i = 0; i < str_Removeandor.Count; i++) { list_all.AddRange(str_Removeandor[i].Split(new char[] { '+', '-', '*', '/', '=', '>', '<', '(', ')' })); } List UsingElementL = new List(); 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 SubElements = new List(); 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(); } private void button_del_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textbox_STDEditor.Text)) { if (textbox_STDEditor.SelectionLength == 0) { textbox_STDEditor.Text = textbox_STDEditor.Text.Remove(textbox_STDEditor.SelectionStart - 1, 1); } else { textbox_STDEditor.Text = textbox_STDEditor.Text.Remove(textbox_STDEditor.SelectionStart, textbox_STDEditor.SelectionLength); } } textbox_STDEditor.Focus(); textbox_STDEditor.SelectionStart = textbox_STDEditor.Text.Length; } private void label_help2_MouseHover(object sender, EventArgs e) { // 创建the ToolTip ToolTip toolTip1 = new ToolTip(); // 设置显示样式 toolTip1.AutoPopDelay = 7000;//提示信息的可见时间 toolTip1.InitialDelay = 500;//事件触发多久后出现提示 toolTip1.ReshowDelay = 500;//指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框 toolTip1.ShowAlways = true;//是否显示提示框 string str = "Dmax:颗粒最大卡规直径\n"+ "Dmin: 颗粒最小卡规直径\n" + "Aspect:颗粒长宽比\n" + "Dperp:与Dmax垂直的对应直径\n"+ "Dmean:平均内接圆直径\n"+ "Area:面积\n"+ "Dferet:费雷特直径\n"+ "Width:宽度(直上直下那种)\n"+ "Height:高度(直上直下那种)\n"+ "Perimeter:周长\n"+ "Dinscr:最大内接圆直径\n"+ "Orientation:朝向角度\n"+ "Delong:展开长度(以最小卡规直径为宽)\n" + "Aspectelong:展开后长宽比\n"+ "Dequalcircle:等效圆直径\n"+ "Vedio:BSE灰度平均值"; // 设置伴随的对象. toolTip1.SetToolTip(this.label_help2, str); } private void label_help1label2_MouseHover(object sender, EventArgs e) { // 创建the ToolTip ToolTip toolTip1 = new ToolTip(); // 设置显示样式 toolTip1.AutoPopDelay = 7000;//提示信息的可见时间 toolTip1.InitialDelay = 500;//事件触发多久后出现提示 toolTip1.ReshowDelay = 500;//指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框 toolTip1.ShowAlways = true;//是否显示提示框 string str = "first_elem/Element#1:颗粒元素分析结果中最大占比的元素"; // 设置伴随的对象. toolTip1.SetToolTip(this.label_help1, str); } } }