Changeset 3291 for trunk/sources
- Timestamp:
- 04/09/10 02:57:16 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimizer/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/StartPageMenuItem.cs
r3163 r3291 66 66 view = new StartPage(); 67 67 view.Show(); 68 } else if (view.IsShown) { 69 view.Hide(); 68 70 } else { 69 view. Close();71 view.Show(); 70 72 } 71 73 } -
trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs
r3202 r3291 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(); 52 55 this.samplesListView = new System.Windows.Forms.ListView(); 53 56 this.nameColumnHeader = new System.Windows.Forms.ColumnHeader(); … … 55 58 this.imageList = new System.Windows.Forms.ImageList(this.components); 56 59 this.samplesGroupBox.SuspendLayout(); 60 this.loadingPanel.SuspendLayout(); 57 61 this.SuspendLayout(); 58 62 // … … 62 66 this.showStartPageCheckBox.AutoSize = true; 63 67 this.showStartPageCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 64 this.showStartPageCheckBox.Location = new System.Drawing.Point(3, 491);68 this.showStartPageCheckBox.Location = new System.Drawing.Point(3, 542); 65 69 this.showStartPageCheckBox.Name = "showStartPageCheckBox"; 66 70 this.showStartPageCheckBox.Size = new System.Drawing.Size(158, 17); … … 81 85 this.firstStepsRichTextBox.Name = "firstStepsRichTextBox"; 82 86 this.firstStepsRichTextBox.ReadOnly = true; 83 this.firstStepsRichTextBox.Size = new System.Drawing.Size( 815, 268);87 this.firstStepsRichTextBox.Size = new System.Drawing.Size(760, 319); 84 88 this.firstStepsRichTextBox.TabIndex = 1; 85 89 this.firstStepsRichTextBox.Text = "First Steps"; … … 93 97 this.titleLabel.Location = new System.Drawing.Point(3, 0); 94 98 this.titleLabel.Name = "titleLabel"; 95 this.titleLabel.Size = new System.Drawing.Size( 815, 30);99 this.titleLabel.Size = new System.Drawing.Size(760, 30); 96 100 this.titleLabel.TabIndex = 0; 97 101 this.titleLabel.Text = "Title"; … … 102 106 this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 103 107 | System.Windows.Forms.AnchorStyles.Right))); 108 this.samplesGroupBox.Controls.Add(this.loadingPanel); 104 109 this.samplesGroupBox.Controls.Add(this.samplesListView); 105 this.samplesGroupBox.Location = new System.Drawing.Point(3, 3 07);110 this.samplesGroupBox.Location = new System.Drawing.Point(3, 358); 106 111 this.samplesGroupBox.Name = "samplesGroupBox"; 107 this.samplesGroupBox.Size = new System.Drawing.Size( 815, 178);112 this.samplesGroupBox.Size = new System.Drawing.Size(760, 178); 108 113 this.samplesGroupBox.TabIndex = 2; 109 114 this.samplesGroupBox.TabStop = false; 110 115 this.samplesGroupBox.Text = "Samples"; 116 // 117 // loadingPanel 118 // 119 this.loadingPanel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; 120 this.loadingPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 121 this.loadingPanel.Controls.Add(this.loadingProgressBar); 122 this.loadingPanel.Controls.Add(this.loadingLabel); 123 this.loadingPanel.Enabled = false; 124 this.loadingPanel.Location = new System.Drawing.Point(205, 74); 125 this.loadingPanel.Name = "loadingPanel"; 126 this.loadingPanel.Size = new System.Drawing.Size(350, 62); 127 this.loadingPanel.TabIndex = 1; 128 // 129 // loadingProgressBar 130 // 131 this.loadingProgressBar.Anchor = System.Windows.Forms.AnchorStyles.None; 132 this.loadingProgressBar.Location = new System.Drawing.Point(101, 19); 133 this.loadingProgressBar.Name = "loadingProgressBar"; 134 this.loadingProgressBar.Size = new System.Drawing.Size(229, 23); 135 this.loadingProgressBar.Step = 1; 136 this.loadingProgressBar.TabIndex = 1; 137 // 138 // loadingLabel 139 // 140 this.loadingLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 141 this.loadingLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 142 this.loadingLabel.Location = new System.Drawing.Point(12, 19); 143 this.loadingLabel.Name = "loadingLabel"; 144 this.loadingLabel.Size = new System.Drawing.Size(83, 23); 145 this.loadingLabel.TabIndex = 0; 146 this.loadingLabel.Text = "Loading ..."; 111 147 // 112 148 // samplesListView … … 121 157 this.samplesListView.Name = "samplesListView"; 122 158 this.samplesListView.ShowItemToolTips = true; 123 this.samplesListView.Size = new System.Drawing.Size( 809, 159);159 this.samplesListView.Size = new System.Drawing.Size(754, 159); 124 160 this.samplesListView.SmallImageList = this.imageList; 125 161 this.samplesListView.Sorting = System.Windows.Forms.SortOrder.Ascending; … … 154 190 this.Controls.Add(this.showStartPageCheckBox); 155 191 this.Name = "StartPage"; 156 this.Size = new System.Drawing.Size( 821, 511);192 this.Size = new System.Drawing.Size(766, 562); 157 193 this.samplesGroupBox.ResumeLayout(false); 194 this.loadingPanel.ResumeLayout(false); 158 195 this.ResumeLayout(false); 159 196 this.PerformLayout(); … … 171 208 private System.Windows.Forms.ImageList imageList; 172 209 private System.Windows.Forms.ColumnHeader descriptionColumnHeader; 210 private System.Windows.Forms.Panel loadingPanel; 211 private System.Windows.Forms.ProgressBar loadingProgressBar; 212 private System.Windows.Forms.Label loadingLabel; 173 213 } 174 214 } -
trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.cs
r3202 r3291 29 29 using HeuristicLab.MainForm; 30 30 using HeuristicLab.Persistence.Default.Xml; 31 using System.Threading; 31 32 32 33 namespace HeuristicLab.Optimizer { … … 54 55 catch (Exception) { } 55 56 56 samples = new List<INamedItem>(); 57 samplesListView.Enabled = false; 58 showStartPageCheckBox.Checked = Properties.Settings.Default.ShowStartPage; 59 Cursor = Cursors.AppStarting; 60 61 ThreadPool.QueueUserWorkItem(new WaitCallback(LoadSamples)); 62 } 63 64 protected override void OnClosing(FormClosingEventArgs e) { 65 base.OnClosing(e); 66 if (e.CloseReason == CloseReason.UserClosing) { 67 e.Cancel = true; 68 this.Hide(); 69 } 70 } 71 72 private void LoadSamples(object state) { 73 Assembly assembly = Assembly.GetExecutingAssembly(); 74 var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl")); 57 75 string path = Path.GetTempFileName(); 58 foreach (string name in assembly.GetManifestResourceNames()) {59 if (name.EndsWith(".hl")) { 60 try{61 using (Stream stream = assembly.GetManifestResourceStream(name)){62 WriteStreamToTempFile(stream, path);63 IItem item = XmlParser.Deserialize<IItem>(path);64 if (item is INamedItem) samples.Add((INamedItem)item);65 }76 int progress = loadingProgressBar.Maximum / samples.Count(); 77 78 foreach (string name in samples) { 79 try { 80 using (Stream stream = assembly.GetManifestResourceStream(name)) { 81 WriteStreamToTempFile(stream, path); 82 IItem item = XmlParser.Deserialize<IItem>(path); 83 OnSampleLoaded(item as INamedItem, progress); 66 84 } 67 catch (Exception) { } 85 } 86 catch (Exception) { } 87 } 88 OnAllSamplesLoaded(); 89 } 90 private void OnSampleLoaded(INamedItem sample, int progress) { 91 if (sample != null) { 92 if (InvokeRequired) 93 Invoke(new Action<INamedItem, int>(OnSampleLoaded), sample, progress); 94 else { 95 ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }); 96 item.ToolTipText = sample.ItemName + " (" + sample.ItemDescription + ")"; 97 samplesListView.SmallImageList.Images.Add(sample.ItemImage); 98 item.ImageIndex = samplesListView.SmallImageList.Images.Count - 1; 99 item.Tag = sample; 100 samplesListView.Items.Add(item); 101 loadingProgressBar.Value += progress; 68 102 } 69 103 } 70 foreach (INamedItem sample in samples) { 71 ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }); 72 item.ToolTipText = sample.ItemName + " (" + sample.ItemDescription + ")"; 73 samplesListView.SmallImageList.Images.Add(sample.ItemImage); 74 item.ImageIndex = samplesListView.SmallImageList.Images.Count - 1; 75 item.Tag = sample; 76 samplesListView.Items.Add(item); 104 } 105 private void OnAllSamplesLoaded() { 106 if (InvokeRequired) 107 Invoke(new Action(OnAllSamplesLoaded)); 108 else { 109 samplesListView.Enabled = samplesListView.Items.Count > 0; 110 if (samplesListView.Items.Count > 0) { 111 for (int i = 0; i < samplesListView.Columns.Count; i++) 112 samplesListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 113 } 114 loadingPanel.Visible = false; 115 Cursor = Cursors.Default; 77 116 } 78 samplesListView.Enabled = samplesListView.Items.Count > 0;79 if (samplesListView.Items.Count > 0) {80 for (int i = 0; i < samplesListView.Columns.Count; i++)81 samplesListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);82 }83 84 showStartPageCheckBox.Checked = Properties.Settings.Default.ShowStartPage;85 117 } 86 118
Note: See TracChangeset
for help on using the changeset viewer.