Changeset 16544
- Timestamp:
- 01/22/19 09:15:40 (6 years ago)
- Location:
- branches/2971_named_intervals
- Files:
-
- 2 added
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r16536 r16544 41 41 <DebugType>full</DebugType> 42 42 <Optimize>false</Optimize> 43 <OutputPath> $(SolutionDir)\bin\</OutputPath>43 <OutputPath>..\..\..\..\trunk\bin\</OutputPath> 44 44 <DefineConstants>DEBUG;TRACE</DefineConstants> 45 45 <ErrorReport>prompt</ErrorReport> … … 306 306 <Compile Include="ProblemDataView.Designer.cs"> 307 307 <DependentUpon>ProblemDataView.cs</DependentUpon> 308 </Compile> 309 <Compile Include="Regression\NamedIntervalsView.cs"> 310 <SubType>UserControl</SubType> 311 </Compile> 312 <Compile Include="Regression\NamedIntervalsView.Designer.cs"> 313 <DependentUpon>NamedIntervalsView.cs</DependentUpon> 308 314 </Compile> 309 315 <Compile Include="Regression\ConfidenceRegressionSolutionEstimatedValuesView.cs"> … … 575 581 <DependentUpon>AbstractFeatureCorrelationView.cs</DependentUpon> 576 582 </EmbeddedResource> 583 <EmbeddedResource Include="Regression\NamedIntervalsView.resx"> 584 <DependentUpon>NamedIntervalsView.cs</DependentUpon> 585 </EmbeddedResource> 577 586 </ItemGroup> 578 587 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/NamedIntervalsView.Designer.cs
r16535 r16544 1 namespace HeuristicLab. Data.Views {2 partial class BoolMatrixView {1 namespace HeuristicLab.Problems.DataAnalysis.Views { 2 partial class NamedIntervalsView { 3 3 /// <summary> 4 4 /// Required designer variable. … … 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this.pictureBox = new System.Windows.Forms.PictureBox(); 27 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 26 this.dataGridView = new System.Windows.Forms.DataGridView(); 27 this.groupBox1 = new System.Windows.Forms.GroupBox(); 28 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); 29 this.groupBox1.SuspendLayout(); 28 30 this.SuspendLayout(); 29 31 // 30 // pictureBox32 // dataGridView 31 33 // 32 this. pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)33 | System.Windows.Forms.AnchorStyles.Left) 34 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 35 | System.Windows.Forms.AnchorStyles.Left) 34 36 | System.Windows.Forms.AnchorStyles.Right))); 35 this.pictureBox.Location = new System.Drawing.Point(3, 3); 36 this.pictureBox.Name = "pictureBox"; 37 this.pictureBox.Size = new System.Drawing.Size(144, 144); 38 this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 39 this.pictureBox.TabIndex = 0; 40 this.pictureBox.TabStop = false; 37 this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 38 this.dataGridView.Location = new System.Drawing.Point(6, 19); 39 this.dataGridView.Name = "dataGridView"; 40 this.dataGridView.RowHeadersWidth = 120; 41 this.dataGridView.Size = new System.Drawing.Size(461, 378); 42 this.dataGridView.TabIndex = 0; 43 this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit); 44 this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_CellValidating); 45 this.dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellValueChanged); 41 46 // 42 // BoolMatrixView 47 // groupBox1 48 // 49 this.groupBox1.Controls.Add(this.dataGridView); 50 this.groupBox1.Location = new System.Drawing.Point(6, 4); 51 this.groupBox1.Name = "groupBox1"; 52 this.groupBox1.Size = new System.Drawing.Size(473, 403); 53 this.groupBox1.TabIndex = 1; 54 this.groupBox1.TabStop = false; 55 this.groupBox1.Text = "Interval Boundaries"; 56 // 57 // NamedIntervalsView 43 58 // 44 59 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 45 60 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 46 this.Controls.Add(this.pictureBox); 47 this.Name = "BoolMatrixView"; 48 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); 61 this.Controls.Add(this.groupBox1); 62 this.Name = "NamedIntervalsView"; 63 this.Size = new System.Drawing.Size(482, 410); 64 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); 65 this.groupBox1.ResumeLayout(false); 49 66 this.ResumeLayout(false); 50 67 … … 53 70 #endregion 54 71 55 private System.Windows.Forms.PictureBox pictureBox; 72 protected System.Windows.Forms.DataGridView dataGridView; 73 private System.Windows.Forms.GroupBox groupBox1; 56 74 } 57 75 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/NamedIntervalsView.cs
r16535 r16544 23 23 using System.ComponentModel; 24 24 using System.Drawing; 25 using HeuristicLab.Core.Views; 25 using System.Linq; 26 using System.Security.Permissions; 27 using System.Windows.Forms; 26 28 using HeuristicLab.MainForm; 29 using HeuristicLab.MainForm.WindowsForms; 30 using HeuristicLab.Problems.DataAnalysis.Implementation; 27 31 28 namespace HeuristicLab. Data.Views {32 namespace HeuristicLab.Problems.DataAnalysis.Views { 29 33 30 [View("BoolMatrixView")] 31 [Content(typeof(BoolMatrix), IsDefaultView = false)] 32 public sealed partial class BoolMatrixView : ItemView { 33 private BackgroundWorker worker; 34 [View("NamedIntervals View")] 35 [Content(typeof(NamedIntervals), true)] 36 public partial class NamedIntervalsView : AsynchronousContentView { 34 37 35 public new BoolMatrixContent {36 get { return (BoolMatrix)base.Content; }37 set { base.Content = value; }38 public new NamedIntervals Content { 39 get => (NamedIntervals)base.Content; 40 set => base.Content = value; 38 41 } 39 42 40 public BoolMatrixView(){41 InitializeComponent();43 public DataGridView DataGridView { 44 get => dataGridView; 42 45 } 43 46 44 protected override void DeregisterContentEvents() { 45 Content.ToStringChanged -= Content_ToStringChanged; 46 base.DeregisterContentEvents(); 47 } 48 49 protected override void RegisterContentEvents() { 50 base.RegisterContentEvents(); 51 Content.ToStringChanged += Content_ToStringChanged; 52 } 53 54 private void Content_ToStringChanged(object sender, EventArgs e) { 55 Rebuild(); 56 } 57 58 private void Rebuild() { 59 int width = pictureBox.Width; 60 int height = pictureBox.Height; 61 int tileWidth = width / Content.Columns; 62 int tileHeight = height / Content.Rows; 63 int border = (int)Math.Round((tileWidth + tileHeight) / 2.0 * 0.05); 64 var bitmap = new Bitmap(width, height); 65 66 if (worker != null) 67 worker.CancelAsync(); 68 69 if (tileWidth == 0 || tileHeight == 0) { 70 using (Graphics g = Graphics.FromImage(bitmap)) { 71 g.DrawString("BoolMatrix is too big to draw.", DefaultFont, new SolidBrush(Color.Black), 10.0f, height / 2.0f); 72 g.Flush(); 73 } 74 pictureBox.Image = bitmap; 75 return; 76 } 77 78 worker = new BackgroundWorker(); 79 worker.WorkerSupportsCancellation = true; 80 worker.DoWork += (s, a) => { 81 using (Graphics g = Graphics.FromImage(bitmap)) { 82 for (int i = 0; i < Content.Rows; i++) { 83 for (int j = 0; j < Content.Columns; j++) { 84 if (worker.CancellationPending) { 85 a.Cancel = true; 86 break; 87 } 88 g.FillRectangle(Content[i, j] ? Brushes.Black : Brushes.White, i * tileWidth, j * tileHeight, 89 tileWidth - border, tileHeight - border); 90 } 91 } 92 g.Flush(); 93 } 94 }; 95 worker.RunWorkerCompleted += (s, a) => { 96 if (!a.Cancelled) 97 pictureBox.Image = bitmap; 98 if (!worker.CancellationPending) 99 worker = null; 100 }; 101 worker.RunWorkerAsync(); 47 public NamedIntervalsView() { 48 InitializeComponent(); 49 setColumnNames(); 50 dataGridView.AutoGenerateColumns = false; 51 dataGridView.AllowUserToAddRows = false; 102 52 } 103 53 … … 105 55 base.OnContentChanged(); 106 56 if (Content == null) { 107 pictureBox.Image = new Bitmap(1, 1); 108 } else { 109 Rebuild(); 57 DataGridView.Rows.Clear(); 58 DataGridView.Columns.Clear(); 59 } else if (!DataGridView.IsCurrentCellInEditMode) { 60 UpdateData(); 110 61 } 62 } 63 64 protected override void SetEnabledStateOfControls() { 65 base.SetEnabledStateOfControls(); 66 dataGridView.Enabled = Content != null; 67 dataGridView.ReadOnly = ReadOnly; 68 } 69 70 protected void UpdateData() { 71 var variablesCount = Content.VariableIntervals.Count; 72 73 DataGridViewRow[] rows = new DataGridViewRow[variablesCount]; 74 for (var i = 0; i < variablesCount; ++i) { 75 var row = new DataGridViewRow(); 76 rows[i] = row; 77 } 78 dataGridView.Rows.AddRange(rows); 79 80 setRowsHeader(); 81 FillRows(); 82 83 dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader); 84 dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); 85 dataGridView.Enabled = true; 86 87 } 88 89 protected void FillRows() { 90 for (var i = 0; i < dataGridView.RowCount; ++i) { 91 var key = (string)dataGridView.Rows[i].HeaderCell.Value; 92 dataGridView.Rows[i].Cells[0].Value = Content.VariableIntervals[key].LowerBound; 93 dataGridView.Rows[i].Cells[1].Value = Content.VariableIntervals[key].UpperBound; 94 } 95 } 96 97 protected void setRowsHeader() { 98 for (var i = 0; i < Content.VariableIntervals.Count; ++i) { 99 var item = Content.VariableIntervals.ElementAt(i); 100 dataGridView.Rows[i].HeaderCell.Value = item.Key; 101 } 102 } 103 104 protected void setColumnNames() { 105 dataGridView.Columns.Add("lowerBound", "Lower Bound"); 106 dataGridView.Columns.Add("upperBound", "Upper Bound"); 107 } 108 109 private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { 110 111 } 112 113 private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 114 double value; 115 116 if (!double.TryParse(e.FormattedValue.ToString(), out value)) { 117 dataGridView.Rows[e.RowIndex].ErrorText = "Value has to be a double value"; 118 e.Cancel = true; 119 } else if (string.IsNullOrEmpty(e.FormattedValue.ToString())) { 120 dataGridView.Rows[e.RowIndex].ErrorText = "Value has to best"; 121 e.Cancel = true; 122 } else if (double.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()) > 123 double.Parse(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString())) { 124 dataGridView.Rows[e.RowIndex].ErrorText = "Lower Bound of Interval has to be smaller than Upper Bound"; 125 e.Cancel = true; 126 } 127 } 128 129 private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { 130 dataGridView.Rows[e.RowIndex].ErrorText = string.Empty; 111 131 } 112 132 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/NamedIntervals.cs
r16426 r16544 24 24 } 25 25 26 public ObservableDictionary<string, Interval> VariableIntervals => variableIntervals; 27 26 28 public bool InsertMany(IEnumerable<KeyValuePair<string, Interval>> entries) { 27 29 if (entries == null) throw new ArgumentNullException("The given dataset is null."); -
branches/2971_named_intervals/NamedIntervals.sln
r16536 r16544 13 13 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{469869A8-5D45-4838-BD0C-03B9A73CE9CA}" 14 14 ProjectSection(SolutionItems) = preProject 15 .editorconfig = .editorconfig 15 16 Build.cmd = Build.cmd 16 17 Build.ps1 = Build.ps1
Note: See TracChangeset
for help on using the changeset viewer.