1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using System.Drawing;
|
---|
26 | using System.Data;
|
---|
27 | using System.Text;
|
---|
28 | using System.Windows.Forms;
|
---|
29 | using HeuristicLab.Core;
|
---|
30 | using HeuristicLab.Data;
|
---|
31 |
|
---|
32 | namespace HeuristicLab.Communication.Data {
|
---|
33 | public partial class ProtocolStateView : ViewBase {
|
---|
34 | public ProtocolState ProtocolState {
|
---|
35 | get { return (ProtocolState)Item; }
|
---|
36 | set { base.Item = value; }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public ProtocolStateView() {
|
---|
40 | InitializeComponent();
|
---|
41 | }
|
---|
42 | public ProtocolStateView(ProtocolState protocolState)
|
---|
43 | : this() {
|
---|
44 | ProtocolState = protocolState;
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected override void RemoveItemEvents() {
|
---|
48 | nameTextBox.DataBindings.Clear();
|
---|
49 | giveBatchCheckBox.DataBindings.Clear();
|
---|
50 | expectBatchCheckBox.DataBindings.Clear();
|
---|
51 | ProtocolState.Changed -= new EventHandler(ProtocolState_Changed);
|
---|
52 | base.RemoveItemEvents();
|
---|
53 | }
|
---|
54 | protected override void AddItemEvents() {
|
---|
55 | base.AddItemEvents();
|
---|
56 | ProtocolState.Changed += new EventHandler(ProtocolState_Changed);
|
---|
57 | expectBatchCheckBox.DataBindings.Add("Checked", ProtocolState, "ExpectBatch");
|
---|
58 | giveBatchCheckBox.DataBindings.Add("Checked", ProtocolState, "GiveBatch");
|
---|
59 | nameTextBox.DataBindings.Add("Text", ProtocolState, "Name");
|
---|
60 | }
|
---|
61 |
|
---|
62 | protected override void UpdateControls() {
|
---|
63 | base.UpdateControls();
|
---|
64 | if (ProtocolState == null) {
|
---|
65 | nameTextBox.Enabled = false;
|
---|
66 | communicationDataTabControl.Enabled = false;
|
---|
67 | giveItemListView.ItemList = null;
|
---|
68 | expectItemListView.ItemList = null;
|
---|
69 | } else {
|
---|
70 | nameTextBox.Text = ProtocolState.Name;
|
---|
71 | giveBatchCheckBox.Checked = ProtocolState.GiveBatch;
|
---|
72 | expectBatchCheckBox.Checked = ProtocolState.ExpectBatch;
|
---|
73 |
|
---|
74 | giveItemListView.ItemList = ProtocolState.Give;
|
---|
75 | expectItemListView.ItemList = ProtocolState.Expect;
|
---|
76 |
|
---|
77 | communicationDataTabControl.Enabled = true;
|
---|
78 | nameTextBox.Enabled = true;
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 | #region ProtocolState change handling (main underlying object)
|
---|
83 | void ProtocolState_Changed(object sender, EventArgs e) {
|
---|
84 | Refresh();
|
---|
85 | }
|
---|
86 | #endregion
|
---|
87 |
|
---|
88 | }
|
---|
89 | }
|
---|