Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
 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
     });
 }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 4
0
        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);
        }