Changeset 9933 for stable/HeuristicLab.Optimizer
- Timestamp:
- 09/03/13 15:55:36 (11 years ago)
- Location:
- stable
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 9849,9851,9865,9867-9868,9893-9896,9900-9901,9905,9907
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimizer/3.3/FileManager.cs
r9456 r9933 22 22 using System; 23 23 using System.Collections.Generic; 24 using System. Linq;24 using System.IO; 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Common; … … 98 98 SaveAs(view); 99 99 else { 100 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();101 Set EnabledStateOfContentViews(content, false);100 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 101 SetSaveOperationProgressInContentViews(content, true); 102 102 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted); 103 103 } … … 123 123 124 124 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 125 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();126 Set EnabledStateOfContentViews(content, false);125 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 126 SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName); 127 127 if (saveFileDialog.FilterIndex == 1) { 128 128 ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted); … … 135 135 private static void SavingCompleted(IStorableContent content, Exception error) { 136 136 try { 137 SetEnabledStateOfContentViews(content, true);138 137 if (error != null) throw error; 139 138 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle(); … … 143 142 } 144 143 finally { 145 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor(); 144 SetSaveOperationProgressInContentViews(content, false); 145 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor(); 146 146 } 147 147 } 148 148 149 private static void Set EnabledStateOfContentViews(IStorableContent content, bool enabled) {149 private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null) { 150 150 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>(); 151 151 #region Mono Compatibility 152 152 // removed the InvokeRequired check because of Mono 153 153 mainForm.Invoke((Action)delegate { 154 var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList(); 155 views.ForEach(v => v.Enabled = enabled); 154 if (showProgress) { 155 mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename))); 156 } else 157 mainForm.RemoveOperationProgressFromContent(content); 156 158 }); 157 159 #endregion -
stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs
r9456 r9933 50 50 this.titleLabel = new System.Windows.Forms.Label(); 51 51 this.samplesGroupBox = new System.Windows.Forms.GroupBox(); 52 this.loadingPanel = new System.Windows.Forms.Panel();53 this.loadingProgressBar = new System.Windows.Forms.ProgressBar();54 this.loadingLabel = new System.Windows.Forms.Label();55 52 this.samplesListView = new System.Windows.Forms.ListView(); 56 this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();57 this.descriptionColumnHeader = new System.Windows.Forms.ColumnHeader();53 this.nameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 54 this.descriptionColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 58 55 this.imageList = new System.Windows.Forms.ImageList(this.components); 59 56 this.splitContainer = new System.Windows.Forms.SplitContainer(); 60 57 this.samplesGroupBox.SuspendLayout(); 61 this.loadingPanel.SuspendLayout();58 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 62 59 this.splitContainer.Panel1.SuspendLayout(); 63 60 this.splitContainer.Panel2.SuspendLayout(); … … 80 77 // firstStepsRichTextBox 81 78 // 82 this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 83 | System.Windows.Forms.AnchorStyles.Left)84 79 this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 80 | System.Windows.Forms.AnchorStyles.Left) 81 | System.Windows.Forms.AnchorStyles.Right))); 85 82 this.firstStepsRichTextBox.BackColor = System.Drawing.SystemColors.Control; 86 83 this.firstStepsRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; … … 96 93 // titleLabel 97 94 // 98 this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 99 95 this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 96 | System.Windows.Forms.AnchorStyles.Right))); 100 97 this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 101 98 this.titleLabel.Location = new System.Drawing.Point(-1, 0); … … 108 105 // samplesGroupBox 109 106 // 110 this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 111 | System.Windows.Forms.AnchorStyles.Left) 112 | System.Windows.Forms.AnchorStyles.Right))); 113 this.samplesGroupBox.Controls.Add(this.loadingPanel); 107 this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 108 | System.Windows.Forms.AnchorStyles.Left) 109 | System.Windows.Forms.AnchorStyles.Right))); 114 110 this.samplesGroupBox.Controls.Add(this.samplesListView); 115 111 this.samplesGroupBox.Location = new System.Drawing.Point(0, 3); … … 119 115 this.samplesGroupBox.TabStop = false; 120 116 this.samplesGroupBox.Text = "Samples"; 121 //122 // loadingPanel123 //124 this.loadingPanel.Anchor = System.Windows.Forms.AnchorStyles.None;125 this.loadingPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;126 this.loadingPanel.Controls.Add(this.loadingProgressBar);127 this.loadingPanel.Controls.Add(this.loadingLabel);128 this.loadingPanel.Enabled = false;129 this.loadingPanel.Location = new System.Drawing.Point(189, 89);130 this.loadingPanel.Name = "loadingPanel";131 this.loadingPanel.Size = new System.Drawing.Size(350, 62);132 this.loadingPanel.TabIndex = 1;133 //134 // loadingProgressBar135 //136 this.loadingProgressBar.Anchor = System.Windows.Forms.AnchorStyles.None;137 this.loadingProgressBar.Location = new System.Drawing.Point(101, 19);138 this.loadingProgressBar.Name = "loadingProgressBar";139 this.loadingProgressBar.Size = new System.Drawing.Size(229, 23);140 this.loadingProgressBar.Step = 1;141 this.loadingProgressBar.TabIndex = 1;142 //143 // loadingLabel144 //145 this.loadingLabel.Anchor = System.Windows.Forms.AnchorStyles.None;146 this.loadingLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));147 this.loadingLabel.Location = new System.Drawing.Point(12, 19);148 this.loadingLabel.Name = "loadingLabel";149 this.loadingLabel.Size = new System.Drawing.Size(83, 23);150 this.loadingLabel.TabIndex = 0;151 this.loadingLabel.Text = "Loading ...";152 117 // 153 118 // samplesListView … … 168 133 this.samplesListView.UseCompatibleStateImageBehavior = false; 169 134 this.samplesListView.View = System.Windows.Forms.View.Details; 135 this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag); 170 136 this.samplesListView.DoubleClick += new System.EventHandler(this.samplesListView_DoubleClick); 171 this.samplesListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.samplesListView_ItemDrag);172 137 // 173 138 // nameColumnHeader … … 189 154 // splitContainer 190 155 // 191 this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 192 | System.Windows.Forms.AnchorStyles.Left)193 156 this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 157 | System.Windows.Forms.AnchorStyles.Left) 158 | System.Windows.Forms.AnchorStyles.Right))); 194 159 this.splitContainer.Location = new System.Drawing.Point(0, 0); 195 160 this.splitContainer.Name = "splitContainer"; … … 210 175 // StartPage 211 176 // 212 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);213 177 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 214 178 this.Controls.Add(this.splitContainer); … … 217 181 this.Size = new System.Drawing.Size(728, 640); 218 182 this.samplesGroupBox.ResumeLayout(false); 219 this.loadingPanel.ResumeLayout(false);220 183 this.splitContainer.Panel1.ResumeLayout(false); 221 184 this.splitContainer.Panel2.ResumeLayout(false); 185 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 222 186 this.splitContainer.ResumeLayout(false); 223 187 this.ResumeLayout(false); … … 236 200 private System.Windows.Forms.ImageList imageList; 237 201 private System.Windows.Forms.ColumnHeader descriptionColumnHeader; 238 private System.Windows.Forms.Panel loadingPanel;239 private System.Windows.Forms.ProgressBar loadingProgressBar;240 private System.Windows.Forms.Label loadingLabel;241 202 private System.Windows.Forms.SplitContainer splitContainer; 242 203 } -
stable/HeuristicLab.Optimizer/3.3/StartPage.cs
r9456 r9933 34 34 [View("Start Page")] 35 35 public partial class StartPage : HeuristicLab.MainForm.WindowsForms.View { 36 private IProgress progress; 37 36 38 public StartPage() { 37 39 InitializeComponent(); … … 67 69 68 70 private void LoadSamples(object state) { 71 progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading..."); 69 72 Assembly assembly = Assembly.GetExecutingAssembly(); 70 73 var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl")); … … 77 80 WriteStreamToTempFile(stream, path); 78 81 INamedItem item = XmlParser.Deserialize<INamedItem>(path); 79 OnSampleLoaded(item, loadingProgressBar.Maximum/ count);82 OnSampleLoaded(item, 1.0 / count); 80 83 } 81 84 } 82 catch (Exception) { } 85 catch (Exception) { 86 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView); 87 } 83 88 } 84 89 OnAllSamplesLoaded(); 85 90 } 86 private void OnSampleLoaded(INamedItem sample, intprogress) {91 private void OnSampleLoaded(INamedItem sample, double progress) { 87 92 if (InvokeRequired) 88 Invoke(new Action<INamedItem, int>(OnSampleLoaded), sample, progress);93 Invoke(new Action<INamedItem, double>(OnSampleLoaded), sample, progress); 89 94 else { 90 95 ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }); … … 94 99 item.Tag = sample; 95 100 samplesListView.Items.Add(item); 96 loadingProgressBar.Value += progress;101 this.progress.ProgressValue += progress; 97 102 } 98 103 } … … 106 111 samplesListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 107 112 } 108 loadingPanel.Visible = false;113 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView); 109 114 } 110 115 }
Note: See TracChangeset
for help on using the changeset viewer.