Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/26/08 10:58:14 (16 years ago)
Author:
gkronber
Message:

fixed #138 (Starting multiple applications concurrently causes some of the splashscreens to stay visible) by simplifying the SplashScreen. Using only one timer for the fadeout and this timer is started by a special event from the plugin infrastructure.

Location:
trunk/sources/HeuristicLab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab/MainForm.cs

    r595 r596  
    8989        } else {
    9090          ApplicationInfo app = (ApplicationInfo)applicationsListView.SelectedItems[0].Tag;
    91           SplashScreen splashScreen = new SplashScreen(3000, "Loading " + app.Name);
     91          SplashScreen splashScreen = new SplashScreen(2000, "Loading " + app.Name);
    9292          splashScreen.Owner = this;
    9393          splashScreen.Show();
  • trunk/sources/HeuristicLab/SplashScreen.cs

    r595 r596  
    3131  public partial class SplashScreen : Form {
    3232    private const int FADE_INTERVAL = 50;
    33     private System.Timers.Timer waitTimer;
    3433    private System.Timers.Timer fadeTimer;
     34    private int initialInterval;
    3535    private object bigLock = new object();
    36 
    37     private int displayTime = 1000;
    38     public int DisplayTime {
    39       get { return (displayTime); }
    40       set {
    41         if(value > 0) {
    42           displayTime = value;
    43         }
    44       }
    45     }
     36    private bool closing = false;
    4637
    4738    public SplashScreen() {
     
    8374    }
    8475
    85     public SplashScreen(int displayTime, string initialText)
     76    public SplashScreen(int initialInterval, string initialText)
    8677      : this() {
    87       DisplayTime = displayTime;
     78      this.initialInterval = initialInterval;
    8879      infoLabel.Text = initialText;
    8980    }
     
    9485
    9586    public void Manager_Action(object sender, PluginManagerActionEventArgs e) {
    96       lock(bigLock) {
    97         if(!this.Disposing && !this.IsDisposed) {
    98           if(waitTimer == null) {
    99             waitTimer = new System.Timers.Timer();
    100             waitTimer.SynchronizingObject = this;
    101             waitTimer.Elapsed += new System.Timers.ElapsedEventHandler(waitTimer_Elapsed);
    102           }
    103           waitTimer.Stop();
    104           waitTimer.Interval = DisplayTime;
    105           waitTimer.AutoReset = true;
    106           string info;
    107           if(e.Action == PluginManagerAction.Initializing) info = "Initializing ...";
    108           else if(e.Action == PluginManagerAction.InitializingPlugin) info = "Initializing Plugin " + e.Id + " ...";
    109           else if(e.Action == PluginManagerAction.InitializedPlugin) info = "Initializing Plugin " + e.Id + " ... Initialized";
    110           else if(e.Action == PluginManagerAction.Initialized) info = "Initialization Completed";
    111           else {
    112             if(e.Id != null) info = e.Action.ToString() + "   (" + e.Id + ")";
    113             else info = e.Action.ToString();
    114           }
    115           SetInfoText(info);
    116           Application.DoEvents();
    117           waitTimer.Start();
    118         }
     87      string info;
     88      if(e.Action == PluginManagerAction.Initializing) info = "Initializing ...";
     89      else if(e.Action == PluginManagerAction.InitializingPlugin) info = "Initializing Plugin " + e.Id + " ...";
     90      else if(e.Action == PluginManagerAction.InitializedPlugin) info = "Initializing Plugin " + e.Id + " ... Initialized";
     91      else if(e.Action == PluginManagerAction.Initialized) {
     92        info = "Initialization Completed";
     93        fadeTimer = new System.Timers.Timer();
     94        fadeTimer.SynchronizingObject = this;
     95        fadeTimer.Elapsed += new System.Timers.ElapsedEventHandler(fadeTimer_Elapsed);
     96        fadeTimer.Interval = initialInterval;
     97        fadeTimer.AutoReset = true;
     98        fadeTimer.Start();
     99      } else {
     100        if(e.Id != null) info = e.Action.ToString() + "   (" + e.Id + ")";
     101        else info = e.Action.ToString();
    119102      }
    120     }
    121 
    122     private void waitTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
    123       lock(bigLock) {
    124         if(!this.Disposing && !this.IsDisposed) {
    125           if(fadeTimer == null) {
    126             fadeTimer = new System.Timers.Timer();
    127             fadeTimer.SynchronizingObject = this;
    128             fadeTimer.Elapsed += new System.Timers.ElapsedEventHandler(fadeTimer_Elapsed);
    129             fadeTimer.Interval = FADE_INTERVAL;
    130             fadeTimer.AutoReset = true;
    131             fadeTimer.Start();
    132           }
    133         }
    134       }
     103      SetInfoText(info);
     104      Application.DoEvents();
    135105    }
    136106
    137107    private void fadeTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
    138       lock(bigLock) {
    139         if(!this.Disposing && !this.IsDisposed) {
    140           fadeTimer.Stop();
    141           if(InvokeRequired) {
    142             Invoke((MethodInvoker)UpdateOpacity);
    143           } else {
    144             UpdateOpacity();
    145           }
    146         }
     108      fadeTimer.Stop();
     109      if(InvokeRequired) {
     110        Invoke((MethodInvoker)UpdateOpacity);
     111      } else {
     112        UpdateOpacity();
    147113      }
    148114    }
    149115
    150116    private void UpdateOpacity() {
    151       if(Opacity > 0.9) {
    152         Opacity = 0.9;
    153         fadeTimer.Start();
    154       } else if(this.Opacity > 0) {
    155         Opacity -= 0.1;
    156         fadeTimer.Start();
    157       } else {
    158         Opacity = 0;
    159         Close();
     117      lock(bigLock) {
     118        if(closing) return;
     119        if(Opacity > 0.9) {
     120          Opacity = 0.9;
     121          fadeTimer.Interval = FADE_INTERVAL;
     122          fadeTimer.Start();
     123        } else if(this.Opacity > 0) {
     124          Opacity -= 0.1;
     125          fadeTimer.Start();
     126        } else {
     127          Opacity = 0;
     128          Close();
     129        }
    160130      }
    161131    }
     
    167137    private void closeButton_Click(object sender, EventArgs e) {
    168138      lock(bigLock) {
     139        closing = true;
    169140        if(fadeTimer != null) fadeTimer.Stop();
    170         if(waitTimer != null) waitTimer.Stop();
    171141        Close();
    172142      }
Note: See TracChangeset for help on using the changeset viewer.