Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Communication.Data/ProtocolStateView.cs @ 820

Last change on this file since 820 was 704, checked in by abeham, 16 years ago

[TICKET #297] communication restructuring

File size: 3.0 KB
RevLine 
[591]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
[584]22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Text;
28using System.Windows.Forms;
29using HeuristicLab.Core;
30using HeuristicLab.Data;
31
32namespace 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() {
[704]48      nameTextBox.DataBindings.Clear();
49      giveBatchCheckBox.DataBindings.Clear();
50      expectBatchCheckBox.DataBindings.Clear();
[584]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);
[704]57      expectBatchCheckBox.DataBindings.Add("Checked", ProtocolState, "ExpectBatch");
58      giveBatchCheckBox.DataBindings.Add("Checked", ProtocolState, "GiveBatch");
59      nameTextBox.DataBindings.Add("Text", ProtocolState, "Name");
[584]60    }
61
62    protected override void UpdateControls() {
63      base.UpdateControls();
64      if (ProtocolState == null) {
[704]65        nameTextBox.Enabled = false;
66        communicationDataTabControl.Enabled = false;
67        giveItemListView.ItemList = null;
68        expectItemListView.ItemList = null;
[584]69      } else {
[704]70        nameTextBox.Text = ProtocolState.Name;
71        giveBatchCheckBox.Checked = ProtocolState.GiveBatch;
72        expectBatchCheckBox.Checked = ProtocolState.ExpectBatch;
[584]73
[704]74        giveItemListView.ItemList = ProtocolState.Give;
75        expectItemListView.ItemList = ProtocolState.Expect;
[584]76
[704]77        communicationDataTabControl.Enabled = true;
78        nameTextBox.Enabled = true;
[584]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}
Note: See TracBrowser for help on using the repository browser.