[4856] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[5445] | 3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4856] | 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.Drawing;
|
---|
| 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.Core.Views;
|
---|
| 26 | using HeuristicLab.Data;
|
---|
| 27 | using HeuristicLab.MainForm;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Problems.VehicleRouting.Encodings;
|
---|
| 30 |
|
---|
| 31 | namespace 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 | }
|
---|