Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape.Views/BoxChart/BitmapItemView.cs @ 13365

Last change on this file since 13365 was 7128, checked in by epitzer, 13 years ago

#1696 Integrate fitness landscape analysis plugins from Heureka! repository.

File size: 2.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Analysis.FitnessLandscape.BoxCharts;
10using HeuristicLab.Core.Views;
11using HeuristicLab.MainForm;
12
13namespace HeuristicLab.Analysis.FitnessLandscape.BoxChart {
14
15  [View("BitmapItemView")]
16  [Content(typeof(BitmapItem), IsDefaultView = true)]
17  public sealed partial class BitmapItemView : ItemView {
18
19    public new BitmapItem Content {
20      get { return (BitmapItem)base.Content; }
21      set { base.Content = value; }
22    }
23
24    public BitmapItemView() {
25      InitializeComponent();
26    }
27
28    protected override void DeregisterContentEvents() {
29      Content.ImageChanged -= new EventHandler(Content_ImageChanged);
30      base.DeregisterContentEvents();
31    }
32
33    protected override void RegisterContentEvents() {
34      base.RegisterContentEvents();
35      Content.ImageChanged += new EventHandler(Content_ImageChanged);
36    }
37
38    protected override void SetEnabledStateOfControls() {
39      base.SetEnabledStateOfControls();
40      saveToolStripMenuItem.Enabled = Content != null && Content.Image != null;
41    }
42
43    #region Event Handlers (Content)
44    private void Content_ImageChanged(object sender, EventArgs e) {
45      if (InvokeRequired)
46        Invoke(new EventHandler(Content_ImageChanged), sender, e);
47      else
48        pictureBox.Image = Content.Image;
49    }
50    #endregion
51
52    protected override void OnContentChanged() {
53      base.OnContentChanged();
54      if (Content == null) {
55        pictureBox.Image = null;
56      } else {
57        pictureBox.Image = Content.Image;
58      }
59    }
60
61    private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
62      if (Content != null && Content.Image != null) {
63        if (saveFileDialog.ShowDialog(ParentForm) == DialogResult.OK) {
64          Content.Save(saveFileDialog.FileName);
65        }
66      }
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.