Changeset 3329
- Timestamp:
- 04/13/10 17:07:10 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/AsynchronousContentView.cs
r3266 r3329 25 25 /// <param name="method">The delegate to invoke.</param> 26 26 protected new void Invoke(Delegate method) { 27 // prevent blocking of worker thread in Invoke, if the control is disposed 27 // prevents blocking of worker thread in Invoke, if the control is disposed 28 if (!IsHandleCreated) 29 return; 28 30 IAsyncResult result = BeginInvoke(method); 29 31 result.AsyncWaitHandle.WaitOne(1000, false); 30 if (result.IsCompleted) try { EndInvoke(result); } catch (ObjectDisposedException) { }31 else {32 if (result.IsCompleted) try { EndInvoke(result); } 33 catch (ObjectDisposedException) { } else { 32 34 ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, 33 35 new WaitOrTimerCallback((x, b) => { try { EndInvoke(result); } catch (ObjectDisposedException) { } }), … … 42 44 /// <param name="args">The invoke arguments.</param> 43 45 protected new void Invoke(Delegate method, params object[] args) { 44 // prevent blocking of worker thread in Invoke, if the control is disposed 46 // prevents blocking of worker thread in Invoke, if the control is disposed 47 if (!IsHandleCreated) 48 return; 45 49 IAsyncResult result = BeginInvoke(method, args); 46 50 result.AsyncWaitHandle.WaitOne(1000, false); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.Designer.cs
r3275 r3329 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExperimentView)); 47 48 this.tabControl = new System.Windows.Forms.TabControl(); 48 49 this.optimizersTabPage = new System.Windows.Forms.TabPage(); 49 50 this.optimizerListView = new HeuristicLab.Optimization.Views.OptimizerListView(); 51 this.runsTabPage = new System.Windows.Forms.TabPage(); 50 52 this.startButton = new System.Windows.Forms.Button(); 51 53 this.stopButton = new System.Windows.Forms.Button(); … … 54 56 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 55 57 this.pauseButton = new System.Windows.Forms.Button(); 56 this.runsTabPage = new System.Windows.Forms.TabPage(); 57 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView(); 58 this.runsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 58 59 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 59 60 this.tabControl.SuspendLayout(); … … 108 109 this.optimizerListView.TabIndex = 0; 109 110 // 111 // runsTabPage 112 // 113 this.runsTabPage.Controls.Add(this.runsViewHost); 114 this.runsTabPage.Location = new System.Drawing.Point(4, 22); 115 this.runsTabPage.Name = "runsTabPage"; 116 this.runsTabPage.Padding = new System.Windows.Forms.Padding(3); 117 this.runsTabPage.Size = new System.Drawing.Size(671, 374); 118 this.runsTabPage.TabIndex = 2; 119 this.runsTabPage.Text = "Runs"; 120 this.runsTabPage.UseVisualStyleBackColor = true; 121 // 110 122 // startButton 111 123 // 112 124 this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 113 this.startButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Play;125 this.startButton.Image = ((System.Drawing.Image)(resources.GetObject("startButton.Image"))); 114 126 this.startButton.Location = new System.Drawing.Point(0, 458); 115 127 this.startButton.Name = "startButton"; … … 123 135 // 124 136 this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 125 this.stopButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Stop;137 this.stopButton.Image = ((System.Drawing.Image)(resources.GetObject("stopButton.Image"))); 126 138 this.stopButton.Location = new System.Drawing.Point(60, 458); 127 139 this.stopButton.Name = "stopButton"; … … 135 147 // 136 148 this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 137 this.resetButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Restart;149 this.resetButton.Image = ((System.Drawing.Image)(resources.GetObject("resetButton.Image"))); 138 150 this.resetButton.Location = new System.Drawing.Point(90, 458); 139 151 this.resetButton.Name = "resetButton"; … … 166 178 // 167 179 this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 168 this.pauseButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Pause;180 this.pauseButton.Image = ((System.Drawing.Image)(resources.GetObject("pauseButton.Image"))); 169 181 this.pauseButton.Location = new System.Drawing.Point(30, 458); 170 182 this.pauseButton.Name = "pauseButton"; … … 175 187 this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click); 176 188 // 177 // runsTabPage 178 // 179 this.runsTabPage.Controls.Add(this.runsView); 180 this.runsTabPage.Location = new System.Drawing.Point(4, 22); 181 this.runsTabPage.Name = "runsTabPage"; 182 this.runsTabPage.Padding = new System.Windows.Forms.Padding(3); 183 this.runsTabPage.Size = new System.Drawing.Size(671, 374); 184 this.runsTabPage.TabIndex = 2; 185 this.runsTabPage.Text = "Runs"; 186 this.runsTabPage.UseVisualStyleBackColor = true; 187 // 188 // runsView 189 // 190 this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 189 // runsViewHost 190 // 191 this.runsViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 191 192 | System.Windows.Forms.AnchorStyles.Left) 192 193 | System.Windows.Forms.AnchorStyles.Right))); 193 this.runsView .Caption = "RunCollection";194 this.runsView .Content = null;195 this.runsView .Location = new System.Drawing.Point(6, 6);196 this.runsView .Name = "runsView";197 this.runsView .Size = new System.Drawing.Size(659, 362);198 this.runsView .TabIndex = 0;194 this.runsViewHost.Content = null; 195 this.runsViewHost.Location = new System.Drawing.Point(2, 6); 196 this.runsViewHost.Name = "runsViewHost"; 197 this.runsViewHost.Size = new System.Drawing.Size(663, 362); 198 this.runsViewHost.TabIndex = 0; 199 this.runsViewHost.ViewType = null; 199 200 // 200 201 // ExperimentView … … 242 243 private OptimizerListView optimizerListView; 243 244 private System.Windows.Forms.TabPage runsTabPage; 244 private RunCollectionView runsView;245 private HeuristicLab.MainForm.WindowsForms.ViewHost runsViewHost; 245 246 246 247 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs
r3275 r3329 71 71 if (Content == null) { 72 72 optimizerListView.Content = null; 73 runsView .Content = null;73 runsViewHost.Content = null; 74 74 tabControl.Enabled = false; 75 75 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false; … … 78 78 } else { 79 79 optimizerListView.Content = Content.Optimizers; 80 runsView .Content = Content.Runs;80 runsViewHost.Content = Content.Runs; 81 81 tabControl.Enabled = true; 82 82 EnableDisableButtons(); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r3274 r3329 180 180 <Name>HeuristicLab.Core-3.3</Name> 181 181 </ProjectReference> 182 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> 183 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project> 184 <Name>HeuristicLab.Data-3.3</Name> 185 </ProjectReference> 182 186 <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.2\HeuristicLab.MainForm.WindowsForms-3.2.csproj"> 183 187 <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project> -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r3317 r3329 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 26 29 27 30 namespace HeuristicLab.Optimization { 28 31 [StorableClass] 29 32 [Item("RunCollection", "Represents a collection of runs.")] 30 public class RunCollection : ItemCollection<IRun> { 31 public RunCollection() : base() { } 32 public RunCollection(int capacity) : base(capacity) { } 33 public RunCollection(IEnumerable<IRun> collection) : base(collection) { } 33 public class RunCollection : ItemCollection<IRun>, IStringConvertibleMatrix { 34 public RunCollection() : base() { Initialize(); } 35 public RunCollection(int capacity) : base(capacity) { Initialize(); } 36 public RunCollection(IEnumerable<IRun> collection) : base(collection) { Initialize(); this.OnItemsAdded(collection); } 37 38 protected static Type[] viewableDataTypes = new Type[]{typeof(BoolValue), typeof(DoubleValue), typeof(IntValue), 39 typeof(PercentValue), typeof(StringValue)}; 40 41 protected override void OnCollectionReset(IEnumerable<IRun> items, IEnumerable<IRun> oldItems) { 42 parameterNames.Clear(); 43 resultNames.Clear(); 44 foreach (IRun run in items) { 45 foreach (KeyValuePair<string, IItem> parameter in run.Parameters) 46 AddParameter(parameter.Key, parameter.Value); 47 foreach (KeyValuePair<string, IItem> result in run.Results) 48 AddResult(result.Key, result.Value); 49 } 50 base.OnCollectionReset(items, oldItems); 51 OnReset(); 52 OnColumnNamesChanged(); 53 OnRowNamesChanged(); 54 } 55 protected override void OnItemsAdded(IEnumerable<IRun> items) { 56 bool columnNamesChanged = false; 57 foreach (IRun run in items) { 58 foreach (KeyValuePair<string, IItem> parameter in run.Parameters) 59 columnNamesChanged |= AddParameter(parameter.Key, parameter.Value); 60 foreach (KeyValuePair<string, IItem> result in run.Results) 61 columnNamesChanged |= AddResult(result.Key, result.Value); 62 } 63 base.OnItemsAdded(items); 64 OnReset(); 65 if (columnNamesChanged) 66 OnColumnNamesChanged(); 67 OnRowNamesChanged(); 68 } 69 protected override void OnItemsRemoved(IEnumerable<IRun> items) { 70 bool columnNamesChanged = false; 71 foreach (IRun run in items) { 72 foreach (string parameterName in run.Parameters.Keys) 73 columnNamesChanged |= RemoveParameterName(parameterName); 74 foreach (string resultName in run.Results.Keys) 75 columnNamesChanged |= RemoveResultName(resultName); 76 } 77 base.OnItemsRemoved(items); 78 OnReset(); 79 if (columnNamesChanged) 80 OnColumnNamesChanged(); 81 OnRowNamesChanged(); 82 } 83 84 private void Initialize() { 85 parameterNames = new List<string>(); 86 resultNames = new List<string>(); 87 this.ReadOnlyView = true; 88 } 89 90 private bool AddParameter(string name, IItem value) { 91 if (value == null) 92 return false; 93 if (!parameterNames.Contains(name) && 94 viewableDataTypes.Any(x => x.IsAssignableFrom(value.GetType()))) { 95 parameterNames.Add(name); 96 return true; 97 } 98 return false; 99 } 100 private bool AddResult(string name, IItem value) { 101 if (value == null) 102 return false; 103 if (!resultNames.Contains(name) && 104 viewableDataTypes.Any(x => x.IsAssignableFrom(value.GetType()))) { 105 resultNames.Add(name); 106 return true; 107 } 108 return false; 109 } 110 private bool RemoveParameterName(string name) { 111 if (!list.Any(x => x.Parameters.ContainsKey(name))) { 112 parameterNames.Remove(name); 113 return true; 114 } 115 return false; 116 } 117 private bool RemoveResultName(string name) { 118 if (!list.Any(x => x.Results.ContainsKey(name))) { 119 resultNames.Remove(name); 120 return true; 121 } 122 return false; 123 } 124 125 #region IStringConvertibleMatrix Members 126 private List<string> parameterNames; 127 private List<string> resultNames; 128 public int Rows { 129 get { return this.Count; } 130 set { throw new System.NotImplementedException(); } 131 } 132 public int Columns { 133 get { return parameterNames.Count + resultNames.Count; } 134 set { throw new NotSupportedException(); } 135 } 136 public IEnumerable<string> ColumnNames { 137 get { 138 List<string> value = new List<string>(parameterNames); 139 value.AddRange(resultNames); 140 return value; 141 } 142 set { throw new NotSupportedException(); } 143 } 144 public IEnumerable<string> RowNames { 145 get { return list.Select(x => x.Name).ToList(); } 146 set { throw new NotSupportedException(); } 147 } 148 public bool SortableView { 149 get { return true; } 150 set { throw new NotSupportedException(); } 151 } 152 153 public string GetValue(int rowIndex, int columnIndex) { 154 IRun run = this.list[rowIndex]; 155 string value = string.Empty; 156 157 if (columnIndex < parameterNames.Count) { 158 string parameterName = parameterNames[columnIndex]; 159 if (run.Parameters.ContainsKey(parameterName)) { 160 IItem param = run.Parameters[parameterName]; 161 if (param != null) value = param.ToString(); 162 } 163 } else if (columnIndex < parameterNames.Count + resultNames.Count) { 164 string resultName = resultNames[columnIndex - parameterNames.Count]; 165 if (run.Results.ContainsKey(resultName)) { 166 IItem result = run.Results[resultName]; 167 if (result != null) value = result.ToString(); 168 } 169 } 170 return value; 171 } 172 173 public event EventHandler<EventArgs<int, int>> ItemChanged; 174 protected virtual void OnItemChanged(int rowIndex, int columnIndex) { 175 if (ItemChanged != null) 176 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); 177 OnToStringChanged(); 178 } 179 public event EventHandler Reset; 180 protected virtual void OnReset() { 181 if (Reset != null) 182 Reset(this, EventArgs.Empty); 183 OnToStringChanged(); 184 } 185 public event EventHandler ColumnNamesChanged; 186 protected virtual void OnColumnNamesChanged() { 187 EventHandler handler = ColumnNamesChanged; 188 if (handler != null) 189 handler(this, EventArgs.Empty); 190 } 191 public event EventHandler RowNamesChanged; 192 protected virtual void OnRowNamesChanged() { 193 EventHandler handler = RowNamesChanged; 194 if (handler != null) 195 handler(this, EventArgs.Empty); 196 } 197 198 public event EventHandler SortableViewChanged; 199 public bool Validate(string value, out string errorMessage) { throw new NotSupportedException(); } 200 public bool SetValue(string value, int rowIndex, int columnIndex) { throw new NotSupportedException(); } 201 #endregion 34 202 } 35 203 }
Note: See TracChangeset
for help on using the changeset viewer.