예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            HotKeyMapper hotkeymapper = new HotKeyMapper();

            hotkeymapper.initializeHotkeys();
        }
예제 #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 ----------------------------------------------------  ");
            });
        }
예제 #3
0
 private void OnHotkeyControlFocusLost(object sender, RoutedEventArgs e)
 {
     if (HotkeyControl.CurrentHotkeyAvailable)
     {
         HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
         HotKeyMapper.RemoveHotkey(settings.Hotkey);
         settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
     }
     else
     {
         HotKeyMapper.SetHotkey(new HotkeyModel(settings.Hotkey), HotKeyMapper.OnToggleHotkey);
     }
 }
        private void HotkeyControl_OnLostFocus(object sender, RoutedEventArgs args)
        {
            if (HotkeyControl.CurrentHotkeyAvailable)
            {
                HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
                Settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
            }
            else
            {
                HotKeyMapper.SetHotkey(new HotkeyModel(Settings.Hotkey), HotKeyMapper.OnToggleHotkey);
            }

            HotkeyControl.tbMsg.Text       = tbMsgTextOriginal;
            HotkeyControl.tbMsg.Foreground = tbMsgForegroundColorOriginal;
        }
        private void btnAdd_OnClick(object sender, RoutedEventArgs e)
        {
            if (!update)
            {
                if (!ctlHotkey.CurrentHotkeyAvailable)
                {
                    MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
                    return;
                }

                if (_settings.CustomPluginHotkeys == null)
                {
                    _settings.CustomPluginHotkeys = new ObservableCollection <CustomPluginHotkey>();
                }

                var pluginHotkey = new CustomPluginHotkey
                {
                    Hotkey        = ctlHotkey.CurrentHotkey.ToString(),
                    ActionKeyword = tbAction.Text
                };
                _settings.CustomPluginHotkeys.Add(pluginHotkey);

                HotKeyMapper.SetCustomQueryHotkey(pluginHotkey);
            }
            else
            {
                if (updateCustomHotkey.Hotkey != ctlHotkey.CurrentHotkey.ToString() && !ctlHotkey.CurrentHotkeyAvailable)
                {
                    MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
                    return;
                }
                var oldHotkey = updateCustomHotkey.Hotkey;
                updateCustomHotkey.ActionKeyword = tbAction.Text;
                updateCustomHotkey.Hotkey        = ctlHotkey.CurrentHotkey.ToString();
                //remove origin hotkey
                HotKeyMapper.RemoveHotkey(oldHotkey);
                HotKeyMapper.SetCustomQueryHotkey(updateCustomHotkey);
            }

            Close();
        }
예제 #6
0
        private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e)
        {
            var item = viewModel.SelectedCustomPluginHotkey;

            if (item == null)
            {
                MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
                return;
            }

            string deleteWarning =
                string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"),
                              item.Hotkey);

            if (
                MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
                                MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                settings.CustomPluginHotkeys.Remove(item);
                HotKeyMapper.RemoveHotkey(item.Hotkey);
            }
        }
 private bool CheckHotkeyAvailability() => HotKeyMapper.CheckAvailability(CurrentHotkey);
예제 #8
0
 private void OnHotkeyControlFocused(object sender, RoutedEventArgs e)
 {
     HotKeyMapper.RemoveHotkey(settings.Hotkey);
 }
 private void HotkeyControl_OnGotFocus(object sender, RoutedEventArgs args)
 {
     HotKeyMapper.RemoveHotkey(Settings.Hotkey);
 }