Changeset 5317
- Timestamp:
- 01/18/11 02:44:26 (14 years ago)
- Location:
- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/OKBExperiment.cs
r5304 r5317 337 337 } 338 338 private void algorithm_Stopped(object sender, EventArgs e) { 339 OnStopped();340 341 339 try { 342 340 OKBClient.Instance.AddRun(AlgorithmId, ProblemId, algorithm); … … 345 343 OnExceptionOccurred(ex); 346 344 } 345 OnStopped(); 347 346 } 348 347 private void algorithm_Runs_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IRun> e) { -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.Designer.cs
r5304 r5317 46 46 private void InitializeComponent() { 47 47 this.components = new System.ComponentModel.Container(); 48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QueryView));49 48 this.refreshResultsButton = new System.Windows.Forms.Button(); 50 49 this.toolTip = new System.Windows.Forms.ToolTip(this.components); … … 55 54 this.resultsGroupBox = new System.Windows.Forms.GroupBox(); 56 55 this.deserializeBlobsCheckBox = new System.Windows.Forms.CheckBox(); 56 this.resultsInfoPanel = new System.Windows.Forms.Panel(); 57 this.abortButton = new System.Windows.Forms.Button(); 58 this.resultsProgressBar = new System.Windows.Forms.ProgressBar(); 59 this.resultsInfoLabel = new System.Windows.Forms.Label(); 60 this.filtersInfoPanel = new System.Windows.Forms.Panel(); 61 this.filtersInfoLabel = new System.Windows.Forms.Label(); 57 62 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 58 63 this.splitContainer.Panel1.SuspendLayout(); … … 61 66 this.filtersGroupBox.SuspendLayout(); 62 67 this.resultsGroupBox.SuspendLayout(); 68 this.resultsInfoPanel.SuspendLayout(); 69 this.filtersInfoPanel.SuspendLayout(); 63 70 this.SuspendLayout(); 64 71 // … … 84 91 this.runCollectionView.Name = "runCollectionView"; 85 92 this.runCollectionView.ReadOnly = false; 86 this.runCollectionView.Size = new System.Drawing.Size( 722, 156);93 this.runCollectionView.Size = new System.Drawing.Size(826, 223); 87 94 this.runCollectionView.TabIndex = 2; 88 95 // … … 103 110 // 104 111 this.splitContainer.Panel2.Controls.Add(this.resultsGroupBox); 105 this.splitContainer.Size = new System.Drawing.Size( 734, 435);106 this.splitContainer.SplitterDistance = 2 17;112 this.splitContainer.Size = new System.Drawing.Size(838, 567); 113 this.splitContainer.SplitterDistance = 282; 107 114 this.splitContainer.TabIndex = 0; 108 115 // … … 115 122 this.filtersGroupBox.Location = new System.Drawing.Point(0, 0); 116 123 this.filtersGroupBox.Name = "filtersGroupBox"; 117 this.filtersGroupBox.Size = new System.Drawing.Size( 734, 214);124 this.filtersGroupBox.Size = new System.Drawing.Size(838, 279); 118 125 this.filtersGroupBox.TabIndex = 0; 119 126 this.filtersGroupBox.TabStop = false; … … 127 134 this.filterPanel.Location = new System.Drawing.Point(6, 19); 128 135 this.filterPanel.Name = "filterPanel"; 129 this.filterPanel.Size = new System.Drawing.Size( 722, 189);136 this.filterPanel.Size = new System.Drawing.Size(826, 254); 130 137 this.filterPanel.TabIndex = 0; 131 138 // … … 140 147 this.resultsGroupBox.Location = new System.Drawing.Point(0, 3); 141 148 this.resultsGroupBox.Name = "resultsGroupBox"; 142 this.resultsGroupBox.Size = new System.Drawing.Size( 734, 211);149 this.resultsGroupBox.Size = new System.Drawing.Size(838, 278); 143 150 this.resultsGroupBox.TabIndex = 0; 144 151 this.resultsGroupBox.TabStop = false; … … 153 160 this.deserializeBlobsCheckBox.Name = "deserializeBlobsCheckBox"; 154 161 this.deserializeBlobsCheckBox.Size = new System.Drawing.Size(106, 17); 155 this.deserializeBlobsCheckBox.TabIndex = 3;162 this.deserializeBlobsCheckBox.TabIndex = 1; 156 163 this.deserializeBlobsCheckBox.Text = "&Deserialize Blobs"; 157 164 this.deserializeBlobsCheckBox.UseVisualStyleBackColor = true; 158 165 // 166 // resultsInfoPanel 167 // 168 this.resultsInfoPanel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; 169 this.resultsInfoPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 170 this.resultsInfoPanel.Controls.Add(this.abortButton); 171 this.resultsInfoPanel.Controls.Add(this.resultsProgressBar); 172 this.resultsInfoPanel.Controls.Add(this.resultsInfoLabel); 173 this.resultsInfoPanel.Location = new System.Drawing.Point(238, 339); 174 this.resultsInfoPanel.Name = "resultsInfoPanel"; 175 this.resultsInfoPanel.Size = new System.Drawing.Size(362, 87); 176 this.resultsInfoPanel.TabIndex = 1; 177 this.resultsInfoPanel.Visible = false; 178 // 179 // abortButton 180 // 181 this.abortButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 182 this.abortButton.Location = new System.Drawing.Point(3, 58); 183 this.abortButton.Name = "abortButton"; 184 this.abortButton.Size = new System.Drawing.Size(354, 23); 185 this.abortButton.TabIndex = 2; 186 this.abortButton.Text = "&Abort"; 187 this.abortButton.UseVisualStyleBackColor = true; 188 this.abortButton.Click += new System.EventHandler(this.abortButton_Click); 189 // 190 // resultsProgressBar 191 // 192 this.resultsProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 193 this.resultsProgressBar.Enabled = false; 194 this.resultsProgressBar.Location = new System.Drawing.Point(3, 29); 195 this.resultsProgressBar.Name = "resultsProgressBar"; 196 this.resultsProgressBar.Size = new System.Drawing.Size(354, 23); 197 this.resultsProgressBar.Step = 1; 198 this.resultsProgressBar.TabIndex = 1; 199 // 200 // resultsInfoLabel 201 // 202 this.resultsInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 203 this.resultsInfoLabel.Enabled = false; 204 this.resultsInfoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 205 this.resultsInfoLabel.Location = new System.Drawing.Point(3, 3); 206 this.resultsInfoLabel.Name = "resultsInfoLabel"; 207 this.resultsInfoLabel.Size = new System.Drawing.Size(354, 23); 208 this.resultsInfoLabel.TabIndex = 0; 209 this.resultsInfoLabel.Text = "Loading ..."; 210 this.resultsInfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 211 // 212 // filtersInfoPanel 213 // 214 this.filtersInfoPanel.Anchor = System.Windows.Forms.AnchorStyles.Top; 215 this.filtersInfoPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 216 this.filtersInfoPanel.Controls.Add(this.filtersInfoLabel); 217 this.filtersInfoPanel.Enabled = false; 218 this.filtersInfoPanel.Location = new System.Drawing.Point(238, 136); 219 this.filtersInfoPanel.Name = "filtersInfoPanel"; 220 this.filtersInfoPanel.Size = new System.Drawing.Size(362, 33); 221 this.filtersInfoPanel.TabIndex = 0; 222 this.filtersInfoPanel.Visible = false; 223 // 224 // filtersInfoLabel 225 // 226 this.filtersInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); 227 this.filtersInfoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 228 this.filtersInfoLabel.Location = new System.Drawing.Point(3, 4); 229 this.filtersInfoLabel.Name = "filtersInfoLabel"; 230 this.filtersInfoLabel.Size = new System.Drawing.Size(354, 23); 231 this.filtersInfoLabel.TabIndex = 0; 232 this.filtersInfoLabel.Text = "Loading Filters ..."; 233 this.filtersInfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 234 // 159 235 // QueryView 160 236 // 161 237 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 162 238 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 239 this.Controls.Add(this.filtersInfoPanel); 240 this.Controls.Add(this.resultsInfoPanel); 163 241 this.Controls.Add(this.splitContainer); 164 242 this.Name = "QueryView"; 165 this.Size = new System.Drawing.Size( 734, 435);243 this.Size = new System.Drawing.Size(838, 567); 166 244 this.splitContainer.Panel1.ResumeLayout(false); 167 245 this.splitContainer.Panel2.ResumeLayout(false); … … 171 249 this.resultsGroupBox.ResumeLayout(false); 172 250 this.resultsGroupBox.PerformLayout(); 251 this.resultsInfoPanel.ResumeLayout(false); 252 this.filtersInfoPanel.ResumeLayout(false); 173 253 this.ResumeLayout(false); 174 254 … … 185 265 private System.Windows.Forms.Panel filterPanel; 186 266 private System.Windows.Forms.CheckBox deserializeBlobsCheckBox; 267 private System.Windows.Forms.Panel resultsInfoPanel; 268 private System.Windows.Forms.ProgressBar resultsProgressBar; 269 private System.Windows.Forms.Label resultsInfoLabel; 270 private System.Windows.Forms.Button abortButton; 271 private System.Windows.Forms.Panel filtersInfoPanel; 272 private System.Windows.Forms.Label filtersInfoLabel; 187 273 188 274 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/QueryView.cs
r5304 r5317 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.IO; 25 24 using System.Linq; 25 using System.Threading; 26 using System.Threading.Tasks; 26 27 using System.Windows.Forms; 27 28 using HeuristicLab.Core; … … 36 37 [Content(typeof(OKBClient), false)] 37 38 public sealed partial class QueryView : HeuristicLab.MainForm.WindowsForms.View { 39 private CancellationTokenSource cancellationTokenSource; 38 40 private CombinedFilterView combinedFilterView; 39 41 … … 44 46 protected override void OnInitialized(EventArgs e) { 45 47 base.OnInitialized(e); 46 this.Cursor = Cursors.AppStarting; 47 48 Func<CombinedFilter> func = () => { 49 return OKBClient.Instance.GetFilters().OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault(); 50 }; 51 52 func.BeginInvoke((IAsyncResult result) => { 53 CombinedFilter filter = func.EndInvoke(result); 54 if (InvokeRequired) Invoke(new Action<CombinedFilter>(FinishedLoadingFilter), filter); 55 else FinishedLoadingFilter(filter); 56 }, null); 48 LoadFiltersAsync(); 57 49 } 58 50 59 private void FinishedLoadingFilter(CombinedFilter filter) {60 if (filter != null) {61 combinedFilterView = (CombinedFilterView)MainFormManager.CreateView(typeof(CombinedFilterView));62 combinedFilterView.Content = (CombinedFilter)filter.Clone();63 Control control = (Control)combinedFilterView;64 control.Dock = DockStyle.Fill;65 filterPanel.Controls.Add(control);66 }67 this.Cursor = Cursors.Default;68 SetEnabledStateOfControls();69 }70 51 71 52 protected override void SetEnabledStateOfControls() { … … 74 55 } 75 56 76 private void refreshResultsButton_Click(object sender, EventArgs e) { 57 #region Load Filters 58 private void LoadFiltersAsync() { 59 Cursor = Cursors.AppStarting; 60 filtersInfoPanel.Visible = true; 61 splitContainer.Enabled = false; 62 63 Task<CombinedFilter> task = Task.Factory.StartNew<CombinedFilter>(() => { 64 return OKBClient.Instance.GetFilters().OfType<CombinedFilter>().Where(x => x.Operation == BooleanOperation.And).FirstOrDefault(); 65 }); 66 task.ContinueWith(t => { 67 CombinedFilter filter = t.Result; 68 Invoke(new Action(() => { 69 if (filter != null) { 70 combinedFilterView = (CombinedFilterView)MainFormManager.CreateView(typeof(CombinedFilterView)); 71 combinedFilterView.Content = (CombinedFilter)filter.Clone(); 72 Control control = (Control)combinedFilterView; 73 control.Dock = DockStyle.Fill; 74 filterPanel.Controls.Add(control); 75 } 76 filtersInfoPanel.Visible = false; 77 splitContainer.Enabled = true; 78 this.Cursor = Cursors.Default; 79 SetEnabledStateOfControls(); 80 })); 81 }); 82 } 83 #endregion 84 85 #region Load Results 86 private void LoadResultsAsync(int batchSize) { 77 87 bool deserialize = deserializeBlobsCheckBox.Checked; 78 88 79 System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); 80 sw.Start(); 81 long count = OKBClient.Instance.GetNumberOfQueryResults(combinedFilterView.Content); 82 sw.Stop(); 83 MessageBox.Show(count.ToString() + " Runs"); 84 if (MessageBox.Show(sw.Elapsed.ToString(), "GetNumberOfQueryResults", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; 89 Cursor = Cursors.AppStarting; 90 resultsInfoLabel.Text = "Loading Results ..."; 91 resultsProgressBar.Value = 0; 92 resultsProgressBar.Step = batchSize; 93 abortButton.Enabled = true; 94 resultsInfoPanel.Visible = true; 95 splitContainer.Enabled = false; 96 cancellationTokenSource = new CancellationTokenSource(); 97 CancellationToken cancellationToken = cancellationTokenSource.Token; 85 98 86 sw.Restart(); 87 var ids = OKBClient.Instance.GetQueryResultIds(combinedFilterView.Content); 88 sw.Stop(); 89 if (MessageBox.Show(sw.Elapsed.ToString(), "GetQueryResultIds", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; 99 Task task = Task.Factory.StartNew(() => { 100 var ids = OKBClient.Instance.GetQueryResultIds(combinedFilterView.Content); 101 int idsCount = ids.Count(); 90 102 91 sw.Restart(); 92 List<QueryResult> results = new List<QueryResult>(); 93 while (ids.Count() > 0) { 94 results.AddRange(OKBClient.Instance.GetQueryResults(ids.Take(50))); 95 ids = ids.Skip(50); 96 } 97 sw.Stop(); 98 if (MessageBox.Show(sw.Elapsed.ToString(), "GetQueryResults", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; 103 Invoke(new Action(() => { 104 resultsInfoLabel.Text = "Loaded 0 of " + idsCount.ToString() + " Results ..."; 105 resultsProgressBar.Maximum = idsCount; 106 })); 99 107 100 sw.Restart(); 101 IEnumerable<QueryResult> res = results.AsEnumerable(); 102 RunCollection runs = new RunCollection(); 103 runCollectionView.Content = runs; 104 while (res.Count() > 0) { 105 runs.AddRange(res.Take(50).Select(x => ConvertToOptimizationRun(x, deserialize))); 106 res = res.Skip(50); 107 } 108 sw.Stop(); 109 MessageBox.Show(sw.Elapsed.ToString(), "Conversion", MessageBoxButtons.OK); 108 RunCollection runs = new RunCollection(); 109 runs.CollectionReset += new Collections.CollectionItemsChangedEventHandler<IRun>(runs_CollectionReset); 110 runCollectionView.Content = runs; 111 while (ids.Count() > 0) { 112 cancellationToken.ThrowIfCancellationRequested(); 113 runs.AddRange(OKBClient.Instance.GetQueryResults(ids.Take(batchSize)).Select(x => ConvertToOptimizationRun(x, deserialize))); 114 ids = ids.Skip(batchSize); 115 Invoke(new Action(() => { 116 resultsInfoLabel.Text = "Loaded " + runs.Count + " of " + idsCount.ToString() + " Results ..."; 117 resultsProgressBar.PerformStep(); 118 })); 119 } 120 }, cancellationToken); 121 task.ContinueWith(t => { 122 Invoke(new Action(() => { 123 cancellationTokenSource.Dispose(); 124 cancellationTokenSource = null; 125 resultsInfoPanel.Visible = false; 126 splitContainer.Enabled = true; 127 this.Cursor = Cursors.Default; 128 SetEnabledStateOfControls(); 129 })); 130 }); 131 } 110 132 111 SetEnabledStateOfControls(); 133 void runs_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IRun> e) { 134 } 135 #endregion 136 137 private void refreshResultsButton_Click(object sender, EventArgs e) { 138 LoadResultsAsync(10); 139 } 140 141 private void abortButton_Click(object sender, EventArgs e) { 142 if (cancellationTokenSource != null) cancellationTokenSource.Cancel(); 143 abortButton.Enabled = false; 112 144 } 113 145
Note: See TracChangeset
for help on using the changeset viewer.