Changeset 7415 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3
- Timestamp:
- 01/26/12 14:50:56 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.Designer.cs
r7412 r7415 47 47 this.assignmentTreeView = new System.Windows.Forms.TreeView(); 48 48 this.label1 = new System.Windows.Forms.Label(); 49 this.qualityTextBox = new System.Windows.Forms.TextBox(); 50 this.label2 = new System.Windows.Forms.Label(); 49 this.qualityLabel = new System.Windows.Forms.Label(); 50 this.assignmentGroupBox = new System.Windows.Forms.GroupBox(); 51 this.characteristicsGroupBox = new System.Windows.Forms.GroupBox(); 52 this.flowDistanceQualityLabel = new System.Windows.Forms.Label(); 53 this.label3 = new System.Windows.Forms.Label(); 54 this.installationQualityLabel = new System.Windows.Forms.Label(); 55 this.label5 = new System.Windows.Forms.Label(); 56 this.overbookedCapacityLabel = new System.Windows.Forms.Label(); 57 this.label7 = new System.Windows.Forms.Label(); 58 this.assignmentGroupBox.SuspendLayout(); 59 this.characteristicsGroupBox.SuspendLayout(); 51 60 this.SuspendLayout(); 52 61 // … … 56 65 | System.Windows.Forms.AnchorStyles.Left) 57 66 | System.Windows.Forms.AnchorStyles.Right))); 58 this.assignmentTreeView.Location = new System.Drawing.Point( 3, 50);67 this.assignmentTreeView.Location = new System.Drawing.Point(6, 19); 59 68 this.assignmentTreeView.Margin = new System.Windows.Forms.Padding(3, 6, 3, 3); 60 69 this.assignmentTreeView.Name = "assignmentTreeView"; 61 this.assignmentTreeView.Size = new System.Drawing.Size( 349, 331);70 this.assignmentTreeView.Size = new System.Drawing.Size(228, 331); 62 71 this.assignmentTreeView.TabIndex = 3; 63 72 // … … 65 74 // 66 75 this.label1.AutoSize = true; 67 this.label1.Location = new System.Drawing.Point(3, 7); 76 this.label1.Location = new System.Drawing.Point(6, 19); 77 this.label1.Margin = new System.Windows.Forms.Padding(3); 68 78 this.label1.Name = "label1"; 69 79 this.label1.Size = new System.Drawing.Size(42, 13); … … 71 81 this.label1.Text = "Quality:"; 72 82 // 73 // qualityTextBox 74 // 75 this.qualityTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 83 // qualityLabel 84 // 85 this.qualityLabel.AutoSize = true; 86 this.qualityLabel.Location = new System.Drawing.Point(91, 19); 87 this.qualityLabel.Margin = new System.Windows.Forms.Padding(3); 88 this.qualityLabel.Name = "qualityLabel"; 89 this.qualityLabel.Size = new System.Drawing.Size(10, 13); 90 this.qualityLabel.TabIndex = 4; 91 this.qualityLabel.Text = "-"; 92 // 93 // assignmentGroupBox 94 // 95 this.assignmentGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 96 | System.Windows.Forms.AnchorStyles.Left) 76 97 | System.Windows.Forms.AnchorStyles.Right))); 77 this.qualityTextBox.Location = new System.Drawing.Point(51, 4); 78 this.qualityTextBox.Name = "qualityTextBox"; 79 this.qualityTextBox.Size = new System.Drawing.Size(301, 20); 80 this.qualityTextBox.TabIndex = 1; 81 // 82 // label2 83 // 84 this.label2.AutoSize = true; 85 this.label2.Location = new System.Drawing.Point(3, 31); 86 this.label2.Name = "label2"; 87 this.label2.Size = new System.Drawing.Size(64, 13); 88 this.label2.TabIndex = 2; 89 this.label2.Text = "Assignment:"; 98 this.assignmentGroupBox.Controls.Add(this.assignmentTreeView); 99 this.assignmentGroupBox.Location = new System.Drawing.Point(217, 3); 100 this.assignmentGroupBox.Name = "assignmentGroupBox"; 101 this.assignmentGroupBox.Size = new System.Drawing.Size(240, 356); 102 this.assignmentGroupBox.TabIndex = 5; 103 this.assignmentGroupBox.TabStop = false; 104 this.assignmentGroupBox.Text = "Assignment"; 105 // 106 // characteristicsGroupBox 107 // 108 this.characteristicsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 109 | System.Windows.Forms.AnchorStyles.Left))); 110 this.characteristicsGroupBox.Controls.Add(this.label7); 111 this.characteristicsGroupBox.Controls.Add(this.overbookedCapacityLabel); 112 this.characteristicsGroupBox.Controls.Add(this.label5); 113 this.characteristicsGroupBox.Controls.Add(this.installationQualityLabel); 114 this.characteristicsGroupBox.Controls.Add(this.label3); 115 this.characteristicsGroupBox.Controls.Add(this.flowDistanceQualityLabel); 116 this.characteristicsGroupBox.Controls.Add(this.label1); 117 this.characteristicsGroupBox.Controls.Add(this.qualityLabel); 118 this.characteristicsGroupBox.Location = new System.Drawing.Point(3, 3); 119 this.characteristicsGroupBox.Name = "characteristicsGroupBox"; 120 this.characteristicsGroupBox.Size = new System.Drawing.Size(208, 356); 121 this.characteristicsGroupBox.TabIndex = 6; 122 this.characteristicsGroupBox.TabStop = false; 123 this.characteristicsGroupBox.Text = "Characteristics"; 124 // 125 // flowDistanceQualityLabel 126 // 127 this.flowDistanceQualityLabel.AutoSize = true; 128 this.flowDistanceQualityLabel.Location = new System.Drawing.Point(91, 38); 129 this.flowDistanceQualityLabel.Margin = new System.Windows.Forms.Padding(3); 130 this.flowDistanceQualityLabel.Name = "flowDistanceQualityLabel"; 131 this.flowDistanceQualityLabel.Size = new System.Drawing.Size(10, 13); 132 this.flowDistanceQualityLabel.TabIndex = 4; 133 this.flowDistanceQualityLabel.Text = "-"; 134 // 135 // label3 136 // 137 this.label3.AutoSize = true; 138 this.label3.Location = new System.Drawing.Point(6, 38); 139 this.label3.Margin = new System.Windows.Forms.Padding(3); 140 this.label3.Name = "label3"; 141 this.label3.Size = new System.Drawing.Size(79, 13); 142 this.label3.TabIndex = 0; 143 this.label3.Text = "Flow/Distance:"; 144 // 145 // installationQualityLabel 146 // 147 this.installationQualityLabel.AutoSize = true; 148 this.installationQualityLabel.Location = new System.Drawing.Point(91, 57); 149 this.installationQualityLabel.Margin = new System.Windows.Forms.Padding(3); 150 this.installationQualityLabel.Name = "installationQualityLabel"; 151 this.installationQualityLabel.Size = new System.Drawing.Size(10, 13); 152 this.installationQualityLabel.TabIndex = 4; 153 this.installationQualityLabel.Text = "-"; 154 // 155 // label5 156 // 157 this.label5.AutoSize = true; 158 this.label5.Location = new System.Drawing.Point(6, 57); 159 this.label5.Margin = new System.Windows.Forms.Padding(3); 160 this.label5.Name = "label5"; 161 this.label5.Size = new System.Drawing.Size(60, 13); 162 this.label5.TabIndex = 0; 163 this.label5.Text = "Installation:"; 164 // 165 // overbookedCapacityLabel 166 // 167 this.overbookedCapacityLabel.AutoSize = true; 168 this.overbookedCapacityLabel.Location = new System.Drawing.Point(91, 76); 169 this.overbookedCapacityLabel.Margin = new System.Windows.Forms.Padding(3); 170 this.overbookedCapacityLabel.Name = "overbookedCapacityLabel"; 171 this.overbookedCapacityLabel.Size = new System.Drawing.Size(10, 13); 172 this.overbookedCapacityLabel.TabIndex = 4; 173 this.overbookedCapacityLabel.Text = "-"; 174 // 175 // label7 176 // 177 this.label7.AutoSize = true; 178 this.label7.Location = new System.Drawing.Point(6, 76); 179 this.label7.Margin = new System.Windows.Forms.Padding(3); 180 this.label7.Name = "label7"; 181 this.label7.Size = new System.Drawing.Size(71, 13); 182 this.label7.TabIndex = 0; 183 this.label7.Text = "Overbooking:"; 90 184 // 91 185 // GQAPAssignmentView … … 93 187 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 94 188 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 95 this.Controls.Add(this.qualityTextBox); 96 this.Controls.Add(this.label2); 97 this.Controls.Add(this.label1); 98 this.Controls.Add(this.assignmentTreeView); 189 this.Controls.Add(this.characteristicsGroupBox); 190 this.Controls.Add(this.assignmentGroupBox); 99 191 this.Name = "GQAPAssignmentView"; 100 this.Size = new System.Drawing.Size(355, 384); 192 this.Size = new System.Drawing.Size(460, 362); 193 this.assignmentGroupBox.ResumeLayout(false); 194 this.characteristicsGroupBox.ResumeLayout(false); 195 this.characteristicsGroupBox.PerformLayout(); 101 196 this.ResumeLayout(false); 102 this.PerformLayout();103 197 104 198 } … … 108 202 private System.Windows.Forms.TreeView assignmentTreeView; 109 203 private System.Windows.Forms.Label label1; 110 private System.Windows.Forms.TextBox qualityTextBox; 111 private System.Windows.Forms.Label label2; 204 private System.Windows.Forms.Label qualityLabel; 205 private System.Windows.Forms.GroupBox assignmentGroupBox; 206 private System.Windows.Forms.GroupBox characteristicsGroupBox; 207 private System.Windows.Forms.Label label3; 208 private System.Windows.Forms.Label flowDistanceQualityLabel; 209 private System.Windows.Forms.Label label7; 210 private System.Windows.Forms.Label overbookedCapacityLabel; 211 private System.Windows.Forms.Label label5; 212 private System.Windows.Forms.Label installationQualityLabel; 112 213 } 113 214 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.cs
r7412 r7415 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 44 45 #region Register Content Events 45 46 protected override void DeregisterContentEvents() { 46 // TODO: Deregister your event handlers on the Content here47 Content.PropertyChanged -= new PropertyChangedEventHandler(Content_PropertyChanged); 47 48 base.DeregisterContentEvents(); 48 49 } 49 50 protected override void RegisterContentEvents() { 50 51 base.RegisterContentEvents(); 51 // TODO: Register your event handlers on the Content here52 Content.PropertyChanged += new PropertyChangedEventHandler(Content_PropertyChanged); 52 53 } 53 54 #endregion … … 55 56 protected override void OnContentChanged() { 56 57 base.OnContentChanged(); 57 assignmentTreeView.Nodes.Clear(); 58 if (Content == null) { 59 qualityTextBox.Text = String.Empty; 60 } else { 61 qualityTextBox.Text = Content.Quality.Value.ToString(); 62 BuildAssignmentTree(); 63 } 58 UpdateQuality(); 59 UpdateAssignment(); 64 60 } 65 61 66 62 protected override void SetEnabledStateOfControls() { 67 63 base.SetEnabledStateOfControls(); 68 qualityTextBox.Enabled = false;69 assignmentTreeView.Enabled = true;70 64 } 71 65 72 66 #region Event Handlers 73 // TODO: Put event handlers here 67 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 68 switch (e.PropertyName) { 69 case "Quality": UpdateQuality(); break; 70 case "FlowDistanceQuality": UpdateFlowDistanceQuality(); break; 71 case "InstallationQuality": UpdateInstallationQuality(); break; 72 case "OverbookedCapacity": UpdateOverbookedCapacity(); break; 73 case "Assignment": UpdateAssignment(); break; 74 case "EquipmentNames": UpdateAssignment(); break; 75 case "LocationNames": UpdateAssignment(); break; 76 default: break; 77 } 78 } 74 79 #endregion 75 80 76 private void BuildAssignmentTree() { 77 IntegerVector assignment = Content.Assignment; 78 Dictionary<int, TreeNode> locationNodes = new Dictionary<int, TreeNode>(); 79 for (int i = 0; i < assignment.Length; i++) { 80 if (!locationNodes.ContainsKey(assignment[i])) { 81 string locationName = assignment[i].ToString(); 82 if (Content.LocationNames != null && Content.LocationNames.Length > 0) 83 locationName = Content.LocationNames[assignment[i] % Content.LocationNames.Length]; 84 locationNodes.Add(assignment[i], new TreeNode(locationName)); 81 private void UpdateQuality() { 82 if (InvokeRequired) Invoke((Action)UpdateQuality); 83 else { 84 if (Content == null) { 85 qualityLabel.Text = "-"; 86 } else { 87 qualityLabel.Text = Content.Quality.ToString(); 85 88 } 86 string equipmentName = i.ToString();87 if (Content.EquipmentNames != null && Content.EquipmentNames.Length > 0)88 equipmentName = Content.EquipmentNames[i % Content.EquipmentNames.Length];89 locationNodes[assignment[i]].Nodes.Add(equipmentName);90 89 } 90 } 91 91 92 assignmentTreeView.BeginUpdate(); 93 try { 94 foreach (var node in locationNodes.OrderBy(x => x.Key).Select(x => x.Value)) { 95 assignmentTreeView.Nodes.Add(node); 96 node.Expand(); 92 private void UpdateFlowDistanceQuality() { 93 if (InvokeRequired) Invoke((Action)UpdateFlowDistanceQuality); 94 else { 95 if (Content == null || Content.FlowDistanceQuality == null) { 96 flowDistanceQualityLabel.Text = "-"; 97 } else { 98 flowDistanceQualityLabel.Text = Content.FlowDistanceQuality.ToString(); 97 99 } 98 } finally { assignmentTreeView.EndUpdate(); } 100 } 101 } 102 103 private void UpdateInstallationQuality() { 104 if (InvokeRequired) Invoke((Action)UpdateInstallationQuality); 105 else { 106 if (Content == null || Content.InstallationQuality == null) { 107 installationQualityLabel.Text = "-"; 108 } else { 109 installationQualityLabel.Text = Content.InstallationQuality.ToString(); 110 } 111 } 112 } 113 114 private void UpdateOverbookedCapacity() { 115 if (InvokeRequired) Invoke((Action)UpdateOverbookedCapacity); 116 else { 117 if (Content == null || Content.OverbookedCapacity == null) { 118 overbookedCapacityLabel.Text = "-"; 119 } else { 120 overbookedCapacityLabel.Text = Content.OverbookedCapacity.ToString(); 121 } 122 } 123 } 124 125 private void UpdateAssignment() { 126 if (InvokeRequired) Invoke((Action)UpdateAssignment); 127 else { 128 assignmentTreeView.Nodes.Clear(); 129 if (Content != null) { 130 IntegerVector assignment = Content.Assignment; 131 Dictionary<int, TreeNode> locationNodes = new Dictionary<int, TreeNode>(); 132 for (int i = 0; i < assignment.Length; i++) { 133 if (!locationNodes.ContainsKey(assignment[i])) { 134 string locationName = assignment[i].ToString(); 135 if (Content.LocationNames != null && Content.LocationNames.Length > assignment[i]) 136 locationName = Content.LocationNames[assignment[i]]; 137 locationNodes.Add(assignment[i], new TreeNode(locationName)); 138 } 139 string equipmentName = i.ToString(); 140 if (Content.EquipmentNames != null && Content.EquipmentNames.Length > i) 141 equipmentName = Content.EquipmentNames[i]; 142 locationNodes[assignment[i]].Nodes.Add(equipmentName); 143 } 144 145 assignmentTreeView.BeginUpdate(); 146 try { 147 foreach (var node in locationNodes.OrderBy(x => x.Key).Select(x => x.Value)) { 148 assignmentTreeView.Nodes.Add(node); 149 node.Expand(); 150 } 151 } finally { assignmentTreeView.EndUpdate(); } 152 } 153 } 99 154 } 100 155 }
Note: See TracChangeset
for help on using the changeset viewer.