FormsToolContent.xaml.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using PDF_Master.ViewModels.Form;
  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. namespace PDF_Master.Views.Form
  17. {
  18. /// <summary>
  19. /// FormsToolContent.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class FormsToolContent : UserControl
  22. {
  23. private FormsToolContentViewModel ViewModel =>DataContext as FormsToolContentViewModel;
  24. public FormsToolContent()
  25. {
  26. InitializeComponent();
  27. }
  28. private void BtnAlignment_Click(object sender, RoutedEventArgs e)
  29. {
  30. MenuAlignment.PlacementTarget = this.BtnAlignment;
  31. MenuAlignment.IsOpen = true;
  32. }
  33. /// <summary>
  34. /// 取消右键弹出下拉菜单
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. private void BtnAlignment_Initialized(object sender, EventArgs e)
  39. {
  40. //取消右键菜单的绑定,只能左键点击弹出
  41. this.BtnAlignment.ContextMenu = null;
  42. }
  43. private void BtnMore_Click(object sender, RoutedEventArgs e)
  44. {
  45. MenuMore.PlacementTarget = this.BtnMore;
  46. MenuMore.IsOpen = true;
  47. }
  48. private void BtnMore_Initialized(object sender, EventArgs e)
  49. {
  50. //取消右键菜单的绑定,只能左键点击弹出
  51. this.BtnMore.ContextMenu = null;
  52. }
  53. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  54. {
  55. if(ViewModel != null)
  56. {
  57. ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent;
  58. ViewModel.UncheckedToolsBtnEvent += ViewModel_UncheckedToolsBtnEvent;
  59. }
  60. }
  61. private void ViewModel_UncheckedToolsBtnEvent(object sender, string e)
  62. {
  63. foreach(var item in PnlTool.Children)
  64. {
  65. var btn = item as RadioButton;
  66. if (btn != null)
  67. {
  68. if (btn.IsChecked == true)
  69. {
  70. btn.IsChecked = false;
  71. break;
  72. }
  73. }
  74. }
  75. }
  76. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  77. {
  78. if (ViewModel != null)
  79. {
  80. ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent;
  81. }
  82. }
  83. }
  84. }