Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Clients.Access.Views/3.3/ClientViews/ClientView.cs @ 8145

Last change on this file since 8145 was 8145, checked in by ascheibe, 12 years ago

#1762 implemented review comments:

  • removed self disposing. The progress view now reacts if a progress is set and Finish() is now called on the progress object and not the view.
  • Moved Cancel event from ProgressView to Progress
  • throw ArgumentNullException if the parent view is null
File size: 3.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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 HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26
27namespace HeuristicLab.Clients.Access.Views {
28  [View("Client View")]
29  [Content(typeof(Client), true)]
30  public partial class ClientView : ItemView {
31    public new Client Content {
32      get { return (Client)base.Content; }
33      set { base.Content = value; }
34    }
35
36    private ProgressView progressView;
37    IProgress progress;
38
39    public ClientView() {
40      InitializeComponent();
41      progressView = new ProgressView(this);
42    }
43
44    protected override void OnContentChanged() {
45      base.OnContentChanged();
46
47      if (Content == null) {
48        txtClientConfiguration.Text = string.Empty;
49        txtClientType.Text = string.Empty;
50        txtDescription.Text = string.Empty;
51        txtMemory.Text = string.Empty;
52        txtName.Text = string.Empty;
53        txtNumberOfCores.Text = string.Empty;
54        txtPerformanceValue.Text = string.Empty;
55        txtProcessor.Text = string.Empty;
56        txtTimestamp.Text = string.Empty;
57        txtVersion.Text = string.Empty;
58        txtId.Text = string.Empty;
59        txtOS.Text = string.Empty;
60      } else {
61        if (Content.ClientConfiguration != null) {
62          txtClientConfiguration.Text = Content.ClientConfiguration.Hash;
63        }
64        if (Content.ClientType != null) {
65          txtClientType.Text = Content.ClientType.Name;
66        }
67        if (Content.OperatingSystem != null) {
68          txtOS.Text = Content.OperatingSystem.Name;
69        }
70        txtDescription.Text = Content.Description;
71        txtMemory.Text = Content.MemorySize.ToString();
72        txtName.Text = Content.Name;
73        txtNumberOfCores.Text = Content.NumberOfCores.ToString();
74        txtPerformanceValue.Text = Content.PerformanceValue.ToString();
75        txtProcessor.Text = Content.ProcessorType;
76        txtTimestamp.Text = Content.Timestamp.ToShortDateString();
77        txtVersion.Text = Content.HeuristicLabVersion;
78        txtId.Text = Content.Id.ToString();
79      }
80    }
81
82    public void StartProgressView() {
83      if (InvokeRequired) {
84        Invoke(new Action(StartProgressView));
85      } else {
86        progress = new Progress();
87        progress.Status = "Downloading client information. Please be patient.";
88        progressView.Progress = progress;
89      }
90    }
91
92    public void FinishProgressView() {
93      if (InvokeRequired) {
94        Invoke(new Action(FinishProgressView));
95      } else {
96        progress.Finish();
97        SetEnabledStateOfControls();
98      }
99    }
100  }
101}
Note: See TracBrowser for help on using the repository browser.