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