private void LoadSavedAccount() { if (!File.Exists(SavedSteamAccount.AccountsFilePath)) { return; } var accounts = SavedSteamAccount.Get(); foreach (var acc in accounts) { var row = this.AccountsDataGridView.Rows.Add(); AccountsDataGridUtils.GetDataGridViewLoginCell(this.AccountsDataGridView, row).Value = acc.Login; AccountsDataGridUtils.GetDataGridViewPasswordCell(this.AccountsDataGridView, row).Value = GetPasswordStars(acc.Password.Length); AccountsDataGridUtils.GetDataGridViewTruePasswordHiddenCell(this.AccountsDataGridView, row).Value = acc.Password; AccountsDataGridUtils.GetDataGridViewSteamApiCell(this.AccountsDataGridView, row).Value = acc.SteamApi; AccountsDataGridUtils.GetDataGridViewMafileHiddenCell(this.AccountsDataGridView, row).Value = acc.MaFile; Task.Run( () => { var profileImage = ImageUtils.GetSteamProfileSmallImage(acc.MaFile.Session.SteamID); if (profileImage != null) { AccountsDataGridUtils.GetDataGridViewImageCell(this.AccountsDataGridView, row).Value = profileImage; } }); } }
private void AddNewAccountButtonClick(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.LoginTextBox.Text) || string.IsNullOrEmpty(this.MafilePathTextBox.Text) || string.IsNullOrEmpty(this.PasswordTextBox.Text) || string.IsNullOrEmpty(this.SteamApiTextBox.Text)) { MessageBox.Show( @"Some fields are filled - incorrectly", @"Error adding account", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error adding account. Some fields are filled - incorrectly"); return; } if (AccountsDataGridUtils.IsAccountAlreadyExist( this.AccountsDataGridView, this.LoginTextBox.Text.Trim())) { Logger.Error($"{this.LoginTextBox.Text.Trim()} already exist in accounts list"); MessageBox.Show( $@"{this.LoginTextBox.Text.Trim()} already exist in accounts list", @"Error on the account add", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SteamGuardAccount account; try { account = JsonConvert.DeserializeObject <SteamGuardAccount>( File.ReadAllText(this.MafilePathTextBox.Text)); } catch (Exception ex) { Logger.Error("Error processing MaFile", ex); MessageBox.Show(ex.Message, @"Error processing MaFile", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (account == null) { Logger.Error("Error processing MaFile"); return; } var row = this.AccountsDataGridView.Rows.Add(); var login = this.LoginTextBox.Text.Trim(); AccountsDataGridUtils.GetDataGridViewLoginCell(this.AccountsDataGridView, row).Value = login; AccountsDataGridUtils.GetDataGridViewPasswordCell(this.AccountsDataGridView, row).Value = GetPasswordStars(this.PasswordTextBox.Text.Trim().Count()); AccountsDataGridUtils.GetDataGridViewSteamApiCell(this.AccountsDataGridView, row).Value = this.SteamApiTextBox.Text.Trim(); AccountsDataGridUtils.GetDataGridViewMafileHiddenCell(this.AccountsDataGridView, row).Value = account; AccountsDataGridUtils.GetDataGridViewTruePasswordHiddenCell(this.AccountsDataGridView, row).Value = this.PasswordTextBox.Text.Trim(); Logger.Debug($"{login} added to accounts list"); Task.Run( () => { if (account.Session == null) { return; } var profileImage = ImageUtils.GetSteamProfileSmallImage(account.Session.SteamID); if (profileImage != null) { AccountsDataGridUtils.GetDataGridViewImageCell(this.AccountsDataGridView, row).Value = profileImage; } }); this.LoginTextBox.Clear(); this.PasswordTextBox.Clear(); this.MafilePathTextBox.Clear(); this.SteamApiTextBox.Clear(); this.UpdateAccountsFile(); } catch (Exception ex) { Logger.Critical(ex); } }