Changeset 14384
- Timestamp:
- 11/11/16 12:26:14 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r14381 r14384 96 96 97 97 // not checked -> remove 98 if (! VariableIsChecked(variableName)) {98 if (!IsVariableChecked(variableName)) { 99 99 dataTableView.SetRowEnabled(variableName, false); 100 100 dataTable.SelectedRows.Remove(variableName); … … 305 305 dataTable.SelectedRows.Clear(); 306 306 foreach (var selectedRow in selectedDataRows) { 307 if ( VariableIsChecked(selectedRow.Name))307 if (IsVariableChecked(selectedRow.Name)) 308 308 dataTable.SelectedRows.Add(selectedRow); 309 309 } -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingCheckedVariablesView.cs
r14382 r14384 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 24 25 using System.Linq; … … 43 44 } 44 45 45 protected bool VariableIsChecked(string name) {46 protected bool IsVariableChecked(string name) { 46 47 return Content.VariableItemList.CheckedItems.Any(x => x.Value.Value == name); 47 48 } 48 49 protected IList<string> GetCheckedVariables() { 50 return checkedItemList.Content.CheckedItems.Select(i => i.Value.Value).ToList(); 51 } 49 52 50 53 protected override void OnContentChanged() { -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.Designer.cs
r14381 r14384 46 46 private void InitializeComponent() { 47 47 this.frameTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 48 this.columnHeaderScrollPanel = new System.Windows.Forms.Panel(); 48 49 this.columnHeaderTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 50 this.rowHeaderScrollPanel = new System.Windows.Forms.Panel(); 49 51 this.rowHeaderTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 52 this.bodyScrollPanel = new System.Windows.Forms.Panel(); 50 53 this.bodyTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 51 54 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); … … 54 57 this.splitContainer.SuspendLayout(); 55 58 this.frameTableLayoutPanel.SuspendLayout(); 59 this.columnHeaderScrollPanel.SuspendLayout(); 60 this.rowHeaderScrollPanel.SuspendLayout(); 61 this.bodyScrollPanel.SuspendLayout(); 56 62 this.SuspendLayout(); 57 63 // … … 68 74 this.frameTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F)); 69 75 this.frameTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); 70 this.frameTableLayoutPanel.Controls.Add(this.columnHeader TableLayoutPanel, 1, 0);71 this.frameTableLayoutPanel.Controls.Add(this.rowHeader TableLayoutPanel, 0, 1);72 this.frameTableLayoutPanel.Controls.Add(this.body TableLayoutPanel, 1, 1);76 this.frameTableLayoutPanel.Controls.Add(this.columnHeaderScrollPanel, 1, 0); 77 this.frameTableLayoutPanel.Controls.Add(this.rowHeaderScrollPanel, 0, 1); 78 this.frameTableLayoutPanel.Controls.Add(this.bodyScrollPanel, 1, 1); 73 79 this.frameTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 74 80 this.frameTableLayoutPanel.Location = new System.Drawing.Point(0, 0); … … 80 86 this.frameTableLayoutPanel.TabIndex = 0; 81 87 // 88 // columnHeaderScrollPanel 89 // 90 this.columnHeaderScrollPanel.Controls.Add(this.columnHeaderTableLayoutPanel); 91 this.columnHeaderScrollPanel.Dock = System.Windows.Forms.DockStyle.Fill; 92 this.columnHeaderScrollPanel.Location = new System.Drawing.Point(40, 0); 93 this.columnHeaderScrollPanel.Margin = new System.Windows.Forms.Padding(0); 94 this.columnHeaderScrollPanel.Name = "columnHeaderScrollPanel"; 95 this.columnHeaderScrollPanel.Size = new System.Drawing.Size(699, 40); 96 this.columnHeaderScrollPanel.TabIndex = 3; 97 // 82 98 // columnHeaderTableLayoutPanel 83 99 // 100 this.columnHeaderTableLayoutPanel.AutoSize = true; 101 this.columnHeaderTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 84 102 this.columnHeaderTableLayoutPanel.ColumnCount = 2; 85 103 this.columnHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 86 104 this.columnHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 87 this.columnHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 88 this.columnHeaderTableLayoutPanel.Location = new System.Drawing.Point(43, 3); 105 this.columnHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Left; 106 this.columnHeaderTableLayoutPanel.Location = new System.Drawing.Point(0, 0); 107 this.columnHeaderTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); 89 108 this.columnHeaderTableLayoutPanel.Name = "columnHeaderTableLayoutPanel"; 90 109 this.columnHeaderTableLayoutPanel.RowCount = 1; 91 110 this.columnHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 92 111 this.columnHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 93 this.columnHeaderTableLayoutPanel.Size = new System.Drawing.Size( 693, 34);112 this.columnHeaderTableLayoutPanel.Size = new System.Drawing.Size(0, 40); 94 113 this.columnHeaderTableLayoutPanel.TabIndex = 1; 95 114 // 115 // rowHeaderScrollPanel 116 // 117 this.rowHeaderScrollPanel.Controls.Add(this.rowHeaderTableLayoutPanel); 118 this.rowHeaderScrollPanel.Dock = System.Windows.Forms.DockStyle.Fill; 119 this.rowHeaderScrollPanel.Location = new System.Drawing.Point(0, 40); 120 this.rowHeaderScrollPanel.Margin = new System.Windows.Forms.Padding(0); 121 this.rowHeaderScrollPanel.Name = "rowHeaderScrollPanel"; 122 this.rowHeaderScrollPanel.Size = new System.Drawing.Size(40, 477); 123 this.rowHeaderScrollPanel.TabIndex = 4; 124 // 96 125 // rowHeaderTableLayoutPanel 97 126 // 127 this.rowHeaderTableLayoutPanel.AutoSize = true; 128 this.rowHeaderTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 98 129 this.rowHeaderTableLayoutPanel.ColumnCount = 1; 99 130 this.rowHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 100 131 this.rowHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 101 this.rowHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 102 this.rowHeaderTableLayoutPanel.Location = new System.Drawing.Point(3, 43); 132 this.rowHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Top; 133 this.rowHeaderTableLayoutPanel.Location = new System.Drawing.Point(0, 0); 134 this.rowHeaderTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); 103 135 this.rowHeaderTableLayoutPanel.Name = "rowHeaderTableLayoutPanel"; 104 136 this.rowHeaderTableLayoutPanel.RowCount = 2; 105 137 this.rowHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 106 138 this.rowHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 107 this.rowHeaderTableLayoutPanel.Size = new System.Drawing.Size( 34, 471);139 this.rowHeaderTableLayoutPanel.Size = new System.Drawing.Size(40, 0); 108 140 this.rowHeaderTableLayoutPanel.TabIndex = 2; 109 141 // 142 // bodyScrollPanel 143 // 144 this.bodyScrollPanel.AutoScroll = true; 145 this.bodyScrollPanel.Controls.Add(this.bodyTableLayoutPanel); 146 this.bodyScrollPanel.Dock = System.Windows.Forms.DockStyle.Fill; 147 this.bodyScrollPanel.Location = new System.Drawing.Point(40, 40); 148 this.bodyScrollPanel.Margin = new System.Windows.Forms.Padding(0); 149 this.bodyScrollPanel.Name = "bodyScrollPanel"; 150 this.bodyScrollPanel.Size = new System.Drawing.Size(699, 477); 151 this.bodyScrollPanel.TabIndex = 5; 152 this.bodyScrollPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bodyScrollPanel_Scroll); 153 // 110 154 // bodyTableLayoutPanel 111 155 // 156 this.bodyTableLayoutPanel.AutoSize = true; 157 this.bodyTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 112 158 this.bodyTableLayoutPanel.ColumnCount = 2; 113 159 this.bodyTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 114 160 this.bodyTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 115 this.bodyTableLayoutPanel. Dock = System.Windows.Forms.DockStyle.Fill;116 this.bodyTableLayoutPanel. Location = new System.Drawing.Point(43, 43);161 this.bodyTableLayoutPanel.Location = new System.Drawing.Point(0, 0); 162 this.bodyTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0); 117 163 this.bodyTableLayoutPanel.Name = "bodyTableLayoutPanel"; 118 164 this.bodyTableLayoutPanel.RowCount = 2; 119 165 this.bodyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 120 166 this.bodyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 121 this.bodyTableLayoutPanel.Size = new System.Drawing.Size( 693, 471);167 this.bodyTableLayoutPanel.Size = new System.Drawing.Size(0, 0); 122 168 this.bodyTableLayoutPanel.TabIndex = 0; 123 this.bodyTableLayoutPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bodyTableLayoutPanel_Scroll);124 169 // 125 170 // ScatterPlotMultiView … … 134 179 this.splitContainer.ResumeLayout(false); 135 180 this.frameTableLayoutPanel.ResumeLayout(false); 181 this.columnHeaderScrollPanel.ResumeLayout(false); 182 this.columnHeaderScrollPanel.PerformLayout(); 183 this.rowHeaderScrollPanel.ResumeLayout(false); 184 this.rowHeaderScrollPanel.PerformLayout(); 185 this.bodyScrollPanel.ResumeLayout(false); 186 this.bodyScrollPanel.PerformLayout(); 136 187 this.ResumeLayout(false); 137 188 … … 144 195 private System.Windows.Forms.TableLayoutPanel rowHeaderTableLayoutPanel; 145 196 private System.Windows.Forms.TableLayoutPanel bodyTableLayoutPanel; 197 private System.Windows.Forms.Panel columnHeaderScrollPanel; 198 private System.Windows.Forms.Panel rowHeaderScrollPanel; 199 private System.Windows.Forms.Panel bodyScrollPanel; 146 200 } 147 201 } -
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs
r14381 r14384 7 7 using HeuristicLab.Collections; 8 8 using HeuristicLab.Common; 9 using HeuristicLab.Core.Views; 9 10 using HeuristicLab.Data; 10 11 using HeuristicLab.MainForm; … … 15 16 [Content(typeof(ScatterPlotContent), false)] 16 17 public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView { 17 private const int MAX_AUTO_SIZE_ELEMENTS = 6; 18 private const int FIXED_CHART_WIDTH = 250; 19 private const int FIXED_CHART_HEIGHT = 150; 18 private const int MaxAutoSizeElements = 6; 19 private const int FixedChartWidth = 250; 20 private const int FixedChartHeight = 150; 21 22 private readonly IDictionary<string, Label> columnHeaderCache; 23 private readonly IDictionary<string, Label> rowHeaderCache; 24 private readonly IDictionary<Tuple<string/*col*/, string/*row*/>, ItemView> bodyCache; 20 25 21 26 public ScatterPlotMultiView() { 22 27 InitializeComponent(); 23 28 24 columnHeaderTableLayoutPanel.HorizontalScroll.Enabled = true; 25 columnHeaderTableLayoutPanel.VerticalScroll.Enabled = false; 26 columnHeaderTableLayoutPanel.HorizontalScroll.Visible = false; 27 columnHeaderTableLayoutPanel.VerticalScroll.Visible = false; 28 29 rowHeaderTableLayoutPanel.HorizontalScroll.Enabled = false; 30 rowHeaderTableLayoutPanel.VerticalScroll.Enabled = true; 31 rowHeaderTableLayoutPanel.HorizontalScroll.Visible = false; 32 rowHeaderTableLayoutPanel.VerticalScroll.Visible = false; 33 34 bodyTableLayoutPanel.HorizontalScroll.Enabled = true; 35 bodyTableLayoutPanel.VerticalScroll.Enabled = true; 36 bodyTableLayoutPanel.HorizontalScroll.Visible = true; 37 bodyTableLayoutPanel.VerticalScroll.Visible = true; 38 bodyTableLayoutPanel.AutoScroll = true; 39 40 bodyTableLayoutPanel.MouseWheel += bodyTableLayoutPanel_MouseWheel; 41 42 splitContainer.Panel1Collapsed = true; // ToDo: remove after correctly handling unchecks 29 columnHeaderScrollPanel.HorizontalScroll.Enabled = true; 30 columnHeaderScrollPanel.VerticalScroll.Enabled = false; 31 columnHeaderScrollPanel.HorizontalScroll.Visible = false; 32 columnHeaderScrollPanel.VerticalScroll.Visible = false; 33 34 rowHeaderScrollPanel.HorizontalScroll.Enabled = false; 35 rowHeaderScrollPanel.VerticalScroll.Enabled = true; 36 rowHeaderScrollPanel.HorizontalScroll.Visible = false; 37 rowHeaderScrollPanel.VerticalScroll.Visible = false; 38 39 bodyScrollPanel.HorizontalScroll.Enabled = true; 40 bodyScrollPanel.VerticalScroll.Enabled = true; 41 bodyScrollPanel.HorizontalScroll.Visible = true; 42 bodyScrollPanel.VerticalScroll.Visible = true; 43 bodyScrollPanel.AutoScroll = true; 44 45 columnHeaderCache = new Dictionary<string, Label>(); 46 rowHeaderCache = new Dictionary<string, Label>(); 47 bodyCache = new Dictionary<Tuple<string, string>, ItemView>(); 48 49 bodyScrollPanel.MouseWheel += bodyScrollPanel_MouseWheel; 43 50 } 44 51 … … 57 64 protected override void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) { 58 65 base.CheckedItemsChanged(sender, checkedItems); 59 66 foreach (var variable in checkedItems.Items.Select(i => i.Value.Value)) { 67 if (IsVariableChecked(variable)) 68 AddChartToTable(variable); 69 else 70 RemoveChartFromTable(variable); 71 } 72 } 73 74 private void AddChartToTable(string variable) { 75 76 } 77 // remove from headers and body and shift remaining slots to fill the gap 78 private void RemoveChartFromTable(string variable) { 79 frameTableLayoutPanel.SuspendLayout(); 80 81 // remove column header 82 var colH = columnHeaderTableLayoutPanel; 83 int colIdx = colH.GetColumn(colH.Controls[variable]); 84 RemoveColumnHelper(colH, colIdx); 85 86 // remove row header 87 var rowH = rowHeaderTableLayoutPanel; 88 int rowIdx = rowH.GetRow(rowH.Controls[variable]); 89 RemoveRowHelper(rowH, rowIdx); 90 91 // remove from body 92 var body = bodyTableLayoutPanel; 93 RemoveColumnHelper(body, colIdx); 94 RemoveRowHelper(body, rowIdx); 95 96 frameTableLayoutPanel.ResumeLayout(true); 97 } 98 99 private void RemoveColumnHelper(TableLayoutPanel tlp, int idx) { 100 for (int r = 0; r < tlp.RowCount; r++) 101 tlp.Controls.Remove(tlp.GetControlFromPosition(idx, r)); 102 for (int c = idx + 1; c < tlp.ColumnCount; c++) { 103 for (int r = 0; r < tlp.RowCount; r++) { 104 var control = tlp.GetControlFromPosition(c, r); 105 if (control != null) { 106 tlp.SetColumn(control, c - 1); 107 } 108 } 109 } 110 tlp.ColumnStyles.RemoveAt(tlp.ColumnCount - 1); 111 tlp.ColumnCount--; 112 } 113 private void RemoveRowHelper(TableLayoutPanel tlp, int idx) { 114 for (int c = 0; c < tlp.ColumnCount; c++) 115 tlp.Controls.Remove(tlp.GetControlFromPosition(c, idx)); 116 for (int r = idx + 1; r < tlp.RowCount; r++) { 117 for (int c = 0; c < tlp.ColumnCount; c++) { 118 var control = tlp.GetControlFromPosition(c, r); 119 if (control != null) { 120 tlp.SetRow(control, r - 1); 121 } 122 } 123 } 124 tlp.RowStyles.RemoveAt(tlp.RowCount - 1); 125 tlp.RowCount--; 60 126 } 61 127 … … 64 130 base.AddVariable(name); 65 131 } 132 66 133 protected override void RemoveVariable(string name) { 67 134 base.RemoveVariable(name); 68 135 136 // clear caches 137 columnHeaderCache.Remove(name); 138 rowHeaderCache.Remove(name); 139 var keys = bodyCache.Keys.Where(t => t.Item1 == name || t.Item2 == name).ToList(); 140 foreach (var key in keys) 141 bodyCache.Remove(key); 142 143 if (IsVariableChecked(name)) { 144 RemoveChartFromTable(name); 145 } 69 146 } 70 147 protected override void UpdateVariable(string name) { 71 148 base.UpdateVariable(name); 72 73 149 } 74 150 protected override void ResetAllVariables() { … … 77 153 #endregion 78 154 155 156 #region Creating Header and Body 157 private Label GetColumnHeader(string variable) { 158 if (!columnHeaderCache.ContainsKey(variable)) { 159 columnHeaderCache.Add(variable, new Label() { 160 Text = variable, 161 TextAlign = ContentAlignment.MiddleCenter, 162 Name = variable, 163 Height = columnHeaderTableLayoutPanel.Height, 164 Dock = DockStyle.Fill, 165 Margin = new Padding(3) 166 }); 167 } 168 return columnHeaderCache[variable]; 169 } 170 private Label GetRowHeader(string variable) { 171 if (!rowHeaderCache.ContainsKey(variable)) { 172 rowHeaderCache.Add(variable, new Label() { 173 Text = variable, 174 TextAlign = ContentAlignment.MiddleCenter, 175 Name = variable, 176 Width = rowHeaderTableLayoutPanel.Width, 177 Dock = DockStyle.Fill, 178 Margin = new Padding(3) 179 }); 180 } 181 return rowHeaderCache[variable]; 182 } 183 private ItemView GetBody(string colVariable, string rowVariable) { 184 var key = Tuple.Create(colVariable, rowVariable); 185 if (!bodyCache.ContainsKey(key)) { 186 if (rowVariable == colVariable) { // use historgram if x and y variable are equal 187 PreprocessingDataTable dataTable = new PreprocessingDataTable(); 188 DataRow dataRow = Content.CreateDataRow(rowVariable, DataRowVisualProperties.DataRowChartType.Histogram); 189 dataTable.Rows.Add(dataRow); 190 PreprocessingDataTableView pcv = new PreprocessingDataTableView { 191 Name = key.ToString(), 192 Content = dataTable, 193 Dock = DockStyle.Fill, 194 ShowLegend = false, 195 XAxisFormat = "G3" 196 }; 197 pcv.ChartDoubleClick += HistogramDoubleClick; 198 bodyCache.Add(key, pcv); 199 } else { //scatter plot 200 ScatterPlot scatterPlot = Content.CreateScatterPlot(colVariable, rowVariable); 201 PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView { 202 Name = key.ToString(), 203 Content = scatterPlot, 204 Dock = DockStyle.Fill, 205 ShowLegend = false, 206 XAxisFormat = "G3" 207 }; 208 pspv.ChartDoubleClick += ScatterPlotDoubleClick; 209 bodyCache.Add(key, pspv); 210 } 211 } 212 return bodyCache[key]; 213 } 214 #endregion 215 216 217 218 79 219 #region Generate Charts 80 220 private void GenerateCharts() { 81 List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList(); 82 var contentTableLayoutPanels = new[] { columnHeaderTableLayoutPanel, rowHeaderTableLayoutPanel, bodyTableLayoutPanel }; 83 84 // Clear table layouts 85 foreach (var tlp in contentTableLayoutPanels) { 86 tlp.Controls.Clear(); 87 //Clear out the existing row and column styles 88 tlp.ColumnStyles.Clear(); 89 tlp.RowStyles.Clear(); 90 } 221 var variables = GetCheckedVariables(); 222 223 // Clear old layouts and cache 224 foreach (var tableLayoutPanel in new[] { columnHeaderTableLayoutPanel, rowHeaderTableLayoutPanel, bodyTableLayoutPanel }) { 225 tableLayoutPanel.Controls.Clear(); 226 tableLayoutPanel.ColumnStyles.Clear(); 227 tableLayoutPanel.RowStyles.Clear(); 228 } 229 columnHeaderCache.Clear(); 230 rowHeaderCache.Clear(); 231 bodyCache.Clear(); 91 232 92 233 // Set row and column count 93 columnHeaderTableLayoutPanel.ColumnCount = variables.Count + 1;94 rowHeaderTableLayoutPanel.RowCount = variables.Count + 1;234 columnHeaderTableLayoutPanel.ColumnCount = variables.Count; 235 rowHeaderTableLayoutPanel.RowCount = variables.Count; 95 236 bodyTableLayoutPanel.ColumnCount = variables.Count; 96 237 bodyTableLayoutPanel.RowCount = variables.Count; 97 238 98 239 // Set column and row layout 99 int width = variables.Count <= M AX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Width / variables.Count : FIXED_CHART_WIDTH;100 int height = variables.Count <= M AX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Height / variables.Count : FIXED_CHART_HEIGHT;240 int width = variables.Count <= MaxAutoSizeElements ? bodyTableLayoutPanel.Width / variables.Count : FixedChartWidth; 241 int height = variables.Count <= MaxAutoSizeElements ? bodyTableLayoutPanel.Height / variables.Count : FixedChartHeight; 101 242 for (int i = 0; i < variables.Count; i++) { 102 243 columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width)); … … 106 247 } 107 248 108 //frameTableLayoutPanel.SuspendLayout();249 frameTableLayoutPanel.SuspendLayout(); 109 250 AddHeaderToTableLayoutPanels(); 110 251 AddChartsToTableLayoutPanel(); 111 //frameTableLayoutPanel.ResumeLayout(true); 252 UpdateHeaderMargin(); 253 frameTableLayoutPanel.ResumeLayout(true); 112 254 } 113 255 114 256 private void AddHeaderToTableLayoutPanels() { 115 List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList(); 116 int width = variables.Count <= MAX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Width / variables.Count : FIXED_CHART_WIDTH; 117 int height = variables.Count <= MAX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Height / variables.Count : FIXED_CHART_HEIGHT; 118 for (int i = 0; i < variables.Count; i++) { 119 columnHeaderTableLayoutPanel.Controls.Add(new Label() { 120 Text = variables[i], 121 TextAlign = ContentAlignment.MiddleCenter, 122 Width = width, 123 Height = columnHeaderTableLayoutPanel.Height, 124 Dock = DockStyle.Fill, 125 Margin = new Padding(3) 126 }, i, 0); 127 rowHeaderTableLayoutPanel.Controls.Add(new Label() { 128 Text = variables[i], 129 TextAlign = ContentAlignment.MiddleCenter, 130 Width = rowHeaderTableLayoutPanel.Width, 131 Height = height, 132 Dock = DockStyle.Fill, 133 Margin = new Padding(3) 134 }, 0, i); 135 } 136 137 // Add empty labels with fixed size to correct scollbar width/height in headers 138 columnHeaderTableLayoutPanel.Controls.Add(new Panel() { 139 Width = bodyTableLayoutPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0, 140 Height = columnHeaderTableLayoutPanel.Height, 141 Dock = DockStyle.Fill, 142 //BackColor = Color.DarkRed 143 }, variables.Count, 0); 144 rowHeaderTableLayoutPanel.Controls.Add(new Panel() { 145 Width = rowHeaderTableLayoutPanel.Width, 146 Height = bodyTableLayoutPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0, 147 Dock = DockStyle.Fill, 148 //BackColor = Color.DarkRed 149 }, 0, variables.Count); 257 int i = 0; 258 foreach (var variable in GetCheckedVariables()) { 259 columnHeaderTableLayoutPanel.Controls.Add(GetColumnHeader(variable), i, 0); 260 rowHeaderTableLayoutPanel.Controls.Add(GetRowHeader(variable), 0, i); 261 i++; 262 } 150 263 } 151 264 private void AddChartsToTableLayoutPanel() { 152 List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList(); 153 154 //set scatter plots and histograms 155 for (int x = 0; x < variables.Count; x++) { 156 for (int y = 0; y < variables.Count; y++) { 157 if (x == y) { // use historgram if x and y variable are equal 158 PreprocessingDataTable dataTable = new PreprocessingDataTable(); 159 DataRow dataRow = Content.CreateDataRow(variables[x], DataRowVisualProperties.DataRowChartType.Histogram); 160 dataTable.Rows.Add(dataRow); 161 PreprocessingDataTableView pcv = new PreprocessingDataTableView { 162 Content = dataTable, 163 Dock = DockStyle.Fill, 164 ShowLegend = false, 165 XAxisFormat = "G3" 166 }; 167 pcv.ChartDoubleClick += HistogramDoubleClick; 168 bodyTableLayoutPanel.Controls.Add(pcv, y, x); 169 } else { //scatter plot 170 ScatterPlot scatterPlot = Content.CreateScatterPlot(variables[x], variables[y]); 171 PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView { 172 Content = scatterPlot, 173 Dock = DockStyle.Fill, 174 ShowLegend = false, 175 XAxisFormat = "G3" 176 }; 177 pspv.ChartDoubleClick += ScatterPlotDoubleClick; 178 bodyTableLayoutPanel.Controls.Add(pspv, x, y); 179 } 180 } 265 int c = 0; 266 foreach (var colVar in GetCheckedVariables()) { 267 if (!IsVariableChecked(colVar)) continue; 268 int r = 0; 269 foreach (var rowVar in GetCheckedVariables()) { 270 if (!IsVariableChecked(rowVar)) continue; 271 bodyTableLayoutPanel.Controls.Add(GetBody(colVar, rowVar), c, r); 272 r++; 273 } 274 c++; 181 275 } 182 276 } … … 221 315 #endregion 222 316 223 private void body TableLayoutPanel_Scroll(object sender, ScrollEventArgs e) {317 private void bodyScrollPanel_Scroll(object sender, ScrollEventArgs e) { 224 318 SyncScroll(); 225 319 226 // update "padding labels" after scrollbars are added or removed 227 var columHeaderPadding = columnHeaderTableLayoutPanel.Controls[columnHeaderTableLayoutPanel.Controls.Count - 1]; 228 var rowHeaderPadding = rowHeaderTableLayoutPanel.Controls[rowHeaderTableLayoutPanel.ColumnCount - 1]; 229 columHeaderPadding.Width = bodyTableLayoutPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0; 230 rowHeaderPadding.Height = bodyTableLayoutPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0; 231 } 232 private void bodyTableLayoutPanel_MouseWheel(object sender, MouseEventArgs e) { 320 UpdateHeaderMargin(); 321 } 322 private void bodyScrollPanel_MouseWheel(object sender, MouseEventArgs e) { 233 323 // Scrolling with the mouse wheel is not captured in the Scoll event 234 324 SyncScroll(); 235 325 } 236 326 private void SyncScroll() { 237 //Debug.WriteLine("H: {0} <- {1}", columnHeader TableLayoutPanel.HorizontalScroll.Value, bodyTableLayoutPanel.HorizontalScroll.Value);238 //Debug.WriteLine("V: {0} <- {1}", row HeaderTableLayoutPanel.VerticalScroll.Value, bodyTableLayoutPanel.VerticalScroll.Value);327 //Debug.WriteLine("H: {0} <- {1}", columnHeaderScrollPanel.HorizontalScroll.Value, bodyScrollPanel.HorizontalScroll.Value); 328 //Debug.WriteLine("V: {0} <- {1}", rowScrollLayoutPanel.VerticalScroll.Value, bodyScrollPanel.VerticalScroll.Value); 239 329 240 330 frameTableLayoutPanel.SuspendRepaint(); 241 331 242 columnHeader TableLayoutPanel.HorizontalScroll.Minimum = bodyTableLayoutPanel.HorizontalScroll.Minimum;243 columnHeader TableLayoutPanel.HorizontalScroll.Maximum = bodyTableLayoutPanel.HorizontalScroll.Maximum;244 rowHeader TableLayoutPanel.VerticalScroll.Minimum = bodyTableLayoutPanel.VerticalScroll.Minimum;245 rowHeader TableLayoutPanel.VerticalScroll.Maximum = bodyTableLayoutPanel.VerticalScroll.Maximum;246 247 columnHeader TableLayoutPanel.HorizontalScroll.Value = Math.Max(bodyTableLayoutPanel.HorizontalScroll.Value, 1);248 rowHeader TableLayoutPanel.VerticalScroll.Value = Math.Max(bodyTableLayoutPanel.VerticalScroll.Value, 1);332 columnHeaderScrollPanel.HorizontalScroll.Minimum = bodyScrollPanel.HorizontalScroll.Minimum; 333 columnHeaderScrollPanel.HorizontalScroll.Maximum = bodyScrollPanel.HorizontalScroll.Maximum; 334 rowHeaderScrollPanel.VerticalScroll.Minimum = bodyScrollPanel.VerticalScroll.Minimum; 335 rowHeaderScrollPanel.VerticalScroll.Maximum = bodyScrollPanel.VerticalScroll.Maximum; 336 337 columnHeaderScrollPanel.HorizontalScroll.Value = Math.Max(bodyScrollPanel.HorizontalScroll.Value, 1); 338 rowHeaderScrollPanel.VerticalScroll.Value = Math.Max(bodyScrollPanel.VerticalScroll.Value, 1); 249 339 // minimum 1 is nececary because of two factors: 250 340 // - setting the Value-property of Horizontal/VerticalScroll updates the internal state but the Value-property stays 0 … … 254 344 frameTableLayoutPanel.ResumeRepaint(true); 255 345 } 346 347 // add a margin to the header table layouts if the scollbar is visible to account for the width/height of the scrollbar 348 private void UpdateHeaderMargin() { 349 columnHeaderScrollPanel.Margin = new Padding(0, 0, bodyScrollPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0, 0); 350 rowHeaderScrollPanel.Margin = new Padding(0, 0, 0, bodyScrollPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0); 351 } 256 352 } 257 353 }
Note: See TracChangeset
for help on using the changeset viewer.