protected override void OnRenderSizeChanged(SizeChangedInfo size) { if (size == null) { return; } if (!size.WidthChanged && !size.HeightChanged) { return; } else if (!AutoFitWindow) { if (Properties.Settings.Default.FullscreenGallery == false) { return; } } //Keep position when size has changed Top += ((size.PreviousSize.Height / MonitorInfo.DpiScaling) - (size.NewSize.Height / MonitorInfo.DpiScaling)) / 2; Left += ((size.PreviousSize.Width / MonitorInfo.DpiScaling) - (size.NewSize.Width / MonitorInfo.DpiScaling)) / 2; // Move cursor after resize when the button has been pressed if (Navigation.RightbuttonClicked) { Point p = RightButton.PointToScreen(new Point(50, 10)); //Points cursor to center of RighButton NativeMethods.SetCursorPos((int)p.X, (int)p.Y); Navigation.RightbuttonClicked = false; } else if (Navigation.LeftbuttonClicked) { Point p = LeftButton.PointToScreen(new Point(50, 10)); NativeMethods.SetCursorPos((int)p.X, (int)p.Y); Navigation.LeftbuttonClicked = false; } else if (Navigation.ClickArrowRightClicked) { Point p = GetClickArrowRight.PointToScreen(new Point(25, 30)); NativeMethods.SetCursorPos((int)p.X, (int)p.Y); Navigation.ClickArrowRightClicked = false; FadeControls.FadeControlsAsync(true); } else if (Navigation.ClickArrowLeftClicked) { Point p = GetClickArrowLeft.PointToScreen(new Point(25, 30)); NativeMethods.SetCursorPos((int)p.X, (int)p.Y); Navigation.ClickArrowLeftClicked = false; FadeControls.FadeControlsAsync(true); } base.OnRenderSizeChanged(size); }
//private void MainWindow_LocationChanged(object sender, EventArgs e) //{ // // TODO Need to figure out a way to handle user dragging app to a monitor, with different resolution. // //MonitorInfo = MonitorSize.GetMonitorSize(); // //ZoomFit(img.Width, img.Height); //} protected override void OnRenderSizeChanged(SizeChangedInfo size) { if (size == null) { return; } if (!FitToWindow || !size.WidthChanged && !size.HeightChanged) { return; } //Keep position when size has changed Top += (size.PreviousSize.Height - size.NewSize.Height) / 2; Left += (size.PreviousSize.Width - size.NewSize.Width) / 2; // Move cursor after resize when the button has been pressed if (RightbuttonClicked) { Point p = RightButton.PointToScreen(new Point(50, 10)); //Points cursor to center of RighButton NativeMethods.SetCursorPos((int)p.X, (int)p.Y); RightbuttonClicked = false; } else if (LeftbuttonClicked) { Point p = LeftButton.PointToScreen(new Point(50, 10)); NativeMethods.SetCursorPos((int)p.X, (int)p.Y); LeftbuttonClicked = false; } else if (clickArrowRightClicked) { Point p = clickArrowRight.PointToScreen(new Point(25, 30)); NativeMethods.SetCursorPos((int)p.X, (int)p.Y); clickArrowRightClicked = false; } else if (clickArrowLeftClicked) { Point p = clickArrowLeft.PointToScreen(new Point(25, 30)); NativeMethods.SetCursorPos((int)p.X, (int)p.Y); clickArrowLeftClicked = false; } base.OnRenderSizeChanged(size); }