Example #1
0
        public void WriteSettings()
        {
            //if (unchanged)
            //    return;

            int n = allUsers.Count;

            if (n == 0)
            {
                return;
            }

            try
            {
                using (BinaryWriter writer = new BinaryWriter(
                           File.Open(GetSettingFilePath(), FileMode.Create)))
                {
                    writer.Write(n);
                    foreach (MPAiUser user in allUsers)
                    {
                        writer.Write(user.getName());
                        writer.Write(user.getCode());
                    }

                    // store the last used user
                    writer.Write(currentUser.getName());
                    writer.Write(currentUser.getCode());
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp);
            }
        }
Example #2
0
        public bool ContainUser(MPAiUser candidate)
        {
            foreach (MPAiUser item in allUsers)
                if (item.getName() == candidate.getName())
                    return true;

            return false;
        }
Example #3
0
        public bool ContainUser(MPAiUser candidate)
        {
            foreach (MPAiUser item in allUsers)
            {
                if (item.getName() == candidate.getName())
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
 public override bool Equals(System.Object obj)
 {
     if (obj is MPAiUser)
     {
         MPAiUser otherUser = (MPAiUser)obj;
         if (userName == null || passWord == null)
         {
             return(false);
         }
         return((getName() == otherUser.getName()) &&
                (passWord == otherUser.getCode()));
     }
     else
     {
         return(false);
     }
 }
Example #5
0
        private void buttonOK_Click(object sender, System.EventArgs e)
        {
            if ((codeBox.Text.Trim() == "") || (codeBox2.Text.Trim() == ""))
            {
                MessageBox.Show("Passwords should not be empty! ",
                                "Ooops", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (codeBox.Text != codeBox2.Text)
            {
                MessageBox.Show("Passwords do not match! ",
                                "Ooops", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            allUsers.ChangeUserCode(currentUser.getName(), codeBox.Text);
            MessageBox.Show("Password changed! ",
                            "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }
Example #6
0
 private void VisualizeUser(MPAiUser user)
 {
     userNameBox.Text = user.getName();
     codeBox.Text     = user.getCode();
 }
Example #7
0
 private void VisualizeUser(MPAiUser user)
 {
     userNameBox.Text = user.getName();
     codeBox.Text = user.getCode();
 }
Example #8
0
 public string GetAppDataDir(MPAiUser user)
 {
     return((GetAppDataDir() + Path.DirectorySeparatorChar + user.getName()) + "\\");
 }
Example #9
0
 public string GetAppDataDir(MPAiUser user)
 {
     return (GetAppDataDir() + Path.DirectorySeparatorChar + user.getName()) + "\\";
 }