Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11122 for stable


Ignore:
Timestamp:
07/07/14 17:02:50 (10 years ago)
Author:
gkronber
Message:

#2195: merged r11048,r11052,r11057,r11067,r11074,r11092 from trunk to stable (release)

Location:
stable
Files:
5 edited
4 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r11103 r11122  
    130130    <EmbeddedResource Include="Documents\GE_ArtificialAnt.hl" />
    131131    <EmbeddedResource Include="Documents\GE_SymbReg.hl" />
     132    <EmbeddedResource Include="Documents\GA_QAP_Script.hl" />
     133    <EmbeddedResource Include="Documents\GUI_Automation_Script.hl" />
     134    <EmbeddedResource Include="Documents\OSGA_Rastrigin_Script.hl" />
     135    <EmbeddedResource Include="Documents\GP_Multiplexer.hl" />
     136    <EmbeddedResource Include="Documents\OSGP_TimeSeries.hl" />
    132137    <None Include="Plugin.cs.frame" />
    133138    <Compile Include="OptimizerSingleDocumentMainForm.cs">
  • stable/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs

    r9933 r11122  
    8686      this.firstStepsRichTextBox.Name = "firstStepsRichTextBox";
    8787      this.firstStepsRichTextBox.ReadOnly = true;
    88       this.firstStepsRichTextBox.Size = new System.Drawing.Size(725, 370);
     88      this.firstStepsRichTextBox.Size = new System.Drawing.Size(389, 581);
    8989      this.firstStepsRichTextBox.TabIndex = 1;
    9090      this.firstStepsRichTextBox.Text = "First Steps";
     
    9898      this.titleLabel.Location = new System.Drawing.Point(-1, 0);
    9999      this.titleLabel.Name = "titleLabel";
    100       this.titleLabel.Size = new System.Drawing.Size(729, 30);
     100      this.titleLabel.Size = new System.Drawing.Size(393, 30);
    101101      this.titleLabel.TabIndex = 0;
    102102      this.titleLabel.Text = "Title";
     
    111111      this.samplesGroupBox.Location = new System.Drawing.Point(0, 3);
    112112      this.samplesGroupBox.Name = "samplesGroupBox";
    113       this.samplesGroupBox.Size = new System.Drawing.Size(728, 201);
     113      this.samplesGroupBox.Size = new System.Drawing.Size(332, 637);
    114114      this.samplesGroupBox.TabIndex = 0;
    115115      this.samplesGroupBox.TabStop = false;
     
    127127      this.samplesListView.Name = "samplesListView";
    128128      this.samplesListView.ShowItemToolTips = true;
    129       this.samplesListView.Size = new System.Drawing.Size(722, 182);
     129      this.samplesListView.Size = new System.Drawing.Size(326, 618);
    130130      this.samplesListView.SmallImageList = this.imageList;
    131131      this.samplesListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
     
    154154      // splitContainer
    155155      //
    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)));
     156      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
    159157      this.splitContainer.Location = new System.Drawing.Point(0, 0);
    160158      this.splitContainer.Name = "splitContainer";
    161       this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
    162159      //
    163160      // splitContainer.Panel1
    164161      //
    165162      this.splitContainer.Panel1.Controls.Add(this.titleLabel);
     163      this.splitContainer.Panel1.Controls.Add(this.showStartPageCheckBox);
    166164      this.splitContainer.Panel1.Controls.Add(this.firstStepsRichTextBox);
    167165      //
     
    169167      //
    170168      this.splitContainer.Panel2.Controls.Add(this.samplesGroupBox);
    171       this.splitContainer.Size = new System.Drawing.Size(728, 614);
    172       this.splitContainer.SplitterDistance = 406;
     169      this.splitContainer.Size = new System.Drawing.Size(728, 640);
     170      this.splitContainer.SplitterDistance = 392;
    173171      this.splitContainer.TabIndex = 0;
    174172      //
     
    177175      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    178176      this.Controls.Add(this.splitContainer);
    179       this.Controls.Add(this.showStartPageCheckBox);
    180177      this.Name = "StartPage";
    181178      this.Size = new System.Drawing.Size(728, 640);
    182179      this.samplesGroupBox.ResumeLayout(false);
    183180      this.splitContainer.Panel1.ResumeLayout(false);
     181      this.splitContainer.Panel1.PerformLayout();
    184182      this.splitContainer.Panel2.ResumeLayout(false);
    185183      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    186184      this.splitContainer.ResumeLayout(false);
    187185      this.ResumeLayout(false);
    188       this.PerformLayout();
    189186
    190187    }
  • stable/HeuristicLab.Optimizer/3.3/StartPage.cs

    r11105 r11122  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.IO;
    2425using System.Linq;
     
    3435  [View("Start Page")]
    3536  public partial class StartPage : HeuristicLab.MainForm.WindowsForms.View {
     37    private const string StandardProblemsGroupName = "Standard Problems";
     38    private const string DataAnalysisGroupName = "Data Analysis";
     39    private const string ScriptsGroupName = "Scripts";
     40    private const string UncategorizedGroupName = "Uncategorized";
     41    private const string SampleNamePrefix = "HeuristicLab.Optimizer.Documents.";
     42    private const string SampleNameSuffix = ".hl";
     43
     44    private readonly Dictionary<ListViewGroup, List<string>> groupLookup = new Dictionary<ListViewGroup, List<string>>();
     45    private readonly ListViewGroup standardProblemsGroup = new ListViewGroup(StandardProblemsGroupName);
     46    private readonly ListViewGroup dataAnalysisGroup = new ListViewGroup(DataAnalysisGroupName);
     47    private readonly ListViewGroup scriptsGroup = new ListViewGroup(ScriptsGroupName);
     48    private readonly ListViewGroup uncategorizedGroup = new ListViewGroup(UncategorizedGroupName);
     49
    3650    private IProgress progress;
    3751
     
    5165        using (Stream stream = assembly.GetManifestResourceStream(typeof(StartPage), "Documents.FirstSteps.rtf"))
    5266          firstStepsRichTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
    53       }
    54       catch (Exception) { }
     67      } catch (Exception) { }
    5568
    5669      samplesListView.Enabled = false;
     70      samplesListView.Groups.Add(standardProblemsGroup);
     71      samplesListView.Groups.Add(dataAnalysisGroup);
     72      samplesListView.Groups.Add(scriptsGroup);
     73      samplesListView.Groups.Add(uncategorizedGroup);
     74      FillGroupLookup();
     75
    5776      showStartPageCheckBox.Checked = Properties.Settings.Default.ShowStartPage;
    5877
     
    7190      progress = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(samplesListView, "Loading...");
    7291      try {
    73         Assembly assembly = Assembly.GetExecutingAssembly();
    74         var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".hl"));
     92        var assembly = Assembly.GetExecutingAssembly();
     93        var samples = assembly.GetManifestResourceNames().Where(x => x.EndsWith(SampleNameSuffix));
    7594        int count = samples.Count();
    76         string path = Path.GetTempFileName();
    77 
    78         foreach (string name in samples) {
    79           try {
    80             using (Stream stream = assembly.GetManifestResourceStream(name)) {
    81               WriteStreamToTempFile(stream, path);
    82               INamedItem item = XmlParser.Deserialize<INamedItem>(path);
    83               OnSampleLoaded(item, 1.0 / count);
    84             }
     95
     96        foreach (var entry in groupLookup) {
     97          var group = entry.Key;
     98          var sampleList = entry.Value;
     99          foreach (var sampleName in sampleList) {
     100            string resourceName = SampleNamePrefix + sampleName + SampleNameSuffix;
     101            LoadSample(resourceName, assembly, group, count);
    85102          }
    86           catch (Exception) {
    87           }
    88         }
     103        }
     104
     105        var categorizedSamples = groupLookup.Select(x => x.Value).SelectMany(x => x).Select(x => SampleNamePrefix + x + SampleNameSuffix);
     106        var uncategorizedSamples = samples.Except(categorizedSamples);
     107
     108        foreach (var resourceName in uncategorizedSamples) {
     109          LoadSample(resourceName, assembly, uncategorizedGroup, count);
     110        }
     111
    89112        OnAllSamplesLoaded();
    90       }
    91       finally {
     113      } finally {
    92114        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(samplesListView);
    93115      }
    94116    }
    95     private void OnSampleLoaded(INamedItem sample, double progress) {
     117
     118    private void LoadSample(string name, Assembly assembly, ListViewGroup group, int count) {
     119      string path = Path.GetTempFileName();
     120      try {
     121        using (var stream = assembly.GetManifestResourceStream(name)) {
     122          WriteStreamToTempFile(stream, path); // create a file in a temporary folder (persistence cannot load these files directly from the stream)
     123          var item = XmlParser.Deserialize<INamedItem>(path);
     124          OnSampleLoaded(item, group, 1.0 / count);
     125        }
     126      } catch (Exception) {
     127      } finally {
     128        if (File.Exists(path)) {
     129          File.Delete(path); // make sure we remove the temporary file
     130        }
     131      }
     132    }
     133
     134    private void FillGroupLookup() {
     135      var standardProblems = new List<string> { "ES_Griewank", "GA_TSP", "GA_VRP", "GE_ArtificialAnt",
     136                "IslandGA_TSP", "LS_Knapsack", "PSO_Schwefel", "RAPGA_JSSP",
     137                "SA_Rastrigin", "SGP_SantaFe","GP_Multiplexer", "SS_VRP", "TS_TSP", "TS_VRP", "VNS_TSP"
     138        };
     139      groupLookup[standardProblemsGroup] = standardProblems;
     140      var dataAnalysisProblems = new List<string> { "SGP_SymbClass", "SGP_SymbReg", "OSGP_TimeSeries", "GE_SymbReg", "GPR" };
     141      groupLookup[dataAnalysisGroup] = dataAnalysisProblems;
     142      var scripts = new List<string> { "GA_QAP_Script", "GUI_Automation_Script", "OSGA_Rastrigin_Script" };
     143      groupLookup[scriptsGroup] = scripts;
     144    }
     145
     146    private void OnSampleLoaded(INamedItem sample, ListViewGroup group, double progress) {
    96147      if (InvokeRequired)
    97         Invoke(new Action<INamedItem, double>(OnSampleLoaded), sample, progress);
     148        Invoke(new Action<INamedItem, ListViewGroup, double>(OnSampleLoaded), sample, group, progress);
    98149      else {
    99         ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description });
     150        ListViewItem item = new ListViewItem(new string[] { sample.Name, sample.Description }, group);
    100151        item.ToolTipText = sample.ItemName + ": " + sample.ItemDescription;
    101152        samplesListView.SmallImageList.Images.Add(sample.ItemImage);
     
    123174
    124175    private void samplesListView_DoubleClick(object sender, EventArgs e) {
    125       if (samplesListView.SelectedItems.Count == 1)
    126         MainFormManager.MainForm.ShowContent((IContent)((IItem)samplesListView.SelectedItems[0].Tag).Clone());
     176      if (samplesListView.SelectedItems.Count == 1) {
     177        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     178        try {
     179          mainForm.SetWaitCursor();
     180          mainForm.ShowContent((IContent)((IItem)samplesListView.SelectedItems[0].Tag).Clone());
     181        } finally {
     182          mainForm.ResetWaitCursor();
     183        }
     184
     185      }
    127186    }
    128187    private void samplesListView_ItemDrag(object sender, ItemDragEventArgs e) {
     
    142201    private void WriteStreamToTempFile(Stream stream, string path) {
    143202      using (FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write)) {
    144         int cnt = 0;
    145         byte[] buffer = new byte[32 * 1024];
    146         while ((cnt = stream.Read(buffer, 0, buffer.Length)) != 0)
    147           output.Write(buffer, 0, cnt);
     203        stream.CopyTo(output);
    148204      }
    149205    }
Note: See TracChangeset for help on using the changeset viewer.