Exemplo n.º 1
0
        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += (S, E) =>
            {
                var dir = Path.Combine(ServiceProvider.SettingsDir, "Crashes");

                Directory.CreateDirectory(dir);

                File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.txt"), E.ExceptionObject.ToString());

                if (E.ExceptionObject is Exception e)
                {
                    Current.Dispatcher.Invoke(() => new ExceptionWindow(e).ShowDialog());
                }

                Shutdown();
            };

            ServiceProvider.LoadModule(new CoreModule());

            Parser.Default.ParseArguments <CmdOptions>(Args.Args)
            .WithParsed(M => CmdOptions = M);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            if (!CmdOptions.Reset)
            {
                settings.Load();
            }

            if (settings.UI.DarkTheme)
            {
                AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
            }

            var accent = settings.UI.AccentColor;

            if (!string.IsNullOrEmpty(accent))
            {
                AppearanceManager.Current.AccentColor = WpfExtensions.ParseColor(accent);
            }

            if (!string.IsNullOrWhiteSpace(settings.UI.Language))
            {
                var matchedCulture = LanguageManager.Instance.AvailableCultures.FirstOrDefault(M => M.Name == settings.UI.Language);

                if (matchedCulture != null)
                {
                    LanguageManager.Instance.CurrentCulture = matchedCulture;
                }
            }

            LanguageManager.Instance.LanguageChanged += L => settings.UI.Language = L.Name;
        }
Exemplo n.º 2
0
        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += (S, E) =>
            {
                var dir = Path.Combine(ServiceProvider.SettingsDir, "Crashes");

                Directory.CreateDirectory(dir);

                File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.txt"), E.ExceptionObject.ToString());

                if (E.ExceptionObject is Exception e)
                {
                    Current.Dispatcher.Invoke(() => new ExceptionWindow(e).ShowDialog());
                }

                Shutdown();
            };

            Parser.Default.ParseArguments <CmdOptions>(Args.Args)
            .WithParsed(M => CmdOptions = M);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            if (!CmdOptions.Reset)
            {
                settings.Load();
            }

            if (settings.UI.DarkTheme)
            {
                AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
            }

            var accent = settings.UI.AccentColor;

            if (!string.IsNullOrEmpty(accent))
            {
                if (ColorConverter.ConvertFromString(accent) is Color accentColor)
                {
                    AppearanceManager.Current.AccentColor = accentColor;
                }
            }

            // A quick fix for WpfToolkit not being copied to build output of console project
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            Xceed.Wpf.Toolkit.ColorSortingMode.Alphabetical.ToString();
        }
Exemplo n.º 3
0
        void Application_Startup(object Sender, StartupEventArgs Args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainOnUnhandledException;

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new ViewCoreModule());

            Parser.Default.ParseArguments <CmdOptions>(Args.Args)
            .WithParsed(M => CmdOptions = M);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            InitTheme(settings);

            BindLanguageSetting(settings);

            BindKeymapSetting(settings);
        }
Exemplo n.º 4
0
        private void Application_Startup(object sender, StartupEventArgs args)
        {
            AppDomain.CurrentDomain.UnhandledException += (o, unhandledExceptionEventArgs) =>
            {
                var dir = Path.Combine(ServiceProvider.SettingsDir, "Crashes");

                Directory.CreateDirectory(dir);

                File.WriteAllText(Path.Combine(dir, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.txt"), unhandledExceptionEventArgs.ExceptionObject.ToString());

                if (unhandledExceptionEventArgs.ExceptionObject is Exception e)
                {
                    Current.Dispatcher.Invoke(() => new ExceptionWindow(e).ShowDialog());
                }

                Shutdown();
            };

            ServiceProvider.LoadModule(new CoreModule());
            ServiceProvider.LoadModule(new ViewCoreModule());

            Parser.Default.ParseArguments <CmdOptions>(args.Args)
            .WithParsed(cmdOptions => CmdOptions = cmdOptions);

            if (CmdOptions.Settings != null)
            {
                ServiceProvider.SettingsDir = CmdOptions.Settings;
            }

            var settings = ServiceProvider.Get <Settings>();

            if (!CmdOptions.Reset)
            {
                settings.Load();
            }

            if (settings.Ui.DarkTheme)
            {
                AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
            }

            var accent = settings.Ui.AccentColor;

            if (!string.IsNullOrEmpty(accent))
            {
                AppearanceManager.Current.AccentColor = WpfExtensions.ParseColor(accent);
            }

            if (!string.IsNullOrWhiteSpace(settings.Ui.Language))
            {
                var matchedCulture = LanguageManager.Instance.AvailableCultures.FirstOrDefault(cultureInfo => cultureInfo.Name == settings.Ui.Language);

                if (matchedCulture != null)
                {
                    LanguageManager.Instance.CurrentCulture = matchedCulture;
                }
            }

            LanguageManager.Instance.LanguageChanged += cultureInfo => settings.Ui.Language = cultureInfo.Name;

            var keymap = ServiceProvider.Get <KeymapViewModel>();

            if (!string.IsNullOrWhiteSpace(settings.Keystrokes.KeymapName))
            {
                var matched = keymap.AvailableKeymaps.FirstOrDefault(keymapItem => keymapItem.Name == settings.Keystrokes.KeymapName);

                if (matched != null)
                {
                    keymap.SelectedKeymap = matched;
                }
            }

            keymap.PropertyChanged += (o, e) => settings.Keystrokes.KeymapName = keymap.SelectedKeymap.Name;
        }