Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3202


Ignore:
Timestamp:
03/23/10 06:59:41 (13 years ago)
Author:
swagner
Message:

Added content of start page (#936).

Location:
trunk/sources/HeuristicLab.Optimizer/3.3
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r3163 r3202  
    136136  <ItemGroup>
    137137    <None Include="app.config" />
     138    <EmbeddedResource Include="Documents\FirstSteps.rtf" />
     139    <EmbeddedResource Include="Documents\GA_TSP.hl" />
     140    <EmbeddedResource Include="Documents\LS_OneMax.hl" />
     141    <EmbeddedResource Include="Documents\SA_Rastrigin.hl" />
    138142    <None Include="HeuristicLab.snk" />
    139143    <None Include="Properties\AssemblyInfo.frame" />
  • trunk/sources/HeuristicLab.Optimizer/3.3/NewItemDialog.Designer.cs

    r2790 r3202  
    8686            this.nameColumnHeader,
    8787            this.descriptioncolumnHeader});
     88      this.itemsListView.FullRowSelect = true;
    8889      this.itemsListView.HideSelection = false;
    8990      this.itemsListView.Location = new System.Drawing.Point(12, 12);
  • trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.Designer.cs

    r3163 r3202  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.showStartPageCheckBox = new System.Windows.Forms.CheckBox();
     49      this.firstStepsRichTextBox = new System.Windows.Forms.RichTextBox();
     50      this.titleLabel = new System.Windows.Forms.Label();
     51      this.samplesGroupBox = new System.Windows.Forms.GroupBox();
     52      this.samplesListView = new System.Windows.Forms.ListView();
     53      this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();
     54      this.descriptionColumnHeader = new System.Windows.Forms.ColumnHeader();
     55      this.imageList = new System.Windows.Forms.ImageList(this.components);
     56      this.samplesGroupBox.SuspendLayout();
    4857      this.SuspendLayout();
    4958      //
     
    5362      this.showStartPageCheckBox.AutoSize = true;
    5463      this.showStartPageCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
    55       this.showStartPageCheckBox.Location = new System.Drawing.Point(3, 262);
     64      this.showStartPageCheckBox.Location = new System.Drawing.Point(3, 491);
    5665      this.showStartPageCheckBox.Name = "showStartPageCheckBox";
    5766      this.showStartPageCheckBox.Size = new System.Drawing.Size(158, 17);
    58       this.showStartPageCheckBox.TabIndex = 0;
     67      this.showStartPageCheckBox.TabIndex = 3;
    5968      this.showStartPageCheckBox.Text = "Show Start Page on Startup";
    6069      this.showStartPageCheckBox.UseVisualStyleBackColor = true;
    6170      this.showStartPageCheckBox.CheckedChanged += new System.EventHandler(this.showStartPageCheckBox_CheckedChanged);
     71      //
     72      // firstStepsRichTextBox
     73      //
     74      this.firstStepsRichTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     75                  | System.Windows.Forms.AnchorStyles.Left)
     76                  | System.Windows.Forms.AnchorStyles.Right)));
     77      this.firstStepsRichTextBox.BackColor = System.Drawing.SystemColors.Control;
     78      this.firstStepsRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
     79      this.firstStepsRichTextBox.Cursor = System.Windows.Forms.Cursors.Arrow;
     80      this.firstStepsRichTextBox.Location = new System.Drawing.Point(3, 33);
     81      this.firstStepsRichTextBox.Name = "firstStepsRichTextBox";
     82      this.firstStepsRichTextBox.ReadOnly = true;
     83      this.firstStepsRichTextBox.Size = new System.Drawing.Size(815, 268);
     84      this.firstStepsRichTextBox.TabIndex = 1;
     85      this.firstStepsRichTextBox.Text = "First Steps";
     86      this.firstStepsRichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.firstStepsRichTextBox_LinkClicked);
     87      //
     88      // titleLabel
     89      //
     90      this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     91                  | System.Windows.Forms.AnchorStyles.Right)));
     92      this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     93      this.titleLabel.Location = new System.Drawing.Point(3, 0);
     94      this.titleLabel.Name = "titleLabel";
     95      this.titleLabel.Size = new System.Drawing.Size(815, 30);
     96      this.titleLabel.TabIndex = 0;
     97      this.titleLabel.Text = "Title";
     98      this.titleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     99      //
     100      // samplesGroupBox
     101      //
     102      this.samplesGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     103                  | System.Windows.Forms.AnchorStyles.Right)));
     104      this.samplesGroupBox.Controls.Add(this.samplesListView);
     105      this.samplesGroupBox.Location = new System.Drawing.Point(3, 307);
     106      this.samplesGroupBox.Name = "samplesGroupBox";
     107      this.samplesGroupBox.Size = new System.Drawing.Size(815, 178);
     108      this.samplesGroupBox.TabIndex = 2;
     109      this.samplesGroupBox.TabStop = false;
     110      this.samplesGroupBox.Text = "Samples";
     111      //
     112      // samplesListView
     113      //
     114      this.samplesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
     115            this.nameColumnHeader,
     116            this.descriptionColumnHeader});
     117      this.samplesListView.Dock = System.Windows.Forms.DockStyle.Fill;
     118      this.samplesListView.FullRowSelect = true;
     119      this.samplesListView.Location = new System.Drawing.Point(3, 16);
     120      this.samplesListView.MultiSelect = false;
     121      this.samplesListView.Name = "samplesListView";
     122      this.samplesListView.ShowItemToolTips = true;
     123      this.samplesListView.Size = new System.Drawing.Size(809, 159);
     124      this.samplesListView.SmallImageList = this.imageList;
     125      this.samplesListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
     126      this.samplesListView.TabIndex = 0;
     127      this.samplesListView.UseCompatibleStateImageBehavior = false;
     128      this.samplesListView.View = System.Windows.Forms.View.Details;
     129      this.samplesListView.DoubleClick += new System.EventHandler(this.samplesListView_DoubleClick);
     130      //
     131      // nameColumnHeader
     132      //
     133      this.nameColumnHeader.Text = "Name";
     134      this.nameColumnHeader.Width = 150;
     135      //
     136      // descriptionColumnHeader
     137      //
     138      this.descriptionColumnHeader.Text = "Description";
     139      this.descriptionColumnHeader.Width = 300;
     140      //
     141      // imageList
     142      //
     143      this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     144      this.imageList.ImageSize = new System.Drawing.Size(16, 16);
     145      this.imageList.TransparentColor = System.Drawing.Color.Transparent;
    62146      //
    63147      // StartPage
     
    65149      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    66150      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     151      this.Controls.Add(this.firstStepsRichTextBox);
     152      this.Controls.Add(this.samplesGroupBox);
     153      this.Controls.Add(this.titleLabel);
    67154      this.Controls.Add(this.showStartPageCheckBox);
    68155      this.Name = "StartPage";
    69       this.Size = new System.Drawing.Size(508, 282);
     156      this.Size = new System.Drawing.Size(821, 511);
     157      this.samplesGroupBox.ResumeLayout(false);
    70158      this.ResumeLayout(false);
    71159      this.PerformLayout();
     
    76164
    77165    private System.Windows.Forms.CheckBox showStartPageCheckBox;
     166    private System.Windows.Forms.RichTextBox firstStepsRichTextBox;
     167    private System.Windows.Forms.Label titleLabel;
     168    private System.Windows.Forms.GroupBox samplesGroupBox;
     169    private System.Windows.Forms.ListView samplesListView;
     170    private System.Windows.Forms.ColumnHeader nameColumnHeader;
     171    private System.Windows.Forms.ImageList imageList;
     172    private System.Windows.Forms.ColumnHeader descriptionColumnHeader;
    78173  }
    79174}
  • trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.cs

    r3163 r3202  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.IO;
     25using System.Linq;
     26using System.Reflection;
     27using System.Windows.Forms;
     28using HeuristicLab.Core;
    2329using HeuristicLab.MainForm;
    24 using HeuristicLab.MainForm.WindowsForms;
     30using HeuristicLab.Persistence.Default.Xml;
    2531
    2632namespace HeuristicLab.Optimizer {
    2733  [View("Start Page")]
    28   public partial class StartPage : View {
     34  public partial class StartPage : HeuristicLab.MainForm.WindowsForms.View {
     35    private List<INamedItem> samples;
     36
    2937    public StartPage() {
    3038      InitializeComponent();
     
    3442    protected override void OnInitialized(EventArgs e) {
    3543      base.OnInitialized(e);
     44      Assembly assembly = Assembly.GetExecutingAssembly();
     45      AssemblyFileVersionAttribute version = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).
     46                                             Cast<AssemblyFileVersionAttribute>().FirstOrDefault();
     47      titleLabel.Text = "HeuristicLab Optimizer";
     48      if (version != null) titleLabel.Text += " " + version.Version;
     49
     50      try {
     51        using (Stream stream = assembly.GetManifestResourceStream(typeof(StartPage), "Documents.FirstSteps.rtf"))
     52          firstStepsRichTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
     53      }
     54      catch (Exception) { }
     55
     56      samples = new List<INamedItem>();
     57      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            }
     66          }
     67          catch (Exception) { }
     68        }
     69      }
     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);
     77      }
     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
    3684      showStartPageCheckBox.Checked = Properties.Settings.Default.ShowStartPage;
     85    }
     86
     87    private void firstStepsRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e) {
     88      System.Diagnostics.Process.Start(e.LinkText);
     89    }
     90
     91    private void samplesListView_DoubleClick(object sender, EventArgs e) {
     92      if (samplesListView.SelectedItems.Count == 1)
     93        MainFormManager.CreateDefaultView(((IItem)samplesListView.SelectedItems[0].Tag).Clone()).Show();
    3794    }
    3895
     
    4198      Properties.Settings.Default.Save();
    4299    }
     100
     101    #region Helpers
     102    private void WriteStreamToTempFile(Stream stream, string path) {
     103      using (FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write)) {
     104        int cnt = 0;
     105        byte[] buffer = new byte[32 * 1024];
     106        while ((cnt = stream.Read(buffer, 0, buffer.Length)) != 0)
     107          output.Write(buffer, 0, cnt);
     108      }
     109    }
     110    #endregion
    43111  }
    44112}
Note: See TracChangeset for help on using the changeset viewer.