Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HivePerformance/sources/HeuristicLab.Clients.Access.Views/3.3/ClientViews/ClientView.cs @ 9539

Last change on this file since 9539 was 9539, checked in by ascheibe, 11 years ago

#2030 merged changes of trunk into branch

File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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    private Progress progress;
38
39    public ClientView() {
40      InitializeComponent();
41      progress = new Progress() {
42        CanBeCanceled = false,
43        ProgressState = ProgressState.Finished
44      };
45    }
46
47    protected override void DeregisterContentEvents() {
48      if (progressView != null) {
49        progressView.Content = null;
50        progressView.Dispose();
51        progressView = null;
52      }
53      base.DeregisterContentEvents();
54    }
55
56    protected override void RegisterContentEvents() {
57      base.RegisterContentEvents();
58      progressView = new ProgressView(this, progress);
59    }
60
61    protected override void OnContentChanged() {
62      base.OnContentChanged();
63
64      if (Content == null) {
65        txtClientConfiguration.Text = string.Empty;
66        txtClientType.Text = string.Empty;
67        txtDescription.Text = string.Empty;
68        txtMemory.Text = string.Empty;
69        txtName.Text = string.Empty;
70        txtNumberOfCores.Text = string.Empty;
71        txtPerformanceValue.Text = string.Empty;
72        txtProcessor.Text = string.Empty;
73        txtTimestamp.Text = string.Empty;
74        txtVersion.Text = string.Empty;
75        txtId.Text = string.Empty;
76        txtOS.Text = string.Empty;
77      } else {
78        if (Content.ClientConfiguration != null) {
79          txtClientConfiguration.Text = Content.ClientConfiguration.Hash;
80        }
81        if (Content.ClientType != null) {
82          txtClientType.Text = Content.ClientType.Name;
83        }
84        if (Content.OperatingSystem != null) {
85          txtOS.Text = Content.OperatingSystem.Name;
86        }
87        txtDescription.Text = Content.Description;
88        txtMemory.Text = Content.MemorySize.ToString();
89        txtName.Text = Content.Name;
90        txtNumberOfCores.Text = Content.NumberOfCores.ToString();
91        txtPerformanceValue.Text = Content.PerformanceValue.ToString();
92        txtProcessor.Text = Content.ProcessorType;
93        txtTimestamp.Text = Content.Timestamp.ToShortDateString();
94        txtVersion.Text = Content.HeuristicLabVersion;
95        txtId.Text = Content.Id.ToString();
96      }
97    }
98
99    public void StartProgressView() {
100      if (InvokeRequired) {
101        Invoke(new Action(StartProgressView));
102      } else {
103        progress.Status = "Downloading client information. Please be patient.";
104        progress.ProgressState = ProgressState.Started;
105      }
106    }
107
108    public void FinishProgressView() {
109      if (InvokeRequired) {
110        Invoke(new Action(FinishProgressView));
111      } else {
112        progress.Finish();
113      }
114    }
115  }
116}
Note: See TracBrowser for help on using the repository browser.