Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/24/15 19:02:57 (8 years ago)
Author:
gkronber
Message:

#2522: removed Starter form and instead init plugin discovery and launch of application from Startup project (.exe)

Location:
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/HeuristicLab.PluginInfrastructure.UI-4.0.csproj

    r13363 r13389  
    7474      <DependentUpon>SplashScreen.cs</DependentUpon>
    7575    </Compile>
    76     <Compile Include="StarterForm.cs">
    77       <SubType>Form</SubType>
    78     </Compile>
    79     <Compile Include="StarterForm.Designer.cs">
    80       <DependentUpon>StarterForm.cs</DependentUpon>
    81     </Compile>
    8276    <Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
    8377  </ItemGroup>
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure.UI/SplashScreen.cs

    r13353 r13389  
    2424using System.Reflection;
    2525using System.Windows.Forms;
    26 using HeuristicLab.PluginInfrastructure.Manager;
    2726
    2827namespace HeuristicLab.PluginInfrastructure.UI {
    29   internal partial class SplashScreen : Form {
     28  public partial class SplashScreen : Form {
    3029    private const int FADE_INTERVAL = 50;
    3130    private Timer fadeTimer;
    3231    private int initialInterval;
    33     private PluginManager pluginManager;
    3432
    35     internal SplashScreen() {
     33    private SplashScreen() {
    3634      InitializeComponent();
    3735    }
    3836
    39     internal SplashScreen(PluginManager manager, int initialInterval)
     37    public SplashScreen(string initialText, int initialInterval)
    4038      : this() {
    4139      this.initialInterval = initialInterval;
    42       this.pluginManager = manager;
    4340
    4441      var entryAssembly = Assembly.GetEntryAssembly();
    45       RegisterPluginManagerEventHandlers();
     42      // RegisterPluginManagerEventHandlers();
    4643
    47       versionLabel.Text = "Version " + entryAssembly.GetFileVersion() + " " 
     44      versionLabel.Text = "Version " + entryAssembly.GetFileVersion() + " "
    4845        + entryAssembly.GetCustomAttributes().OfType<AssemblyInformationalVersionAttribute>().First().InformationalVersion; // code name
    4946      infoLabel.Text = "";
     
    5552      fadeTimer.Tick += fadeTimer_Elapsed;
    5653      fadeTimer.Interval = initialInterval;
     54      fadeTimer.Start();
     55
     56      Opacity = 1;
     57      infoLabel.Text = initialText;
     58
    5759    }
    5860
    59     #region events
    60     private void RegisterPluginManagerEventHandlers() {
    61       pluginManager.ApplicationStarted += new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarted);
    62       pluginManager.ApplicationStarting += new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarting);
    63       pluginManager.Initializing += new EventHandler<PluginInfrastructureEventArgs>(manager_Initializing);
    64       pluginManager.Initialized += new EventHandler<PluginInfrastructureEventArgs>(manager_Initialized);
    65       pluginManager.PluginLoaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginLoaded);
    66       pluginManager.PluginUnloaded += new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded);
    67     }
    68 
    69     private void DeregisterPluginManagerEventHandlers() {
    70       pluginManager.ApplicationStarted -= new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarted);
    71       pluginManager.ApplicationStarting -= new EventHandler<PluginInfrastructureEventArgs>(manager_ApplicationStarting);
    72       pluginManager.Initializing -= new EventHandler<PluginInfrastructureEventArgs>(manager_Initializing);
    73       pluginManager.Initialized -= new EventHandler<PluginInfrastructureEventArgs>(manager_Initialized);
    74       pluginManager.PluginLoaded -= new EventHandler<PluginInfrastructureEventArgs>(manager_PluginLoaded);
    75       pluginManager.PluginUnloaded -= new EventHandler<PluginInfrastructureEventArgs>(manager_PluginUnloaded);
    76     }
    77 
    78     private void manager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) {
    79       SafeUpdateMessage("Unloaded " + e.Entity);
    80     }
    81 
    82     private void manager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) {
    83       SafeUpdateMessage("Loaded " + e.Entity);
    84     }
    85 
    86     private void manager_Initialized(object sender, PluginInfrastructureEventArgs e) {
    87       SafeUpdateMessage("Initialized");
    88     }
    89 
    90     private void manager_Initializing(object sender, PluginInfrastructureEventArgs e) {
    91       SafeUpdateMessage("Initializing");
    92     }
    93 
    94     private void manager_ApplicationStarting(object sender, PluginInfrastructureEventArgs e) {
    95       SafeUpdateMessage("Starting " + e.Entity);
    96     }
    97 
    98     private void manager_ApplicationStarted(object sender, PluginInfrastructureEventArgs e) {
    99       SafeUpdateMessage("Started " + e.Entity);
    100     }
    101     // called from event handlers
    102     private void SafeUpdateMessage(string msg) {
     61    public void UpdateMessage(string msg) {
    10362      try {
    104         Invoke((Action<string>)UpdateMessage, msg);
     63        if (InvokeRequired) Invoke((Action<string>)UpdateMessage, msg);
     64        else {
     65          ResetFadeTimer();
     66          infoLabel.Text = msg;
     67        }
    10568      } catch (ObjectDisposedException) { }
    10669    }
     
    11174      FadeOut();
    11275    }
    113     #endregion
    114 
    115     public void Show(string initialText) {
    116       if (InvokeRequired) Invoke((Action<string>)Show, initialText);
    117       else {
    118         Opacity = 1;
    119         infoLabel.Text = initialText;
    120         ResetFadeTimer();
    121         Show();
    122       }
    123     }
    124 
    125     public void Show(IWin32Window owner, string initialText) {
    126       if (InvokeRequired) Invoke((Action<IWin32Window, string>)Show, owner, initialText);
    127       else {
    128         Opacity = 1;
    129         infoLabel.Text = initialText;
    130         ResetFadeTimer();
    131         Show(owner);
    132       }
    133     }
    13476
    13577    private void ResetFadeTimer() {
     
    13880      fadeTimer.Interval = initialInterval;
    13981      fadeTimer.Start();
    140     }
    141 
    142     private void UpdateMessage(string msg) {
    143       ResetFadeTimer();
    144       infoLabel.Text = msg;
    145       Application.DoEvents(); // force immediate update of splash screen control
    14682    }
    14783
     
    15692        Opacity = 0;
    15793        fadeTimer.Stop();
    158         Hide();
     94        Close();
    15995      }
    160     }
    161 
    162     protected override void OnClosing(System.ComponentModel.CancelEventArgs e) {
    163       // deregister events when form is closing
    164       DeregisterPluginManagerEventHandlers();
    165       base.OnClosing(e);
    16696    }
    16797  }
Note: See TracChangeset for help on using the changeset viewer.