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;
|
---|
14 | public DispatcherView(DispatcherBase dispatcher) : base() {
|
---|
15 | this.dispatcher = dispatcher;
|
---|
16 | InitializeComponent();
|
---|
17 | UpdateControls();
|
---|
18 | dispatcher.Changed += (sender, args) => UpdateControls();
|
---|
19 | }
|
---|
20 |
|
---|
21 | protected override void UpdateControls() {
|
---|
22 | if (InvokeRequired) {
|
---|
23 | Invoke((Action)UpdateControls);
|
---|
24 | } else {
|
---|
25 | base.UpdateControls();
|
---|
26 | targetVariableList.Items.Clear();
|
---|
27 | inputVariableList.Items.Clear();
|
---|
28 |
|
---|
29 | foreach (string targetVar in dispatcher.TargetVariables) {
|
---|
30 | targetVariableList.Items.Add(targetVar, false);
|
---|
31 | }
|
---|
32 |
|
---|
33 | foreach (string inputVar in dispatcher.InputVariables) {
|
---|
34 | inputVariableList.Items.Add(inputVar, false);
|
---|
35 | }
|
---|
36 | targetVariableList.ClearSelected();
|
---|
37 | inputVariableList.Enabled = false;
|
---|
38 | }
|
---|
39 | }
|
---|
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) {
|
---|
50 | string selectedTarget = (string)targetVariableList.SelectedItem;
|
---|
51 | if (e.NewValue == CheckState.Checked) {
|
---|
52 | dispatcher.EnableInputVariable(selectedTarget, (string)inputVariableList.Items[e.Index]);
|
---|
53 | } else if (e.NewValue == CheckState.Unchecked) {
|
---|
54 | dispatcher.DisableInputVariable(selectedTarget, (string)inputVariableList.Items[e.Index]);
|
---|
55 | }
|
---|
56 | }
|
---|
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 | }
|
---|
71 | }
|
---|
72 | }
|
---|