Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/SingleObjectiveOKBSolutionView.cs @ 17399

Last change on this file since 17399 was 17181, checked in by swagner, 5 years ago

#2875: Merged r17180 from trunk to stable

File size: 3.4 KB
RevLine 
[13693]1#region License Information
2/* HeuristicLab
[17181]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[13693]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;
[17059]43      uploadButton.Image = VSImageLibrary.Save;
[13693]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.