Example #1
0
        static void Main()
        {
            bool bUpdatePending = GithubUpdater.FindAndApplyUpdates();

            if (bUpdatePending)
            {
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Example #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Logger.Initialize(e.Args);

            bool canStart = false;

            bool updatePending = GithubUpdater.FindAndApplyUpdates();

            if (!updatePending)
            {
                bool hasAssets = LoadAssets();
                if (hasAssets)
                {
                    canStart = true;
                }
                else
                {
                    string appName = Assembly.GetEntryAssembly().GetName().Name;
                    MessageBox.Show("Failed to initialize resources!", appName, MessageBoxButton.OK, MessageBoxImage.Stop);
                }
            }

#if DEBUG
            if (Array.Find(e.Args, x => x == "-runTests") != null)
            {
                TestManager.RunTests();
                canStart = false;
            }
            else if (Array.Find(e.Args, x => x == "-dataConvert") != null)
            {
                var converter = new DataConverter();
                converter.Run();
                canStart = false;
            }
#endif // DEBUG

            if (canStart)
            {
                DialogWindowService.Initialize();
                OverlayWindowService.Initialize();
                AppWindowService.Initialize();

                canSaveSettings = true;

                var window = new MainWindow();

                var settingsDB = PlayerSettingsDB.Get();
                window.FontSize = settingsDB.fontSize;
                window.Topmost  = settingsDB.alwaysOnTop;

                if (settingsDB.lastHeight > window.MinHeight)
                {
                    window.Height = settingsDB.lastHeight;
                }
                if (settingsDB.lastWidth > window.MinWidth)
                {
                    window.Width = settingsDB.lastWidth;
                }

                window.Show();
            }
            else
            {
                Shutdown();
            }
        }