private static void InitSplashScreen() { var waiting = true; var ssThread = new Thread(() => { SynchronizationContext.SetSynchronizationContext( new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)); SplashScreen = new SplashScreen(); SplashScreen.SetText("Initializing..."); SplashScreen.SetVer(AppVersion); SplashScreen.Show(); waiting = false; Dispatcher.Run(); }) { Name = "SplashScreen window thread" }; ssThread.SetApartmentState(ApartmentState.STA); ssThread.Start(); while (waiting) { Thread.Sleep(1); } }
private async void OnStartup(object sender, StartupEventArgs e) { BaseDispatcher = Dispatcher.CurrentDispatcher; BaseDispatcher.Thread.Name = "Main"; TccMessageBox.Create(); //Create it here in STA thread if (IsRunning()) { TccMessageBox.Show("Another instance of TCC is already running. Shutting down.", MessageBoxType.Information); Current.Shutdown(); return; } Loading = true; var v = Assembly.GetExecutingAssembly().GetName().Version; AppVersion = $"TCC v{v.Major}.{v.Minor}.{v.Build}{(Experimental ? "-e" : "")}"; InitSplashScreen(); AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler.HandleGlobalException; TryDeleteUpdater(); SplashScreen.SetText("Checking for application updates..."); await UpdateManager.CheckAppVersion(); SplashScreen.SetText("Checking for database updates..."); await UpdateManager.CheckIconsVersion(); SplashScreen.SetText("Loading settings..."); var sr = new SettingsReader(); sr.LoadWindowSettings(); sr.LoadSettings(); Process.GetCurrentProcess().PriorityClass = SettingsHolder.HighPriority ? ProcessPriorityClass.High : ProcessPriorityClass.Normal; if (SettingsHolder.ForceSoftwareRendering) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } SplashScreen.SetText("Pre-loading databases..."); UpdateManager.CheckDatabaseHash(); SessionManager.InitDatabasesAsync(string.IsNullOrEmpty(SettingsHolder.LastLanguage) ? "EU-EN" : SettingsHolder.LastLanguage == "EU" ? "EU-EN" : SettingsHolder.LastLanguage); UpdateManager.CheckServersFile(); SplashScreen.SetText("Initializing windows..."); WindowManager.Init(); SplashScreen.SetText("Initializing packet processor..."); PacketAnalyzer.InitAsync(); SplashScreen.SetText("Starting"); TimeManager.Instance.SetServerTimeZone(SettingsHolder.LastLanguage); ChatWindowManager.Instance.AddTccMessage(AppVersion); SplashScreen.CloseWindowSafe(); UpdateManager.StartPeriodicCheck(); if (!Experimental && SettingsHolder.ExperimentalNotification && UpdateManager.IsExperimentalNewer()) { WindowManager.FloatingButton.NotifyExtended("TCC experimental", "An experimental version of TCC is available. Open System settings to download it or disable this notification.", NotificationType.Success, 10000); } Loading = false; }
private void OnStartup(object sender, StartupEventArgs e) { var v = Assembly.GetExecutingAssembly().GetName().Version; _version = $"TCC v{v.Major}.{v.Minor}.{v.Build}"; InitSplashScreen(); BaseDispatcher = Dispatcher.CurrentDispatcher; TccMessageBox.Create(); //Create it here in STA thread AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler; Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; TryDeleteUpdater(); SplashScreen.SetText("Checking for application updates..."); UpdateManager.CheckAppVersion(); SplashScreen.SetText("Checking for database updates..."); UpdateManager.CheckDatabaseVersion(); SplashScreen.SetText("Loading settings..."); SettingsManager.LoadWindowSettings(); SettingsManager.LoadSettings(); SplashScreen.SetText("Pre-loading databases..."); SessionManager.InitDatabases(string.IsNullOrEmpty(SettingsManager.LastRegion) ? "EU-EN" : SettingsManager.LastRegion == "EU" ? "EU-EN" : SettingsManager.LastRegion); SplashScreen.SetText("Initializing windows..."); WindowManager.Init(); FocusManager.FocusTimer.Start(); SplashScreen.SetText("Initializing Twitch connector..."); TwitchConnector.Instance.Init(); SplashScreen.SetText("Initializing packet processor..."); PacketProcessor.Init(); TeraSniffer.Instance.NewConnection += TeraSniffer_OnNewConnection; TeraSniffer.Instance.EndConnection += TeraSniffer_OnEndConnection; TeraSniffer.Instance.Enabled = true; SplashScreen.SetText("Starting"); SessionManager.CurrentPlayer.Class = Class.None; SessionManager.CurrentPlayer.Name = "player"; SessionManager.CurrentPlayer.PlayerId = 10; TimeManager.Instance.SetServerTimeZone(SettingsManager.LastRegion); ChatWindowManager.Instance.AddTccMessage(_version); SplashScreen.CloseWindowSafe(); UpdateManager.StartCheck(); //WindowManager.LfgListWindow.ShowWindow(); // var l = new Listing(); // l.LeaderId = 10; // l.Message = "SJG exp only"; // l.LeaderName = "Foglio"; // l.Players.Add(new User(WindowManager.LfgListWindow.Dispatcher){PlayerId = 10, IsLeader = true, Online = true}); // l.Applicants.Add(new User(WindowManager.LfgListWindow.Dispatcher){PlayerId = 1, Name = "Applicant", Online = true, UserClass = Class.Priest}); // WindowManager.LfgListWindow.VM.Listings.Add(l); //var l = new List<User>(); //var r = new Random(); //for (uint i = 0; i < 30; i++) // GroupWindowViewModel.Instance.AddOrUpdateMember(new User(GroupWindowViewModel.Instance.GetDispatcher()) // { // Name = i.ToString(), // PlayerId = i, // ServerId = i, // EntityId = i, // UserClass = (Class)r.Next(0, 12) // }); //GroupWindowViewModel.Instance.SetRaid(true); //GroupWindowViewModel.Instance.SetNewLeader(10, "player"); }
//public static DebugWindow DebugWindow; private void OnStartup(object sender, StartupEventArgs e) { Loading = true; //#if DEBUG // DebugWindow = new DebugWindow(); // DebugWindow.Show(); //#endif var v = Assembly.GetExecutingAssembly().GetName().Version; _version = $"TCC v{v.Major}.{v.Minor}.{v.Build}"; InitSplashScreen(); BaseDispatcher = Dispatcher.CurrentDispatcher; TccMessageBox.Create(); //Create it here in STA thread #if !DEBUG AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler; #endif TryDeleteUpdater(); SplashScreen.SetText("Checking for application updates..."); UpdateManager.CheckAppVersion(); SplashScreen.SetText("Checking for database updates..."); UpdateManager.CheckDatabaseVersion(); SplashScreen.SetText("Loading settings..."); var sr = new SettingsReader(); sr.LoadWindowSettings(); sr.LoadSettings(); Process.GetCurrentProcess().PriorityClass = Settings.HighPriority ? ProcessPriorityClass.High : ProcessPriorityClass.Normal; if (Settings.ForceSoftwareRendering) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } SplashScreen.SetText("Pre-loading databases..."); SessionManager.InitDatabases(string.IsNullOrEmpty(Settings.LastRegion) ? "EU-EN" : Settings.LastRegion == "EU" ? "EU-EN" : Settings.LastRegion); SplashScreen.SetText("Initializing windows..."); WindowManager.Init(); //SplashScreen.SetText("Initializing Twitch connector..."); //TwitchConnector.Instance.Init(); SplashScreen.SetText("Initializing packet processor..."); PacketProcessor.Init(); TeraSniffer.Instance.NewConnection += TeraSniffer_OnNewConnection; TeraSniffer.Instance.EndConnection += TeraSniffer_OnEndConnection; TeraSniffer.Instance.Enabled = true; WindowManager.FloatingButton.NotifyExtended("TCC", "Ready to connect.", NotificationType.Normal); SplashScreen.SetText("Starting"); SessionManager.CurrentPlayer.Class = Class.None; SessionManager.CurrentPlayer.Name = "player"; SessionManager.CurrentPlayer.EntityId = 10; TimeManager.Instance.SetServerTimeZone(Settings.LastRegion); ChatWindowManager.Instance.AddTccMessage(_version); SplashScreen.CloseWindowSafe(); UpdateManager.StartCheck(); if (Settings.LastRegion == "NA" || Settings.LastRegion == "") { WindowManager.FloatingButton.NotifyExtended("So long, and thanks for all the fish", ThankYou_mEME, NotificationType.Error, 15000); } if (Debug) { DebugStuff(); } Loading = false; }