Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2507 for branches


Ignore:
Timestamp:
11/19/09 15:46:55 (15 years ago)
Author:
gkronber
Message:

Renamed MainForm to StarterForm and added possibility to start a specific application from the command line. #799

Location:
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure
Files:
1 edited
3 moved

Legend:

Unmodified
Added
Removed
  • branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj

    r2504 r2507  
    116116      <SubType>Designer</SubType>
    117117    </EmbeddedResource>
    118     <EmbeddedResource Include="Starter\MainForm.resx">
    119       <DependentUpon>MainForm.cs</DependentUpon>
    120     </EmbeddedResource>
    121118    <EmbeddedResource Include="Starter\SplashScreen.resx">
    122119      <DependentUpon>SplashScreen.cs</DependentUpon>
     120    </EmbeddedResource>
     121    <EmbeddedResource Include="Starter\StarterForm.resx">
     122      <DependentUpon>StarterForm.cs</DependentUpon>
    123123    </EmbeddedResource>
    124124    <Compile Include="Properties\Resources.Designer.cs">
     
    139139      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    140140    </Compile>
    141     <Compile Include="Starter\MainForm.cs">
    142       <SubType>Form</SubType>
    143     </Compile>
    144     <Compile Include="Starter\MainForm.Designer.cs">
    145       <DependentUpon>MainForm.cs</DependentUpon>
    146     </Compile>
    147141    <Compile Include="Starter\SplashScreen.cs">
    148142      <SubType>Form</SubType>
     
    150144    <Compile Include="Starter\SplashScreen.Designer.cs">
    151145      <DependentUpon>SplashScreen.cs</DependentUpon>
     146    </Compile>
     147    <Compile Include="Starter\StarterForm.cs">
     148      <SubType>Form</SubType>
     149    </Compile>
     150    <Compile Include="Starter\StarterForm.Designer.cs">
     151      <DependentUpon>StarterForm.cs</DependentUpon>
    152152    </Compile>
    153153  </ItemGroup>
  • branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Starter/StarterForm.Designer.cs

    r2504 r2507  
    2121
    2222namespace HeuristicLab.PluginInfrastructure {
    23   partial class MainForm {
     23  partial class StarterForm {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StarterForm));
    4949      System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("Plugin Management", System.Windows.Forms.HorizontalAlignment.Left);
    5050      System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("Applications", System.Windows.Forms.HorizontalAlignment.Left);
  • branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Starter/StarterForm.cs

    r2505 r2507  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections.Generic;
    2425using System.ComponentModel;
     
    3435
    3536namespace HeuristicLab.PluginInfrastructure {
    36   public partial class MainForm : Form {
     37  public partial class StarterForm : Form {
    3738
    3839    private ListViewItem pluginManagerListViewItem;
     
    4041    private PluginManager pluginManager;
    4142
    42     public MainForm()
     43    public StarterForm()
    4344      : base() {
    4445      InitializeComponent();
     
    7677    }
    7778
     79    public StarterForm(string appName)
     80      : this() {
     81      var appDesc = (from desc in pluginManager.Applications
     82                     where desc.Name == appName
     83                     select desc).Single();
     84      if (appDesc != null) {
     85        StartApplication(appDesc);
     86      } else {
     87        MessageBox.Show("Cannot start application " + appName + ".",
     88                        "HeuristicLab",
     89                        MessageBoxButtons.OK,
     90                        MessageBoxIcon.Warning);
     91      }
     92    }
     93
    7894    private void applicationsListView_ItemActivate(object sender, EventArgs e) {
    7995      if (applicationsListView.SelectedItems.Count > 0) {
     
    93109        } else {
    94110          ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag;
    95           SplashScreen splashScreen = new SplashScreen(pluginManager, 2000, "Loading " + app.Name);
    96           splashScreen.Show();
    97           Thread t = new Thread(delegate() {
    98             bool stopped = false;
    99             do {
    100               try {
    101                 if (!abortRequested)
    102                   pluginManager.Run(app);
    103                 stopped = true;
    104               }
    105               catch (Exception ex) {
    106                 stopped = false;
    107                 ThreadPool.QueueUserWorkItem(delegate(object exception) { ShowErrorMessageBox((Exception)exception); }, ex);
    108                 Thread.Sleep(5000); // sleep 5 seconds before autorestart
    109               }
    110             } while (!abortRequested && !stopped && app.AutoRestart);
    111           });
    112           t.SetApartmentState(ApartmentState.STA); // needed for the AdvancedOptimizationFrontent
    113           t.Start();
     111          StartApplication(app);
    114112        }
    115113      }
     114    }
     115
     116    private void StartApplication(ApplicationDescription app) {
     117      SplashScreen splashScreen = new SplashScreen(pluginManager, 2000, "Loading " + app.Name);
     118      splashScreen.Show();
     119      Thread t = new Thread(delegate() {
     120        bool stopped = false;
     121        do {
     122          try {
     123            if (!abortRequested)
     124              pluginManager.Run(app);
     125            stopped = true;
     126          }
     127          catch (Exception ex) {
     128            stopped = false;
     129            ThreadPool.QueueUserWorkItem(delegate(object exception) { ShowErrorMessageBox((Exception)exception); }, ex);
     130            Thread.Sleep(5000); // sleep 5 seconds before autorestart
     131          }
     132        } while (!abortRequested && !stopped && app.AutoRestart);
     133      });
     134      t.SetApartmentState(ApartmentState.STA); // needed for the AdvancedOptimizationFrontent
     135      t.Start();
    116136    }
    117137
Note: See TracChangeset for help on using the changeset viewer.