/* * private void tBox_KeyPress(object sender, KeyPressEventArgs e) * * { * if(e.KeyChar == 0x20) * { * e.KeyChar = (char)0; //禁止空格键 * } * * if((e.KeyChar == 0x2D) && (((TextBox)sender).Text.Length == 0)) * { * return; //处理负数 * } * * if(e.KeyChar > 0x20) * { * try * { * double.Parse(((TextBox)sender).Text + e.KeyChar.ToString()); * } * catch * { * e.KeyChar = (char)0; //处理非法字符 * } * } * } * private void textBox1_Validating(object sender, CancelEventArgs e) * { * const string pattern = @"^\d+\.?\d+{1}"; * string content = ((TextBox)sender).Text; * * if(!(Regex.IsMatch(content, pattern))) * { * ErrorProvider.SetError((Control)sender, "只能输入数字!"); * e.Cancel = true; * } * else * { * ErrorProvider.SetError((Control)sender, null); * } * } */ private void SysSetting_Load(object sender, EventArgs e) { torsionUpLimit.Text = iniFileOp.ReadString(section, key1Up, string.Empty); torsionDownLimit.Text = iniFileOp.ReadString(section, key1Down, string.Empty); torsion2UpLimit.Text = iniFileOp.ReadString(section, key2Up, string.Empty); torsion2DownLimit.Text = iniFileOp.ReadString(section, key2Down, string.Empty); string redo = iniFileOp.ReadString(section, reDo, string.Empty); checkBox1.Checked = (redo == "true") ? true : false; }
/// <summary> /// 更新产品列表框 /// </summary> private void UpdateProductCombo() { //加载产品名称 List <string> secList = new List <string>(); secList = iniFileOp.ReadSections(); productNameList.Clear(); for (int i = 0; i < secList.Count; i++) { if (secList[i] == "SysSetting" || secList[i] == "CurOpProduct") { secList.RemoveAt(i); } } if (secList.Count <= 0) { return; } foreach (string sec in secList) { productNameList.Add(sec); } productCombo.Items.AddRange(secList.ToArray()); curProductName = iniFileOp.ReadString("CurOpProduct", "ProductName", string.Empty);;//secList[0]; productCombo.SelectedIndex = productCombo.FindString(curProductName); UpdatePointCombo(); }
/// <summary> /// 是否采用sp的方式获取数据结构信息 /// </summary> /// <returns></returns> private bool IsDboSp() { if (File.Exists(cmcfgfile)) { cfgfile = new IniFileHelper(cmcfgfile); string val = cfgfile.ReadString("dbo", "dbosp", ""); if (val.Trim() == "1") { isdbosp = true; } } return(isdbosp); }
/* * private void tBox_KeyPress(object sender, KeyPressEventArgs e) * * { * if(e.KeyChar == 0x20) * { * e.KeyChar = (char)0; //禁止空格键 * } * * if((e.KeyChar == 0x2D) && (((TextBox)sender).Text.Length == 0)) * { * return; //处理负数 * } * * if(e.KeyChar > 0x20) * { * try * { * double.Parse(((TextBox)sender).Text + e.KeyChar.ToString()); * } * catch * { * e.KeyChar = (char)0; //处理非法字符 * } * } * } * private void textBox1_Validating(object sender, CancelEventArgs e) * { * const string pattern = @"^\d+\.?\d+{1}"; * string content = ((TextBox)sender).Text; * * if(!(Regex.IsMatch(content, pattern))) * { * ErrorProvider.SetError((Control)sender, "只能输入数字!"); * e.Cancel = true; * } * else * { * ErrorProvider.SetError((Control)sender, null); * } * } */ private void SysSetting_Load(object sender, EventArgs e) { InitBaudRate(); torsionUpLimit.Text = iniFileOp.ReadString(section, key1Up, string.Empty); torsionDownLimit.Text = iniFileOp.ReadString(section, key1Down, string.Empty); torsion2UpLimit.Text = iniFileOp.ReadString(section, key2Up, string.Empty); torsion2DownLimit.Text = iniFileOp.ReadString(section, key2Down, string.Empty); string redo = iniFileOp.ReadString(section, reDo, string.Empty); checkBox1.Checked = (redo == "true") ? true : false; curBaudRate = Convert.ToInt32(iniFileOp.ReadString(section, baudRate, string.Empty)); baudRateCb.SelectedIndex = curBaudRate; }