private int videoMode = 0;  //0 camera test //1 标定 //2 芯片检测 //3 整体联动


        public FormChipDetection(bool isResetConfiguration)
        {
            mIsResetConfiguration = isResetConfiguration;
            InitializeComponent();                                    //控件及文本

            Parameter.GetInstance().LoadOptionFile();                 //参数option.ini(改参数在这里)
            mConfiguration = new Configuration(isResetConfiguration); //配置

            if (isResetConfiguration)                                 //用户配置
            {
                UserConfiguration.GetInstance().CreateDefualtUserConfigurationFile();
            }
            else
            {
                UserConfiguration.GetInstance().LoadUserConfigurationFile();
            }
            mChipDetection = new ChipDetection();//新的ChipDetection


            lblMark.BackColor = Color.Transparent;//是那个上面的3999
            Form.CheckForIllegalCrossThreadCalls = false;

            //显示窗口刷新
            picImage.Paint += new PaintEventHandler(PicImage_Paint);//函数PicImage_Paint
            //mExcelModalFileName = MiscFunction.GetInstance().GetAssemblyPath() + Parameter.GetInstance().ExcelFileName + ".xlsx";//EXCEL名称

            InitializeTimers(); //定时器
            UserLogin(false);   //用户登录


            m_grabThreadExited = new AutoResetEvent(false);
            CAM_connect();     //相机连接

            ResetTestStatus(); //界面参数全都初始化
        }
Exemple #2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            mIsInvalidClose = false;
            try
            {
                //this.DialogResult = DialogResult.Cancel;
                string userName = txtUserName.Text.Trim();
                if (string.IsNullOrEmpty(userName))
                {
                    txtUserName.Focus();
                    txtUserName.SelectAll();

                    MessageBox.Show("用户名不能为空!", "错误");
                    return;
                }
                string password = txtPassword.Text.Trim();
                if (password.Length != 6)
                {
                    txtPassword.Focus();
                    txtPassword.SelectAll();

                    MessageBox.Show("密码长度为6位!", "错误");
                    return;
                }
                if (UserConfiguration.GetInstance().User.ContainsKey(userName))
                {
                    mUserAuthority = UserConfiguration.GetInstance().User[userName];
                    if (password.Equals(mUserAuthority.Password))
                    {
                        MessageBox.Show("登录成功!", "提示");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        txtPassword.Focus();
                        txtPassword.SelectAll();
                        MessageBox.Show("密码错误!", "错误");
                    }
                }
                else
                {
                    txtUserName.Focus();
                    txtUserName.SelectAll();
                    MessageBox.Show("无效用户名!", "错误");
                    return;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "错误");
            }
            finally
            {
                mIsInvalidClose = true;
            }
        }
Exemple #3
0
        private void InitializeGrid()
        {
            IDictionaryEnumerator enumerator = UserConfiguration.GetInstance().User.GetEnumerator();

            while (enumerator.MoveNext())
            {
                UserAuthority userAuthority = (UserAuthority)enumerator.Value;
                int           index         = this.usrGrid.Rows.Add();
                AddUserAuthority(userAuthority, index);
            }
            usrGrid.Update();
        }
Exemple #4
0
        public FormChipDetection(bool isResetConfiguration)
        {
            mIsResetConfiguration = isResetConfiguration;
            InitializeComponent();

            Parameter.GetInstance().LoadOptionFile();
            mConfiguration = new Configuration(isResetConfiguration);

            if (isResetConfiguration)
            {
                UserConfiguration.GetInstance().CreateDefualtUserConfigurationFile();
            }
            else
            {
                UserConfiguration.GetInstance().LoadUserConfigurationFile();
            }
            mChipDetection = new ChipDetection();

            Parameter.GetInstance().WidthRatio  = ((double)Parameter.GetInstance().WidthPixels) / picImage.Width;
            Parameter.GetInstance().HeightRatio = ((double)Parameter.GetInstance().HeightPixels) / picImage.Height;

            lblMark.BackColor = Color.Transparent;
            Form.CheckForIllegalCrossThreadCalls = false;

            picImage.Paint += new PaintEventHandler(PicImage_Paint);

            InitializeTimers();
            //UserLogin(false);

            m_grabThreadExited = new AutoResetEvent(false);
            CAM_connect();

            //mCom_ = new SerialPort();
            //mCom_Open();

            ResetTestStatus();

            lblStatusIndicator.Text = "初始化完成";
        }
