Example #1
0
        private void FormLogin_Load(object sender, EventArgs e)
        {
            comboBox_Login.Items.Add(new AccessLevel_Localized(AccessLevel.Operator, ResourceUtility.GetString("RtOperator")));
            comboBox_Login.Items.Add(new AccessLevel_Localized(AccessLevel.Supervisor, ResourceUtility.GetString("RtSupervisor")));
            comboBox_Login.Items.Add(new AccessLevel_Localized(AccessLevel.Administrator, ResourceUtility.GetString("RtAdministrator")));
            // default access level is "Operator"
            comboBox_Login.SelectedIndex = (int)mCurrentAccessLevel;
            label_CurrentLogin.Text      = string.Format("(当前登陆用户:{0})", mCurrentAccessLevel.ToString());

            // create, validate & setup the password file
            string passwordfname = Utility.ResolveAssociatedFilename(FormMain.strLoadedVppFilePath[0], "passwords.txt");

            mCurrentPasswordFile = new PasswordFile(passwordfname);
            if (mCurrentPasswordFile.PasswordFileFound && !mCurrentPasswordFile.PasswordFileValid)
            {
                string quoted = "\"" + mCurrentPasswordFile.PasswordFilename + "\"";
                // label_controlErrorMessage.Text = ResourceUtility.FormatString("RtInvalidPasswordFile", quoted);
            }
            // mCurrentPasswordFile.SetDefaultPassword(AccessLevel.Operator, mDefaultOperatorPassword);
            mCurrentPasswordFile.SetDefaultPassword(AccessLevel.Administrator, mDefaultAdministratorPassword);
            mCurrentPasswordFile.SetDefaultPassword(AccessLevel.Supervisor, mDefaultSupervisorPassword);

            EnableOk();
        }
Example #2
0
        private void button_SignIn_Click(object sender, EventArgs e)
        {
            mPassword = textBox_Password.Text;
            AccessLevel newAccessLevel = ((AccessLevel_Localized)(comboBox_Login.SelectedItem)).val;

            // No password is needed when choosing operator access level
            if (newAccessLevel == AccessLevel.Operator)
            {
                mCurrentAccessLevel = newAccessLevel; this.Close();
            }
            else
            {
                // Not using passwords, or going "down" in access level - always allowed
                string expected = mCurrentPasswordFile.GetPasswordForAccessLevel(newAccessLevel);
                if (expected != "")
                {
                    // get password from user
                    if (mPassword == expected)
                    {
                        mCurrentAccessLevel = newAccessLevel;
                        this.Close();
                    }
                    else
                    {
                        // prompt for a password - only update accessLevel if promt is successful
                        this.textBox_Password.Clear();
                        MessageBox.Show(ResourceUtility.GetString("RtInvalidPassword2"), ResourceUtility.GetString("RtInvalidPassword"));
                    }
                }
            }
        }
 private void FormPasswordPrompt_Load(object sender, System.EventArgs e)
 {
     this.label_Password.Text = ResourceUtility.GetString("RtPassword");
     this.button_OK.Text      = ResourceUtility.GetString("RtOK");
     this.button_Cancel.Text  = ResourceUtility.GetString("RtCancel");
 }