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