Ejemplo n.º 1
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Logger.StopWatchNormal("Startup cost", () =>
            {
                Constant.Initialize();

                Logger.WoxInfo("Begin Wox startup----------------------------------------------------");
                Logger.WoxInfo($"Runtime info:{ExceptionFormatter.RuntimeInfo()}");


                RegisterAppDomainExceptions();
                RegisterDispatcherUnhandledException();

                //throw new Exception("sentry wox exception");

                _portable.PreStartCleanUpAfterPortabilityUpdate();


                ImageLoader.Initialize();

                _settingsVM = new SettingWindowViewModel(_updater, _portable);
                _settings   = _settingsVM.Settings;

                _alphabet.Initialize(_settings);
                _stringMatcher         = new StringMatcher(_alphabet);
                StringMatcher.Instance = _stringMatcher;
                _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                _mainVM    = new MainViewModel(_settings);
                var window = new MainWindow(_settings, _mainVM);
                API        = new PublicAPIInstance(_settingsVM, _mainVM, _alphabet);
                PluginManager.InitializePlugins(API);

                Current.MainWindow       = window;
                Current.MainWindow.Title = Constant.Wox;

                // todo temp fix for instance code logic
                // load plugin before change language, because plugin language also needs be changed
                InternationalizationManager.Instance.Settings = _settings;
                InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
                // main windows needs initialized before theme change because of blur settigns
                ThemeManager.Instance.Settings = _settings;
                ThemeManager.Instance.ChangeTheme(_settings.Theme);

                Http.Proxy = _settings.Proxy;

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                ParseCommandLineArgs(SingleInstance <App> .CommandLineArgs);
                _mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;

                Logger.WoxInfo($"SDK Info: {ExceptionFormatter.SDKInfo()}");
                Logger.WoxInfo("End Wox startup ----------------------------------------------------  ");
            });
        }
Ejemplo n.º 2
0
        private async void OnStartupAsync(object sender, StartupEventArgs e)
        {
            await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async() =>
            {
                _portable.PreStartCleanUpAfterPortabilityUpdate();

                Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");
                Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}");
                RegisterAppDomainExceptions();
                RegisterDispatcherUnhandledException();

                ImageLoader.Initialize();

                _settingsVM = new SettingWindowViewModel(_updater, _portable);
                _settings   = _settingsVM.Settings;

                _alphabet.Initialize(_settings);
                _stringMatcher         = new StringMatcher(_alphabet);
                StringMatcher.Instance = _stringMatcher;
                _stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                _mainVM = new MainViewModel(_settings);

                API = new PublicAPIInstance(_settingsVM, _mainVM, _alphabet);

                Http.API   = API;
                Http.Proxy = _settings.Proxy;

                await PluginManager.InitializePlugins(API);
                var window = new MainWindow(_settings, _mainVM);

                Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}");

                Current.MainWindow       = window;
                Current.MainWindow.Title = Constant.FlowLauncher;

                HotKeyMapper.Initialize(_mainVM);

                // happlebao todo temp fix for instance code logic
                // load plugin before change language, because plugin language also needs be changed
                InternationalizationManager.Instance.Settings = _settings;
                InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
                // main windows needs initialized before theme change because of blur settigns
                ThemeManager.Instance.Settings = _settings;
                ThemeManager.Instance.ChangeTheme(_settings.Theme);

                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                API.SaveAppAllSettings();
                Log.Info("|App.OnStartup|End Flow Launcher startup ----------------------------------------------------  ");
            });
        }