Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/HiveItemView.cs @ 6382

Last change on this file since 6382 was 6373, checked in by cneumuel, 13 years ago

#1233

  • moved ExperimentManager into separate plugin
  • moved Administration into separate plugin
File size: 2.1 KB
Line 
1using System;
2using System.ComponentModel;
3using System.Windows.Forms;
4using HeuristicLab.Core.Views;
5using HeuristicLab.MainForm;
6using HeuristicLab.PluginInfrastructure;
7
8namespace HeuristicLab.Clients.Hive.Views {
9  [View("HiveItem View")]
10  [Content(typeof(HiveItem), IsDefaultView = false)]
11  [Content(typeof(IHiveItem), IsDefaultView = false)]
12  public partial class HiveItemView : ItemView {
13    public new IHiveItem Content {
14      get { return (IHiveItem)base.Content; }
15      set { base.Content = value; }
16    }
17
18    public HiveItemView() {
19      InitializeComponent();
20    }
21
22    protected override void DeregisterContentEvents() {
23      Content.PropertyChanged -= new PropertyChangedEventHandler(Content_PropertyChanged);
24      Content.ModifiedChanged -= new EventHandler(Content_ModifiedChanged);
25      base.DeregisterContentEvents();
26    }
27    protected override void RegisterContentEvents() {
28      base.RegisterContentEvents();
29      Content.PropertyChanged += new PropertyChangedEventHandler(Content_PropertyChanged);
30      Content.ModifiedChanged += new EventHandler(Content_ModifiedChanged);
31    }
32
33    protected override void SetEnabledStateOfControls() {
34      base.SetEnabledStateOfControls();
35      storeButton.Enabled = (Content != null) && !ReadOnly && Content.Modified;
36    }
37
38    private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
39      if (InvokeRequired)
40        Invoke(new PropertyChangedEventHandler(Content_PropertyChanged), sender, e);
41      else {
42        OnContentPropertyChanged(e.PropertyName);
43      }
44    }
45    protected virtual void OnContentPropertyChanged(string propertyName) { }
46    protected virtual void Content_ModifiedChanged(object sender, EventArgs e) {
47      if (InvokeRequired)
48        Invoke(new EventHandler(Content_ModifiedChanged), sender, e);
49      else
50        SetEnabledStateOfControls();
51    }
52
53    protected virtual void storeButton_Click(object sender, EventArgs e) {
54      try {
55        Content.Store();
56      }
57      catch (Exception ex) {
58        ErrorHandling.ShowErrorDialog(this, "Store failed.", ex);
59      }
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.