Changeset 14388
- Timestamp:
- 11/11/16 16:16:40 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.Designer.cs
r14384 r14388 52 52 this.bodyScrollPanel = new System.Windows.Forms.Panel(); 53 53 this.bodyTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 54 this.sizeGroupBox = new System.Windows.Forms.GroupBox(); 55 this.heightLabel = new System.Windows.Forms.Label(); 56 this.widthLabel = new System.Windows.Forms.Label(); 57 this.heightTrackBar = new System.Windows.Forms.TrackBar(); 58 this.widthTrackBar = new System.Windows.Forms.TrackBar(); 54 59 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 55 60 this.splitContainer.Panel1.SuspendLayout(); … … 60 65 this.rowHeaderScrollPanel.SuspendLayout(); 61 66 this.bodyScrollPanel.SuspendLayout(); 67 this.sizeGroupBox.SuspendLayout(); 68 ((System.ComponentModel.ISupportInitialize)(this.heightTrackBar)).BeginInit(); 69 ((System.ComponentModel.ISupportInitialize)(this.widthTrackBar)).BeginInit(); 62 70 this.SuspendLayout(); 63 71 // 72 // checkedItemList 73 // 74 this.checkedItemList.Size = new System.Drawing.Size(113, 369); 75 // 64 76 // splitContainer 65 77 // 66 78 // 79 // splitContainer.Panel1 80 // 81 this.splitContainer.Panel1.Controls.Add(this.sizeGroupBox); 82 // 67 83 // splitContainer.Panel2 68 84 // 69 85 this.splitContainer.Panel2.Controls.Add(this.frameTableLayoutPanel); 86 this.splitContainer.Size = new System.Drawing.Size(863, 520); 87 this.splitContainer.SplitterDistance = 120; 70 88 // 71 89 // frameTableLayoutPanel … … 83 101 this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); 84 102 this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); 85 this.frameTableLayoutPanel.Size = new System.Drawing.Size(739, 5 17);103 this.frameTableLayoutPanel.Size = new System.Drawing.Size(739, 520); 86 104 this.frameTableLayoutPanel.TabIndex = 0; 87 105 // … … 120 138 this.rowHeaderScrollPanel.Margin = new System.Windows.Forms.Padding(0); 121 139 this.rowHeaderScrollPanel.Name = "rowHeaderScrollPanel"; 122 this.rowHeaderScrollPanel.Size = new System.Drawing.Size(40, 4 77);140 this.rowHeaderScrollPanel.Size = new System.Drawing.Size(40, 480); 123 141 this.rowHeaderScrollPanel.TabIndex = 4; 124 142 // … … 148 166 this.bodyScrollPanel.Margin = new System.Windows.Forms.Padding(0); 149 167 this.bodyScrollPanel.Name = "bodyScrollPanel"; 150 this.bodyScrollPanel.Size = new System.Drawing.Size(699, 4 77);168 this.bodyScrollPanel.Size = new System.Drawing.Size(699, 480); 151 169 this.bodyScrollPanel.TabIndex = 5; 152 170 this.bodyScrollPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bodyScrollPanel_Scroll); … … 168 186 this.bodyTableLayoutPanel.TabIndex = 0; 169 187 // 188 // sizeGroupBox 189 // 190 this.sizeGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 191 | System.Windows.Forms.AnchorStyles.Right))); 192 this.sizeGroupBox.Controls.Add(this.heightLabel); 193 this.sizeGroupBox.Controls.Add(this.widthLabel); 194 this.sizeGroupBox.Controls.Add(this.heightTrackBar); 195 this.sizeGroupBox.Controls.Add(this.widthTrackBar); 196 this.sizeGroupBox.Location = new System.Drawing.Point(4, 379); 197 this.sizeGroupBox.Name = "sizeGroupBox"; 198 this.sizeGroupBox.Size = new System.Drawing.Size(113, 124); 199 this.sizeGroupBox.TabIndex = 5; 200 this.sizeGroupBox.TabStop = false; 201 this.sizeGroupBox.Text = "Chart Size"; 202 // 203 // heightLabel 204 // 205 this.heightLabel.AutoSize = true; 206 this.heightLabel.Location = new System.Drawing.Point(6, 64); 207 this.heightLabel.Name = "heightLabel"; 208 this.heightLabel.Size = new System.Drawing.Size(41, 13); 209 this.heightLabel.TabIndex = 2; 210 this.heightLabel.Text = "Height:"; 211 // 212 // widthLabel 213 // 214 this.widthLabel.AutoSize = true; 215 this.widthLabel.Location = new System.Drawing.Point(6, 16); 216 this.widthLabel.Name = "widthLabel"; 217 this.widthLabel.Size = new System.Drawing.Size(38, 13); 218 this.widthLabel.TabIndex = 1; 219 this.widthLabel.Text = "Width:"; 220 // 221 // heightTrackBar 222 // 223 this.heightTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 224 | System.Windows.Forms.AnchorStyles.Right))); 225 this.heightTrackBar.LargeChange = 50; 226 this.heightTrackBar.Location = new System.Drawing.Point(6, 83); 227 this.heightTrackBar.Maximum = 100; 228 this.heightTrackBar.Name = "heightTrackBar"; 229 this.heightTrackBar.Size = new System.Drawing.Size(101, 45); 230 this.heightTrackBar.SmallChange = 10; 231 this.heightTrackBar.TabIndex = 0; 232 this.heightTrackBar.TickFrequency = 10; 233 this.heightTrackBar.Value = 20; 234 this.heightTrackBar.ValueChanged += new System.EventHandler(this.heightTrackBar_ValueChanged); 235 // 236 // widthTrackBar 237 // 238 this.widthTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 239 | System.Windows.Forms.AnchorStyles.Right))); 240 this.widthTrackBar.LargeChange = 50; 241 this.widthTrackBar.Location = new System.Drawing.Point(6, 32); 242 this.widthTrackBar.Maximum = 100; 243 this.widthTrackBar.Name = "widthTrackBar"; 244 this.widthTrackBar.Size = new System.Drawing.Size(101, 45); 245 this.widthTrackBar.SmallChange = 10; 246 this.widthTrackBar.TabIndex = 0; 247 this.widthTrackBar.TickFrequency = 10; 248 this.widthTrackBar.Value = 20; 249 this.widthTrackBar.ValueChanged += new System.EventHandler(this.widthTrackBar_ValueChanged); 250 // 170 251 // ScatterPlotMultiView 171 252 // … … 173 254 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 174 255 this.Name = "ScatterPlotMultiView"; 175 this.Size = new System.Drawing.Size(863, 5 17);256 this.Size = new System.Drawing.Size(863, 520); 176 257 this.splitContainer.Panel1.ResumeLayout(false); 177 258 this.splitContainer.Panel2.ResumeLayout(false); … … 185 266 this.bodyScrollPanel.ResumeLayout(false); 186 267 this.bodyScrollPanel.PerformLayout(); 268 this.sizeGroupBox.ResumeLayout(false); 269 this.sizeGroupBox.PerformLayout(); 270 ((System.ComponentModel.ISupportInitialize)(this.heightTrackBar)).EndInit(); 271 ((System.ComponentModel.ISupportInitialize)(this.widthTrackBar)).EndInit(); 187 272 this.ResumeLayout(false); 188 273 … … 198 283 private System.Windows.Forms.Panel rowHeaderScrollPanel; 199 284 private System.Windows.Forms.Panel bodyScrollPanel; 285 private System.Windows.Forms.GroupBox sizeGroupBox; 286 private System.Windows.Forms.TrackBar widthTrackBar; 287 private System.Windows.Forms.TrackBar heightTrackBar; 288 private System.Windows.Forms.Label heightLabel; 289 private System.Windows.Forms.Label widthLabel; 200 290 } 201 291 } -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs
r14384 r14388 16 16 [Content(typeof(ScatterPlotContent), false)] 17 17 public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView { 18 private const int MaxAutoSizeElements = 6;19 private const int FixedChartWidth = 250;20 private const int FixedChartHeight = 150;21 22 18 private readonly IDictionary<string, Label> columnHeaderCache; 23 19 private readonly IDictionary<string, Label> rowHeaderCache; … … 27 23 InitializeComponent(); 28 24 25 #region Initialize Scrollbars 29 26 columnHeaderScrollPanel.HorizontalScroll.Enabled = true; 30 27 columnHeaderScrollPanel.VerticalScroll.Enabled = false; … … 42 39 bodyScrollPanel.VerticalScroll.Visible = true; 43 40 bodyScrollPanel.AutoScroll = true; 41 #endregion 44 42 45 43 columnHeaderCache = new Dictionary<string, Label>(); … … 72 70 } 73 71 72 #region Add and remove charts 74 73 private void AddChartToTable(string variable) { 75 76 } 77 // remove from headers and body and shift remaining slots to fill the gap 74 frameTableLayoutPanel.SuspendLayout(); 75 76 // find index to insert 77 var variables = checkedItemList.Content.Select(v => v.Value).ToList(); 78 int idx = variables // all variables 79 .TakeWhile(t => t != variable) // ... until the variable that was checked 80 .Count(IsVariableChecked); // ... how many checked variables 81 82 // add column header 83 var colH = columnHeaderTableLayoutPanel; 84 AddColumnHelper(colH, idx, _ => GetColumnHeader(variable)); 85 86 // add row header 87 var rowH = rowHeaderTableLayoutPanel; 88 AddRowHelper(rowH, idx, _ => GetRowHeader(variable)); 89 90 // add body 91 var body = bodyTableLayoutPanel; 92 var vars = GetCheckedVariables(); 93 var varsMinus = vars.Except(new[] { variable }).ToList(); 94 AddColumnHelper(body, idx, r => GetBody(variable, varsMinus[r])); // exclude "variable" because the row for it does not exist yet 95 AddRowHelper(body, idx, c => GetBody(vars[c], variable)); 96 97 frameTableLayoutPanel.ResumeLayout(true); 98 } 99 private void AddColumnHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) { 100 // add column 101 tlp.ColumnCount++; 102 tlp.ColumnStyles.Insert(idx, new ColumnStyle(SizeType.Absolute, GetColumnWidth())); 103 // shift right 104 for (int c = tlp.ColumnCount; c > idx - 1; c--) { 105 for (int r = 0; r < tlp.RowCount; r++) { 106 var control = tlp.GetControlFromPosition(c, r); 107 if (control != null) { 108 tlp.SetColumn(control, c + 1); 109 } 110 } 111 } 112 // add controls 113 for (int r = 0; r < tlp.RowCount; r++) { 114 if (tlp.GetControlFromPosition(idx, r) == null) 115 tlp.Controls.Add(creatorFunc(r), idx, r); 116 } 117 118 } 119 private void AddRowHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) { 120 // add row 121 tlp.RowCount++; 122 tlp.RowStyles.Insert(idx, new RowStyle(SizeType.Absolute, GetRowHeight())); 123 // shift right 124 for (int r = tlp.RowCount; r > idx - 1; r--) { 125 for (int c = 0; c < tlp.ColumnCount; c++) { 126 var control = tlp.GetControlFromPosition(c, r); 127 if (control != null) { 128 tlp.SetRow(control, r + 1); 129 } 130 } 131 } 132 // add controls 133 for (int c = 0; c < tlp.ColumnCount; c++) 134 if (tlp.GetControlFromPosition(c, idx) == null) 135 tlp.Controls.Add(creatorFunc(c), c, idx); 136 } 137 78 138 private void RemoveChartFromTable(string variable) { 79 139 frameTableLayoutPanel.SuspendLayout(); … … 96 156 frameTableLayoutPanel.ResumeLayout(true); 97 157 } 98 99 158 private void RemoveColumnHelper(TableLayoutPanel tlp, int idx) { 159 // remove controls 100 160 for (int r = 0; r < tlp.RowCount; r++) 101 161 tlp.Controls.Remove(tlp.GetControlFromPosition(idx, r)); 162 // shift left 102 163 for (int c = idx + 1; c < tlp.ColumnCount; c++) { 103 164 for (int r = 0; r < tlp.RowCount; r++) { … … 108 169 } 109 170 } 171 // delete column 110 172 tlp.ColumnStyles.RemoveAt(tlp.ColumnCount - 1); 111 173 tlp.ColumnCount--; 112 174 } 113 175 private void RemoveRowHelper(TableLayoutPanel tlp, int idx) { 176 // remove controls 114 177 for (int c = 0; c < tlp.ColumnCount; c++) 115 178 tlp.Controls.Remove(tlp.GetControlFromPosition(c, idx)); 179 // shift left 116 180 for (int r = idx + 1; r < tlp.RowCount; r++) { 117 181 for (int c = 0; c < tlp.ColumnCount; c++) { … … 122 186 } 123 187 } 188 // delete rows 124 189 tlp.RowStyles.RemoveAt(tlp.RowCount - 1); 125 190 tlp.RowCount--; 126 191 } 127 128 #region Add/Remove/Update Variable, Reset 192 #endregion 193 194 #region Add/Remove/Update Variable 129 195 protected override void AddVariable(string name) { 130 196 base.AddVariable(name); 131 } 132 197 if (IsVariableChecked(name)) 198 AddChartToTable(name); 199 } 133 200 protected override void RemoveVariable(string name) { 134 201 base.RemoveVariable(name); … … 147 214 protected override void UpdateVariable(string name) { 148 215 base.UpdateVariable(name); 216 RemoveVariable(name); 217 AddVariable(name); 149 218 } 150 219 protected override void ResetAllVariables() { … … 153 222 #endregion 154 223 155 156 #region Creating Header and Body 224 #region Creating Headers and Body 157 225 private Label GetColumnHeader(string variable) { 158 226 if (!columnHeaderCache.ContainsKey(variable)) { … … 214 282 #endregion 215 283 216 217 218 219 284 #region Generate Charts 220 285 private void GenerateCharts() { … … 238 303 239 304 // Set column and row layout 240 int width = variables.Count <= MaxAutoSizeElements ? bodyTableLayoutPanel.Width / variables.Count : FixedChartWidth;241 int height = variables.Count <= MaxAutoSizeElements ? bodyTableLayoutPanel.Height / variables.Count : FixedChartHeight;242 305 for (int i = 0; i < variables.Count; i++) { 243 columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width));244 rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, height));245 bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width));246 bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, height));306 columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, GetColumnWidth())); 307 rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, GetRowHeight())); 308 bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, GetColumnWidth())); 309 bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, GetRowHeight())); 247 310 } 248 311 … … 315 378 #endregion 316 379 380 #region Scrolling 317 381 private void bodyScrollPanel_Scroll(object sender, ScrollEventArgs e) { 318 382 SyncScroll(); … … 325 389 } 326 390 private void SyncScroll() { 327 //Debug.WriteLine("H: {0} <- {1}", columnHeaderScrollPanel.HorizontalScroll.Value, bodyScrollPanel.HorizontalScroll.Value);328 //Debug.WriteLine("V: {0} <- {1}", rowScrollLayoutPanel.VerticalScroll.Value, bodyScrollPanel.VerticalScroll.Value);329 330 391 frameTableLayoutPanel.SuspendRepaint(); 331 392 … … 344 405 frameTableLayoutPanel.ResumeRepaint(true); 345 406 } 346 347 407 // add a margin to the header table layouts if the scollbar is visible to account for the width/height of the scrollbar 348 408 private void UpdateHeaderMargin() { … … 350 410 rowHeaderScrollPanel.Margin = new Padding(0, 0, 0, bodyScrollPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0); 351 411 } 412 #endregion 413 414 #region Sizing of Charts 415 private int GetColumnWidth() { return (int)(bodyScrollPanel.Width * ((float)widthTrackBar.Value / 100)); } 416 private int GetRowHeight() { return (int)(bodyScrollPanel.Height * ((float)heightTrackBar.Value / 100)); } 417 private void widthTrackBar_ValueChanged(object sender, EventArgs e) { 418 frameTableLayoutPanel.SuspendRepaint(); 419 for (int i = 0; i < columnHeaderTableLayoutPanel.ColumnCount; i++) { 420 columnHeaderTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth(); 421 bodyTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth(); 422 } 423 frameTableLayoutPanel.ResumeRepaint(true); 424 } 425 private void heightTrackBar_ValueChanged(object sender, EventArgs e) { 426 frameTableLayoutPanel.SuspendRepaint(); 427 428 for (int i = 0; i < rowHeaderTableLayoutPanel.RowCount; i++) { 429 rowHeaderTableLayoutPanel.RowStyles[i].Height = GetRowHeight(); 430 bodyTableLayoutPanel.RowStyles[i].Height = GetRowHeight(); 431 } 432 frameTableLayoutPanel.ResumeRepaint(true); 433 } 434 #endregion 352 435 } 353 436 }
Note: See TracChangeset
for help on using the changeset viewer.