source: branches/2839_HiveProjectManagement/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/SingleObjectiveOKBSolutionView.cs @ 16057

Last change on this file since 16057 was 16057, checked in by jkarder, 14 months ago

#2839:

File size: 3.4 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 HeuristicLab.Common.Resources;
23using HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25using System;
26using System.Globalization;
27
28namespace HeuristicLab.Clients.OKB.RunCreation.Views {
29  [View("OKB Solution View (single-objective)")]
30  [Content(typeof(SingleObjectiveOKBSolution), IsDefaultView = true)]
31  public partial class SingleObjectiveOKBSolutionView : ItemView {
32
33    public new SingleObjectiveOKBSolution Content {
34      get { return (SingleObjectiveOKBSolution)base.Content; }
35      set { base.Content = value; }
36    }
37
38    public SingleObjectiveOKBSolutionView() {
39      InitializeComponent();
40      refreshButton.Text = string.Empty;
41      refreshButton.Image = VSImageLibrary.Refresh;
42      uploadButton.Text = string.Empty;
43      uploadButton.Image = VSImageLibrary.Save;
44    }
45
46    protected override void RegisterContentEvents() {
47      base.RegisterContentEvents();
48      Content.QualityChanged += ContentOnQualityChanged;
49      Content.SolutionChanged += ContentOnSolutionChanged;
50    }
51
52    protected override void DeregisterContentEvents() {
53      base.DeregisterContentEvents();
54      Content.QualityChanged -= ContentOnQualityChanged;
55      Content.SolutionChanged -= ContentOnSolutionChanged;
56    }
57
58    protected override void OnContentChanged() {
59      base.OnContentChanged();
60      if (Content == null) {
61        qualityTextBox.Text = string.Empty;
62        solutionViewHost.Content = null;
63      } else {
64        qualityTextBox.Text = Content.Quality.ToString(CultureInfo.CurrentCulture.NumberFormat);
65        solutionViewHost.Content = Content.Solution;
66      }
67    }
68
69    protected override void SetEnabledStateOfControls() {
70      base.SetEnabledStateOfControls();
71      refreshButton.Enabled = Content != null & !Locked && !ReadOnly && Content.SolutionId != -1;
72      uploadButton.Enabled = Content != null && !Locked && !ReadOnly && Content.SolutionId == -1;
73    }
74
75    private void ContentOnSolutionChanged(object sender, EventArgs eventArgs) {
76      solutionViewHost.Content = Content.Solution;
77    }
78
79    private void ContentOnQualityChanged(object sender, EventArgs eventArgs) {
80      qualityTextBox.Text = Content.Quality.ToString(CultureInfo.CurrentCulture.NumberFormat);
81    }
82
83    private void refreshButton_Click(object sender, System.EventArgs e) {
84      Content.Download(Content.SolutionId);
85      SetEnabledStateOfControls();
86    }
87
88    private void uploadButton_Click(object sender, System.EventArgs e) {
89      Content.Upload();
90      SetEnabledStateOfControls();
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.