Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Server/3.3/DispatcherView.cs @ 2257

Last change on this file since 2257 was 2223, checked in by mkommend, 15 years ago

reintegrated branch new heuristic.modeling database backend (ticket #712)

File size: 2.7 KB
RevLine 
[2088]1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core;
10
11namespace HeuristicLab.CEDMA.Server {
12  public partial class DispatcherView : ViewBase {
13    private DispatcherBase dispatcher;
[2223]14    public DispatcherView(DispatcherBase dispatcher)
15      : base() {
[2088]16      this.dispatcher = dispatcher;
17      InitializeComponent();
18      UpdateControls();
[2094]19      dispatcher.Changed += (sender, args) => UpdateControls();
[2223]20      this.inputVariableList.CheckOnClick = true;
[2088]21    }
22
23    protected override void UpdateControls() {
[2153]24      if (InvokeRequired) {
25        Invoke((Action)UpdateControls);
26      } else {
27        base.UpdateControls();
28        targetVariableList.Items.Clear();
29        inputVariableList.Items.Clear();
[2088]30
[2153]31        foreach (string targetVar in dispatcher.TargetVariables) {
32          targetVariableList.Items.Add(targetVar, false);
33        }
[2088]34
[2153]35        foreach (string inputVar in dispatcher.InputVariables) {
36          inputVariableList.Items.Add(inputVar, false);
37        }
38        targetVariableList.ClearSelected();
39        inputVariableList.Enabled = false;
[2088]40      }
41    }
[2119]42
43    private void targetVariableList_ItemCheck(object sender, ItemCheckEventArgs e) {
44      if (e.NewValue == CheckState.Checked) {
45        dispatcher.EnableTargetVariable((string)targetVariableList.Items[e.Index]);
46      } else if (e.NewValue == CheckState.Unchecked) {
47        dispatcher.DisableTargetVariable((string)targetVariableList.Items[e.Index]);
48      }
49    }
50
51    private void inputVariableList_ItemCheck(object sender, ItemCheckEventArgs e) {
[2153]52      string selectedTarget = (string)targetVariableList.SelectedItem;
[2119]53      if (e.NewValue == CheckState.Checked) {
[2153]54        dispatcher.EnableInputVariable(selectedTarget, (string)inputVariableList.Items[e.Index]);
[2119]55      } else if (e.NewValue == CheckState.Unchecked) {
[2153]56        dispatcher.DisableInputVariable(selectedTarget, (string)inputVariableList.Items[e.Index]);
[2119]57      }
58    }
[2153]59
60    private void targetVariableList_SelectedValueChanged(object sender, EventArgs e) {
61      string selectedTarget = (string)targetVariableList.SelectedItem;
62      UpdateInputVariableList(selectedTarget);
63    }
64
65    private void UpdateInputVariableList(string target) {
66      inputVariableList.Items.Clear();
67      var activatedInputVariables = dispatcher.GetInputVariables(target);
68      foreach (string inputVar in dispatcher.InputVariables) {
69        inputVariableList.Items.Add(inputVar, activatedInputVariables.Contains(inputVar));
70      }
71      inputVariableList.Enabled = true;
72    }
[2088]73  }
74}
Note: See TracBrowser for help on using the repository browser.