[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 {
|
---|
| 32 | private int myDisplayTime = 1000;
|
---|
| 33 | public int DisplayTime {
|
---|
| 34 | get { return (myDisplayTime); }
|
---|
| 35 | set {
|
---|
| 36 | if(value > 0) {
|
---|
| 37 | myDisplayTime = value;
|
---|
| 38 | waitTimer.Interval = value;
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public SplashScreen() {
|
---|
| 44 | InitializeComponent();
|
---|
| 45 |
|
---|
| 46 | Assembly assembly = this.GetType().Assembly;
|
---|
| 47 | object[] attributes = assembly.GetCustomAttributes(false);
|
---|
| 48 | string user, company;
|
---|
| 49 |
|
---|
| 50 | titleLabel.Text = Application.ProductName;
|
---|
| 51 | versionLabel.Text = "Version " + Application.ProductVersion;
|
---|
| 52 | infoLabel.Text = "";
|
---|
| 53 |
|
---|
| 54 | foreach(object obj in attributes) {
|
---|
| 55 | if(obj is AssemblyCopyrightAttribute) {
|
---|
| 56 | copyrightLabel.Text = "Copyright " + ((AssemblyCopyrightAttribute)obj).Copyright;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | try {
|
---|
| 61 | user = HeuristicLab.Properties.Settings.Default.User;
|
---|
| 62 | company = HeuristicLab.Properties.Settings.Default.Organization;
|
---|
| 63 |
|
---|
| 64 | if((user == null) || (user.Equals(""))) {
|
---|
| 65 | userNameLabel.Text = "-";
|
---|
| 66 | } else {
|
---|
| 67 | userNameLabel.Text = user;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | if((company == null) || (company.Equals(""))) {
|
---|
| 71 | companyLabel.Text = "-";
|
---|
| 72 | } else {
|
---|
| 73 | companyLabel.Text = company;
|
---|
| 74 | }
|
---|
| 75 | } catch(Exception) {
|
---|
| 76 | userNameLabel.Text = "-";
|
---|
| 77 | companyLabel.Text = "-";
|
---|
| 78 | }
|
---|
| 79 | waitTimer.Start();
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | public SplashScreen(int displayTime, string initialText)
|
---|
| 83 | : this() {
|
---|
| 84 | waitTimer.Stop();
|
---|
| 85 | DisplayTime = displayTime;
|
---|
| 86 | waitTimer.Start();
|
---|
| 87 | infoLabel.Text = initialText;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | private void SetInfoText(string text) {
|
---|
| 91 | this.Invoke((MethodInvoker)delegate() { infoLabel.Text = text; });
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | 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) {
|
---|
[17] | 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();
|
---|
| 130 | }
|
---|
| 131 | });
|
---|
[2] | 132 | } else {
|
---|
[17] | 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();
|
---|
| 141 | }
|
---|
[2] | 142 | }
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e) {
|
---|
| 147 | PluginManager.Manager.Action -= new PluginManagerActionEventHandler(this.Manager_Action);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | private void closeButton_Click(object sender, EventArgs e) {
|
---|
| 151 | waitTimer.Stop();
|
---|
| 152 | Close();
|
---|
| 153 | }
|
---|
| 154 | }
|
---|
| 155 | }
|
---|