public static void CreateAndRun() { FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory); if (AppArguments.GetBool(AppFlag.DisableSaving)) { ValuesStorage.Initialize(); CacheStorage.Initialize(); } else { ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), InternalUtils.GetValuesStorageEncryptionKey(), AppArguments.GetBool(AppFlag.DisableValuesCompression)); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); } if (!AppArguments.GetBool(AppFlag.DisableLogging)) { var logFilename = EntryPoint.GetLogName("Main Log"); Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging, true)); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); } if (AppArguments.GetBool(AppFlag.NoProxy, true)) { WebRequest.DefaultWebProxy = null; } NonfatalError.Initialize(); LocaleHelper.InitializeAsync().Wait(); new App().Run(); }
public static void CreateAndRun() { FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory); if (AppArguments.GetBool(AppFlag.DisableSaving)) { ValuesStorage.Initialize(); CacheStorage.Initialize(); } else { ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), InternalUtils.GetValuesStorageEncryptionKey(), AppArguments.GetBool(AppFlag.DisableValuesCompression)); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); LargeFileUploaderParams.Initialize(FilesStorage.Instance.GetFilename("Authentication.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); } if (!AppArguments.GetBool(AppFlag.DisableLogging)) { var logFilename = EntryPoint.GetLogName("Main Log"); Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging, true)); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); } if (AppArguments.GetBool(AppFlag.NoProxy, true)) { WebRequest.DefaultWebProxy = null; } NonfatalError.Initialize(); LocaleHelper.InitializeAsync().Wait(); AppearanceManager.DefaultValuesSource = new Uri("/AcManager.Controls;component/Assets/ModernUI.Default.xaml", UriKind.Relative); new App().Run(); }
public App() { // FirstFloor.ModernUI initialization (library used here is a forked version from Content Manager project with extra bits) ValuesStorage.Initialize(TypoModel.DataFilename, "_key_zsu4b3ws1k17ties_" + Environment.UserName, true); CacheStorage.Initialize(); Logging.Initialize(TypoModel.LogFilename, false); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); if (Directory.GetFiles(TypoModel.DataDirectory).Length == 0) { using (var memory = new MemoryStream(Typo4.Properties.Resources.Typo4Data)) { new ZipArchive(memory).ExtractToDirectory(TypoModel.DataDirectory); } } AppearanceManager.Current.Initialize(); AppearanceManager.Current.SetTheme(new Uri("pack://application:,,,/Typo4;component/Assets/AppTheme.xaml", UriKind.Absolute)); AppearanceManager.Current.BoldTitleLinks = false; AppearanceManager.Current.LargerTitleLinks = false; AppearanceManager.Current.SubMenuFontSize = FontSize.Small; Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Typo4;component/Assets/AppAssets.xaml", UriKind.Absolute) }); MuiSystemAccent.Initialize(); NonfatalError.Initialize(); AppIconService.Initialize(this); FatalErrorMessage.Register(this); // All logic in relationship to UI _typoModel = new TypoModel(); // Some more UI initialization bits PrepareUi(); AppShortcut.Initialize("x4fab.Typo4", "Typo4"); Toast.SetDefaultAction(() => (Current.Windows.OfType <ModernWindow>().FirstOrDefault(x => x.IsActive) ?? Current.MainWindow as ModernWindow)?.BringToFront()); BbCodeBlock.OptionEmojiProvider = this; // Let’s at least try to handle stuff properly AppDomain.CurrentDomain.ProcessExit += OnProcessExit; // Log stuff using FirstFloor.ModernUI library TypoLogging.Logger = (s, m, p, l) => Logging.Write($"{s} (Typo)", m, p, l); TypoLogging.TypoLoggingNonFatalErrorHandler = (s, c, e) => NonfatalError.Notify(s, c, e); // Most of the time app should work from system tray _typoModel.Initialize(); _trayInterface = new TrayInterface(_typoModel); // Close only manually ShutdownMode = ShutdownMode.OnExplicitShutdown; // Fancy blur for all windows DpiAwareWindow.NewWindowCreated += OnWindowLoaded; }
public static void CreateAndRun(bool forceSoftwareRenderingMode) { FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory); if (!AppArguments.GetBool(AppFlag.DisableLogging)) { var logFilename = EntryPoint.GetLogName("Main Log"); Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging)); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); } if (AppArguments.GetBool(AppFlag.DisableSaving)) { ValuesStorage.Initialize(); CacheStorage.Initialize(); AuthenticationStorage.Initialize(); } else { ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), InternalUtils.GetValuesStorageEncryptionKey(), AppArguments.GetBool(AppFlag.DisableValuesCompression)); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); AuthenticationStorage.Initialize(FilesStorage.Instance.GetFilename("Authentication.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); if (MathUtils.Random(0, 10) == 0) { LazierCached.Purge(); } FatalErrorHandler.FatalError += OnFatalError; } if (AppArguments.GetBool(AppFlag.NoProxy, true)) { WebRequest.DefaultWebProxy = null; } NonfatalError.Initialize(); LocaleHelper.InitializeAsync().Wait(); var softwareRenderingModeWasEnabled = IsSoftwareRenderingModeEnabled(); if (forceSoftwareRenderingMode) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, true); } if (IsSoftwareRenderingModeEnabled()) { SwitchToSoftwareRendering(); } var app = new App(); // Some sort of safe mode if (forceSoftwareRenderingMode && !softwareRenderingModeWasEnabled) { Toast.Show("Safe mode", "Failed to start the last time, now CM uses software rendering", () => { if (ModernDialog.ShowMessage( "Would you like to switch back to hardware rendering? You can always do that in Settings/Appearance. App will be restarted.", "Switch back", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, false); Storage.SaveBeforeExit(); // Just in case WindowsHelper.RestartCurrentApplication(); } }); } app.Run(); }
public App() { FilesStorage.Initialize(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AcTools Arcade Corsa")); ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), null); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data")); NonfatalError.Initialize(); LimitedSpace.Initialize(); LimitedStorage.Initialize(); DataProvider.Initialize(); DpiAwareWindow.OptionScale = 2d; Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 20 }); AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; Resources.MergedDictionaries.Add(new SharedResourceDictionary { Source = new Uri("/FirstFloor.ModernUI;component/Assets/ModernUI.xaml", UriKind.Relative) }); Resources.MergedDictionaries.Add(new SharedResourceDictionary { Source = new Uri("/Arcade Corsa;component/Assets/Theme.xaml", UriKind.Relative) }); if (MainExecutingFile.Name.IndexOf("fancy", StringComparison.OrdinalIgnoreCase) != -1) { Resources["EffectsEnabled"] = true; Resources["ShadowEffect"] = new DropShadowEffect { RenderingBias = RenderingBias.Performance, BlurRadius = 30, Direction = -90, Color = Colors.Black, ShadowDepth = 4, Opacity = 0.6 }; } else { Resources["EffectsEnabled"] = false; Resources["ShadowEffect"] = null; } var config = Path.Combine(MainExecutingFile.Directory, "Config.json"); string acRoot; if (File.Exists(config)) { var options = JsonConvert.DeserializeObject <Options>(File.ReadAllText(config)); if (options.AcRoot == null) { options.AcRoot = AcRootDirectory.TryToFind(); File.WriteAllText(config, JsonConvert.SerializeObject(options)); } acRoot = options.AcRoot; } else { acRoot = AcRootDirectory.TryToFind(); } AcRootDirectory.Initialize(acRoot); if (!AcRootDirectory.Instance.IsReady) { ModernDialog.ShowMessage("Can’t find AC root directory. Please, specify it using Config.json file."); return; } Superintendent.Initialize(); StartupUri = new Uri("MainWindow.xaml", UriKind.Relative); }
public static void CreateAndRun(bool forceSoftwareRenderingMode) { FilesStorage.Initialize(EntryPoint.ApplicationDataDirectory); if (!AppArguments.GetBool(AppFlag.DisableLogging)) { var logFilename = EntryPoint.GetLogName("Main Log"); Logging.Initialize(FilesStorage.Instance.GetFilename("Logs", logFilename), AppArguments.GetBool(AppFlag.OptimizeLogging)); Logging.Write($"App version: {BuildInformation.AppVersion} ({BuildInformation.Platform}, {WindowsVersionHelper.GetVersion()})"); } Storage.TemporaryBackupsDirectory = FilesStorage.Instance.GetTemporaryDirectory("Storages Backups"); if (AppArguments.GetBool(AppFlag.DisableSaving)) { ValuesStorage.Initialize(); CacheStorage.Initialize(); AuthenticationStorage.Initialize(); } else { ValuesStorage.Initialize(FilesStorage.Instance.GetFilename("Values.data"), InternalUtils.GetValuesStorageEncryptionKey(), AppArguments.GetBool(AppFlag.DisableValuesCompression)); CacheStorage.Initialize(FilesStorage.Instance.GetFilename("Cache.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); AuthenticationStorage.Initialize(FilesStorage.Instance.GetFilename("Authentication.data"), AppArguments.GetBool(AppFlag.DisableValuesCompression)); if (MathUtils.Random(0, 10) == 0) { LazierCached.Purge(); } FatalErrorHandler.FatalError += OnFatalError; } if (AppArguments.GetBool(AppFlag.NoProxy, true)) { WebRequest.DefaultWebProxy = null; } NonfatalError.Initialize(); LocaleHelper.InitializeAsync().Wait(); var softwareRenderingModeWasEnabled = IsSoftwareRenderingModeEnabled(); if (forceSoftwareRenderingMode) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, true); } if (IsSoftwareRenderingModeEnabled()) { SwitchToSoftwareRendering(); } var app = new App(); // Some sort of safe mode if (forceSoftwareRenderingMode && !softwareRenderingModeWasEnabled) { Toast.Show("Safe mode", "Failed to start the last time, now CM uses software rendering", () => { if (MessageDialog.Show( "Would you like to switch back to hardware rendering? You can always do that in Settings/Appearance. App will be restarted.", "Switch back", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ValuesStorage.Set(AppAppearanceManager.KeySoftwareRendering, false); Storage.SaveBeforeExit(); // Just in case WindowsHelper.RestartCurrentApplication(); } }); } var move = AppArguments.Get(AppFlag.MoveApp); if (move != null && File.Exists(move)) { for (var i = 0; i < 10; i++) { if (FileUtils.TryToDelete(move) || !File.Exists(move)) { break; } Thread.Sleep(100); } Toast.Show("App moved", $"App moved from AC root folder, now Oculus Rift should work better", () => { var originalRemoved = File.Exists(move) ? "failed to remove original file" : "original file removed"; if (MessageDialog.Show( $"New location is “{MainExecutingFile.Location}”, {originalRemoved}. Please don’t forget to recreate any shortcuts you might have created.", "Content Manager is moved", new MessageDialogButton { [MessageBoxResult.Yes] = "View new location", [MessageBoxResult.No] = UiStrings.Ok }) == MessageBoxResult.Yes) { WindowsHelper.ViewFile(MainExecutingFile.Location); } }); } app.Run(); }