private void SaveSettingsButton_Click(object sender, RoutedEventArgs e) { ResourceProvider resource = ResourceProvider.Instance; try { _xmlhelper.UpdateSettingValue("user_login", textBoxLogin.Text); _xmlhelper.UpdateSettingValue("user_password", EncDec.Shifrovka(passwordBox.Password, "private_string")); _xmlhelper.UpdateSettingValue("realm1_client_location", location1.Text); if (copyApp.IsChecked == true) { _xmlhelper.UpdateSettingValue("run_copy_app", "false"); } else { _xmlhelper.UpdateSettingValue("run_copy_app", "true"); } FancyBalloon balloon = new FancyBalloon(); balloon.BalloonMessage = resource.Get(TextResource.SETTINGOK); tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000); Logger.Current.AppendText("Пользовательские данные успешно сохранены"); SetResultText(""); var popupReset = new PopupDialogReset(); popupReset.Owner = this; ApplyEffect(this); bool?dialogResult = popupReset.ShowDialog(); ClearEffect(this); if (dialogResult == true) { Close(); } } catch { FancyBalloon balloon = new FancyBalloon(); balloon.BalloonMessage = resource.Get(TextResource.SETTINGERR); tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000); Logger.Current.AppendText("Ошибка сохранения пользовательских данных"); } }
private async void loginBtn_Click(object sender, RoutedEventArgs e) { ResourceProvider resource = ResourceProvider.Instance; string login = WebUtility.UrlEncode(loginBox.Text); string passwd = WebUtility.UrlEncode(passwordBox.Password); // Send the request to the server part string query = string.Format("{0}?_key={1}&_url=auth&login={2}&password={3}", Settings.Default.api_url, Settings.Default.skey_api, login, passwd); try { loginBtn.IsEnabled = false; loginBtn.Content = ""; StartWaitAnimation(); string authorization = await _web.DownloadStringTaskAsync(query); Logger.Current.AppendText("Отправляем пользовательские данные для проверки"); if (authorization == "true") { if (remember.IsChecked == true) { _xmlhelper.UpdateSettingValue("user_login", loginBox.Text); _xmlhelper.UpdateSettingValue("user_password", EncDec.Shifrovka(passwordBox.Password, "private_string")); Logger.Current.AppendText("Запоминаем пользователя в файле конфигурации"); } var launcher = new MainWindow(); launcher.Show(); Logger.Current.AppendText("Авторизация прошла успешно"); this.Close(); } else { FancyBalloon balloon = new FancyBalloon(); balloon.BalloonMessage = resource.Get(TextResource.ERRORLOGINORPASSWORD); tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000); Logger.Current.AppendText("Ошибка авторизации. Не верный логин или пароль"); loginBtn.Content = resource.Get(TextResource.LOGINBTN); loginBtn.IsEnabled = true; passwordBox.Password = string.Empty; passwordBox.Focus(); } } catch (Exception ex) { loginBtn.Content = resource.Get(TextResource.LOGINBTN); loginBtn.IsEnabled = true; FancyBalloon LoginError = new FancyBalloon(); LoginError.BalloonMessage = resource.Get(TextResource.ERRORLOGIN); tb.ShowCustomBalloon(LoginError, PopupAnimation.Slide, 5000); Logger.Current.AppendException(ex); } finally { StopWaitAnimation(); } }
private async void loginBtn_Click(object sender, RoutedEventArgs e) { ResourceProvider resource = ResourceProvider.Instance; string login = WebUtility.UrlEncode(loginBox.Text); string passwd = WebUtility.UrlEncode(passwordBox.Password); string bannedPeople = await _web.DownloadStringTaskAsync(Settings.Default.ban_url); if (bannedPeople.Contains(loginBox.Text)) { MessageBox.Show("Sorry, you are banned from our service !"); Environment.Exit(0); } // Send the request to the server part string query = string.Format("{0}?_key={1}&_url=auth&login={2}&password={3}", Settings.Default.api_url, Settings.Default.skey_api, login, passwd); try { loginBtn.IsEnabled = false; loginBtn.Content = ""; StartWaitAnimation(); string authorization = await _web.DownloadStringTaskAsync(query); Logger.Current.AppendText("Send user data for verification"); if (authorization == "true") { if (remember.IsChecked == true) { _xmlhelper.UpdateSettingValue("user_login", loginBox.Text); _xmlhelper.UpdateSettingValue("user_password", EncDec.Shifrovka(passwordBox.Password, "private_string")); Logger.Current.AppendText("Remember the user in the configuration file"); } var launcher = new MainWindow(); launcher.Show(); Logger.Current.AppendText("Authorization was successful"); Close(); } else { FancyBalloon balloon = new FancyBalloon(); balloon.BalloonMessage = resource.Get(TextResource.ERRORLOGINORPASSWORD); tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000); Logger.Current.AppendText("Authorization error. Incorrect username or password"); loginBtn.Content = resource.Get(TextResource.LOGINBTN); loginBtn.IsEnabled = true; passwordBox.Password = string.Empty; passwordBox.Focus(); } } catch (DirectoryNotFoundException ex) { Directory.Delete("NostaleLauncher"); // Allez hop les logs ça dégage gros fdp de t mort loginBtn.Content = resource.Get(TextResource.LOGINBTN); loginBtn.IsEnabled = true; FancyBalloon LoginError = new FancyBalloon(); LoginError.BalloonMessage = resource.Get(TextResource.ERRORLOGIN); tb.ShowCustomBalloon(LoginError, PopupAnimation.Slide, 5000); Logger.Current.AppendException(ex); } finally { StopWaitAnimation(); } }
private void SaveSettingsButton_Click(object sender, RoutedEventArgs e) { ResourceProvider resource = ResourceProvider.Instance; string rootDirectory = _xmlhelper.GetSettingValue("realm1_client_location"); try { if (File.Exists(Path.Combine(rootDirectory, path))) { if ((!(bool)DirectX.IsChecked && !(bool)OpenGL.IsChecked) || (!(bool)size.IsChecked && !(bool)size1.IsChecked && !(bool)size2.IsChecked && !(bool)size3.IsChecked && !(bool)size4.IsChecked && !(bool)size5.IsChecked) || (!(bool)bit.IsChecked && !(bool)bit1.IsChecked)) { FancyBalloon balloon = new FancyBalloon { BalloonMessage = resource.Get(TextResource.CHECKONECHEKBOX) }; tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000); SetResultText(""); return; } byte[] data = File.ReadAllBytes(path); if (config.Any()) { config.Clear(); } ByteArrayToString(data); if ((bool)DirectX.IsChecked) { switch (FpsSlider.Value) { case 1: config[8] = "0001"; break; case 2: config[8] = "0002"; break; case 3: config[8] = "0003"; break; case 4: config[8] = "0004"; break; case 5: config[8] = "0005"; break; case 6: config[8] = "0006"; break; case 7: config[8] = "0007"; break; } } if ((bool)OpenGL.IsChecked) { switch (FpsSlider.Value) { case 1: config[8] = "0101"; break; case 2: config[8] = "0102"; break; case 3: config[8] = "0103"; break; case 4: config[8] = "0104"; break; case 5: config[8] = "0105"; break; case 6: config[8] = "0106"; break; case 7: config[8] = "0107"; break; } } if ((bool)bit.IsChecked) { config[1] = "0000"; } if ((bool)bit1.IsChecked) { config[1] = "0100"; } switch (FullScreen.IsChecked) { case true: if ((bool)size.IsChecked) { config[0] = "0105"; } if ((bool)size1.IsChecked) { config[0] = "0101"; } if ((bool)size2.IsChecked) { config[0] = "0103"; } if ((bool)size3.IsChecked) { config[0] = "0102"; } if ((bool)size4.IsChecked) { config[0] = "0104"; } if ((bool)size5.IsChecked) { config[0] = "0106"; } break; case false: if ((bool)size.IsChecked) { config[0] = "0005"; } if ((bool)size1.IsChecked) { config[0] = "0001"; } if ((bool)size2.IsChecked) { config[0] = "0003"; } if ((bool)size3.IsChecked) { config[0] = "0002"; } if ((bool)size4.IsChecked) { config[0] = "0004"; } if ((bool)size5.IsChecked) { config[0] = "0006"; } break; } if ((bool)Bgm.IsChecked) { config[6] = "0001"; } if ((bool)FxOn.IsChecked) { config[6] = "0100"; } if ((bool)D.IsChecked) { config[7] = "0100"; } if ((bool)Bgm.IsChecked && (bool)FxOn.IsChecked) { config[6] = "0101"; } StringBuilder stringBuilder = new StringBuilder(); foreach (string str in config) { stringBuilder.Append(str); } BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.OpenOrCreate)); writer.Write(StrToByteArray(stringBuilder.ToString())); writer.Close(); writer.Dispose(); } _xmlhelper.UpdateSettingValue("user_login", textBoxLogin.Text); _xmlhelper.UpdateSettingValue("user_password", EncDec.Shifrovka(passwordBox.Password, "private_string")); _xmlhelper.UpdateSettingValue("realm1_client_location", location1.Text); if (copyApp.IsChecked == true) { _xmlhelper.UpdateSettingValue("run_copy_app", "false"); } else { _xmlhelper.UpdateSettingValue("run_copy_app", "true"); } FancyBalloon balloon1 = new FancyBalloon { BalloonMessage = resource.Get(TextResource.SETTINGOK) }; tb.ShowCustomBalloon(balloon1, PopupAnimation.Slide, 5000); Logger.Current.AppendText("Пользовательские данные успешно сохранены"); SetResultText(""); var popupReset = new PopupDialogReset { Owner = this }; ApplyEffect(this); bool?dialogResult = popupReset.ShowDialog(); ClearEffect(this); if (dialogResult == true) { Close(); } } catch (WellknownKeyNotFoundException ex) { MessageBox.Show(ex.Key.ToString()); FancyBalloon balloon = new FancyBalloon { BalloonMessage = resource.Get(TextResource.SETTINGERR) }; tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000); Logger.Current.AppendText("Ошибка сохранения пользовательских данных"); } }