[7128] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.ComponentModel;
|
---|
| 4 | using System.Drawing;
|
---|
| 5 | using System.Data;
|
---|
| 6 | using System.Linq;
|
---|
| 7 | using System.Text;
|
---|
| 8 | using System.Windows.Forms;
|
---|
| 9 | using HeuristicLab.Analysis.FitnessLandscape.BoxCharts;
|
---|
| 10 | using HeuristicLab.Core.Views;
|
---|
| 11 | using HeuristicLab.MainForm;
|
---|
| 12 |
|
---|
| 13 | namespace 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 | }
|
---|