[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;
|
---|
[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 | }
|
---|