Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPEncodingView.cs @ 6440

Last change on this file since 6440 was 5445, checked in by swagner, 14 years ago

Updated year of copyrights (#1406)

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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
22using System;
23using System.Drawing;
24using System.Windows.Forms;
25using HeuristicLab.Core.Views;
26using HeuristicLab.Data;
27using HeuristicLab.MainForm;
28using HeuristicLab.Parameters;
29using HeuristicLab.Problems.VehicleRouting.Encodings;
30
31namespace HeuristicLab.Problems.VehicleRouting.Views {
32  /// <summary>
33  /// The base class for visual representations of items.
34  /// </summary>
35  [View("VRPEncoding View")]
36  [Content(typeof(IVRPEncoding), true)]
37  public sealed partial class VRPEncodingView : ItemView {
38    public new IVRPEncoding Content {
39      get { return (IVRPEncoding)base.Content; }
40      set { base.Content = value; }
41    }
42
43    public VRPEncodingView() {
44      InitializeComponent();
45    }
46
47    protected override void OnContentChanged() {
48      base.OnContentChanged();
49
50      if (Content != null) {
51        typeTextBox.Text = Content.GetType().Name;
52        valueTextBox.Text = Content.ToString();
53      } else {
54        typeTextBox.Text = string.Empty;
55        valueTextBox.Text = string.Empty;
56      }
57    }
58
59    protected override void RegisterContentEvents() {
60      base.RegisterContentEvents();
61
62      Content.ToStringChanged += new EventHandler(Content_ToStringChanged);
63    }
64
65    protected override void DeregisterContentEvents() {
66      base.DeregisterContentEvents();
67
68      Content.ToStringChanged -= new EventHandler(Content_ToStringChanged);
69    }
70
71    void Content_ToStringChanged(object sender, EventArgs e) {
72      if (InvokeRequired)
73        Invoke(new EventHandler(Content_ToStringChanged), sender, e);
74      else {
75        valueTextBox.Text = Content.ToString();
76      }
77    }
78
79  }
80}
Note: See TracBrowser for help on using the repository browser.