Ejemplo n.º 1
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Stopwatch.Normal("Startup Time", () =>
            {
                RegisterDispatcherUnhandledException();

                var settingVM = new SettingWindowViewModel();
                _settings     = settingVM.Settings;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                var mainVM = new MainViewModel(_settings);
                var window = new MainWindow(_settings, mainVM);
                API        = new PublicAPIInstance(settingVM, mainVM);
                PluginManager.InitializePlugins(API);

                ImageLoader.PreloadImages();

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

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
            });
        }
Ejemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Stopwatch.Debug("Startup Time", () =>
            {
                base.OnStartup(e);
                WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString();
                RegisterUnhandledException();

                ThreadPool.SetMaxThreads(30, 10);
                ThreadPool.SetMinThreads(10, 5);
                ThreadPool.QueueUserWorkItem(_ => { ImageLoader.ImageLoader.PreloadImages(); });

                PluginManager.Initialize();
                UserSettingStorage settings = UserSettingStorage.Instance;

                // happlebao temp fix for instance code logic
                HttpProxy.Instance.Settings = settings;
                InternationalizationManager.Instance.Settings = settings;
                ThemeManager.Instance.Settings = settings;

                MainViewModel mainVM = new MainViewModel(settings);
                API = new PublicAPIInstance(mainVM, settings);
                PluginManager.InitializePlugins(API);

                Window = new MainWindow(settings, mainVM);
                NotifyIconManager notifyIconManager = new NotifyIconManager(API);
                CommandArgsFactory.Execute(e.Args.ToList());
            });
        }
Ejemplo n.º 3
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Stopwatch.Debug("Startup Time", () =>
            {
                RegisterDispatcherUnhandledException();

                ImageLoader.PreloadImages();

                var storage = new JsonStrorage <Settings>();
                _settings   = storage.Load();

                PluginManager.LoadPlugins(_settings.PluginSettings);
                var vm     = new MainViewModel(_settings, storage);
                var window = new MainWindow(_settings, vm);
                API        = new PublicAPIInstance(_settings, vm);
                PluginManager.InitializePlugins(API);

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

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                window.Show();
            });
        }
Ejemplo n.º 4
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
            {
                Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
                RegisterDispatcherUnhandledException();

                ImageLoader.Initialize();
                Alphabet.Initialize();

                var settingVM = new SettingWindowViewModel();
                _settings     = settingVM.Settings;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                var mainVM = new MainViewModel(_settings);
                var window = new MainWindow(_settings, mainVM);
                API        = new PublicAPIInstance(settingVM, mainVM);
                PluginManager.InitializePlugins(API);

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

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
                Log.Info("|App.OnStartup|End Wox startup ----------------------------------------------------  ");
            });
        }
Ejemplo n.º 5
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.º 6
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
            {
                Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
                Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}");
                RegisterAppDomainExceptions();
                RegisterDispatcherUnhandledException();

                ImageLoader.Initialize();

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

                Alphabet.Initialize(_settings);

                StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;
                StringMatcher.ShouldUsePinyin            = _settings.ShouldUsePinyin;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                _mainVM    = new MainViewModel(_settings);
                var window = new MainWindow(_settings, _mainVM);
                API        = new PublicAPIInstance(_settingsVM, _mainVM);
                PluginManager.InitializePlugins(API);
                Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}");

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

                // 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);

                Http.Proxy = _settings.Proxy;

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                _mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
                Log.Info("|App.OnStartup|End Wox startup ----------------------------------------------------  ");
            });
        }
Ejemplo n.º 7
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
            {
                Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
                RegisterDispatcherUnhandledException();

                ImageLoader.Initialize();
                Alphabet.Initialize();

                var settingVM = new SettingWindowViewModel();
                _settings     = settingVM.Settings;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                var mainVM = new MainViewModel(_settings);
                var window = new MainWindow(_settings, mainVM);
                API        = new PublicAPIInstance(settingVM, mainVM);
                PluginManager.InitializePlugins(API);

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

                // happlebao todo temp fix for instance code logic
                // remove all dictionaries defined in xaml e.g.g App.xaml
                Current.Resources.MergedDictionaries.Clear();
                // 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();

                mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
                Log.Info("|App.OnStartup|End Wox startup ----------------------------------------------------  ");
            });
        }
Ejemplo n.º 8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Stopwatch.Debug("Startup Time", () =>
            {
                base.OnStartup(e);
                RegisterUnhandledException();

                Task.Factory.StartNew(ImageLoader.PreloadImages);

                MainViewModel mainVM = new MainViewModel();
                API = new PublicAPIInstance(mainVM, mainVM._settings);
                PluginManager.InitializePlugins(API);

                mainVM._settings.UpdatePluginSettings();

                Window = new MainWindow(mainVM._settings, mainVM);
                NotifyIconManager notifyIconManager = new NotifyIconManager(API);
                CommandArgsFactory.Execute(e.Args.ToList());
            });
        }
Ejemplo n.º 9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Stopwatch.Debug("Startup Time", () =>
            {
                base.OnStartup(e);
                WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString();
                RegisterUnhandledException();

                ThreadPool.SetMaxThreads(30, 10);
                ThreadPool.SetMinThreads(10, 5);
                ThreadPool.QueueUserWorkItem(_ => { ImageLoader.ImageLoader.PreloadImages(); });

                MainViewModel mainVM = new MainViewModel();
                API = new PublicAPIInstance(mainVM);
                Window = new MainWindow {DataContext = mainVM};

                NotifyIconManager notifyIconManager = new NotifyIconManager(API);

                PluginManager.Init(API);
                CommandArgsFactory.Execute(e.Args.ToList());
            });
        }
Ejemplo n.º 10
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            Stopwatch.Normal("Startup Time", () =>
            {
                RegisterDispatcherUnhandledException();

                var settingVM = new SettingWindowViewModel();
                _settings = settingVM.Settings;

                PluginManager.LoadPlugins(_settings.PluginSettings);
                var mainVM = new MainViewModel(_settings);
                var window = new MainWindow(_settings, mainVM);
                API = new PublicAPIInstance(settingVM, mainVM);
                PluginManager.InitializePlugins(API);

                ImageLoader.PreloadImages();

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

                RegisterExitEvents();

                AutoStartup();
                AutoUpdates();

                if (!_settings.HideOnStartup)
                {
                    mainVM.MainWindowVisibility = Visibility.Visible;
                }
            });
        }