Beispiel #1
0
        public static int Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture   = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

            try {
                var options = new Options();
                if (!Parser.Default.ParseArguments(args, options))
                {
                    return(1);
                }

                FilesStorage.Initialize(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AcTools Console Wrapper"));
                ValuesStorage.Initialize(null, null);
                CacheStorage.Initialize(null);
                LimitedSpace.Initialize();
                LimitedStorage.Initialize();
                DataProvider.Initialize();

                AcRootDirectory.Initialize(options.AcRoot);
                if (!AcRootDirectory.Instance.IsReady)
                {
                    Console.Error.WriteLine("Invalid AC root directory");
                    return(3);
                }

                Superintendent.Initialize();

                AsyncContext.Run(() => MainAsync(options));
                return(0);
            } catch (InformativeException e) {
                Console.Error.WriteLine(e.Message);
                return(2);
            } catch (Exception e) {
                Console.Error.WriteLine(e.ToString());
                return(2);
            }
        }
Beispiel #2
0
        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);
        }