Beispiel #1
0
 private void UsernameTxt_Entering(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(UsernameTxt.Text) || UsernameTextEmpty == true)
     {
         UsernameTxt.Clear(); // When the text box is clicked on the sample text inside will disappear
     }
 }
Beispiel #2
0
        /*
         #region Validation
         * string ValidateInputs(string username, string password, string confirmPassword)
         * {
         *  string errorMessage = "";
         *  var naV = new NewAccountValidation(username, password, confirmPassword);
         *  errorMessage += UsernameValidation.ValidateUsername(username);
         *  errorMessage += PasswordValidation.ValidatePassword(password);
         *  errorMessage += ConfirmPasswordValidation.ValidateConfirmPassword(password, confirmPassword);
         *  return errorMessage;
         * }
         * void IsInputValid(string errorMessage, string username, string password)
         * {
         *  //If no error is found
         *  if (errorMessage == "")
         *  {
         *      //stores username and hashed password
         *      CreateNewAccountService.Instance.username = username;
         *      CreateNewAccountService.Instance.password = UserAccount.stringToHashString(password);
         *
         *      var ui = UICreatePage.GetAdminDetailsPage();
         *      CreateNewAccountService.Instance.Window.Content = ui;
         *  }
         *  else
         *  {
         *      ErrorTxt.Text = errorMessage;
         *      ClearInputFields();
         *  }
         * }
         #endregion*/

        #region Utility methods
        void ClearInputFields()
        {
            //Clear all fields on the view
            UsernameTxt.Clear();
            passwordBox.Clear();
            ConfirmPasswordBox.Clear();
        }
Beispiel #3
0
 private void Loginbtn_Click(object sender, EventArgs e)
 {
     if (UsernameTxt.Text == "" || PasswordTxt.Text == "")
     {
         MessageBox.Show("Please Fill in All Fields", "Empty Fields Detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         FormOperations.user = DataAccess.GetUsers(UsernameTxt.Text, PasswordTxt.Text);
         if (FormOperations.user != null)
         {
             FormOperations.OpenMenu();
             this.Close();
         }
         else
         {
             MessageBox.Show("Incorrect Username or Password. Please Try Again");
             UsernameTxt.Clear();
             PasswordTxt.Clear();
         }
     }
 }
Beispiel #4
0
 public void EnterUsername(string username)
 {
     UsernameTxt.SendKeys(username);
 }
Beispiel #5
0
 private void ClearBtn_Click(object sender, EventArgs e)
 {
     UsernameTxt.Text = "";
     PasswordTxt.Text = "";
     UsernameTxt.Focus();
 }
        private async void GenerateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (NameRoom.Text != "" && !string.IsNullOrWhiteSpace(UsernameTxt.Text) && !string.IsNullOrWhiteSpace(AioKeyTxt.Password) && !string.IsNullOrWhiteSpace(Key_EndToEnd.Text) && !Key_EndToEnd.Text.Contains("GENERATE"))
            {
                HttpRequest req = new HttpRequest();

                string KeyRoomDec = req.getCorretName(NameRoom.Text) + "|" + UsernameTxt.Text + "|" + AioKeyTxt.Password + "|" + Key_EndToEnd.Text + "|" + MqttConnection.NickName + "|" + UrlTxt.Text + "|" + CheckControll.IsChecked + "|" + MqttConnection.MqttServer + "|" + MqttConnection.MqttPort.ToString();
                string KeyRoomEnc = StringCipher.Encrypt(KeyRoomDec, "");

                if (CheckCurrentData.IsChecked == true)
                {
                    if (getNumFeed(req.getAllFeeds()) != 10)
                    {
                        MqttConnection.MqttUnsubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                        if (req.createFeed(NameRoom.Text, DescriptionTxt.Text, Key_EndToEnd.Text, UrlTxt.Text, CheckControll.IsChecked.ToString()))
                        {
                            MqttConnection.setKeyEndToEnd(Key_EndToEnd.Text);
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_ROOMGROUP_" + NameRoom.Text + "_" + UrlTxt.Text);
                            Clipboard.SetText(KeyRoomEnc);
                            MessageBox.Show("Room created!!!" + '\n' + '\n' + "Don't worry, I copy the access key to the group, share it with your friends, you just have to paste and they just have to copy it and click on \"I have a key\"");
                            Close();
                        }
                        else
                        {
                            MqttConnection.setKeyEndToEnd("");
                            MqttConnection.setChatRoomNameKey("chat");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            ShowSnackBar("Error creating room!");
                        }
                    }
                    else
                    {
                        ShowSnackBar("Max number of group created, delete one!");
                    }
                }
                else
                {
                    string tempUser   = MqttConnection.UserName;
                    string tempAioKey = MqttConnection.AioKey;
                    MqttConnection.MqttDisconnect();
                    MqttConnection.setUser(UsernameTxt.Text);
                    MqttConnection.setAioKey(AioKeyTxt.Password);
                    if (!(await MqttConnection.MqttFastConnect()))
                    {
                        MqttConnection.setUser(tempUser);
                        MqttConnection.setAioKey(tempAioKey);
                        ShowSnackBar("Erron to connect with new data!");
                        UsernameTxt.Focus();
                        return;
                    }

                    if (getNumFeed(req.getAllFeeds()) != 10)
                    {
                        if (req.createFeed(NameRoom.Text, DescriptionTxt.Text, Key_EndToEnd.Text, UrlTxt.Text, CheckControll.IsChecked.ToString()))
                        {
                            MqttConnection.setKeyEndToEnd(Key_EndToEnd.Text);
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/clients");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_ROOMGROUP_" + NameRoom.Text + "_" + UrlTxt.Text);
                            Clipboard.SetText(KeyRoomEnc);
                            MessageBox.Show("Room created!!!" + '\n' + '\n' + "Don't worry, I copy the access key to the group, share it with your friends, you just have to paste and they just have to copy it and click on \"I have a key\"");
                            Close();
                        }
                        else
                        {
                            MqttConnection.setKeyEndToEnd("");
                            MqttConnection.setChatRoomNameKey("chat");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/clients");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            ShowSnackBar("Error creating room!");
                        }
                    }
                    else
                    {
                        ShowSnackBar("Max number of group created, delete one!");
                    }
                }
            }
            else
            {
                ShowSnackBar("Complete the box please");
            }
        }