[4905] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.MainForm;
|
---|
[5955] | 25 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 26 | using HeuristicLab.PluginInfrastructure;
|
---|
[4905] | 27 |
|
---|
| 28 | namespace HeuristicLab.Clients.Hive.Views {
|
---|
| 29 | /// <summary>
|
---|
| 30 | /// The base class for visual representations of items.
|
---|
| 31 | /// </summary>
|
---|
| 32 | [View("Hive Experiment Manager View")]
|
---|
[5955] | 33 | [Content(typeof(ExperimentManagerClient), true)]
|
---|
| 34 | public partial class HiveExperimentManagerView : AsynchronousContentView {
|
---|
[4905] | 35 |
|
---|
[5955] | 36 | public new ExperimentManagerClient Content {
|
---|
| 37 | get { return (ExperimentManagerClient)base.Content; }
|
---|
[4905] | 38 | set { base.Content = value; }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | /// <summary>
|
---|
| 42 | /// Initializes a new instance of <see cref="ItemBaseView"/>.
|
---|
| 43 | /// </summary>
|
---|
| 44 | public HiveExperimentManagerView() {
|
---|
| 45 | InitializeComponent();
|
---|
| 46 | }
|
---|
| 47 |
|
---|
[5955] | 48 | protected override void RegisterContentEvents() {
|
---|
| 49 | base.RegisterContentEvents();
|
---|
| 50 | Content.Refreshing += new EventHandler(Content_Refreshing);
|
---|
| 51 | Content.Refreshed += new EventHandler(Content_Refreshed);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | protected override void DeregisterContentEvents() {
|
---|
| 55 | Content.Refreshing -= new EventHandler(Content_Refreshing);
|
---|
| 56 | Content.Refreshed -= new EventHandler(Content_Refreshed);
|
---|
| 57 | base.DeregisterContentEvents();
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[4905] | 60 | protected override void OnContentChanged() {
|
---|
| 61 | base.OnContentChanged();
|
---|
[5955] | 62 | if (Content == null) {
|
---|
| 63 | hiveExperimentListView.Content = null;
|
---|
| 64 | } else {
|
---|
| 65 | hiveExperimentListView.Content = Content.HiveExperiments;
|
---|
| 66 | if(Content != null)
|
---|
| 67 | Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex)));
|
---|
| 68 | }
|
---|
[4905] | 69 | }
|
---|
| 70 |
|
---|
[5512] | 71 | protected override void SetEnabledStateOfControls() {
|
---|
| 72 | base.SetEnabledStateOfControls();
|
---|
[5955] | 73 | refreshButton.Enabled = Content != null;
|
---|
| 74 | hiveExperimentListView.Enabled = Content != null;
|
---|
[5512] | 75 | }
|
---|
| 76 |
|
---|
[5955] | 77 | private void Content_Refreshing(object sender, EventArgs e) {
|
---|
| 78 | if (InvokeRequired) {
|
---|
| 79 | Invoke(new EventHandler(Content_Refreshing), sender, e);
|
---|
| 80 | } else {
|
---|
| 81 | Cursor = Cursors.AppStarting;
|
---|
| 82 | refreshButton.Enabled = false;
|
---|
| 83 | hiveExperimentListView.Enabled = false;
|
---|
| 84 | }
|
---|
[4905] | 85 | }
|
---|
[5955] | 86 | private void Content_Refreshed(object sender, EventArgs e) {
|
---|
| 87 | if (InvokeRequired) {
|
---|
| 88 | Invoke(new EventHandler(Content_Refreshed), sender, e);
|
---|
| 89 | } else {
|
---|
| 90 | hiveExperimentListView.Content = Content.HiveExperiments;
|
---|
| 91 | refreshButton.Enabled = true;
|
---|
| 92 | hiveExperimentListView.Enabled = true;
|
---|
| 93 | Cursor = Cursors.Default;
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
[4905] | 96 |
|
---|
[5955] | 97 | private void refreshButton_Click(object sender, EventArgs e) {
|
---|
| 98 | Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex)));
|
---|
[4905] | 99 | }
|
---|
| 100 |
|
---|
[5955] | 101 | protected override void OnClosing(FormClosingEventArgs e) {
|
---|
| 102 | base.OnClosing(e);
|
---|
[4905] | 103 | if (Content != null) {
|
---|
[5955] | 104 | foreach (var exp in Content.HiveExperiments) {
|
---|
| 105 | if (exp.RefreshAutomatically) {
|
---|
| 106 | exp.RefreshAutomatically = false; // stop result polling
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
[4905] | 109 | }
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 | }
|
---|