protected override void OnLoad(EventArgs e) { currentCropProfile = new CropProfile(); base.OnLoad(e); _context = new ImageEditorDataEntities(); if (_context.CropProfiles.Count() > 0) _context.CropProfiles.Load(); this.cropProfileBindingSource.DataSource = _context.CropProfiles.Local.ToBindingList(); if (newProfile != null) { using (dlgNameProfile dlg = new dlgNameProfile()) { if (dlg.ShowDialog() == DialogResult.OK) { newProfile.Name = dlg.ProfileName; _context.CropProfiles.Add(newProfile); _context.SaveChanges(); dgvCropProfiles.Refresh(); btnOk.Visible = true; btnOk.Enabled = true; } else this.Close(); } } }
// Save current profile public frmCropProfile(CropProfile cropProfile) { InitializeComponent(); newProfile = cropProfile; btnOk.Visible = true; }
private void loadProfileToolStripMenuItem_Click(object sender, EventArgs e) { using (frmCropProfile profiles = new frmCropProfile()) { if (profiles.ShowDialog() == DialogResult.OK) { Size cropSize = new Size(profiles.currentCropProfile.Width, profiles.currentCropProfile.Height); if (currentImage != null) { currentImage.RemoveCrop(); if (currentImage.AddCrop(cropSize)) { currentProfile = profiles.currentCropProfile; txtBoundHeight.Text = currentProfile.Height.ToString(); txtBoundWidth.Text = currentProfile.Width.ToString(); txtDefaultImageDir.Text = currentProfile.ImageDirectory; pen.Color = Color.FromArgb(currentProfile.CropColor); pbxImage.Invalidate(); } else MessageBox.Show("You must first enlarge the picture for that crop size."); } else { currentProfile = profiles.currentCropProfile; txtBoundHeight.Text = currentProfile.Height.ToString(); txtBoundWidth.Text = currentProfile.Width.ToString(); txtDefaultImageDir.Text = currentProfile.ImageDirectory; pen.Color = Color.FromArgb(currentProfile.CropColor); } } } }
// Load saved profile public frmCropProfile() { InitializeComponent(); newProfile = null; btnLoad.Visible = true; }
private void frmMain_Load(object sender, EventArgs e) { currentProfile = new CropProfile(); currentProfile.Name = "Temp Name"; currentProfile.Height = 200; currentProfile.Width = 200; currentProfile.ImageDirectory = "C:\\"; currentProfile.CropColor = 0x780000FF; txtDefaultImageDir.Text = currentProfile.ImageDirectory; pen = new Pen(Color.FromArgb(currentProfile.CropColor)); }