- Timestamp:
- 06/16/15 16:30:05 (9 years ago)
- Location:
- branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.Designer.cs
r12388 r12459 58 58 this.sizeComboBox = new System.Windows.Forms.ComboBox(); 59 59 this.sizeLabel = new System.Windows.Forms.Label(); 60 this.sourceLabel = new System.Windows.Forms.Label(); 61 this.levelNumericUpDown = new System.Windows.Forms.NumericUpDown(); 62 this.includeChildrenCheckBox = new System.Windows.Forms.CheckBox(); 60 63 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 61 64 this.childrenGroupBox.SuspendLayout(); … … 64 67 this.splitContainer.Panel2.SuspendLayout(); 65 68 this.splitContainer.SuspendLayout(); 69 ((System.ComponentModel.ISupportInitialize)(this.levelNumericUpDown)).BeginInit(); 66 70 this.SuspendLayout(); 67 71 // … … 69 73 // 70 74 this.yLabel.AutoSize = true; 71 this.yLabel.Location = new System.Drawing.Point(3 , 6);75 this.yLabel.Location = new System.Drawing.Point(305, 6); 72 76 this.yLabel.Name = "yLabel"; 73 77 this.yLabel.Size = new System.Drawing.Size(15, 13); … … 79 83 this.xLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 80 84 this.xLabel.AutoSize = true; 81 this.xLabel.Location = new System.Drawing.Point( 461, 586);85 this.xLabel.Location = new System.Drawing.Point(725, 713); 82 86 this.xLabel.Name = "xLabel"; 83 87 this.xLabel.Size = new System.Drawing.Size(15, 13); … … 101 105 series2.YValuesPerPoint = 2; 102 106 this.chart.Series.Add(series2); 103 this.chart.Size = new System.Drawing.Size( 663, 541);107 this.chart.Size = new System.Drawing.Size(880, 668); 104 108 this.chart.TabIndex = 7; 109 this.chart.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(this.chart_AxisViewChanged); 105 110 // 106 111 // yAxisComboBox … … 108 113 this.yAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 109 114 this.yAxisComboBox.FormattingEnabled = true; 110 this.yAxisComboBox.Location = new System.Drawing.Point( 24, 3);115 this.yAxisComboBox.Location = new System.Drawing.Point(326, 3); 111 116 this.yAxisComboBox.Name = "yAxisComboBox"; 112 117 this.yAxisComboBox.Size = new System.Drawing.Size(340, 21); … … 119 124 this.xAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 120 125 this.xAxisComboBox.FormattingEnabled = true; 121 this.xAxisComboBox.Location = new System.Drawing.Point( 482, 583);126 this.xAxisComboBox.Location = new System.Drawing.Point(746, 710); 122 127 this.xAxisComboBox.Name = "xAxisComboBox"; 123 128 this.xAxisComboBox.Size = new System.Drawing.Size(340, 21); … … 133 138 this.treeView.Location = new System.Drawing.Point(6, 19); 134 139 this.treeView.Name = "treeView"; 135 this.treeView.Size = new System.Drawing.Size(1 28, 516);140 this.treeView.Size = new System.Drawing.Size(175, 643); 136 141 this.treeView.TabIndex = 10; 137 142 this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterCheck); 143 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); 138 144 // 139 145 // childrenGroupBox … … 145 151 this.childrenGroupBox.Location = new System.Drawing.Point(3, 3); 146 152 this.childrenGroupBox.Name = "childrenGroupBox"; 147 this.childrenGroupBox.Size = new System.Drawing.Size(1 40, 541);153 this.childrenGroupBox.Size = new System.Drawing.Size(187, 668); 148 154 this.childrenGroupBox.TabIndex = 11; 149 155 this.childrenGroupBox.TabStop = false; … … 165 171 // 166 172 this.splitContainer.Panel2.Controls.Add(this.chart); 167 this.splitContainer.Size = new System.Drawing.Size( 819, 547);168 this.splitContainer.SplitterDistance = 1 46;173 this.splitContainer.Size = new System.Drawing.Size(1083, 674); 174 this.splitContainer.SplitterDistance = 193; 169 175 this.splitContainer.TabIndex = 12; 170 176 // … … 174 180 this.sizeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 175 181 this.sizeComboBox.FormattingEnabled = true; 176 this.sizeComboBox.Location = new System.Drawing.Point( 542, 3);182 this.sizeComboBox.Location = new System.Drawing.Point(806, 3); 177 183 this.sizeComboBox.Name = "sizeComboBox"; 178 184 this.sizeComboBox.Size = new System.Drawing.Size(280, 21); … … 184 190 this.sizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 185 191 this.sizeLabel.AutoSize = true; 186 this.sizeLabel.Location = new System.Drawing.Point( 470, 6);192 this.sizeLabel.Location = new System.Drawing.Point(734, 6); 187 193 this.sizeLabel.Name = "sizeLabel"; 188 194 this.sizeLabel.Size = new System.Drawing.Size(66, 13); … … 190 196 this.sizeLabel.Text = "Bubble Size:"; 191 197 // 198 // sourceLabel 199 // 200 this.sourceLabel.AutoSize = true; 201 this.sourceLabel.Location = new System.Drawing.Point(3, 6); 202 this.sourceLabel.Name = "sourceLabel"; 203 this.sourceLabel.Size = new System.Drawing.Size(36, 13); 204 this.sourceLabel.TabIndex = 15; 205 this.sourceLabel.Text = "Level:"; 206 // 207 // levelNumericUpDown 208 // 209 this.levelNumericUpDown.Location = new System.Drawing.Point(45, 4); 210 this.levelNumericUpDown.Name = "levelNumericUpDown"; 211 this.levelNumericUpDown.Size = new System.Drawing.Size(43, 20); 212 this.levelNumericUpDown.TabIndex = 16; 213 this.levelNumericUpDown.ValueChanged += new System.EventHandler(this.levelNumericUpDown_ValueChanged); 214 // 215 // includeChildrenCheckBox 216 // 217 this.includeChildrenCheckBox.AutoSize = true; 218 this.includeChildrenCheckBox.Location = new System.Drawing.Point(94, 4); 219 this.includeChildrenCheckBox.Name = "includeChildrenCheckBox"; 220 this.includeChildrenCheckBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes; 221 this.includeChildrenCheckBox.Size = new System.Drawing.Size(102, 17); 222 this.includeChildrenCheckBox.TabIndex = 17; 223 this.includeChildrenCheckBox.Text = "Include Children"; 224 this.includeChildrenCheckBox.UseVisualStyleBackColor = true; 225 this.includeChildrenCheckBox.CheckedChanged += new System.EventHandler(this.includeChildrenCheckBox_CheckedChanged); 226 // 192 227 // BubbleChartView 193 228 // … … 196 231 this.BackColor = System.Drawing.SystemColors.Window; 197 232 this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 233 this.Controls.Add(this.includeChildrenCheckBox); 234 this.Controls.Add(this.levelNumericUpDown); 235 this.Controls.Add(this.sourceLabel); 198 236 this.Controls.Add(this.sizeLabel); 199 237 this.Controls.Add(this.sizeComboBox); … … 204 242 this.Controls.Add(this.yAxisComboBox); 205 243 this.Name = "BubbleChartView"; 206 this.Size = new System.Drawing.Size( 825, 607);244 this.Size = new System.Drawing.Size(1089, 734); 207 245 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); 208 246 this.childrenGroupBox.ResumeLayout(false); … … 211 249 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 212 250 this.splitContainer.ResumeLayout(false); 251 ((System.ComponentModel.ISupportInitialize)(this.levelNumericUpDown)).EndInit(); 213 252 this.ResumeLayout(false); 214 253 this.PerformLayout(); … … 228 267 private System.Windows.Forms.ComboBox sizeComboBox; 229 268 private System.Windows.Forms.Label sizeLabel; 269 private System.Windows.Forms.Label sourceLabel; 270 private System.Windows.Forms.NumericUpDown levelNumericUpDown; 271 private System.Windows.Forms.CheckBox includeChildrenCheckBox; 230 272 } 231 273 } -
branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.cs
r12389 r12459 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Windows.Forms; … … 30 31 using HeuristicLab.Data; 31 32 using HeuristicLab.MainForm; 33 using HeuristicLab.MainForm.WindowsForms; 32 34 33 35 namespace HeuristicLab.Optimization.BubbleChart { … … 59 61 60 62 UpdateTreeView(); 63 UpdateLevelControl(); 64 61 65 UpdateComboBoxes(); 62 66 UpdateDataPoints(); 63 67 //UpdateCaption(); 64 68 } 69 protected override void SetEnabledStateOfControls() { 70 base.SetEnabledStateOfControls(); 71 levelNumericUpDown.Enabled = Content != null; 72 // ToDo 73 } 65 74 66 75 #region Tree Queries 76 77 private IEnumerable<RecursiveDataItem> GetAvailableItems() { 78 return IterateCheckedNodes() 79 .Select(n => (RecursiveDataItem)n.Tag); 80 } 67 81 private IEnumerable<string> GetAvailableKeys() { 68 var collector = new List<string>(); 69 foreach (TreeNode node in treeView.Nodes) 70 GetAvailableKeys(node, collector); 71 return collector.Distinct(); 72 } 73 private void GetAvailableKeys(TreeNode node, List<string> collector) { 74 var item = (RecursiveDataItem)node.Tag; 75 if (node.Checked) 76 collector.AddRange(item.Data.Keys); 77 foreach (TreeNode child in node.Nodes) 78 GetAvailableKeys(child, collector); 79 } 80 81 private IEnumerable<RecursiveDataItem> GetAvailableItems() { 82 var collector = new List<RecursiveDataItem>(); 83 foreach (TreeNode child in treeView.Nodes) 84 GetAvailableItems(child, collector); 85 return collector; 86 } 87 88 private void GetAvailableItems(TreeNode node, List<RecursiveDataItem> collector) { 89 var item = (RecursiveDataItem)node.Tag; 90 if (node.Checked) 91 collector.Add(item); 92 foreach (TreeNode child in node.Nodes) 93 GetAvailableItems(child, collector); 82 return GetAvailableItems() 83 .SelectMany(n => n.Data.Keys) 84 .Distinct(); 94 85 } 95 86 #endregion 96 87 97 88 #region Update Controls 89 private void UpdateLevelControl() { 90 if (Content == null) return; 91 if (treeView.Nodes.Count > 0) 92 levelNumericUpDown.Maximum = IterateAllNodes().Max(t => t.Level); 93 else 94 levelNumericUpDown.Maximum = 0; 95 } 96 98 97 private void UpdateTreeView() { 99 98 treeView.Nodes.Clear(); 100 101 if (Content != null) { 99 if (Content != null) 102 100 treeView.Nodes.Add(CreateTreeNode(Content)); 103 }104 105 101 treeView.ExpandAll(); 106 102 splitContainer.Panel1Collapsed = treeView.Nodes.Count == 0; 103 if (treeView.Nodes.Count > 0) 104 treeView.SelectedNode = treeView.Nodes[0]; 107 105 } 108 106 private TreeNode CreateTreeNode(RecursiveDataItem item) { … … 114 112 node.Nodes.Add(CreateTreeNode(child)); 115 113 return node; 114 } 115 116 private void UpdateTreeViewCheckBoxes() { 117 int level = (int)levelNumericUpDown.Value; 118 bool includeChildren = includeChildrenCheckBox.Checked; 119 //treeView.BeginUpdate(); 120 foreach (var node in IterateAllNodes()) 121 node.Checked = includeChildren ? node.Level >= level : node.Level == level; 122 //treeView.EndUpdate(); 116 123 } 117 124 … … 240 247 switch (sizeDimension) { 241 248 case SizeDimension.Constant: 242 value = 2;249 value = 5; 243 250 break; 244 251 default: … … 258 265 } 259 266 } 267 268 private void UpdateAxisLabels() { 269 return; 270 Axis xAxis = chart.ChartAreas[0].AxisX; 271 Axis yAxis = chart.ChartAreas[0].AxisY; 272 //mkommend: combobox.SelectedIndex could not be used as this changes during hovering over possible values 273 var xSAxisSelected = xAxisValue == null ? null : (string)xAxisComboBox.SelectedItem; 274 var ySAxisSelected = yAxisValue == null ? null : (string)yAxisComboBox.SelectedItem; 275 SetCustomAxisLabels(xAxis, xSAxisSelected); 276 SetCustomAxisLabels(yAxis, ySAxisSelected); 277 if (xAxisValue != null) 278 xAxis.Title = xAxisValue; 279 if (yAxisValue != null) 280 yAxis.Title = yAxisValue; 281 } 282 private void chart_AxisViewChanged(object sender, System.Windows.Forms.DataVisualization.Charting.ViewEventArgs e) { 283 this.UpdateAxisLabels(); 284 } 285 private void SetCustomAxisLabels(Axis axis, string key) { 286 axis.CustomLabels.Clear(); 287 if (categoricalMapping.ContainsKey(key)) { 288 foreach (var pair in categoricalMapping[key]) { 289 string labelText = pair.Key.ToString(); 290 CustomLabel label = new CustomLabel(); 291 label.ToolTip = labelText; 292 if (labelText.Length > 25) 293 labelText = labelText.Substring(0, 25) + " ... "; 294 label.Text = labelText; 295 label.GridTicks = GridTickTypes.TickMark; 296 label.FromPosition = pair.Value - 0.5; 297 label.ToPosition = pair.Value + 0.5; 298 axis.CustomLabels.Add(label); 299 } 300 } else if (key != null && Content.Data[key] is TimeSpanValue) { 301 chart.ChartAreas[0].RecalculateAxesScale(); 302 for (double i = axis.Minimum; i <= axis.Maximum; i += axis.LabelStyle.Interval) { 303 TimeSpan time = TimeSpan.FromSeconds(i); 304 string x = string.Format("{0:00}:{1:00}:{2:00}", time.Hours, time.Minutes, time.Seconds); 305 axis.CustomLabels.Add(i - axis.LabelStyle.Interval / 2, i + axis.LabelStyle.Interval / 2, x); 306 } 307 } 308 } 309 310 private void UpdateNodeColors() { 311 var selectedDepth = treeView.SelectedNode != null ? treeView.SelectedNode.Level : (int?)null; 312 var selectedIndex = treeView.SelectedNode != null ? treeView.SelectedNode.Index : (int?)null; 313 foreach (TreeNode node in treeView.Nodes) { 314 UpdateNodeColor(node, selectedDepth, selectedIndex); 315 } 316 } 317 private void UpdateNodeColor(TreeNode node, int? depth, int? index) { 318 if (depth.HasValue && index.HasValue && node.Level == depth /*&& node.Index == index*/) 319 node.BackColor = Color.Yellow; 320 else 321 node.BackColor = Color.White; 322 foreach (TreeNode child in node.Nodes) 323 UpdateNodeColor(child, depth, index); 324 } 260 325 #endregion 261 326 … … 263 328 private void treeView_AfterCheck(object sender, TreeViewEventArgs e) { 264 329 UpdateComboBoxes(); 265 UpdateDataPoints(); 330 //UpdateDataPoints(); 331 } 332 private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { 333 //UpdateNodeColors(); 334 //UpdateComboBoxes(); 335 //UpdateDataPoints(); 266 336 } 267 337 … … 274 344 275 345 UpdateDataPoints(); 276 //UpdateAxisLabels(); 346 UpdateAxisLabels(); 347 } 348 349 private void includeChildrenCheckBox_CheckedChanged(object sender, EventArgs e) { 350 UpdateTreeViewCheckBoxes(); 351 UpdateComboBoxes(); 352 } 353 354 private void levelNumericUpDown_ValueChanged(object sender, EventArgs e) { 355 UpdateTreeViewCheckBoxes(); 356 UpdateComboBoxes(); 357 } 358 #endregion 359 360 #region Helpers 361 362 private IEnumerable<TreeNode> IterateAllNodes() { 363 return Collect(treeView.Nodes); 364 } 365 private IEnumerable<TreeNode> IterateCheckedNodes() { 366 return IterateAllNodes().Where(t => t.Checked); 367 } 368 private IEnumerable<TreeNode> Collect(TreeNodeCollection nodes) { 369 foreach (TreeNode node in nodes) { 370 yield return node; 371 foreach (var child in Collect(node.Nodes)) 372 yield return child; 373 } 277 374 } 278 375 #endregion
Note: See TracChangeset
for help on using the changeset viewer.