Don't error when cannot open icon. I assume this fixes #283

This commit is contained in:
UnknownShadow200 2017-02-02 19:41:00 +11:00
parent 27bb92b58f
commit 479d8ec5cf
2 changed files with 12 additions and 5 deletions

View File

@ -39,13 +39,15 @@ namespace ClassicalSharp {
public void LoadIcon() {
string launcherPath = Path.Combine(Program.AppDirectory, "Launcher2.exe");
if (File.Exists(launcherPath)) {
Icon = Icon.ExtractAssociatedIcon(launcherPath); return;
if (!File.Exists(launcherPath)) {
launcherPath = Path.Combine(Program.AppDirectory, "Launcher.exe");
}
if (!File.Exists(launcherPath)) return;
launcherPath = Path.Combine(Program.AppDirectory, "Launcher.exe");
if (File.Exists(launcherPath)) {
try {
Icon = Icon.ExtractAssociatedIcon(launcherPath);
} catch (Exception ex) {
ErrorHandler.LogError("DesktopWindow.LoadIcon()", ex);
}
}

View File

@ -79,8 +79,13 @@ namespace Launcher {
Window.Keyboard.KeyDown += KeyDown;
LoadFont();
logoFont = new Font(FontName, 32, FontStyle.Regular);
string path = Assembly.GetExecutingAssembly().Location;
Window.Icon = Icon.ExtractAssociatedIcon(path);
try {
Window.Icon = Icon.ExtractAssociatedIcon(path);
} catch (Exception ex) {
ErrorHandler2.LogError("LauncherWindow.Init() - Icon", ex);
}
//Minimised = Window.WindowState == WindowState.Minimized;
PlatformID platform = Environment.OSVersion.Platform;