//private void btnOK_Click(object sender, EventArgs e) //{ // UserName = comboBox1.Text; // PassWord = ini.IniReadValue(UserName, "PassWord"); // if (textBox1.Text == PassWord) // { // if (UserName == "Operator") // PublicVar.bPasswordOperator = true; // else // PublicVar.bPasswordOperator = false; // if (UserName == "Engineer") // PublicVar.bPasswordEngineer = true; // else // PublicVar.bPasswordEngineer = false; // if (UserName == "Administrator") // PublicVar.bPasswordManager = true; // else // PublicVar.bPasswordManager = false; // bPassword = true; // this.Dispose(); // } // else // { // MessageBox.Show("密码或用户名称错误,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // textBox1.Text = ""; // textBox1.Focus(); // } //} private void btnOK_Click(object sender, EventArgs e) { UserName = comboBox1.Text; PassWord = ini.IniReadValue(UserName, "PassWord"); string PassWord_Operator = ""; string PassWord_Engineer = "1214"; string PassWord_Manager = "2428"; if (UserName == "Operator") { if (textBox1.Text == PassWord_Operator) { PublicVar.bPasswordOperator = true; bPassword = true; this.Dispose(); } else { MessageBox.Show("密码错误,请重新输入!"); textBox1.Text = ""; textBox1.Focus(); } } else if (UserName == "Engineer") { if (textBox1.Text == PassWord_Engineer) { PublicVar.bPasswordEngineer = true; bPassword = true; this.Dispose(); } else { MessageBox.Show("密码错误,请重新输入!"); textBox1.Text = ""; textBox1.Focus(); } } else if (UserName == "Administrator") { if (textBox1.Text == PassWord_Manager) { PublicVar.bPasswordManager = true; bPassword = true; this.Dispose(); } else { MessageBox.Show("密码错误,请重新输入!"); textBox1.Text = ""; textBox1.Focus(); } } }
public static bool License(int iPwd) { string strSerial = ""; strSerial = GetSerial(iPwd); CIni ReadMac = new CIni("c:\\hhiatsn.ini"); string strID = ReadMac.IniReadValue("SN", "ID"); if (strSerial != strID && strID != "hhiat123") { MessageBox.Show("System Error"); return(false); } string sTime = ReadMac.IniReadValue("Time", "T"); if (sTime != "-1") { DateTime datetime = DateTime.Now; string[] d = new string[6]; d[0] = sTime.Substring(0, 2); //day d[1] = sTime.Substring(2, 2); //month d[2] = sTime.Substring(4, 2); //year_L d[3] = sTime.Substring(6, 2); //len d[4] = sTime.Substring(8, 2); //Year_R DateTime datetimeStart = new DateTime(Convert.ToInt16(d[2] + d[4]), Convert.ToInt16(d[1]), Convert.ToInt16(d[0]), 0, 0, 0); if ((datetime - datetimeStart).Days > Convert.ToInt16(d[3]) * 30 || (datetime - datetimeStart).Days < 0) { d[0] = "00" + datetime.Day.ToString(); //day d[1] = "00" + datetime.Month.ToString(); //month d[2] = datetime.Year.ToString(); d[3] = "00"; //len d[4] = d[2].Substring(0, 2); //year-L d[5] = "00"; //year_R string s = ""; s = d[0].Substring(d[0].Length - 2, 2) + d[1].Substring(d[1].Length - 2, 2) + d[4] + d[3] + d[5]; ReadMac.IniWriteValue("Time", "T", s); // MessageBox.Show("System Time Error"); return(false); } } return(true); }
private void btnMatch_Click(object sender, EventArgs e) { btnSaveModel.Enabled = false; btnOK.Enabled = false; RectangleContour rect = new RectangleContour(); rect.Left = 0; rect.Top = 0; rect.Width = C.Image.Width; rect.Height = C.Image.Height; PointContour p2 = new PointContour(); string TemplateFile = ""; TemplateFile = System.Windows.Forms.Application.StartupPath + "\\ModelPos.png"; if (File.Exists(TemplateFile) && C.Image != null) { imageViewerModel.Image.ReadFile(TemplateFile); CIni PosIni = new CIni(System.Windows.Forms.Application.StartupPath + "\\Doc\\Pos.ini"); float dScore = Convert.ToSingle(PosIni.IniReadValue("PatternPos", "Score"));//匹配度 p2 = MachineTool.MatchPattern(C.Image, rect, TemplateFile, 1, dScore); MessageBox.Show("X:" + p2.X.ToString("f3") + ", Y:" + p2.Y.ToString("f3")); } }
private void ReadParam() { string strPath; strPath = Application.StartupPath + "\\DOC"; if (!Directory.Exists(strPath)) { Directory.CreateDirectory(strPath); } strPath += "\\Setting.ini"; CIni IniSetting = new CIni(strPath); string strTemp; strTemp = IniSetting.IniReadValue("Unit", "CameraX"); txtCheckCameraXUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "CameraY"); txtCheckCameraYUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "CameraPos"); txtPosCameraUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "X"); txtMotorXUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "Y"); txtMotorYUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "CY"); txtMotorCYUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "CZ"); txtMotorCZUnit.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "EncoderX"); txtCameraXEncoder.Text = strTemp; strTemp = IniSetting.IniReadValue("Unit", "EncoderY"); txtCameraYEncoder.Text = strTemp; strTemp = IniSetting.IniReadValue("X", "LeftTop"); txtLeftTopX.Text = strTemp; strTemp = IniSetting.IniReadValue("Y", "LeftTop"); txtLeftTopY.Text = strTemp; strTemp = IniSetting.IniReadValue("X", "RightTop"); txtRightTopX.Text = strTemp; strTemp = IniSetting.IniReadValue("Y", "RightTop"); txtRightTopY.Text = strTemp; strTemp = IniSetting.IniReadValue("X", "RightBottom"); txtRightBottomX.Text = strTemp; strTemp = IniSetting.IniReadValue("Y", "RightBottom"); txtRightBottomY.Text = strTemp; //定位相机是否二值化 strTemp = IniSetting.IniReadValue("Select", "CameraThre"); if (strTemp == "1") { chk_CameraThreshold.Checked = true; } else { chk_CameraThreshold.Checked = false; } txtRun1.Text = IniSetting.IniReadValue("CHX", "InitVel"); txtRun2.Text = IniSetting.IniReadValue("CHX", "ACC"); txtRun3.Text = IniSetting.IniReadValue("CHX", "DEC"); txtRun7.Text = IniSetting.IniReadValue("CHX", "Speed"); txtRun4.Text = IniSetting.IniReadValue("CHY", "InitVel"); txtRun5.Text = IniSetting.IniReadValue("CHY", "ACC"); txtRun6.Text = IniSetting.IniReadValue("CHY", "DEC"); txtRun8.Text = IniSetting.IniReadValue("CHY", "Speed"); txtRun9.Text = IniSetting.IniReadValue("CHCY", "InitVel"); txtRun10.Text = IniSetting.IniReadValue("CHCY", "ACC"); txtRun11.Text = IniSetting.IniReadValue("CHCY", "DEC"); txtRun12.Text = IniSetting.IniReadValue("CHCY", "Speed"); txtRun13.Text = IniSetting.IniReadValue("CHCZ", "InitVel"); txtRun14.Text = IniSetting.IniReadValue("CHCZ", "ACC"); txtRun15.Text = IniSetting.IniReadValue("CHCZ", "DEC"); txtRun16.Text = IniSetting.IniReadValue("CHCZ", "Speed"); txtCHCYInitPos.Text = IniSetting.IniReadValue("CHCY", "InitPos"); txtCHCZInitPos.Text = IniSetting.IniReadValue("CHCZ", "InitPos"); txtCHCYWorkPos.Text = IniSetting.IniReadValue("CHCY", "WorkPos"); txtCHCZWorkPos.Text = IniSetting.IniReadValue("CHCZ", "WorkPos"); txtCHCZWorkPos1.Text = IniSetting.IniReadValue("CHCZ", "WorkPos1"); txtCHCZLowVel.Text = IniSetting.IniReadValue("CHCZ", "LowVel"); txtHome1.Text = IniSetting.IniReadValue("CHX", "HomeInitVel"); txtHome2.Text = IniSetting.IniReadValue("CHX", "HomeMaxVel"); txtHome3.Text = IniSetting.IniReadValue("CHX", "HomeACC"); txtHome4.Text = IniSetting.IniReadValue("CHX", "HomeDEC"); txtHome5.Text = IniSetting.IniReadValue("CHY", "HomeInitVel"); txtHome6.Text = IniSetting.IniReadValue("CHY", "HomeMaxVel"); txtHome7.Text = IniSetting.IniReadValue("CHY", "HomeACC"); txtHome8.Text = IniSetting.IniReadValue("CHY", "HomeDEC"); txtHome9.Text = IniSetting.IniReadValue("CHCY", "HomeInitVel"); txtHome10.Text = IniSetting.IniReadValue("CHCY", "HomeMaxVel"); txtHome11.Text = IniSetting.IniReadValue("CHCY", "HomeACC"); txtHome12.Text = IniSetting.IniReadValue("CHCY", "HomeDEC"); txtHome13.Text = IniSetting.IniReadValue("CHCZ", "HomeInitVel"); txtHome14.Text = IniSetting.IniReadValue("CHCZ", "HomeMaxVel"); txtHome15.Text = IniSetting.IniReadValue("CHCZ", "HomeACC"); txtHome16.Text = IniSetting.IniReadValue("CHCZ", "HomeDEC"); txtCHXInitPos.Text = IniSetting.IniReadValue("CHX", "InitPos"); txtCHYInitPos.Text = IniSetting.IniReadValue("CHY", "InitPos"); txtHighSpeed.Text = IniSetting.IniReadValue("JogSpeed", "High"); txtMidSpeed.Text = IniSetting.IniReadValue("JogSpeed", "Mid"); txtLowSpeed.Text = IniSetting.IniReadValue("JogSpeed", "Low"); txtXCaliCorr.Text = IniSetting.IniReadValue("CHX", "CaliCorr"); txtRepairXAngle.Text = IniSetting.IniReadValue("CHX", "RepairAngle"); txtYCaliCorr.Text = IniSetting.IniReadValue("CHY", "CaliCorr"); txtRepairYAngle.Text = IniSetting.IniReadValue("CHY", "RepairAngle"); try { txtRepairIntervalX.Text = IniSetting.IniReadValue("RepairInterval", "X"); txtRepairIntervalY.Text = IniSetting.IniReadValue("RepairInterval", "Y"); txtRepairStartX.Text = IniSetting.IniReadValue("RepairStart", "X"); txtRepairStartY.Text = IniSetting.IniReadValue("RepairStart", "Y"); } catch { txtRepairIntervalX.Text = "2"; txtRepairIntervalY.Text = "2"; txtRepairStartX.Text = "10"; txtRepairStartY.Text = "10"; } try { txtMasterPos1X.Text = IniSetting.IniReadValue("Master", "PosX1"); txtMasterPos1Y.Text = IniSetting.IniReadValue("Master", "PosY1"); txtMasterPos2X.Text = IniSetting.IniReadValue("Master", "PosX2"); txtMasterPos2Y.Text = IniSetting.IniReadValue("Master", "PosY2"); txtMasterPos3X.Text = IniSetting.IniReadValue("Master", "PosX3"); txtMasterPos3Y.Text = IniSetting.IniReadValue("Master", "PosY3"); txtMasterPos4X.Text = IniSetting.IniReadValue("Master", "PosX4"); txtMasterPos4Y.Text = IniSetting.IniReadValue("Master", "PosY4"); txtMasterNumHZ.Text = IniSetting.IniReadValue("Master", "NumHZ"); txtMasterL1.Text = IniSetting.IniReadValue("Master", "L1"); txtMasterL2.Text = IniSetting.IniReadValue("Master", "L2"); txtMasterW1.Text = IniSetting.IniReadValue("Master", "W1"); txtMasterW2.Text = IniSetting.IniReadValue("Master", "W2"); txtMasterLight.Text = IniSetting.IniReadValue("Master", "Light"); txtMasterThreshold.Text = IniSetting.IniReadValue("Master", "Threshold"); txtCorrX1K.Text = IniSetting.IniReadValue("Corr", "X1K"); txtCorrX1Offset.Text = IniSetting.IniReadValue("Corr", "X1Offset"); txtCorrX2K.Text = IniSetting.IniReadValue("Corr", "X2K"); txtCorrX2Offset.Text = IniSetting.IniReadValue("Corr", "X2Offset"); txtCorrY1K.Text = IniSetting.IniReadValue("Corr", "Y1K"); txtCorrY1Offset.Text = IniSetting.IniReadValue("Corr", "Y1Offset"); txtCorrY2K.Text = IniSetting.IniReadValue("Corr", "Y2K"); txtCorrY2Offset.Text = IniSetting.IniReadValue("Corr", "Y2Offset"); } catch { } }