using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using HeuristicLab.Analysis.FitnessLandscape.BoxCharts; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; namespace HeuristicLab.Analysis.FitnessLandscape.BoxChart { [View("BitmapItemView")] [Content(typeof(BitmapItem), IsDefaultView = true)] public sealed partial class BitmapItemView : ItemView { public new BitmapItem Content { get { return (BitmapItem)base.Content; } set { base.Content = value; } } public BitmapItemView() { InitializeComponent(); } protected override void DeregisterContentEvents() { Content.ImageChanged -= new EventHandler(Content_ImageChanged); base.DeregisterContentEvents(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); Content.ImageChanged += new EventHandler(Content_ImageChanged); } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); saveToolStripMenuItem.Enabled = Content != null && Content.Image != null; } #region Event Handlers (Content) private void Content_ImageChanged(object sender, EventArgs e) { if (InvokeRequired) Invoke(new EventHandler(Content_ImageChanged), sender, e); else pictureBox.Image = Content.Image; } #endregion protected override void OnContentChanged() { base.OnContentChanged(); if (Content == null) { pictureBox.Image = null; } else { pictureBox.Image = Content.Image; } } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (Content != null && Content.Image != null) { if (saveFileDialog.ShowDialog(ParentForm) == DialogResult.OK) { Content.Save(saveFileDialog.FileName); } } } } }