SplitScreenContent.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using PDF_Master.ViewModels.PropertyPanel.ViewModular;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using System.Windows.Threading;
  17. namespace PDF_Master.Views.PropertyPanel.ViewModular
  18. {
  19. /// <summary>
  20. /// SplitScreenContent.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class SplitScreenContent : UserControl
  23. {
  24. private SplitScreenContentViewModel splitScreenContentViewModel = null;
  25. private bool isLoadMenuSelectedFiles = false;
  26. private bool isLoadMenuReselect = false;
  27. public SplitScreenContent()
  28. {
  29. InitializeComponent();
  30. splitScreenContentViewModel = (SplitScreenContentViewModel)this.DataContext;
  31. }
  32. private void BtnSelectedFiles_Click(object sender, RoutedEventArgs e)
  33. {
  34. MenuSelectedFiles.PlacementTarget = this.BtnSelectedFiles;
  35. MenuSelectedFiles.IsOpen = true;
  36. if (splitScreenContentViewModel != null && !isLoadMenuSelectedFiles)
  37. {
  38. splitScreenContentViewModel.SelectedFilesCommand.Execute(MenuSelectedFiles);
  39. isLoadMenuSelectedFiles = true;
  40. }
  41. }
  42. private void BtnSelectedFiles_Initialized(object sender, EventArgs e)
  43. {
  44. this.BtnSelectedFiles.ContextMenu = null;
  45. }
  46. private void BtnReselect_Click(object sender, RoutedEventArgs e)
  47. {
  48. MenuReselect.PlacementTarget = this.BtnReselect;
  49. MenuReselect.IsOpen = true;
  50. if (splitScreenContentViewModel != null && !isLoadMenuReselect)
  51. {
  52. splitScreenContentViewModel.SelectedFilesCommand.Execute(MenuReselect);
  53. isLoadMenuReselect = true;
  54. }
  55. }
  56. private void BtnReselect_Initialized(object sender, EventArgs e)
  57. {
  58. this.BtnReselect.ContextMenu = null;
  59. }
  60. private void RectReselect_MouseEnter(object sender, MouseEventArgs e)
  61. {
  62. Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate
  63. {
  64. this.BtnReselect.Visibility = Visibility.Visible;
  65. this.MenuReselect.Visibility = Visibility.Visible;
  66. this.RectReselect.Visibility = Visibility.Collapsed;
  67. }));
  68. }
  69. private async void BtnReselect_MouseLeave(object sender, MouseEventArgs e)
  70. {
  71. //IInputElement focusedControl = FocusManager.GetFocusedElement(MenuReselect);
  72. //if (focusedControl is MenuItem menu)
  73. //{
  74. // if (menu.Header.ToString() != "Select file")
  75. // {
  76. // await System.Threading.Tasks.Task.Delay(3000);
  77. // this.BtnReselect.Visibility = Visibility.Collapsed;
  78. // this.RectReselect.Visibility = Visibility.Visible;
  79. // }
  80. //}
  81. //else
  82. //{
  83. // await System.Threading.Tasks.Task.Delay(3000);
  84. // this.BtnReselect.Visibility = Visibility.Collapsed;
  85. // this.RectReselect.Visibility = Visibility.Visible;
  86. //}
  87. await System.Threading.Tasks.Task.Delay(3000);
  88. this.BtnReselect.Visibility = Visibility.Collapsed;
  89. this.MenuReselect.Visibility = Visibility.Collapsed;
  90. this.RectReselect.Visibility = Visibility.Visible;
  91. }
  92. private void MenuReselect_MouseEnter(object sender, MouseEventArgs e)
  93. {
  94. this.BtnReselect.Visibility = Visibility.Visible;
  95. this.MenuReselect.Visibility = Visibility.Visible;
  96. this.RectReselect.Visibility = Visibility.Collapsed;
  97. }
  98. }
  99. }