Exemple #5
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                //this.DialogResult = DialogResult.Cancel;
                string userName = txtUserName.Text.Trim();
                if (string.IsNullOrEmpty(userName))
                {
                    txtUserName.Focus();
                    txtUserName.SelectAll();

                    MessageBox.Show("用户名不能为空!", "错误");
                    return;
                }
                //string oldPassword = txtOldPassword.Text.Trim();
                string newPassword = txtNewPassword.Text.Trim();

                //if (oldPassword.Length!=6)
                //{
                //    txtOldPassword.Focus();
                //    txtOldPassword.SelectAll();
                //    MessageBox.Show(mResources.GetString("txtPasswordLengthError"), mResources.GetString("error"));
                //    return;
                //}
                if (newPassword.Length != 6)
                {
                    txtNewPassword.Focus();
                    txtNewPassword.SelectAll();
                    MessageBox.Show("密码长度应为6位!", "错误");
                    return;
                }
                if (!UserConfiguration.GetInstance().User.ContainsKey(userName))
                {
                    mUserAuthority = new UserAuthority(userName, newPassword, (UserType)cmbUserType.SelectedIndex);
                    UserConfiguration.GetInstance().User.Add(mUserAuthority.Name, mUserAuthority);
                    //if (oldPassword.Equals(userAuthority.Password))
                    {
                        //userAuthority.Set(userName,newPassword,userAuthority.UserType);
                        //mUserConfiguration.SaveConfigurationFile();
                        //MessageBox.Show(mResources.GetString("txtChangePasswordSuccess"), mResources.GetString("hint"));
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }

                    //else
                    //{
                    //    txtOldPassword.Focus();
                    //    txtOldPassword.SelectAll();

                    //    MessageBox.Show(mResources.GetString("txtWrongPassword"), mResources.GetString("error"));

                    //}
                }
                else
                {
                    txtUserName.Focus();
                    txtUserName.SelectAll();
                    MessageBox.Show("用户名错误!", "错误");
                    return;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "错误");
            }
        }
Exemple #6
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                int myrow;
                for (int row = 0; row < usrGrid.Rows.Count - 1; row++)
                {
                    if (usrGrid.Rows[row].Cells[0].Value == null)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行输入的用户名为空,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }
                    if (usrGrid.Rows[row].Cells[1].Value == null)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行输入的密码为空,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }
                    if (usrGrid.Rows[row].Cells[2].Value == null)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行用户类型为空,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }

                    string password = usrGrid.Rows[row].Cells[1].Value.ToString();
                    if (password.Length != 6)
                    {
                        myrow = row + 1;
                        MessageBox.Show("第" + myrow.ToString() + "行输入的密码长度必须会6位,请重新输入!", "错误");
                        usrGrid.Rows[row].Selected = true;
                        return;
                    }
                    string strusrname = usrGrid.Rows[row].Cells[0].Value.ToString();
                    strusrname.Trim();

                    for (int i = 0; i < row; i++)
                    {
                        string prename = usrGrid.Rows[i].Cells[0].Value.ToString();
                        if (prename.Trim().Equals(strusrname))
                        {
                            myrow = row + 1;
                            MessageBox.Show("第" + myrow.ToString() + "行输入的用户名已存在,请重新输入!", "错误");
                            usrGrid.Rows[row].Selected = true;
                            return;
                        }
                    }
                }

                UserConfiguration.GetInstance().User.Clear();
                for (int row = 0; row < usrGrid.Rows.Count - 1; row++)
                {
                    string        name     = usrGrid.Rows[row].Cells[0].Value.ToString();
                    string        password = usrGrid.Rows[row].Cells[1].Value.ToString();
                    UserType      type     = usrGrid.Rows[row].Cells[2].Value.ToString().Equals("管理员") ? UserType.Administrator : UserType.Operator;
                    UserAuthority user     = new UserAuthority(name, password, type);
                    user.Remark = "";
                    if (usrGrid.Rows[row].Cells[3].Value != null)
                    {
                        user.Remark = usrGrid.Rows[row].Cells[3].Value.ToString();
                    }
                    UserConfiguration.GetInstance().User.Add(user.Name, user);
                }
                UserConfiguration.GetInstance().SaveConfigurationFile();
                MessageBox.Show("保存用户权限成功!", "提示");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "错误");
            }
        }