Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/UpdateableHiveExperimentManagerView.cs @ 5636

Last change on this file since 5636 was 5512, checked in by ascheibe, 14 years ago

#1233 worked on administration gui

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Threading;
24using System.Windows.Forms;
25using HeuristicLab.MainForm;
26using HeuristicLab.PluginInfrastructure;
27
28namespace HeuristicLab.Clients.Hive.Views {
29  [View("Updateable Hive Experiment Manager View")]
30  [Content(typeof(HiveExperimentManagerClient), true)]
31  public partial class UpdateableHiveExperimentManagerView : HiveExperimentManagerView {
32    private ProgressView progressView;
33
34    public UpdateableHiveExperimentManagerView() {
35      InitializeComponent();
36      updateExperimentsPanel.Dock = DockStyle.Fill;
37    }
38
39    protected override void OnContentChanged() {
40      base.OnContentChanged();
41      Content_IsProgressingChanged(this, EventArgs.Empty);
42      if (Content != null) UpdateExperimentsAsync();
43    }
44
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47      this.Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
48    }
49
50    protected override void DeregisterContentEvents() {
51      base.DeregisterContentEvents();
52      this.Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
53    }
54
55    private void updateExperimentsButton_Click(object sender, EventArgs e) {
56      if (Content != null) UpdateExperimentsAsync();
57    }
58
59    private void Content_IsProgressingChanged(object sender, EventArgs e) {
60      if (this.InvokeRequired) {
61        Invoke(new EventHandler(Content_IsProgressingChanged), sender, e);
62      } else {
63        if (Content != null && Content.IsProgressing) {
64          SetProgressView();
65        } else {
66          FinishProgressView();
67        }
68      }
69    }
70
71    private void SetProgressView() {
72      if (progressView == null) {
73        progressView = new ProgressView(this, Content.Progress);
74      } else {
75        progressView.Progress = Content.Progress;
76      }
77    }
78
79    private void FinishProgressView() {
80      if (progressView != null) {
81        progressView.Finish();
82        progressView = null;
83        SetEnabledStateOfControls();
84      }
85    }
86
87    protected override void SetEnabledStateOfControls() {
88      base.SetEnabledStateOfControls();
89      updateExperimentsPanel.Visible = Content != null && Content.HiveExperiments == null;
90    }
91
92    protected void UpdateExperimentsAsync() {
93      MethodInvoker invoker = new MethodInvoker(Content.UpdateExperimentList);
94      invoker.BeginInvoke((ar) => {
95        try {
96          invoker.EndInvoke(ar);
97        }
98        catch (Exception ex) {
99          ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
100        }
101      }, null);
102    }
103  }
104}
Note: See TracBrowser for help on using the repository browser.