[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Data;
|
---|
| 25 | using System.Drawing;
|
---|
| 26 | using System.Windows.Forms;
|
---|
| 27 | using System.Reflection;
|
---|
| 28 | using HeuristicLab.PluginInfrastructure;
|
---|
| 29 |
|
---|
| 30 | namespace HeuristicLab {
|
---|
| 31 | public partial class SplashScreen : Form {
|
---|
[595] | 32 | private const int FADE_INTERVAL = 50;
|
---|
| 33 | private System.Timers.Timer fadeTimer;
|
---|
[596] | 34 | private int initialInterval;
|
---|
[595] | 35 | private object bigLock = new object();
|
---|
[596] | 36 | private bool closing = false;
|
---|
[595] | 37 |
|
---|
[2] | 38 | public SplashScreen() {
|
---|
| 39 | InitializeComponent();
|
---|
| 40 |
|
---|
| 41 | Assembly assembly = this.GetType().Assembly;
|
---|
| 42 | object[] attributes = assembly.GetCustomAttributes(false);
|
---|
| 43 | string user, company;
|
---|
| 44 |
|
---|
| 45 | titleLabel.Text = Application.ProductName;
|
---|
| 46 | versionLabel.Text = "Version " + Application.ProductVersion;
|
---|
| 47 | infoLabel.Text = "";
|
---|
| 48 |
|
---|
| 49 | foreach(object obj in attributes) {
|
---|
| 50 | if(obj is AssemblyCopyrightAttribute) {
|
---|
| 51 | copyrightLabel.Text = "Copyright " + ((AssemblyCopyrightAttribute)obj).Copyright;
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | try {
|
---|
| 56 | user = HeuristicLab.Properties.Settings.Default.User;
|
---|
| 57 | company = HeuristicLab.Properties.Settings.Default.Organization;
|
---|
| 58 |
|
---|
| 59 | if((user == null) || (user.Equals(""))) {
|
---|
| 60 | userNameLabel.Text = "-";
|
---|
| 61 | } else {
|
---|
| 62 | userNameLabel.Text = user;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | if((company == null) || (company.Equals(""))) {
|
---|
| 66 | companyLabel.Text = "-";
|
---|
| 67 | } else {
|
---|
| 68 | companyLabel.Text = company;
|
---|
| 69 | }
|
---|
| 70 | } catch(Exception) {
|
---|
| 71 | userNameLabel.Text = "-";
|
---|
| 72 | companyLabel.Text = "-";
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[596] | 76 | public SplashScreen(int initialInterval, string initialText)
|
---|
[2] | 77 | : this() {
|
---|
[596] | 78 | this.initialInterval = initialInterval;
|
---|
[2] | 79 | infoLabel.Text = initialText;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | private void SetInfoText(string text) {
|
---|
| 83 | this.Invoke((MethodInvoker)delegate() { infoLabel.Text = text; });
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | public void Manager_Action(object sender, PluginManagerActionEventArgs e) {
|
---|
[596] | 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();
|
---|
[2] | 102 | }
|
---|
[596] | 103 | SetInfoText(info);
|
---|
| 104 | Application.DoEvents();
|
---|
[2] | 105 | }
|
---|
| 106 |
|
---|
[596] | 107 | private void fadeTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
|
---|
| 108 | fadeTimer.Stop();
|
---|
| 109 | if(InvokeRequired) {
|
---|
| 110 | Invoke((MethodInvoker)UpdateOpacity);
|
---|
| 111 | } else {
|
---|
| 112 | UpdateOpacity();
|
---|
[2] | 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[596] | 116 | private void UpdateOpacity() {
|
---|
[595] | 117 | lock(bigLock) {
|
---|
[596] | 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();
|
---|
[17] | 129 | }
|
---|
[2] | 130 | }
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e) {
|
---|
| 134 | PluginManager.Manager.Action -= new PluginManagerActionEventHandler(this.Manager_Action);
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | private void closeButton_Click(object sender, EventArgs e) {
|
---|
[595] | 138 | lock(bigLock) {
|
---|
[596] | 139 | closing = true;
|
---|
[595] | 140 | if(fadeTimer != null) fadeTimer.Stop();
|
---|
| 141 | Close();
|
---|
| 142 | }
|
---|
[2] | 143 | }
|
---|
| 144 | }
|
---|
| 145 | }
|
---|