public void SlideUp() { using (var dpiSettings = new DpiCalculator()) { dpiSettings.LoadDpi(); System.Drawing.Point cursor = Control.MousePosition; SlideUpAnimation.From = Top = Screen.PrimaryScreen.Bounds.Bottom; Show(); Left = cursor.X / dpiSettings.ScalingFactorX - ActualWidth / 2; if ((Left + ActualWidth) * dpiSettings.ScalingFactorX > Screen.PrimaryScreen.Bounds.Right) { Left = Screen.PrimaryScreen.Bounds.Right / dpiSettings.ScalingFactorX - ActualWidth; } // The WPF form height is already adjusted for the DPI (software pixels) - WorkingArea.Bottom will report the physical pixels. SlideUpAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom / dpiSettings.ScalingFactorY - ActualHeight; } SlideUpStoryboard.Begin(this); }
public void SlideDown() { if (!IsVisible) return; var dpiSettings = new DpiCalculator(); dpiSettings.LoadDpi(); SlideDownAnimation.From = Top; SlideDownAnimation.To = Screen.PrimaryScreen.Bounds.Bottom; SlideDownStoryboard.Begin(this); }