[6662] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.ComponentModel;
|
---|
| 4 | using System.Data;
|
---|
| 5 | using System.Drawing;
|
---|
| 6 | using System.Linq;
|
---|
| 7 | using System.Text;
|
---|
| 8 | using System.Windows.Forms;
|
---|
| 9 | using HeuristicLab.Common;
|
---|
| 10 | using HeuristicLab.Core;
|
---|
| 11 | using HeuristicLab.Core.Views;
|
---|
| 12 | using HeuristicLab.MainForm;
|
---|
| 13 |
|
---|
| 14 | namespace HeuristicLab.Optimization.Views {
|
---|
| 15 |
|
---|
| 16 | [View("RunCollection Calculator View")]
|
---|
| 17 | [Content(typeof(RunCollectionModificationEvaluator), IsDefaultView = true)]
|
---|
| 18 | public sealed partial class RunCollectionModificationEvaluatorView : NamedItemView {
|
---|
| 19 |
|
---|
| 20 | public new RunCollectionModificationEvaluator Content {
|
---|
| 21 | get { return (RunCollectionModificationEvaluator)base.Content; }
|
---|
| 22 | set { base.Content = value; }
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public RunCollectionModificationEvaluatorView() {
|
---|
| 26 | InitializeComponent();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | protected override void DeregisterContentEvents() {
|
---|
| 30 | Content.RunCollectionParameter.ValueChanged -= new EventHandler(RunCollection_Changed);
|
---|
| 31 | Content.ModifiersParameter.ValueChanged -= new EventHandler(Modifiers_Changed);
|
---|
| 32 | base.DeregisterContentEvents();
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | protected override void RegisterContentEvents() {
|
---|
| 36 | base.RegisterContentEvents();
|
---|
| 37 | Content.RunCollectionParameter.ValueChanged += new EventHandler(RunCollection_Changed);
|
---|
| 38 | Content.ModifiersParameter.ValueChanged += new EventHandler(Modifiers_Changed);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | #region Event Handlers (Content)
|
---|
| 42 | private void RunCollection_Changed(object sender, EventArgs args) {
|
---|
| 43 | if (InvokeRequired)
|
---|
| 44 | Invoke(new EventHandler(RunCollection_Changed), sender, args);
|
---|
| 45 | else
|
---|
| 46 | runCollectionViewHost.Content = Content.RunCollection;
|
---|
| 47 | }
|
---|
| 48 | private void Modifiers_Changed(object sender, EventArgs args) {
|
---|
| 49 | if (InvokeRequired)
|
---|
| 50 | Invoke(new EventHandler(Modifiers_Changed), sender, args);
|
---|
| 51 | else
|
---|
| 52 | modifiersViewHost.Content = Content.Modifiers;
|
---|
| 53 | }
|
---|
| 54 | #endregion
|
---|
| 55 |
|
---|
| 56 | protected override void OnContentChanged() {
|
---|
| 57 | base.OnContentChanged();
|
---|
| 58 | if (Content == null) {
|
---|
| 59 | runCollectionViewHost.Content = null;
|
---|
| 60 | modifiersViewHost.Content = null;
|
---|
| 61 | } else {
|
---|
| 62 | runCollectionViewHost.Content = Content.RunCollection;
|
---|
| 63 | modifiersViewHost.Content = Content.Modifiers;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | protected override void SetEnabledStateOfControls() {
|
---|
| 68 | base.SetEnabledStateOfControls();
|
---|
| 69 | evaluateButton.Enabled = Content != null;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | #region Event Handlers (child controls)
|
---|
| 73 | private void evaluateButton_Click(object sender, EventArgs e) {
|
---|
| 74 | evaluateButton.Enabled = false;
|
---|
| 75 | var worker = new BackgroundWorker();
|
---|
| 76 | worker.DoWork += (s, a) => Content.Evaluate();
|
---|
| 77 | worker.RunWorkerCompleted += (s, a) => { evaluateButton.Enabled = Content != null; };
|
---|
| 78 | worker.RunWorkerAsync();
|
---|
| 79 | }
|
---|
| 80 | #endregion
|
---|
| 81 |
|
---|
| 82 | }
|
---|
| 83 | }
|
---|