[8055] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[11171] | 3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[8055] | 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;
|
---|
| 25 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 26 | using HeuristicLab.PluginInfrastructure;
|
---|
| 27 |
|
---|
| 28 | namespace 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 | }
|
---|