Changeset 1109
- Timestamp:
- 01/11/09 23:25:59 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 3 deleted
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Charting/BubbleChart.cs
r1108 r1109 65 65 entryToPrimitiveDictionary = new Dictionary<ResultsEntry, IPrimitive>(); 66 66 this.results = results; 67 68 foreach (var resultsEntry in results.GetEntries()) { 69 if(resultsEntry.Get(X_JITTER) ==null) 70 resultsEntry.Set(X_JITTER, random.NextDouble() * 2.0 - 1.0); 71 if(resultsEntry.Get(Y_JITTER) == null) 72 resultsEntry.Set(Y_JITTER, random.NextDouble() * 2.0 - 1.0); 73 records.Add(resultsEntry); 74 } 75 76 results.Changed += new EventHandler(results_Changed); 67 77 } 68 78 … … 75 85 : this(results, new PointD(x1, y1), new PointD(x2, y2)) { 76 86 } 77 78 //void results_OnRecordAdded(object sender, RecordAddedEventArgs e) {79 // lock(records) {80 // records.Add(e.Record);81 // }82 //}83 87 84 88 public void SetBubbleSizeDimension(string dimension, bool inverted) { … … 94 98 this.yDimension = yDimension; 95 99 96 foreach (var resultsEntry in results.SelectRows()) {97 resultsEntry.Set(X_JITTER, random.NextDouble() * 2.0 - 1.0);98 resultsEntry.Set(Y_JITTER, random.NextDouble() * 2.0 - 1.0);99 records.Add(resultsEntry);100 }101 100 ResetViewSize(); 102 101 Repaint(); … … 240 239 } 241 240 } 242 //results.FireChanged();241 if(primitives.Count() > 0) results.FireChanged(); 243 242 } else { 244 243 base.MouseDrag(start, end, button); … … 250 249 ResultsEntry r = GetResultsEntry(point); 251 250 if (r != null) r.ToggleSelected(); 252 //results.FireChanged();251 results.FireChanged(); 253 252 } else { 254 253 base.MouseClick(point, button); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Charting/BubbleChartView.cs
r1108 r1109 10 10 using HeuristicLab.CEDMA.Charting; 11 11 using HeuristicLab.CEDMA.Core; 12 using HeuristicLab.PluginInfrastructure; 12 13 13 14 namespace HeuristicLab.CEDMA.Charting { 14 public partial class BubbleChartView : ViewBase, IResultsView { 15 private Results results; 15 public class BubbleChartViewFactory : IResultsViewFactory { 16 #region IResultsViewFactory Members 17 18 public string Name { 19 get { return "Bubble chart"; } 20 } 21 22 public IControl CreateView(Results results) { 23 return new BubbleChartView(results); 24 } 25 26 #endregion 27 } 28 29 public partial class BubbleChartView : ViewBase { 30 private Results Results { 31 get { return (Results)Item; } 32 set { Item = value; } 33 } 16 34 private const string CONSTANT_SIZE = "<constant>"; 17 35 private Label pleaseSelectAxisLabel = new Label(); 18 19 public BubbleChartView() { 36 public BubbleChartView(Results results) { 20 37 InitializeComponent(); 38 Results = results; 39 bubbleChartControl.Chart = new BubbleChart(Results, 0, 0, 100, 100); 40 xAxisComboBox.Items.AddRange(Results.OrdinalVariables); 41 xAxisComboBox.Items.AddRange(Results.CategoricalVariables); 42 yAxisComboBox.Items.AddRange(Results.OrdinalVariables); 43 yAxisComboBox.Items.AddRange(Results.CategoricalVariables); 44 sizeComboBox.Items.Add(CONSTANT_SIZE); 45 sizeComboBox.Items.AddRange(Results.OrdinalVariables); 46 sizeComboBox.SelectedItem = sizeComboBox.Items[0]; 47 yAxisComboBox.SelectedItem = yAxisComboBox.Items[0]; 48 xAxisComboBox.SelectedItem = xAxisComboBox.Items[0]; 21 49 } 22 50 … … 31 59 32 60 private void jitterTrackBar_ValueChanged(object sender, EventArgs e) { 33 if (bubbleChartControl.Chart != null) { 34 double xJitterFactor = xTrackBar.Value / 100.0; 35 double yJitterFactor = yTrackBar.Value / 100.0; 36 bubbleChartControl.Chart.SetJitter(xJitterFactor, yJitterFactor); 37 } 61 double xJitterFactor = xTrackBar.Value / 100.0; 62 double yJitterFactor = yTrackBar.Value / 100.0; 63 bubbleChartControl.Chart.SetJitter(xJitterFactor, yJitterFactor); 38 64 UpdateChart(); 39 65 } 40 66 41 67 private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) { 42 if (bubbleChartControl.Chart != null) { 43 bubbleChartControl.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked); 44 UpdateChart(); 45 } 68 bubbleChartControl.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked); 69 UpdateChart(); 46 70 } 47 48 #region IResultsView Members49 50 public Control Control {51 get { return this; }52 }53 54 string IResultsView.Name {55 get { return "Bubble chart"; }56 }57 58 public void ShowResults(Results results) {59 this.results = results;60 bubbleChartControl.Chart = new BubbleChart(results, 0, 0, 100, 100);61 xAxisComboBox.Items.AddRange(Results.OrdinalVariables);62 xAxisComboBox.Items.AddRange(Results.CategoricalVariables);63 yAxisComboBox.Items.AddRange(Results.OrdinalVariables);64 yAxisComboBox.Items.AddRange(Results.CategoricalVariables);65 sizeComboBox.Items.Add(CONSTANT_SIZE);66 sizeComboBox.Items.AddRange(Results.OrdinalVariables);67 sizeComboBox.SelectedItem = sizeComboBox.Items[0];68 yAxisComboBox.SelectedItem = yAxisComboBox.Items[0];69 xAxisComboBox.SelectedItem = xAxisComboBox.Items[0];70 }71 72 #endregion73 71 } 74 72 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.Designer.cs
r1108 r1109 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.editorGroupBox = new System.Windows.Forms.GroupBox(); 48 this.activateButton = new System.Windows.Forms.Button(); 49 this.resultsButton = new System.Windows.Forms.Button(); 50 this.SuspendLayout(); 51 // 52 // editorGroupBox 53 // 54 this.editorGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 55 | System.Windows.Forms.AnchorStyles.Left) 56 | System.Windows.Forms.AnchorStyles.Right))); 57 this.editorGroupBox.Location = new System.Drawing.Point(0, 3); 58 this.editorGroupBox.Name = "editorGroupBox"; 59 this.editorGroupBox.Size = new System.Drawing.Size(274, 119); 60 this.editorGroupBox.TabIndex = 0; 61 this.editorGroupBox.TabStop = false; 62 this.editorGroupBox.Text = "&Editor:"; 63 // 64 // activateButton 65 // 66 this.activateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 67 this.activateButton.Location = new System.Drawing.Point(3, 128); 68 this.activateButton.Name = "activateButton"; 69 this.activateButton.Size = new System.Drawing.Size(75, 23); 70 this.activateButton.TabIndex = 2; 71 this.activateButton.Text = "&Activate"; 72 this.activateButton.UseVisualStyleBackColor = true; 73 this.activateButton.Click += new System.EventHandler(this.activateButton_Click); 74 // 75 // resultsButton 76 // 77 this.resultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 78 this.resultsButton.Location = new System.Drawing.Point(84, 128); 79 this.resultsButton.Name = "resultsButton"; 80 this.resultsButton.Size = new System.Drawing.Size(86, 23); 81 this.resultsButton.TabIndex = 3; 82 this.resultsButton.Text = "Show results"; 83 this.resultsButton.UseVisualStyleBackColor = true; 84 this.resultsButton.Click += new System.EventHandler(this.resultsButton_Click); 85 // 86 // DataSetView 87 // 88 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 89 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 90 this.Controls.Add(this.resultsButton); 91 this.Controls.Add(this.activateButton); 92 this.Controls.Add(this.editorGroupBox); 93 this.Name = "DataSetView"; 94 this.Size = new System.Drawing.Size(274, 154); 95 this.ResumeLayout(false); 47 this.editorGroupBox = new System.Windows.Forms.GroupBox(); 48 this.activateButton = new System.Windows.Forms.Button(); 49 this.resultsButton = new System.Windows.Forms.Button(); 50 this.progressBar = new System.Windows.Forms.ProgressBar(); 51 this.viewComboBox = new System.Windows.Forms.ComboBox(); 52 this.SuspendLayout(); 53 // 54 // editorGroupBox 55 // 56 this.editorGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 57 | System.Windows.Forms.AnchorStyles.Left) 58 | System.Windows.Forms.AnchorStyles.Right))); 59 this.editorGroupBox.Location = new System.Drawing.Point(0, 3); 60 this.editorGroupBox.Name = "editorGroupBox"; 61 this.editorGroupBox.Size = new System.Drawing.Size(381, 218); 62 this.editorGroupBox.TabIndex = 0; 63 this.editorGroupBox.TabStop = false; 64 this.editorGroupBox.Text = "&Editor:"; 65 // 66 // activateButton 67 // 68 this.activateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 69 this.activateButton.Location = new System.Drawing.Point(0, 227); 70 this.activateButton.Name = "activateButton"; 71 this.activateButton.Size = new System.Drawing.Size(75, 23); 72 this.activateButton.TabIndex = 2; 73 this.activateButton.Text = "&Activate"; 74 this.activateButton.UseVisualStyleBackColor = true; 75 this.activateButton.Click += new System.EventHandler(this.activateButton_Click); 76 // 77 // resultsButton 78 // 79 this.resultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 80 this.resultsButton.Location = new System.Drawing.Point(130, 254); 81 this.resultsButton.Name = "resultsButton"; 82 this.resultsButton.Size = new System.Drawing.Size(86, 23); 83 this.resultsButton.TabIndex = 3; 84 this.resultsButton.Text = "Show results"; 85 this.resultsButton.UseVisualStyleBackColor = true; 86 this.resultsButton.Click += new System.EventHandler(this.resultsButton_Click); 87 // 88 // progressBar 89 // 90 this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 91 | System.Windows.Forms.AnchorStyles.Right))); 92 this.progressBar.Location = new System.Drawing.Point(222, 254); 93 this.progressBar.Name = "progressBar"; 94 this.progressBar.Size = new System.Drawing.Size(156, 23); 95 this.progressBar.TabIndex = 4; 96 // 97 // viewComboBox 98 // 99 this.viewComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 100 this.viewComboBox.FormattingEnabled = true; 101 this.viewComboBox.Location = new System.Drawing.Point(3, 256); 102 this.viewComboBox.Name = "viewComboBox"; 103 this.viewComboBox.Size = new System.Drawing.Size(121, 21); 104 this.viewComboBox.TabIndex = 5; 105 // 106 // DataSetView 107 // 108 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 109 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 110 this.Controls.Add(this.viewComboBox); 111 this.Controls.Add(this.progressBar); 112 this.Controls.Add(this.resultsButton); 113 this.Controls.Add(this.activateButton); 114 this.Controls.Add(this.editorGroupBox); 115 this.Name = "DataSetView"; 116 this.Size = new System.Drawing.Size(381, 280); 117 this.ResumeLayout(false); 96 118 97 119 } … … 102 124 private System.Windows.Forms.Button activateButton; 103 125 private System.Windows.Forms.Button resultsButton; 126 private System.Windows.Forms.ProgressBar progressBar; 127 private System.Windows.Forms.ComboBox viewComboBox; 104 128 } 105 129 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs
r1106 r1109 25 25 using System.Drawing; 26 26 using System.Data; 27 using System.Linq; 27 28 using System.Text; 28 29 using System.Windows.Forms; … … 38 39 set { dataSet = value; } 39 40 } 40 41 private Results results; 41 42 public DataSetView() { 42 43 InitializeComponent(); … … 55 56 problemControl.Dock = DockStyle.Fill; 56 57 editorGroupBox.Controls.Add(problemControl); 58 PopulateViewComboBox(); 59 resultsButton.Enabled = viewComboBox.SelectedItem != null; 60 } 61 62 private void PopulateViewComboBox() { 63 DiscoveryService service = new DiscoveryService(); 64 IResultsViewFactory[] factories = service.GetInstances<IResultsViewFactory>(); 65 viewComboBox.DataSource = factories; 66 viewComboBox.ValueMember = "Name"; 57 67 } 58 68 … … 63 73 64 74 private void resultsButton_Click(object sender, EventArgs e) { 65 Results results = dataSet.GetResults(); 66 IControl resultsControl = new ResultsViewContainer(results); 67 PluginManager.ControlManager.ShowControl(resultsControl); 75 if (results == null) 76 ReloadResults(); 77 try { 78 IResultsViewFactory factory = (IResultsViewFactory)viewComboBox.SelectedItem; 79 BackgroundWorker worker = new BackgroundWorker(); 80 worker.WorkerReportsProgress = true; 81 worker.WorkerSupportsCancellation = true; 82 worker.ProgressChanged += delegate(object progressChangedSender, ProgressChangedEventArgs progressChangedArgs) { 83 progressBar.Value = progressChangedArgs.ProgressPercentage; 84 }; 85 worker.DoWork += delegate(object doWorkSender, DoWorkEventArgs doWorkArgs) { 86 worker.ReportProgress(10); 87 results.GetEntries().Last(); // preload list by accessing last element 88 worker.ReportProgress(100); 89 }; 90 resultsButton.Enabled = false; 91 worker.RunWorkerAsync(); 92 worker.RunWorkerCompleted += delegate(object completedSender, RunWorkerCompletedEventArgs compledArgs) { 93 resultsButton.Enabled = true; 94 progressBar.Value = 0; 95 IControl control = factory.CreateView(results); 96 PluginManager.ControlManager.ShowControl(control); 97 }; 98 } 99 catch (Exception ex) { 100 string text = "Couldn't load selected view: " + viewComboBox.SelectedItem + "\n" + ex.Message; 101 MessageBox.Show(text, "Unable to create view", MessageBoxButtons.OK, MessageBoxIcon.Error); 102 } 103 } 104 105 private void ReloadResults() { 106 results = dataSet.GetResults(); 68 107 } 69 108 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
r1108 r1109 72 72 </ItemGroup> 73 73 <ItemGroup> 74 <Compile Include="IResultsViewFactory.cs" /> 74 75 <Compile Include="ResultsEntry.cs" /> 75 76 <Compile Include="TableResultsView.cs"> … … 83 84 <SubType>UserControl</SubType> 84 85 </Compile> 85 <Compile Include="IResultsView.cs" />86 86 <Compile Include="Problem.cs" /> 87 87 <Compile Include="DataSet.cs" /> … … 109 109 <Compile Include="ProblemInjector.cs" /> 110 110 <Compile Include="Results.cs" /> 111 <Compile Include="ResultsViewContainer.cs">112 <SubType>UserControl</SubType>113 </Compile>114 <Compile Include="ResultsViewContainer.Designer.cs">115 <DependentUpon>ResultsViewContainer.cs</DependentUpon>116 </Compile>117 111 </ItemGroup> 118 112 <ItemGroup> … … 162 156 <DependentUpon>ProblemView.cs</DependentUpon> 163 157 </EmbeddedResource> 164 <EmbeddedResource Include="ResultsViewContainer.resx">165 <DependentUpon>ResultsViewContainer.cs</DependentUpon>166 </EmbeddedResource>167 158 </ItemGroup> 168 159 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/IResultsViewFactory.cs
r1108 r1109 29 29 using HeuristicLab.Operators; 30 30 using System.Windows.Forms; 31 using HeuristicLab.PluginInfrastructure; 31 32 32 33 namespace HeuristicLab.CEDMA.Core { 33 public interface IResultsView { 34 Control Control { get; } 34 public interface IResultsViewFactory { 35 35 string Name { get; } 36 void ShowResults(Results results);36 IControl CreateView(Results results); 37 37 } 38 38 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs
r1108 r1109 36 36 37 37 namespace HeuristicLab.CEDMA.Core { 38 public class Results {38 public class Results : ItemBase { 39 39 public static string[] CategoricalVariables { 40 40 get { return new string[] { "TargetVariable" }; } … … 63 63 } 64 64 65 public IEnumerable<ResultsEntry> SelectRows() { 65 private List<ResultsEntry> entries = null; 66 public IEnumerable<ResultsEntry> GetEntries() { 67 if (entries == null) 68 Reload(); 69 return entries.AsEnumerable(); 70 } 71 72 internal void Reload() { 73 entries = SelectRows().ToList(); 74 FireChanged(); 75 } 76 77 private IEnumerable<ResultsEntry> SelectRows() { 66 78 if (store == null) yield break; 67 79 -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ResultsEntry.cs
r1108 r1109 37 37 38 38 private bool selected = false; 39 public bool Selected { get { return selected; } } 39 public bool Selected { 40 get { return selected; } 41 set { selected = value; } 42 } 40 43 41 44 private string uri; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/TableResultsView.Designer.cs
r1106 r1109 39 39 this.dataGridView.Size = new System.Drawing.Size(450, 459); 40 40 this.dataGridView.TabIndex = 0; 41 this.dataGridView.SelectionChanged += new System.EventHandler(this.dataGridView_SelectionChanged); 41 42 // 42 43 // TableResultsView -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/TableResultsView.cs
r1108 r1109 9 9 using HeuristicLab.Core; 10 10 using HeuristicLab.CEDMA.Core; 11 using HeuristicLab.PluginInfrastructure; 11 12 12 13 namespace HeuristicLab.CEDMA.Core { 13 public partial class TableResultsView : ViewBase, IResultsView { 14 private Results results; 15 public TableResultsView() { 14 15 public partial class TableResultsView : ViewBase { 16 private Results Results { 17 get { return (Results)Item; } 18 set { Item = value; } 19 } 20 private bool suppressEvents; 21 public TableResultsView(Results results) { 22 suppressEvents = false; 16 23 InitializeComponent(); 24 Results = results; 25 results.Changed += new EventHandler(results_Changed); 17 26 } 18 27 19 public Control Control { 20 get { return this; } 21 } 22 23 string IResultsView.Name { 24 get { return "Table"; } 25 } 26 27 public void ShowResults(Results results) { 28 this.results = results; 28 void results_Changed(object sender, EventArgs e) { 29 if (suppressEvents) return; 29 30 UpdateControls(); 30 31 } 31 32 32 33 protected override void UpdateControls() { 33 base.UpdateControls(); 34 if (results == null) return; 34 suppressEvents = true; 35 35 dataGridView.Rows.Clear(); 36 36 dataGridView.Columns.Clear(); 37 List<string> attributeNames = results.SelectModelAttributes().ToList();37 List<string> attributeNames = Results.SelectModelAttributes().ToList(); 38 38 foreach (var attribute in attributeNames) { 39 39 dataGridView.Columns.Add(attribute, attribute); 40 40 } 41 41 42 var entries = results.SelectRows();42 var entries = Results.GetEntries(); 43 43 foreach (var entry in entries) { 44 44 int rowIndex = dataGridView.Rows.Add(); 45 dataGridView.Rows[rowIndex].Tag = entry; 45 46 foreach (string attrName in attributeNames) { 46 47 dataGridView.Rows[rowIndex].Cells[attrName].Value = entry.Get(attrName); 47 48 } 48 dataGridView.Rows.Add(row);49 if (entry.Selected) dataGridView.Rows[rowIndex].Selected = true; 49 50 } 50 51 dataGridView.Update(); 52 suppressEvents = false; 53 } 54 55 private void dataGridView_SelectionChanged(object sender, EventArgs e) { 56 if (suppressEvents) return; 57 foreach (DataGridViewRow row in dataGridView.Rows) { 58 ((ResultsEntry)row.Tag).Selected = row.Selected; 59 } 60 suppressEvents = true; 61 Results.FireChanged(); 62 suppressEvents = false; 51 63 } 52 64 } 65 66 public class TablesResultsViewFactory : IResultsViewFactory { 67 #region IResultsViewFactory Members 68 69 public string Name { 70 get { return "Table"; } 71 } 72 73 public IControl CreateView(Results results) { 74 return new TableResultsView(results); 75 } 76 77 #endregion 78 } 53 79 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.Grid/HeuristicLab.Grid.csproj
r852 r1109 56 56 <RequiredTargetFramework>3.5</RequiredTargetFramework> 57 57 </Reference> 58 <Reference Include="System.Data.SQLite, Version=1.0. 51.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">58 <Reference Include="System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86"> 59 59 <SpecificVersion>False</SpecificVersion> 60 60 <HintPath>..\HeuristicLab.SQLite\System.Data.SQLite.DLL</HintPath>
Note: See TracChangeset
for help on using the changeset viewer.