Free cookie consent management tool by TermsFeed Policy Generator

source: branches/histogram/HeuristicLab.Problems.ExternalEvaluation.Views/3.3/EvaluationCacheView.cs @ 6244

Last change on this file since 6244 was 6195, checked in by abeham, 13 years ago

#1465

  • updated branch with latest version of trunk
File size: 2.1 KB
Line 
1using System;
2using System.Windows.Forms;
3using HeuristicLab.Core.Views;
4using HeuristicLab.MainForm;
5
6namespace HeuristicLab.Problems.ExternalEvaluation.Views {
7
8  [View("EvaluationCacheView")]
9  [Content(typeof(EvaluationCache), IsDefaultView = true)]
10  public sealed partial class EvaluationCacheView : ParameterizedNamedItemView {
11
12    public new EvaluationCache Content {
13      get { return (EvaluationCache)base.Content; }
14      set { base.Content = value; }
15    }
16
17    public EvaluationCacheView() {
18      InitializeComponent();
19    }
20
21    protected override void DeregisterContentEvents() {
22      Content.SizeChanged -= new System.EventHandler(Content_StatusChanged);
23      Content.HitsChanged -= new System.EventHandler(Content_StatusChanged);
24      Content.ActiveEvalutionsChanged -= new EventHandler(Content_StatusChanged);
25      base.DeregisterContentEvents();
26    }
27
28    protected override void RegisterContentEvents() {
29      base.RegisterContentEvents();
30      Content.SizeChanged += new System.EventHandler(Content_StatusChanged);
31      Content.HitsChanged += new System.EventHandler(Content_StatusChanged);
32      Content.ActiveEvalutionsChanged += new EventHandler(Content_StatusChanged);
33    }
34
35    #region Event Handlers (Content)
36    void Content_StatusChanged(object sender, EventArgs e) {
37      if (InvokeRequired)
38        Invoke(new EventHandler(Content_StatusChanged), sender, e);
39      else
40        hits_sizeTextBox.Text = string.Format("{0}/{1} ({2} active)", Content.Hits, Content.Size, Content.ActiveEvaluations);
41    }
42
43    #endregion
44
45    protected override void OnContentChanged() {
46      base.OnContentChanged();
47      if (Content == null) {
48        hits_sizeTextBox.Text = "#/#";
49      } else {
50        Content_StatusChanged(this, EventArgs.Empty);
51      }
52    }
53
54    protected override void SetEnabledStateOfControls() {
55      base.SetEnabledStateOfControls();
56      clearButton.Enabled = !ReadOnly && Content != null;
57    }
58
59    #region Event Handlers (child controls)
60    private void clearButton_Click(object sender, EventArgs e) {
61      Content.Reset();
62    }
63    #endregion
64  }
65}
Note: See TracBrowser for help on using the repository browser.