1 | using System;
|
---|
2 | using System.Windows.Forms;
|
---|
3 | using HeuristicLab.Analysis.FitnessLandscape.BoxCharts;
|
---|
4 | using HeuristicLab.Core.Views;
|
---|
5 | using HeuristicLab.MainForm;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|