Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Clients.OKB.Views/3.3/Administration/Views/AdministratorView.cs @ 16374

Last change on this file since 16374 was 15584, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers on stable

File size: 4.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26using HeuristicLab.PluginInfrastructure;
27
28namespace HeuristicLab.Clients.OKB.Administration {
29  [View("OKB Administrator")]
30  [Content(typeof(AdministrationClient), true)]
31  public sealed partial class AdministratorView : AsynchronousContentView {
32    public new AdministrationClient Content {
33      get { return (AdministrationClient)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public AdministratorView() {
38      InitializeComponent();
39    }
40
41    protected override void DeregisterContentEvents() {
42      Content.Refreshing -= new EventHandler(Content_Refreshing);
43      Content.Refreshed -= new EventHandler(Content_Refreshed);
44      base.DeregisterContentEvents();
45    }
46
47    protected override void RegisterContentEvents() {
48      base.RegisterContentEvents();
49      Content.Refreshing += new EventHandler(Content_Refreshing);
50      Content.Refreshed += new EventHandler(Content_Refreshed);
51    }
52
53
54    protected override void OnContentChanged() {
55      base.OnContentChanged();
56      if (Content == null) {
57        platformCollectionView.Content = null;
58        algorithmClassCollectionView.Content = null;
59        algorithmCollectionView.Content = null;
60        problemClassCollectionView.Content = null;
61        problemCollectionView.Content = null;
62      } else {
63        platformCollectionView.Content = Content.Platforms;
64        algorithmClassCollectionView.Content = Content.AlgorithmClasses;
65        algorithmCollectionView.Content = Content.Algorithms;
66        problemClassCollectionView.Content = Content.ProblemClasses;
67        problemCollectionView.Content = Content.Problems;
68      }
69    }
70
71    protected override void SetEnabledStateOfControls() {
72      base.SetEnabledStateOfControls();
73      refreshButton.Enabled = Content != null;
74      platformCollectionView.Enabled = Content != null;
75      algorithmClassCollectionView.Enabled = Content != null;
76      algorithmCollectionView.Enabled = Content != null;
77      problemClassCollectionView.Enabled = Content != null;
78      problemCollectionView.Enabled = Content != null;
79    }
80
81    private void Content_Refreshing(object sender, EventArgs e) {
82      if (InvokeRequired) {
83        Invoke(new EventHandler(Content_Refreshing), sender, e);
84      } else {
85        Cursor = Cursors.AppStarting;
86        refreshButton.Enabled = false;
87        tabControl.Enabled = false;
88      }
89    }
90    private void Content_Refreshed(object sender, EventArgs e) {
91      if (InvokeRequired) {
92        Invoke(new EventHandler(Content_Refreshed), sender, e);
93      } else {
94        platformCollectionView.Content = Content.Platforms;
95        algorithmClassCollectionView.Content = Content.AlgorithmClasses;
96        algorithmCollectionView.Content = Content.Algorithms;
97        problemClassCollectionView.Content = Content.ProblemClasses;
98        problemCollectionView.Content = Content.Problems;
99        refreshButton.Enabled = true;
100        tabControl.Enabled = true;
101        Cursor = Cursors.Default;
102      }
103    }
104
105    private void refreshButton_Click(object sender, EventArgs e) {
106      Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex)));
107    }
108  }
109}
Note: See TracBrowser for help on using the repository browser.