From 749432b9765e2d2d71864f23cd6efa88e3e9bab8 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Tue, 21 Feb 2012 22:33:38 +0100 Subject: [PATCH] added try-catch and some error-logs for icon and logo loading --- Vocaluxe/Program.cs | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 0a8015dd..aa7a536c 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -172,11 +172,40 @@ namespace Vocaluxe { public SplashScreen() { - Bitmap logo = new Bitmap(Path.Combine(Environment.CurrentDirectory, Path.Combine("Graphics", "logo.png"))); - this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon)); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.ClientSize = new Size(logo.Width, logo.Height); - this.BackgroundImage = logo; + string path = Path.Combine(Environment.CurrentDirectory, Path.Combine("Graphics", "logo.png")); + if (File.Exists(path)) + { + try + { + Bitmap logo = new Bitmap(path); + this.ClientSize = new Size(logo.Width, logo.Height); + this.BackgroundImage = logo; + } + catch (Exception e) + { + CLog.LogError("Error loading logo: " + e.Message); + } + + } + else + CLog.LogError("Can't find " + path); + + path = Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon); + if (File.Exists(path)) + { + try + { + this.Icon = new System.Drawing.Icon(path); + } + catch (Exception e) + { + CLog.LogError("Error loading icon: " + e.Message); + } + } + else + CLog.LogError("Can't find " + path); + + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Text = CSettings.sProgramName; this.CenterToScreen(); this.Show();