Beispiel #1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            _mainWindow = Application.Current.MainWindow;
            if (_mainWindow == null)
            {
                Trace.TraceError("mainWindow is null");
                return;
            }
            if (Options.HideTabs)
            {
                Application.Current.Resources.MergedDictionaries.Add(ResourceOverrides);
            }
            _mainWindow.LayoutUpdated    += DetectLayoutElements;
            _nonClientTracker             = new NonClientMouseTracker(_mainWindow);
            _nonClientTracker.MouseEnter += () => OnIsMouseOverChanged(null, null);
            _nonClientTracker.MouseLeave += () => OnIsMouseOverChanged(null, null);
            EventManager.RegisterClassHandler(typeof(UIElement), UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(PopupLostKeyboardFocus));
            _mouseEnterTimer = new DispatcherTimer {
                IsEnabled = false, Interval = TimeSpan.FromMilliseconds(Options.MouseEnterDelay)
            };
            _mouseLeaveTimer = new DispatcherTimer {
                IsEnabled = false, Interval = TimeSpan.FromMilliseconds(Options.MouseLeaveDelay)
            };
            _mouseEnterTimer.Tick   += _mouseEnterTimer_Tick;
            _mouseLeaveTimer.Tick   += _mouseLeaveTimer_Tick;
            Options.PropertyChanged += OptionsChanged;
        }
Beispiel #2
0
 /// <summary>
 /// Initialization of the package; this method is called right after the package is sited, so this is the place
 /// where you can put all the initialization code that rely on services provided by VisualStudio.
 /// </summary>
 protected override void Initialize()
 {
     base.Initialize();
     _mainWindow = Application.Current.MainWindow;
     if (_mainWindow == null)
     {
         Trace.TraceError("mainWindow is null");
         return;
     }
     if (Options.HideTabs)
     {
         Application.Current.Resources.MergedDictionaries.Add(ResourceOverrides);
     }
     _mainWindow.LayoutUpdated    += DetectLayoutElements;
     _nonClientTracker             = new NonClientMouseTracker(_mainWindow);
     _nonClientTracker.MouseEnter += () => OnIsMouseOverChanged(null, null);
     _nonClientTracker.MouseLeave += () => OnIsMouseOverChanged(null, null);
     EventManager.RegisterClassHandler(typeof(UIElement), UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(PopupLostKeyboardFocus));
     _mouseEnterTimer = new DispatcherTimer {
         IsEnabled = false, Interval = TimeSpan.FromMilliseconds(Options.MouseEnterDelay)
     };
     _mouseLeaveTimer = new DispatcherTimer {
         IsEnabled = false, Interval = TimeSpan.FromMilliseconds(Options.MouseLeaveDelay)
     };
     _mouseEnterTimer.Tick   += _mouseEnterTimer_Tick;
     _mouseLeaveTimer.Tick   += _mouseLeaveTimer_Tick;
     Options.PropertyChanged += OptionsChanged;
 }