Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/OptimizationKnowledgeCenter.cs @ 13745

Last change on this file since 13745 was 13722, checked in by abeham, 9 years ago

#2457:

  • Renamed remaining files from ExpertSystem to KnowledgeCenter
  • Added ability to scatter plot to display a regression line
  • Allowed to execute multiple instances at once and displaying either only final result or tracking result
  • Split runs in seeded runs and instance runs
File size: 3.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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;
23using HeuristicLab.MainForm;
24using HeuristicLab.MainForm.WindowsForms;
25using HeuristicLab.OptimizationExpertSystem.Common;
26using System;
27using System.Windows.Forms;
28
29namespace HeuristicLab.OptimizationExpertSystem {
30  public partial class OptimizationKnowledgeCenter : DockingMainForm {
31    private ToolStripProgressBar progressBar;
32    private ToolStripLabel progressLabel;
33
34    public KnowledgeCenter ExpertSystem { get; private set; }
35   
36    public OptimizationKnowledgeCenter(Type userInterfaceType) : base(userInterfaceType) {
37      InitializeComponent();
38      ExpertSystem = new KnowledgeCenter();
39      ExpertSystem.DownloadStarted += ExpertSystemOnDownloadStarted;
40      ShowContentInViewHost = false;
41    }
42
43    private void ExpertSystemOnDownloadStarted(object sender, EventArgs<IProgress> e) {
44      e.Value.ProgressStateChanged += OnProgressStateChanged;
45      e.Value.ProgressValueChanged += OnProgressValueChanged;
46      e.Value.StatusChanged += OnProgressStatusChanged;
47      progressBar.Value = progressBar.Minimum;
48      progressLabel.Text = string.Empty;
49      progressBar.Visible = true;
50      progressLabel.Visible = true;
51    }
52
53    private void OnProgressStateChanged(object sender, EventArgs e) {
54      var progress = (IProgress)sender;
55      if (progress.ProgressState == ProgressState.Canceled
56          || progress.ProgressState == ProgressState.Finished) {
57        progress.ProgressStateChanged -= OnProgressStateChanged;
58        progress.ProgressValueChanged -= OnProgressValueChanged;
59        progress.StatusChanged -= OnProgressStatusChanged;
60        progressBar.Visible = false;
61        progressLabel.Visible = false;
62      }
63    }
64
65    private void OnProgressValueChanged(object sender, EventArgs e) {
66      var progress = (IProgress)sender;
67      progressBar.Value = Math.Max(progressBar.Minimum, Math.Min(progressBar.Maximum, (int)(progress.ProgressValue * 100)));
68    }
69
70    private void OnProgressStatusChanged(object sender, EventArgs e) {
71      var progress = (IProgress)sender;
72      progressLabel.Text = progress.Status.Replace(Environment.NewLine, "   ");
73    }
74
75    protected override void AdditionalCreationOfGuiElements() {
76      base.AdditionalCreationOfGuiElements();
77      progressBar = new ToolStripProgressBar();
78      statusStrip.Items.Add(progressBar);
79      progressLabel = new ToolStripLabel();
80      statusStrip.Items.Add(progressLabel);
81    }
82
83    private void OptimizationExpertSystem_Load(object sender, EventArgs e) {
84      ShowContent(ExpertSystem.Problem);
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.