using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading.Tasks; using System.Diagnostics; namespace DuckEmulator.GUI { partial class SplashScreen : Form { internal Boolean ExitBool = false; internal SplashScreen() { InitializeComponent(); } private void Timer_Tick(object sender, EventArgs e) { this.Timer.Dispose(); this.Timer.Stop(); this.Timer = null; if (!CanStart()) { this.label1.ForeColor = Color.Red; this.label1.Text = "DuckEmulator is already running!"; this.CloseEnvironment.Visible = true; this.pictureBox1.Enabled = false; } else { this.Visible = false; Interface i = new Interface(); i.Show(); i.BringToFront(); i.Activate(); i.Focus(); i.Splash = this; } } private Boolean CanStart() { foreach (Process P in Process.GetProcesses()) { if (P.ProcessName == "DuckEmulator" && P.Id != Process.GetCurrentProcess().Id) { return false; } } return true; } internal void Exit() { ExitBool = true; this.Visible = true; this.BringToFront(); this.Activate(); this.label1.Text = "Please wait, DuckEmulator is closing..."; EndTimer.Enabled = true; } private void EndTimer_Tick(object sender, EventArgs e) { Environment.Exit(0); } private void CloseEnvironment_Click(object sender, EventArgs e) { Environment.Exit(0); } } }