private string GetCurrentPasteValue() { if (this.dataGridViewMain.SelectedRows.Count < 1) { return(null); } var currentSelectedItem = (Guid)this.dataGridViewMain.SelectedRows[0].Cells["Id"].Value; var record = allDataCache.Find(i => i.Id == currentSelectedItem); if (IsCurrentPasteUsername) { this.IsCurrentPasteUsername = false; if (string.IsNullOrWhiteSpace(record.Username)) { return(null); } return(record.Username); } else { this.IsCurrentPasteUsername = true; if (record.Password == null) { return(null); } return(SecureStringHelper.GetStringFromSecureString(record.Password)); } }
public Record ToDataModel() { return(new Record { Id = this.Id, Name = this.Name, PictureForLogo = ImageHelper.GetBase64StringFromImage(this.PictureForLogo), Keywords = this.Keywords, Username = this.Username, Password = SecureStringHelper.GetStringFromSecureString(this.Password), Remarks = this.Remarks }); }
private void InitializeForm() { if (this.record == null) { this.Text = "Create"; } else { this.Text = $"Edit - {this.record.Name}"; this.textBoxName.Text = this.record.Name; this.pictureBoxLogo.Image = this.record.PictureForLogo; this.textBoxLogoFilePath.Text = string.Empty; this.textBoxUsername.Text = this.record.Username; this.textBoxPassword.Text = SecureStringHelper.GetStringFromSecureString(this.record.Password); this.textBoxKeywords.Text = this.record.Keywords; this.textBoxRemarks.Text = this.record.Remarks; } }
private void dataGridViewMain_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { var dataGrid = this.dataGridViewMain; var targetCell = dataGrid.Rows[e.RowIndex].Cells[e.ColumnIndex]; // If it is password field, show the characters if (e.ColumnIndex == dataGrid.Columns["PasswordForDisplay"].Index) { if (targetCell.Value.ToString() == defalutPasswordPattern) { var passwordIndex = dataGrid.Columns["Password"].Index; targetCell.Value = SecureStringHelper.GetStringFromSecureString( dataGrid.Rows[e.RowIndex].Cells[passwordIndex].Value as SecureString); } else { targetCell.Value = defalutPasswordPattern; } } // Copy current cell's value to clipboard this.CopyToClipBoard(targetCell.Value); }