Index: stable/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj
===================================================================
--- stable/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj (revision 11121)
+++ stable/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj (revision 11122)
@@ -130,4 +130,9 @@
+
+
+
+
+
Index: stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs
===================================================================
--- stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs (revision 11121)
+++ stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs (revision 11122)
@@ -86,5 +86,5 @@
this.firstStepsRichTextBox.Name = "firstStepsRichTextBox";
this.firstStepsRichTextBox.ReadOnly = true;
- this.firstStepsRichTextBox.Size = new System.Drawing.Size(725, 370);
+ this.firstStepsRichTextBox.Size = new System.Drawing.Size(389, 581);
this.firstStepsRichTextBox.TabIndex = 1;
this.firstStepsRichTextBox.Text = "First Steps";
@@ -98,5 +98,5 @@
this.titleLabel.Location = new System.Drawing.Point(-1, 0);
this.titleLabel.Name = "titleLabel";
- this.titleLabel.Size = new System.Drawing.Size(729, 30);
+ this.titleLabel.Size = new System.Drawing.Size(393, 30);
this.titleLabel.TabIndex = 0;
this.titleLabel.Text = "Title";
@@ -111,5 +111,5 @@
this.samplesGroupBox.Location = new System.Drawing.Point(0, 3);
this.samplesGroupBox.Name = "samplesGroupBox";
- this.samplesGroupBox.Size = new System.Drawing.Size(728, 201);
+ this.samplesGroupBox.Size = new System.Drawing.Size(332, 637);
this.samplesGroupBox.TabIndex = 0;
this.samplesGroupBox.TabStop = false;
@@ -127,5 +127,5 @@
this.samplesListView.Name = "samplesListView";
this.samplesListView.ShowItemToolTips = true;
- this.samplesListView.Size = new System.Drawing.Size(722, 182);
+ this.samplesListView.Size = new System.Drawing.Size(326, 618);
this.samplesListView.SmallImageList = this.imageList;
this.samplesListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
@@ -154,14 +154,12 @@
// splitContainer
//
- this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
+ this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.Location = new System.Drawing.Point(0, 0);
this.splitContainer.Name = "splitContainer";
- this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.Controls.Add(this.titleLabel);
+ this.splitContainer.Panel1.Controls.Add(this.showStartPageCheckBox);
this.splitContainer.Panel1.Controls.Add(this.firstStepsRichTextBox);
//
@@ -169,6 +167,6 @@
//
this.splitContainer.Panel2.Controls.Add(this.samplesGroupBox);
- this.splitContainer.Size = new System.Drawing.Size(728, 614);
- this.splitContainer.SplitterDistance = 406;
+ this.splitContainer.Size = new System.Drawing.Size(728, 640);
+ this.splitContainer.SplitterDistance = 392;
this.splitContainer.TabIndex = 0;
//
@@ -177,14 +175,13 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.Controls.Add(this.splitContainer);
- this.Controls.Add(this.showStartPageCheckBox);
this.Name = "StartPage";
this.Size = new System.Drawing.Size(728, 640);
this.samplesGroupBox.ResumeLayout(false);
this.splitContainer.Panel1.ResumeLayout(false);
+ this.splitContainer.Panel1.PerformLayout();
this.splitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false);
- this.PerformLayout();
}
Index: stable/HeuristicLab.Optimizer/3.3/StartPage.cs
===================================================================
--- stable/HeuristicLab.Optimizer/3.3/StartPage.cs (revision 11121)
+++ stable/HeuristicLab.Optimizer/3.3/StartPage.cs (revision 11122)
@@ -1,5 +1,5 @@
#region License Information
/* HeuristicLab
- * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
@@ -21,4 +21,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -34,4 +35,17 @@
[View("Start Page")]
public partial class StartPage : HeuristicLab.MainForm.WindowsForms.View {
+ private const string StandardProblemsGroupName = "Standard Problems";
+ private const string DataAnalysisGroupName = "Data Analysis";
+ private const string ScriptsGroupName = "Scripts";
+ private const string UncategorizedGroupName = "Uncategorized";
+ private const string SampleNamePrefix = "HeuristicLab.Optimizer.Documents.";
+ private const string SampleNameSuffix = ".hl";
+
+ private readonly Dictionary> groupLookup = new Dictionary>();
+ private readonly ListViewGroup standardProblemsGroup = new ListViewGroup(StandardProblemsGroupName);
+ private readonly ListViewGroup dataAnalysisGroup = new ListViewGroup(DataAnalysisGroupName);
+ private readonly ListViewGroup scriptsGroup = new ListViewGroup(ScriptsGroupName);
+ private readonly ListViewGroup uncategorizedGroup = new ListViewGroup(UncategorizedGroupName);
+
private IProgress progress;
@@ -51,8 +65,13 @@
using (Stream stream = assembly.GetManifestResourceStream(typeof(StartPage), "Documents.FirstSteps.rtf"))
firstStepsRichTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
- }
- catch (Exception) { }
+ } catch (Exception) { }
samplesListView.Enabled = false;
+ samplesListView.Groups.Add(standardProblemsGroup);
+ samplesListView.Groups.Add(dataAnalysisGroup);
+ samplesListView.Groups.Add(scriptsGroup);
+ samplesListView.Groups.Add(uncategorizedGroup);
+ FillGroupLookup();
+
showStartPageCheckBox.Checked = Properties.Settings.Default.ShowStartPage;
@@ -71,31 +90,63 @@
progress = MainFormManager.GetMainForm().AddOperationProgressToView(samplesListView, "Loading...");
try {
- Assembly assembly = Assembly.GetExecutingAssembly();
- var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl"));
+ var assembly = Assembly.GetExecutingAssembly();
+ var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(SampleNameSuffix));
int count = samples.Count();
- string path = Path.GetTempFileName();
-
- foreach (string name in samples) {
- try {
- using (Stream stream = assembly.GetManifestResourceStream(name)) {
- WriteStreamToTempFile(stream, path);
- INamedItem item = XmlParser.Deserialize(path);
- OnSampleLoaded(item, 1.0 / count);
- }
+
+ foreach (var entry in groupLookup) {
+ var group = entry.Key;
+ var sampleList = entry.Value;
+ foreach (var sampleName in sampleList) {
+ string resourceName = SampleNamePrefix + sampleName + SampleNameSuffix;
+ LoadSample(resourceName, assembly, group, count);
}
- catch (Exception) {
- }
- }
+ }
+
+ var categorizedSamples = groupLookup.Select(x => x.Value).SelectMany(x => x).Select(x => SampleNamePrefix + x + SampleNameSuffix);
+ var uncategorizedSamples = samples.Except(categorizedSamples);
+
+ foreach (var resourceName in uncategorizedSamples) {
+ LoadSample(resourceName, assembly, uncategorizedGroup, count);
+ }
+
OnAllSamplesLoaded();
- }
- finally {
+ } finally {
MainFormManager.GetMainForm().RemoveOperationProgressFromView(samplesListView);
}
}
- private void OnSampleLoaded(INamedItem sample, double progress) {
+
+ private void LoadSample(string name, Assembly assembly, ListViewGroup group, int count) {
+ string path = Path.GetTempFileName();
+ try {
+ using (var stream = assembly.GetManifestResourceStream(name)) {
+ WriteStreamToTempFile(stream, path); // create a file in a temporary folder (persistence cannot load these files directly from the stream)
+ var item = XmlParser.Deserialize(path);
+ OnSampleLoaded(item, group, 1.0 / count);
+ }
+ } catch (Exception) {
+ } finally {
+ if (File.Exists(path)) {
+ File.Delete(path); // make sure we remove the temporary file
+ }
+ }
+ }
+
+ private void FillGroupLookup() {
+ var standardProblems = new List { "ES_Griewank", "GA_TSP", "GA_VRP", "GE_ArtificialAnt",
+ "IslandGA_TSP", "LS_Knapsack", "PSO_Schwefel", "RAPGA_JSSP",
+ "SA_Rastrigin", "SGP_SantaFe","GP_Multiplexer", "SS_VRP", "TS_TSP", "TS_VRP", "VNS_TSP"
+ };
+ groupLookup[standardProblemsGroup] = standardProblems;
+ var dataAnalysisProblems = new List { "SGP_SymbClass", "SGP_SymbReg", "OSGP_TimeSeries", "GE_SymbReg", "GPR" };
+ groupLookup[dataAnalysisGroup] = dataAnalysisProblems;
+ var scripts = new List { "GA_QAP_Script", "GUI_Automation_Script", "OSGA_Rastrigin_Script" };
+ groupLookup[scriptsGroup] = scripts;
+ }
+
+ private void OnSampleLoaded(INamedItem sample, ListViewGroup group, double progress) {
if (InvokeRequired)
- Invoke(new Action(OnSampleLoaded), sample, progress);
+ Invoke(new Action(OnSampleLoaded), sample, group, progress);
else {
- ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description });
+ ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }, group);
item.ToolTipText = sample.ItemName + ": " + sample.ItemDescription;
samplesListView.SmallImageList.Images.Add(sample.ItemImage);
@@ -123,6 +174,14 @@
private void samplesListView_DoubleClick(object sender, EventArgs e) {
- if (samplesListView.SelectedItems.Count == 1)
- MainFormManager.MainForm.ShowContent((IContent)((IItem)samplesListView.SelectedItems[0].Tag).Clone());
+ if (samplesListView.SelectedItems.Count == 1) {
+ var mainForm = MainFormManager.GetMainForm();
+ try {
+ mainForm.SetWaitCursor();
+ mainForm.ShowContent((IContent)((IItem)samplesListView.SelectedItems[0].Tag).Clone());
+ } finally {
+ mainForm.ResetWaitCursor();
+ }
+
+ }
}
private void samplesListView_ItemDrag(object sender, ItemDragEventArgs e) {
@@ -142,8 +201,5 @@
private void WriteStreamToTempFile(Stream stream, string path) {
using (FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write)) {
- int cnt = 0;
- byte[] buffer = new byte[32 * 1024];
- while ((cnt = stream.Read(buffer, 0, buffer.Length)) != 0)
- output.Write(buffer, 0, cnt);
+ stream.CopyTo(output);
}
}