Example #1
0
        public MainViewModel(
            IMouseInfoProvider mouseInfoProvider,
            ZoomWindowHelper zoomWindowHelper,
            AppStateHandler appStateHandler,
            KeyboardMonitor keyboardMonitor,
            IUserSettings userSettings)
        {
            _zoomWindowHelper = zoomWindowHelper;
            _appStateHandler  = appStateHandler;
            _userSettings     = userSettings;
            NativeEventWaiter.WaitForEventLoop(Constants.ShowColorPickerSharedEvent(), _appStateHandler.StartUserSession);
            NativeEventWaiter.WaitForEventLoop(Constants.ColorPickerSendSettingsTelemetryEvent(), _userSettings.SendSettingsTelemetry);

            if (mouseInfoProvider != null)
            {
                mouseInfoProvider.MouseColorChanged += Mouse_ColorChanged;
                mouseInfoProvider.OnMouseDown       += MouseInfoProvider_OnMouseDown;
                mouseInfoProvider.OnMouseWheel      += MouseInfoProvider_OnMouseWheel;
            }

            _userSettings.ShowColorName.PropertyChanged += (s, e) => { OnPropertyChanged(nameof(ShowColorName)); };

            // Only start a local keyboard low level hook if running as a standalone.
            // Otherwise, the global keyboard hook from runner will be used to activate Color Picker through ShowColorPickerSharedEvent
            // and the Escape key will be registered as a shortcut by appStateHandler when ColorPicker is being used.
            // This is much lighter than using a local low level keyboard hook.
            if ((System.Windows.Application.Current as ColorPickerUI.App).IsRunningDetachedFromPowerToys())
            {
                keyboardMonitor?.Start();
            }
        }
Example #2
0
 public KeyboardMonitor(AppStateHandler appStateHandler, IUserSettings userSettings, ColorsHistoryWindowHelper colorsHistoryWindowHelper, ZoomWindowHelper zoomWindowHelper)
 {
     _appStateHandler           = appStateHandler;
     _userSettings              = userSettings;
     _colorsHistoryWindowHelper = colorsHistoryWindowHelper;
     _zoomWindowHelper          = zoomWindowHelper;
     _userSettings.ActivationShortcut.PropertyChanged += ActivationShortcut_PropertyChanged;
     SetActivationKeys();
 }
Example #3
0
        public MainViewModel(
            IMouseInfoProvider mouseInfoProvider,
            ZoomWindowHelper zoomWindowHelper,
            AppStateHandler appStateHandler,
            KeyboardMonitor keyboardMonitor,
            IUserSettings userSettings)
        {
            _zoomWindowHelper = zoomWindowHelper;
            _appStateHandler  = appStateHandler;
            _userSettings     = userSettings;

            mouseInfoProvider.MouseColorChanged += Mouse_ColorChanged;
            mouseInfoProvider.OnMouseDown       += MouseInfoProvider_OnMouseDown;
            mouseInfoProvider.OnMouseWheel      += MouseInfoProvider_OnMouseWheel;

            keyboardMonitor.Start();
        }
Example #4
0
        public MainViewModel(
            IMouseInfoProvider mouseInfoProvider,
            ZoomWindowHelper zoomWindowHelper,
            AppStateHandler appStateHandler,
            KeyboardMonitor keyboardMonitor,
            AppUpdateManager appUpdateManager,
            IUserSettings userSettings)
        {
            _zoomWindowHelper = zoomWindowHelper;
            _appStateHandler  = appStateHandler;
            mouseInfoProvider.MouseColorChanged += Mouse_ColorChanged;
            mouseInfoProvider.OnMouseDown       += MouseInfoProvider_OnMouseDown;
            mouseInfoProvider.OnMouseWheel      += MouseInfoProvider_OnMouseWheel;

            keyboardMonitor.Start();

            #if !DEBUG
            CheckForUpdates(appUpdateManager, userSettings);
            #endif
        }
Example #5
0
        public MainViewModel(
            IMouseInfoProvider mouseInfoProvider,
            ZoomWindowHelper zoomWindowHelper,
            AppStateHandler appStateHandler,
            KeyboardMonitor keyboardMonitor,
            IUserSettings userSettings)
        {
            _zoomWindowHelper = zoomWindowHelper;
            _appStateHandler  = appStateHandler;
            _userSettings     = userSettings;

            if (mouseInfoProvider != null)
            {
                mouseInfoProvider.MouseColorChanged += Mouse_ColorChanged;
                mouseInfoProvider.OnMouseDown       += MouseInfoProvider_OnMouseDown;
                mouseInfoProvider.OnMouseWheel      += MouseInfoProvider_OnMouseWheel;
            }

            _userSettings.ShowColorName.PropertyChanged += (s, e) => { OnPropertyChanged(nameof(ShowColorName)); };
            keyboardMonitor?.Start();
        }
Example #6
0
        public MainViewModel(
            IMouseInfoProvider mouseInfoProvider,
            ZoomWindowHelper zoomWindowHelper,
            AppStateHandler appStateHandler,
            KeyboardMonitor keyboardMonitor,
            IUserSettings userSettings)
        {
            _zoomWindowHelper = zoomWindowHelper;
            _appStateHandler  = appStateHandler;
            _userSettings     = userSettings;
            NativeEventWaiter.WaitForEventLoop(Constants.ShowColorPickerSharedEvent(), _appStateHandler.StartUserSession);
            NativeEventWaiter.WaitForEventLoop(Constants.ColorPickerSendSettingsTelemetryEvent(), _userSettings.SendSettingsTelemetry);

            if (mouseInfoProvider != null)
            {
                mouseInfoProvider.MouseColorChanged += Mouse_ColorChanged;
                mouseInfoProvider.OnMouseDown       += MouseInfoProvider_OnMouseDown;
                mouseInfoProvider.OnMouseWheel      += MouseInfoProvider_OnMouseWheel;
            }

            _userSettings.ShowColorName.PropertyChanged += (s, e) => { OnPropertyChanged(nameof(ShowColorName)); };
            keyboardMonitor?.Start();
        }
Example #7
0
 private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
 {
     AssociatedObject.PreviewKeyDown      += AssociatedObject_PreviewKeyDown;
     AssociatedObject.MouseLeftButtonDown += AssociatedObject_MouseLeftButtonDown;
     _zoomWindowHelper = Bootstrapper.Container.GetExportedValue <ZoomWindowHelper>();
 }