Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2738_QAPGenerators/HeuristicLab.Problems.Instances.QAPGenerator.Views/3.3/TaibQAPInstanceGeneratorDescriptorView.cs @ 16752

Last change on this file since 16752 was 14704, checked in by abeham, 8 years ago

#2738: added branch

File size: 4.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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.ComponentModel;
24using HeuristicLab.MainForm;
25
26namespace HeuristicLab.Problems.Instances.QAPGenerator.Views {
27  [View("Tai-b QAP Instance Generator Descriptor View")]
28  [Content(typeof(TaibQAPInstanceGeneratorDescriptor), IsDefaultView = true)]
29  public partial class TaibQAPInstanceGeneratorDescriptorView : QAPInstanceGeneratorDescriptorView {
30
31    public new TaibQAPInstanceGeneratorDescriptor Content {
32      get { return (TaibQAPInstanceGeneratorDescriptor)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public TaibQAPInstanceGeneratorDescriptorView() {
37      InitializeComponent();
38    }
39
40    #region Event Handlers (Content)
41    protected override void ContentOnPropertyChanged(object sender, PropertyChangedEventArgs eventArgs) {
42      base.ContentOnPropertyChanged(sender, eventArgs);
43      SuppressEvents = true;
44      try {
45        switch (eventArgs.PropertyName) {
46          case "MaxClusterDistance":
47            globalRadiusNumericUpDown.Value = Content.MaxClusterDistance;
48            break;
49          case "MaxClusterSize":
50            clusterSizeNumericUpDown.Value = Content.MaxClusterSize;
51            break;
52          case "MaxClusterRadius":
53            clusterRadiusNumericUpDown.Value = Content.MaxClusterRadius;
54            break;
55          case "MinFlowExponent":
56            minFlowExponentNumericUpDown.Value = Content.MinFlowExponent;
57            break;
58          case "MaxFlowExponent":
59            maxFlowExponentNumericUpDown.Value = Content.MaxFlowExponent;
60            break;
61        }
62      } finally { SuppressEvents = false; }
63    }
64    #endregion
65
66    protected override void OnContentChanged() {
67      base.OnContentChanged();
68      SuppressEvents = true;
69      try {
70        if (Content == null) {
71          globalRadiusNumericUpDown.Value = 0;
72          clusterSizeNumericUpDown.Value = 0;
73          clusterRadiusNumericUpDown.Value = 0;
74          minFlowExponentNumericUpDown.Value = 0;
75          maxFlowExponentNumericUpDown.Value = 0;
76        } else {
77          globalRadiusNumericUpDown.Value = Content.MaxClusterDistance;
78          clusterSizeNumericUpDown.Value = Content.MaxClusterSize;
79          clusterRadiusNumericUpDown.Value = Content.MaxClusterRadius;
80          minFlowExponentNumericUpDown.Value = Content.MinFlowExponent;
81          maxFlowExponentNumericUpDown.Value = Content.MaxFlowExponent;
82        }
83      } finally { SuppressEvents = false; }
84    }
85
86
87    protected override void SetEnabledStateOfControls() {
88      base.SetEnabledStateOfControls();
89      globalRadiusNumericUpDown.Enabled = !Locked && !ReadOnly && Content != null;
90      clusterSizeNumericUpDown.Enabled = !Locked && !ReadOnly && Content != null;
91      clusterRadiusNumericUpDown.Enabled = !Locked && !ReadOnly && Content != null;
92      minFlowExponentNumericUpDown.Enabled = !Locked && !ReadOnly && Content != null;
93      maxFlowExponentNumericUpDown.Enabled = !Locked && !ReadOnly && Content != null;
94    }
95
96    #region Event Handlers (child controls)
97    protected virtual void globalRadiusNumericUpDown_ValueChanged(object sender, EventArgs e) {
98      if (SuppressEvents) return;
99      Content.MaxClusterDistance = (int)globalRadiusNumericUpDown.Value;
100    }
101
102    protected virtual void clusterSizeNumericUpDown_ValueChanged(object sender, EventArgs e) {
103      if (SuppressEvents) return;
104      Content.MaxClusterSize = (int)clusterSizeNumericUpDown.Value;
105    }
106
107    protected virtual void clusterRadiusNumericUpDown_ValueChanged(object sender, EventArgs e) {
108      if (SuppressEvents) return;
109      Content.MaxClusterRadius = (int)clusterRadiusNumericUpDown.Value;
110    }
111
112    protected virtual void minFlowExponentNumericUpDown_ValueChanged(object sender, EventArgs e) {
113      if (SuppressEvents) return;
114      Content.MinFlowExponent = (int)minFlowExponentNumericUpDown.Value;
115    }
116
117    protected virtual void maxFlowExponentNumericUpDown_ValueChanged(object sender, EventArgs e) {
118      if (SuppressEvents) return;
119      Content.MaxFlowExponent = (int)maxFlowExponentNumericUpDown.Value;
120    }
121    #endregion
122  }
123}
Note: See TracBrowser for help on using the repository browser.