private static void _CloseProgram() { // Unloading in reverse order try { CController.Close(); CVocaluxeServer.Close(); CGraphics.Close(); CThemes.Close(); CCover.Close(); CFonts.Close(); CBackgroundMusic.Close(); CWebcam.Close(); CDataBase.Close(); CVideo.Close(); CRecord.Close(); CSound.Close(); CDraw.Close(); } catch (Exception e) { CLog.LogError("Error during shutdown!", false, false, e); } GC.Collect(); // Do a GC run here before we close logs to have finalizers run try { CLog.Close(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode); }
public override void OnShow() { base.OnShow(); _OldCoverTheme = CCover.GetCoverThemeIndex(); _OldTheme = CTheme.GetThemeIndex(); _OldSkin = CTheme.GetSkinIndex(); _TempSkin = _OldSkin; }
public override void LoadTheme(string xmlPath) { base.LoadTheme(xmlPath); _SelectSlides[_SelectSlideCover].AddValues(CCover.CoverThemes); _SelectSlides[_SelectSlideCover].Selection = CCover.GetCoverThemeIndex(); _SelectSlides[_SelectSlideNoteLines].SetValues <EOffOn>((int)CConfig.Config.Theme.DrawNoteLines); _SelectSlides[_SelectSlideToneHelper].SetValues <EOffOn>((int)CConfig.Config.Theme.DrawToneHelper); _SelectSlides[_SelectSlideTimerLook].SetValues <ETimerLook>((int)CConfig.Config.Theme.TimerLook); _SelectSlides[_SelectSlideFadeInfo].SetValues <EFadePlayerInfo>((int)CConfig.Config.Theme.FadePlayerInfo); _SelectSlides[_SelectSlideCoverLoading].SetValues <ECoverLoading>((int)CConfig.Config.Theme.CoverLoading); }
private void _SaveConfig() { CConfig.Config.Theme.CoverTheme = CCover.CoverThemes[_SelectSlides[_SelectSlideCover].Selection]; CConfig.Config.Theme.DrawNoteLines = (EOffOn)_SelectSlides[_SelectSlideNoteLines].Selection; CConfig.Config.Theme.DrawToneHelper = (EOffOn)_SelectSlides[_SelectSlideToneHelper].Selection; CConfig.Config.Theme.TimerLook = (ETimerLook)_SelectSlides[_SelectSlideTimerLook].Selection; CConfig.Config.Theme.FadePlayerInfo = (EFadePlayerInfo)_SelectSlides[_SelectSlideFadeInfo].Selection; CConfig.Config.Theme.CoverLoading = (ECoverLoading)_SelectSlides[_SelectSlideCoverLoading].Selection; CConfig.SaveConfig(); if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].SelectedValue) { CCover.ReloadCovers(); } }
public override void LoadTheme() { base.LoadTheme(); SelectSlides[htSelectSlides(SelectSlideTheme)].AddValues(CTheme.ThemeNames); SelectSlides[htSelectSlides(SelectSlideTheme)].Selection = CTheme.GetThemeIndex(); SelectSlides[htSelectSlides(SelectSlideSkin)].AddValues(CTheme.SkinNames); SelectSlides[htSelectSlides(SelectSlideSkin)].Selection = CTheme.GetSkinIndex(); SelectSlides[htSelectSlides(SelectSlideCover)].AddValues(CCover.CoverThemes); SelectSlides[htSelectSlides(SelectSlideCover)].Selection = CCover.GetCoverThemeIndex(); SelectSlides[htSelectSlides(SelectSlideNoteLines)].SetValues <EOffOn>((int)CConfig.DrawNoteLines); SelectSlides[htSelectSlides(SelectSlideToneHelper)].SetValues <EOffOn>((int)CConfig.DrawToneHelper); SelectSlides[htSelectSlides(SelectSlideTimerLook)].SetValues <ETimerLook>((int)CConfig.TimerLook); SelectSlides[htSelectSlides(SelectSlideCoverLoading)].SetValues <ECoverLoading>((int)CConfig.CoverLoading); }
private void SaveConfig() { CConfig.Theme = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection]; CConfig.Skin = CTheme.SkinNames[SelectSlides[htSelectSlides(SelectSlideSkin)].Selection]; CConfig.CoverTheme = CCover.CoverThemes[SelectSlides[htSelectSlides(SelectSlideCover)].Selection]; CConfig.DrawNoteLines = (EOffOn)SelectSlides[htSelectSlides(SelectSlideNoteLines)].Selection; CConfig.DrawToneHelper = (EOffOn)SelectSlides[htSelectSlides(SelectSlideToneHelper)].Selection; CConfig.TimerLook = (ETimerLook)SelectSlides[htSelectSlides(SelectSlideTimerLook)].Selection; CConfig.FadePlayerInfo = (EFadePlayerInfo)SelectSlides[htSelectSlides(SelectSlideFadeInfo)].Selection; CConfig.CoverLoading = (ECoverLoading)SelectSlides[htSelectSlides(SelectSlideCoverLoading)].Selection; CConfig.SaveConfig(); if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection) { CCover.ReloadCover(); CSongs.Sort(CConfig.SongSorting); } if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection) { CConfig.Theme = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection]; _OldTheme = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection; CTheme.UnloadSkins(); CFonts.UnloadThemeFonts(CConfig.Theme); CTheme.ListSkins(); CConfig.Skin = CTheme.SkinNames[0]; _OldSkin = 0; _TempSkin = _OldSkin; CConfig.SaveConfig(); CTheme.LoadSkins(); CTheme.LoadTheme(); CGraphics.ReloadTheme(); return; } }
private static void _Run(string[] args) { Application.DoEvents(); try { // Create data folder Directory.CreateDirectory(CSettings.DataFolder); // Init Log CLog.Init(); if (!CProgrammHelper.CheckRequirements()) { return; } CProgrammHelper.Init(); CLog.StartBenchmark("Init Program"); CMain.Init(); Application.DoEvents(); // Init Language CLog.StartBenchmark("Init Language"); if (!CLanguage.Init()) { throw new CLoadingException("Language"); } CLog.StopBenchmark("Init Language"); Application.DoEvents(); // load config CLog.StartBenchmark("Init Config"); CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); CLog.StopBenchmark("Init Config"); // Create folders CSettings.CreateFolders(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark("Init Draw"); if (!CDraw.Init()) { throw new CLoadingException("drawing"); } CLog.StopBenchmark("Init Draw"); Application.DoEvents(); // Init Playback CLog.StartBenchmark("Init Playback"); if (!CSound.Init()) { throw new CLoadingException("playback"); } CLog.StopBenchmark("Init Playback"); Application.DoEvents(); // Init Record CLog.StartBenchmark("Init Record"); if (!CRecord.Init()) { throw new CLoadingException("record"); } CLog.StopBenchmark("Init Record"); Application.DoEvents(); // Init VideoDecoder CLog.StartBenchmark("Init Videodecoder"); if (!CVideo.Init()) { throw new CLoadingException("video"); } CLog.StopBenchmark("Init Videodecoder"); Application.DoEvents(); // Init Database CLog.StartBenchmark("Init Database"); if (!CDataBase.Init()) { throw new CLoadingException("database"); } CLog.StopBenchmark("Init Database"); Application.DoEvents(); //Init Webcam CLog.StartBenchmark("Init Webcam"); if (!CWebcam.Init()) { throw new CLoadingException("webcam"); } CLog.StopBenchmark("Init Webcam"); Application.DoEvents(); // Init Background Music CLog.StartBenchmark("Init Background Music"); CBackgroundMusic.Init(); CLog.StopBenchmark("Init Background Music"); Application.DoEvents(); // Init Profiles CLog.StartBenchmark("Init Profiles"); CProfiles.Init(); CLog.StopBenchmark("Init Profiles"); Application.DoEvents(); // Init Fonts CLog.StartBenchmark("Init Fonts"); if (!CFonts.Init()) { throw new CLoadingException("fonts"); } CLog.StopBenchmark("Init Fonts"); Application.DoEvents(); // Theme System CLog.StartBenchmark("Init Theme"); if (!CThemes.Init()) { throw new CLoadingException("theme"); } CLog.StopBenchmark("Init Theme"); CLog.StartBenchmark("Load Theme"); CThemes.Load(); CLog.StopBenchmark("Load Theme"); Application.DoEvents(); // Load Cover CLog.StartBenchmark("Init Cover"); if (!CCover.Init()) { throw new CLoadingException("covertheme"); } CLog.StopBenchmark("Init Cover"); Application.DoEvents(); // Init Screens CLog.StartBenchmark("Init Screens"); CGraphics.Init(); CLog.StopBenchmark("Init Screens"); Application.DoEvents(); // Init Server CLog.StartBenchmark("Init Server"); CVocaluxeServer.Init(); CLog.StopBenchmark("Init Server"); Application.DoEvents(); // Init Input CLog.StartBenchmark("Init Input"); CController.Init(); CController.Connect(); CLog.StopBenchmark("Init Input"); Application.DoEvents(); // Init Game; CLog.StartBenchmark("Init Game"); CGame.Init(); CProfiles.Update(); CConfig.UsePlayers(); CLog.StopBenchmark("Init Game"); Application.DoEvents(); // Init Party Modes; CLog.StartBenchmark("Init Party Modes"); if (!CParty.Init()) { throw new CLoadingException("Party Modes"); } CLog.StopBenchmark("Init Party Modes"); Application.DoEvents(); //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage //Rely on GC doing its job afterwards and call Dispose methods where appropriate GC.Collect(); CLog.StopBenchmark("Init Program"); } catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message); CLog.LogError("Error on start up: " + e); if (_SplashScreen != null) { _SplashScreen.Close(); } _CloseProgram(); return; } Application.DoEvents(); // Start Main Loop if (_SplashScreen != null) { _SplashScreen.Close(); } CDraw.MainLoop(); }
private static void _Run(string[] args) { Application.DoEvents(); try { // Create data folder Directory.CreateDirectory(CSettings.DataFolder); // Init Log CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc, ELogLevel.Information); if (!CProgrammHelper.CheckRequirements()) { return; } CProgrammHelper.Init(); using (CBenchmark.Time("Init Program")) { CMain.Init(); Application.DoEvents(); // Init Language using (CBenchmark.Time("Init Language")) { if (!CLanguage.Init()) { throw new CLoadingException("Language"); } } Application.DoEvents(); // load config using (CBenchmark.Time("Init Config")) { CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); } // Create folders CSettings.CreateFolders(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw using (CBenchmark.Time("Init Draw")) { if (!CDraw.Init()) { throw new CLoadingException("drawing"); } } Application.DoEvents(); // Init Playback using (CBenchmark.Time("Init Playback")) { if (!CSound.Init()) { throw new CLoadingException("playback"); } } Application.DoEvents(); // Init Record using (CBenchmark.Time("Init Record")) { if (!CRecord.Init()) { throw new CLoadingException("record"); } } Application.DoEvents(); // Init VideoDecoder using (CBenchmark.Time("Init Videodecoder")) { if (!CVideo.Init()) { throw new CLoadingException("video"); } } Application.DoEvents(); // Init Database using (CBenchmark.Time("Init Database")) { if (!CDataBase.Init()) { throw new CLoadingException("database"); } } Application.DoEvents(); //Init Webcam using (CBenchmark.Time("Init Webcam")) { if (!CWebcam.Init()) { throw new CLoadingException("webcam"); } } Application.DoEvents(); // Init Background Music using (CBenchmark.Time("Init Background Music")) { CBackgroundMusic.Init(); } Application.DoEvents(); // Init Profiles using (CBenchmark.Time("Init Profiles")) { CProfiles.Init(); } Application.DoEvents(); // Init Fonts using (CBenchmark.Time("Init Fonts")) { if (!CFonts.Init()) { throw new CLoadingException("fonts"); } } Application.DoEvents(); // Theme System using (CBenchmark.Time("Init Theme")) { if (!CThemes.Init()) { throw new CLoadingException("theme"); } } using (CBenchmark.Time("Load Theme")) { CThemes.Load(); } Application.DoEvents(); // Load Cover using (CBenchmark.Time("Init Cover")) { if (!CCover.Init()) { throw new CLoadingException("covertheme"); } } Application.DoEvents(); // Init Screens using (CBenchmark.Time("Init Screens")) { CGraphics.Init(); } Application.DoEvents(); // Init Server using (CBenchmark.Time("Init Server")) { CVocaluxeServer.Init(); } Application.DoEvents(); // Init Input using (CBenchmark.Time("Init Input")) { CController.Init(); CController.Connect(); } Application.DoEvents(); // Init Game using (CBenchmark.Time("Init Game")) { CGame.Init(); CProfiles.Update(); CConfig.UsePlayers(); } Application.DoEvents(); // Init Party Modes using (CBenchmark.Time("Init Party Modes")) { if (!CParty.Init()) { throw new CLoadingException("Party Modes"); } } Application.DoEvents(); //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage //Rely on GC doing its job afterwards and call Dispose methods where appropriate GC.Collect(); } } catch (Exception e) { CLog.Error(e, "Error on start up: {ExceptionMessage}", CLog.Params(e.Message), show: true); if (_SplashScreen != null) { _SplashScreen.Close(); } _CloseProgram(); return; } Application.DoEvents(); // Start Main Loop if (_SplashScreen != null) { _SplashScreen.Close(); } CDraw.MainLoop(); }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver); // Close program if there is another instance running if (!EnsureSingleInstance()) { //TODO: put it into language file MessageBox.Show("Another Instance of Vocaluxe is already runnning!"); return; } Application.DoEvents(); try { // Init Log CLog.Init(); CSettings.CreateFolders(); Application.DoEvents(); // Init Language CLog.StartBenchmark(0, "Init Language"); CLanguage.Init(); CLog.StopBenchmark(0, "Init Language"); Application.DoEvents(); // load config CLog.StartBenchmark(0, "Init Config"); CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); CLog.StopBenchmark(0, "Init Config"); Application.DoEvents(); _SplashScreen = new SplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark(0, "Init Draw"); CDraw.InitDraw(); CLog.StopBenchmark(0, "Init Draw"); Application.DoEvents(); // Init Database CLog.StartBenchmark(0, "Init Database"); CDataBase.Init(); CLog.StopBenchmark(0, "Init Database"); Application.DoEvents(); // Init Playback CLog.StartBenchmark(0, "Init Playback"); CSound.PlaybackInit(); CLog.StopBenchmark(0, "Init Playback"); Application.DoEvents(); // Init Record CLog.StartBenchmark(0, "Init Record"); CSound.RecordInit(); CLog.StopBenchmark(0, "Init Record"); Application.DoEvents(); //Init Webcam CLog.StartBenchmark(0, "Init Webcam"); CWebcam.Init(); CLog.StopBenchmark(0, "Init Webcam"); Application.DoEvents(); // Init Background Music CLog.StartBenchmark(0, "Init Background Music"); CBackgroundMusic.Init(); CLog.StopBenchmark(0, "Init Background Music"); Application.DoEvents(); // Init Profiles CLog.StartBenchmark(0, "Init Profiles"); CProfiles.Init(); CLog.StopBenchmark(0, "Init Profiles"); Application.DoEvents(); // Init Font CLog.StartBenchmark(0, "Init Font"); CFonts.Init(); CLog.StopBenchmark(0, "Init Font"); Application.DoEvents(); // Init VideoDecoder CLog.StartBenchmark(0, "Init Videodecoder"); CVideo.Init(); CLog.StopBenchmark(0, "Init Videodecoder"); Application.DoEvents(); // Load Cover CLog.StartBenchmark(0, "Init Cover"); CCover.Init(); CLog.StopBenchmark(0, "Init Cover"); Application.DoEvents(); // Theme System CLog.StartBenchmark(0, "Init Theme"); CTheme.InitTheme(); CLog.StopBenchmark(0, "Init Theme"); Application.DoEvents(); // Init Screens CLog.StartBenchmark(0, "Init Screens"); CGraphics.InitGraphics(); CLog.StopBenchmark(0, "Init Screens"); Application.DoEvents(); // Init Input CLog.StartBenchmark(0, "Init Input"); CInput.Init(); CLog.StopBenchmark(0, "Init Input"); // Init Game; CLog.StartBenchmark(0, "Init Game"); CGame.Init(); CLog.StopBenchmark(0, "Init Game"); } catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message + e.StackTrace); CLog.LogError("Error on start up: " + e.Message + e.StackTrace); CloseProgram(); Environment.Exit(Environment.ExitCode); } Application.DoEvents(); // Start Main Loop _SplashScreen.Close(); try { CDraw.MainLoop(); } catch (Exception e) { MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace); CLog.LogError("Unhandled error: " + e.Message + e.StackTrace); } CloseProgram(); }