MainWindow.xaml.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using PicView.SystemIntegration;
  2. using PicView.UI.Loading;
  3. using System.Windows;
  4. using static PicView.Library.Fields;
  5. using static PicView.UI.Sizing.WindowLogic;
  6. using static PicView.UI.UserControls.UC;
  7. namespace PicView.UI.Windows
  8. {
  9. public partial class MainWindow : Window
  10. {
  11. public MainWindow()
  12. {
  13. InitializeComponent();
  14. Loaded += delegate { StartLoading.PreStart(); };
  15. ContentRendered += async delegate { await StartLoading.Start().ConfigureAwait(false); };
  16. }
  17. #region OnRenderSizeChanged override
  18. protected override void OnRenderSizeChanged(SizeChangedInfo size)
  19. {
  20. if (size == null)
  21. {
  22. return;
  23. }
  24. if (!SetWindowBehaviour || !size.WidthChanged && !size.HeightChanged)
  25. {
  26. return;
  27. }
  28. //Keep position when size has changed
  29. Top += (size.PreviousSize.Height - size.NewSize.Height) / 2;
  30. Left += (size.PreviousSize.Width - size.NewSize.Width) / 2;
  31. // Move cursor after resize when the button has been pressed
  32. if (RightbuttonClicked)
  33. {
  34. Point p = RightButton.PointToScreen(new Point(50, 10)); //Points cursor to center of RighButton
  35. NativeMethods.SetCursorPos((int)p.X, (int)p.Y);
  36. RightbuttonClicked = false;
  37. }
  38. else if (LeftbuttonClicked)
  39. {
  40. Point p = LeftButton.PointToScreen(new Point(50, 10));
  41. NativeMethods.SetCursorPos((int)p.X, (int)p.Y);
  42. LeftbuttonClicked = false;
  43. }
  44. else if (ClickArrowRightClicked)
  45. {
  46. Point p = clickArrowRight.PointToScreen(new Point(25, 30));
  47. NativeMethods.SetCursorPos((int)p.X, (int)p.Y);
  48. ClickArrowRightClicked = false;
  49. }
  50. else if (ClickArrowLeftClicked)
  51. {
  52. Point p = clickArrowLeft.PointToScreen(new Point(25, 30));
  53. NativeMethods.SetCursorPos((int)p.X, (int)p.Y);
  54. ClickArrowLeftClicked = false;
  55. }
  56. base.OnRenderSizeChanged(size);
  57. }
  58. #endregion OnRenderSizeChanged override
  59. }
  60. }