Free cookie consent management tool by TermsFeed Policy Generator

Changeset 595 for trunk/sources


Ignore:
Timestamp:
09/25/08 16:47:35 (16 years ago)
Author:
gkronber
Message:

worked on #138

Location:
trunk/sources/HeuristicLab
Files:
4 edited

Legend:

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

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

    r2 r595  
    5050      this.components = new System.ComponentModel.Container();
    5151      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SplashScreen));
    52       this.waitTimer = new System.Windows.Forms.Timer(this.components);
    5352      this.panel = new System.Windows.Forms.Panel();
    5453      this.closeButton = new System.Windows.Forms.Button();
     
    6261      this.copyrightLabel = new System.Windows.Forms.Label();
    6362      this.pictureBox = new System.Windows.Forms.PictureBox();
    64       this.fadeTimer = new System.Windows.Forms.Timer(this.components);
    6563      this.panel.SuspendLayout();
    6664      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    6765      this.SuspendLayout();
    68       //
    69       // waitTimer
    70       //
    71       this.waitTimer.Interval = 1000;
    72       this.waitTimer.Tick += new System.EventHandler(this.waitTimer_Tick);
    7366      //
    7467      // panel
     
    205198      this.pictureBox.TabIndex = 0;
    206199      this.pictureBox.TabStop = false;
    207       //
    208       // fadeTimer
    209       //
    210       this.fadeTimer.Interval = 50;
    211       this.fadeTimer.Tick += new System.EventHandler(this.fadeTimer_Tick);
    212200      //
    213201      // SplashScreen
     
    235223    #endregion
    236224
    237     private System.Windows.Forms.Timer waitTimer;
    238225    private System.Windows.Forms.Panel panel;
    239226    private System.Windows.Forms.PictureBox pictureBox;
     
    247234    private System.Windows.Forms.ImageList imageList;
    248235    private System.Windows.Forms.Button closeButton;
    249     private System.Windows.Forms.Timer fadeTimer;
    250236  }
    251237}
  • trunk/sources/HeuristicLab/SplashScreen.cs

    r17 r595  
    3030namespace HeuristicLab {
    3131  public partial class SplashScreen : Form {
    32     private int myDisplayTime = 1000;
     32    private const int FADE_INTERVAL = 50;
     33    private System.Timers.Timer waitTimer;
     34    private System.Timers.Timer fadeTimer;
     35    private object bigLock = new object();
     36
     37    private int displayTime = 1000;
    3338    public int DisplayTime {
    34       get { return (myDisplayTime); }
     39      get { return (displayTime); }
    3540      set {
    3641        if(value > 0) {
    37           myDisplayTime = value;
    38           waitTimer.Interval = value;
     42          displayTime = value;
    3943        }
    4044      }
     
    7781        companyLabel.Text = "-";
    7882      }
    79       waitTimer.Start();
    8083    }
    8184
    8285    public SplashScreen(int displayTime, string initialText)
    8386      : this() {
    84       waitTimer.Stop();
    8587      DisplayTime = displayTime;
    86       waitTimer.Start();
    8788      infoLabel.Text = initialText;
    8889    }
     
    9394
    9495    public void Manager_Action(object sender, PluginManagerActionEventArgs e) {
    95       if(!this.Disposing && !this.IsDisposed) {
    96         waitTimer.Stop();
    97         string info;
    98         if(e.Action == PluginManagerAction.Initializing) info = "Initializing ...";
    99         else if(e.Action == PluginManagerAction.InitializingPlugin) info = "Initializing Plugin " + e.Id + " ...";
    100         else if(e.Action == PluginManagerAction.InitializedPlugin) info = "Initializing Plugin " + e.Id + " ... Initialized";
    101         else if(e.Action == PluginManagerAction.Initialized) info = "Initialization Completed";
    102         else {
    103           if(e.Id != null) info = e.Action.ToString() + "   (" + e.Id + ")";
    104           else info = e.Action.ToString();
    105         }
    106         SetInfoText(info);
    107         Application.DoEvents();
    108         waitTimer.Start();
    109       }
    110     }
    111 
    112     private void waitTimer_Tick(object sender, System.EventArgs e) {
    113       if(!this.Disposing && !this.IsDisposed) {
    114         waitTimer.Stop();
    115         fadeTimer.Start();
    116       }
    117     }
    118 
    119     private void fadeTimer_Tick(object sender, EventArgs e) {
    120       if(InvokeRequired) {
    121         Invoke((MethodInvoker)delegate() {
    122           if(Opacity > 0.9) {
    123             Opacity = 0.9;
    124           } else if(this.Opacity > 0) {
    125             Opacity -= 0.1;
    126           } else {
    127             Opacity = 0;
    128             fadeTimer.Stop();
    129             Close();
     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);
    130102          }
    131         });
    132       } else {
    133         if(Opacity > 0.9) {
    134           Opacity = 0.9;
    135         } else if(this.Opacity > 0) {
    136           Opacity -= 0.1;
    137         } else {
    138           Opacity = 0;
    139           fadeTimer.Stop();
    140           Close();
     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();
    141118        }
    142119      }
    143120    }
    144121
     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      }
     135    }
     136
     137    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        }
     147      }
     148    }
     149
     150    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();
     160      }
     161    }
    145162
    146163    private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e) {
     
    149166
    150167    private void closeButton_Click(object sender, EventArgs e) {
    151       waitTimer.Stop();
    152       Close();
     168      lock(bigLock) {
     169        if(fadeTimer != null) fadeTimer.Stop();
     170        if(waitTimer != null) waitTimer.Stop();
     171        Close();
     172      }
    153173    }
    154174  }
  • trunk/sources/HeuristicLab/SplashScreen.resx

    r2 r595  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
    120   <metadata name="waitTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    121     <value>16, 17</value>
    122   </metadata>
    123120  <metadata name="imageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124121    <value>219, 17</value>
     
    136133</value>
    137134  </data>
    138   <metadata name="fadeTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    139     <value>116, 17</value>
    140   </metadata>
    141135</root>
Note: See TracChangeset for help on using the changeset viewer.