Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape.Views/BoxChart/BitmapItemView.cs @ 17800

Last change on this file since 17800 was 16995, checked in by gkronber, 6 years ago

#2520 Update plugin dependencies and references for HL.FLA for new persistence

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