public static void Main(string[] args) { bool mutexReserved; using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved)) { if (mutexReserved) { bool ProgramIsNew = false; #if !DEBUG try { #endif Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); #if !DEBUG ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory); ProfileOptimization.StartProfile("Startup.Profile"); #endif //todo implement own updater Options = OptionsControl.Load(out ProgramIsNew); Assembly assembly = Assembly.GetExecutingAssembly(); NeutralResourcesLanguageAttribute a = (NeutralResourcesLanguageAttribute)assembly.GetCustomAttribute(typeof(NeutralResourcesLanguageAttribute)); Culture.cultures = Culture.GetAvailableCultures(); CultureInfo defCultureInfo = new CultureInfo(string.IsNullOrEmpty(Options.Language) ? a.CultureName : Options.Language); CultureInfo.DefaultThreadCurrentUICulture = defCultureInfo; CultureInfo.DefaultThreadCurrentCulture = defCultureInfo; ConfigList = ConfigLoader.Load(); foreach (Config config in ConfigList.Configs.Where(config => config.Name == Options.SelectedConfig)) { ConfigList.CurrentConfig = ConfigList.Configs.IndexOf(config); break; } if (!Options.UseHardwareAcceleration) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } #if !DEBUG if (ProgramIsNew) { if (Translations.AvailableLanguageIDs.Length > 0) { splashScreen.Close(new TimeSpan(0, 0, 1)); var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages); languageWindow.ShowDialog(); string potentialSelectedLanguageID = languageWindow.SelectedID; if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID)) { OptionsObject.Language = potentialSelectedLanguageID; Translations.LoadLanguage(potentialSelectedLanguageID); } splashScreen.Show(false, true); } } #endif MainWindow = new MainWindow(); new PipeInteropServer(MainWindow).Start(); #if !DEBUG } catch (Exception e) { File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING")); MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.", "Error while Loading", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(Environment.ExitCode); } #endif Application app = new Application(); #if !DEBUG try { if (OptionsObject.Program_CheckForUpdates) { UpdateCheck.Check(true); } #endif app.Run(MainWindow); OptionsControl.Save(); #if !DEBUG } catch (Exception e) { File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN")); MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(Environment.ExitCode); } #endif } else { try { StringBuilder sBuilder = new StringBuilder(); bool addedFiles = false; for (int i = 0; i < args.Length; ++i) { if (!string.IsNullOrWhiteSpace(args[i])) { FileInfo fInfo = new FileInfo(args[i]); if (fInfo.Exists) { string ext = fInfo.Extension.ToLowerInvariant().Trim('.', ' '); //todo fix this? if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx") { addedFiles = true; sBuilder.Append(fInfo.FullName); if ((i + 1) != args.Length) { sBuilder.Append("|"); } } } } } if (addedFiles) { PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); } } catch (Exception) { } //dont f**k the user up with irrelevant data } } }
public static void Main(string[] args) { // Init Discord RPC discordClient.Initialize(); // Set default presence discordClient.SetPresence(new RichPresence() { State = "Idle", Timestamps = discordTime, Assets = new Assets() { LargeImageKey = "immagine", } }); bool mutexReserved; using (new Mutex(true, "SpeditGlobalMutex", out mutexReserved)) { if (mutexReserved) { #if !DEBUG try { #endif SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png"); splashScreen.Show(false, true); Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new NullReferenceException(); #if !DEBUG ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory); ProfileOptimization.StartProfile("Startup.Profile"); #endif UpdateStatus = new UpdateInfo(); OptionsObject = OptionsControlIOObject.Load(out var ProgramIsNew); Translations = new TranslationProvider(); Translations.LoadLanguage(OptionsObject.Language, true); for (int i = 0; i < args.Length; ++i) { if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey { OptionsObject.ReCreateCryptoKey(); MakeRCCKAlert(); } } Configs = ConfigLoader.Load(); for (int i = 0; i < Configs.Length; ++i) { if (Configs[i].Name == OptionsObject.Program_SelectedConfig) { SelectedConfig = i; break; } } if (!OptionsObject.Program_UseHardwareAcceleration) { RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; } #if !DEBUG if (ProgramIsNew) { if (Translations.AvailableLanguageIDs.Length > 0) { splashScreen.Close(new TimeSpan(0, 0, 1)); var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages); languageWindow.ShowDialog(); string potentialSelectedLanguageID = languageWindow.SelectedID; if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID)) { OptionsObject.Language = potentialSelectedLanguageID; Translations.LoadLanguage(potentialSelectedLanguageID); } splashScreen.Show(false, true); } } #endif MainWindow = new MainWindow(splashScreen); PipeInteropServer pipeServer = new PipeInteropServer(MainWindow); pipeServer.Start(); #if !DEBUG } catch (Exception e) { File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING")); MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.", "Error while Loading", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(Environment.ExitCode); } #endif Application app = new Application(); #if !DEBUG try { if (OptionsObject.Program_CheckForUpdates) { UpdateCheck.Check(true); } #endif app.Startup += App_Startup; app.Run(MainWindow); OptionsControlIOObject.Save(); #if !DEBUG } catch (Exception e) { File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN")); MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(Environment.ExitCode); } #endif } else { try { StringBuilder sBuilder = new StringBuilder(); bool addedFiles = false; for (int i = 0; i < args.Length; ++i) { if (!string.IsNullOrWhiteSpace(args[i])) { FileInfo fInfo = new FileInfo(args[i]); if (fInfo.Exists) { string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' }); if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx") { addedFiles = true; sBuilder.Append(fInfo.FullName); if ((i + 1) != args.Length) { sBuilder.Append("|"); } } } } } if (addedFiles) { PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); } } catch (Exception) { // ignored } //dont f**k the user up with irrelevant data } } }
public static void Main(string[] args) { bool InSafe = false; bool mutexReserved; using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved)) { if (mutexReserved) { #if !DEBUG try { #endif SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png"); splashScreen.Show(false, true); UpdateStatus = new UpdateInfo(); Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); OptionsObject = OptionsControlIOObject.Load(); for (int i = 0; i < args.Length; ++i) { if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey { var opt = OptionsObject; OptionsObject.ReCreateCryptoKey(); MessageBox.Show("All FTP passwords are now encrypted wrong!" + Environment.NewLine + "You have to replace them!", "Created new crypto key", MessageBoxButton.OK, MessageBoxImage.Information); } else if (args[i].ToLowerInvariant() == "-safe") { InSafe = true; } } Configs = ConfigLoader.Load(); for (int i = 0; i < Configs.Length; ++i) { if (Configs[i].Name == OptionsObject.Program_SelectedConfig) { Program.SelectedConfig = i; break; } } if (!OptionsObject.Program_UseHardwareAcceleration) { RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; } MainWindow = new MainWindow(splashScreen); PipeInteropServer pipeServer = new PipeInteropServer(MainWindow); pipeServer.Start(); #if !DEBUG } catch (Exception e) { File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING")); MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.", "Error while Loading", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(Environment.ExitCode); } #endif Application app = new Application(); if (InSafe) { try { #if !DEBUG if (OptionsObject.Program_CheckForUpdates) { UpdateCheck.Check(true); } #endif app.Run(MainWindow); OptionsControlIOObject.Save(); } catch (Exception e) { File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN")); MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(Environment.ExitCode); } } else { #if !DEBUG if (OptionsObject.Program_CheckForUpdates) { UpdateCheck.Check(true); } #endif app.Run(MainWindow); OptionsControlIOObject.Save(); } } else { try { StringBuilder sBuilder = new StringBuilder(); bool addedFiles = false; for (int i = 0; i < args.Length; ++i) { if (!string.IsNullOrWhiteSpace(args[i])) { FileInfo fInfo = new FileInfo(args[i]); if (fInfo.Exists) { string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' }); if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx") { addedFiles = true; sBuilder.Append(fInfo.FullName); if ((i + 1) != args.Length) { sBuilder.Append("|"); } } } } } if (addedFiles) { PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); } } catch (Exception) { } //dont f**k the user up with irrelevant data } } }