/// <summary>
        /// Initialize the SystemTrayPositionProvider, this hooks all the event handlers
        /// </summary>
        /// <param name="xOffset">X-offset for the toasts relative to the location of the taskbar</param>
        /// <param name="yOffset">Y-offset for the toasts relative to the location of the taskbar</param>
        public SystemTrayPositionProvider(int xOffset = 0, int yOffset = 0)
        {
            _xOffset = xOffset;
            _yOffset = yOffset;

            // Make sure we generate an event to recalculate the location on "workarea" changes, use Dapplo.Windows.EnvironmentMonitor
            _subscription = EnvironmentMonitor.EnvironmentUpdateEvents
                            // Only on SPI_SETWORKAREA changes
                            .Where(args => args.SystemParametersInfoAction == SystemParametersInfoActions.SPI_SETWORKAREA)
                            // Create UpdatePositionRequested event
                            .Subscribe(args =>
            {
                // TODO: Make it also work for when the taskbar moves screens or a resolution change is made.
                UpdateHeightRequested?.Invoke(this, EventArgs.Empty);
                UpdateEjectDirectionRequested?.Invoke(this, EventArgs.Empty);
                UpdatePositionRequested?.Invoke(this, EventArgs.Empty);
            });
        }
Ejemplo n.º 2
0
 protected virtual void RequestUpdatePosition()
 {
     UpdateHeightRequested?.Invoke(this, EventArgs.Empty);
     UpdateEjectDirectionRequested?.Invoke(this, EventArgs.Empty);
     UpdatePositionRequested?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 3
0
 protected virtual void RequestUpdatePosition()
 {
     UpdatePositionRequested?.Invoke(this, EventArgs.Empty);
 }