Exemple #1
0
 public RecordForDisplay(Record data)
 {
     this.Id             = data.Id;
     this.Name           = data.Name;
     this.PictureForLogo = ImageHelper.GetImageFromBase64String(data.PictureForLogo);
     this.Keywords       = data.Keywords;
     this.Username       = data.Username;
     this.Password       = SecureStringHelper.GetSecureStringFromString(data.Password);
     this.Remarks        = data.Remarks;
 }
Exemple #2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.textBoxName.Text))
            {
                MessageBox.Show("Please select a valid name for current item.", "Save Item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Image logo         = null;
            var   logoFilePath = this.textBoxLogoFilePath.Text;

            if (!string.IsNullOrWhiteSpace(logoFilePath))
            {
                try
                {
                    logo = Image.FromFile(logoFilePath);
                    logo = ImageHelper.ZoomPicture(logo, 100, 50);
                }
                catch
                {
                    MessageBox.Show("Please select a valid image for Logo.", "Save Item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (this.record == null)
            {
                this.record = new RecordForDisplay {
                    Id = Guid.NewGuid()
                };
            }

            this.record.Name = this.textBoxName.Text;
            var image = this.textBoxLogoFilePath.Text;

            this.record.PictureForLogo = logo;
            this.record.Username       = this.textBoxUsername.Text;
            this.record.Password       = SecureStringHelper.GetSecureStringFromString(this.textBoxPassword.Text);
            this.record.Keywords       = this.textBoxKeywords.Text;
            this.record.Remarks        = this.textBoxRemarks.Text;

            ResourceProcessor.GetInstance().Save(this.record);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }