Exemple #1
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"));
                    }
                }
            }
        }
        public static void FillUserResultData(Control ctrl, ICogRecord result, string path, bool convertRadiansToDegrees)
        {
            // Extract the data identified by the path (if available) from the given result record.
            // Use a format string for doubles.
            string rtn;
            HorizontalAlignment align = HorizontalAlignment.Left;

            if (result == null)
            {
                rtn = ResourceUtility.GetString("RtResultNotAvailable");
            }
            else
            {
                object obj = null;

                try
                {
                    obj = result.SubRecords[path].Content;
                }
                catch
                {
                }

                // check if data is available
                if (obj != null && obj.GetType().FullName != "System.Object")
                {
                    if (obj.GetType() == typeof(double))
                    {
                        double d = (double)obj;
                        if (convertRadiansToDegrees)
                        {
                            d = CogMisc.RadToDeg(d);
                        }
                        rtn = d.ToString("0.000");
                    }
                    else
                    {
                        rtn = obj.ToString();
                    }

                    if (TypeIsNumeric(obj.GetType()))
                    {
                        align = HorizontalAlignment.Right;
                    }
                }
                else
                {
                    rtn = ResourceUtility.GetString("RtResultNotAvailable");
                }
            }

            ctrl.Text = rtn;
            TextBox box = ctrl as TextBox;

            if (box != null)
            {
                box.TextAlign = align;
            }
        }
Exemple #3
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();
        }
 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");
 }