static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); bool audioInitialized = PlaybackStreamer.IsAudioAvailable(); if (!audioInitialized) { bool installed = installOpenAL(); if (installed) { Restart(string.Empty); } } if (audioInitialized) { try { if (args.Length > 1) { startSeveralInstances(args); } else { startSingleInstance(args); } } catch (Exception ex) { Logger.Log(ex.ToString()); string errorMessage = string.Format(WYZTracker.Properties.Resources.ApplicationError, Logger.LogPath); MessageBox.Show(errorMessage, WYZTracker.Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); if (audioInitialized) { PlaybackStreamer.StopAudio(); } } } VirtualPiano.ReleaseDevices(); Application.Exit(); }
private static void startSingleInstance(string[] args) { if (args.Length == 1 && args[0] == CREATE_ASSOC_PARAM) { try { createWYZFileAssociation(); } catch (Exception ex) { Logger.Log(ex.ToString()); } } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logger.FileName = "WYZTracker.log"; LocalizationManager.LocalizeApplication(Properties.Settings.Default.Language); if (Properties.Settings.Default.ShowSplash) { ApplicationState.Instance.SplashScreen = new Splash(); ApplicationState.Instance.SplashScreen.FadeIn(); } try { checkWYZFileAssociation(); } catch (Exception ex) { Logger.Log(ex.ToString()); } // Speed the cloning of songs a little... SerializationUtils.Clone(new Song()); PlaybackStreamer.InitializeAudio(); Application.Run(new frmDockedMain(args)); PlaybackStreamer.StopAudio(); } }