CheckBoxProperty.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using PDF_Master.CustomControl;
  2. using PDF_Master.ViewModels.Form;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PDF_Master.Views.Form
  18. {
  19. /// <summary>
  20. /// CheckBoxProperty.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class CheckBoxProperty : UserControl
  23. {
  24. public CheckBoxPropertyViewModel ViewModel => DataContext as CheckBoxPropertyViewModel;
  25. public CheckBoxProperty()
  26. {
  27. InitializeComponent();
  28. this.Loaded += usercontrol_Loaded;
  29. BindingEvent();
  30. }
  31. private void usercontrol_Loaded(object sender, RoutedEventArgs e)
  32. {
  33. BindingEvent();
  34. }
  35. private void BindingEvent()
  36. {
  37. if (ViewModel != null)
  38. {
  39. ViewModel.SelectResetColorBtnHandler -= ViewModel_SelectResetColorBtnHandler;
  40. ViewModel.SelectResetColorBtnHandler += ViewModel_SelectResetColorBtnHandler;
  41. }
  42. }
  43. private void ViewModel_SelectResetColorBtnHandler(object sender, int e)
  44. {
  45. switch (e)
  46. {
  47. case 0:
  48. OneBtn.IsChecked = false;
  49. TwoBtn.IsChecked = false;
  50. ThreeBtn.IsChecked = false;
  51. ForthBtn.IsChecked = false;
  52. break;
  53. case 1:
  54. OneBtn.IsChecked = true;
  55. break;
  56. case 2:
  57. TwoBtn.IsChecked = true;
  58. break;
  59. case 3:
  60. ThreeBtn.IsChecked = true;
  61. break;
  62. case 4:
  63. ForthBtn.IsChecked = true;
  64. break;
  65. }
  66. }
  67. private void EditMenuItem_Click(object sender, RoutedEventArgs e)
  68. {
  69. var Btnitem = sender as MenuItem;
  70. if (Btnitem == null) return;
  71. if (ViewModel != null)
  72. {
  73. // ViewModel.ResetColorCommand?.Execute(Btnitem);
  74. }
  75. }
  76. private void BtnLineStyle_Click(object sender, RoutedEventArgs e)
  77. {
  78. var btn = sender as CustomIconToggleBtn;
  79. foreach (var item in PnlLineStyle.Children)
  80. {
  81. var btnItem = item as CustomIconToggleBtn;
  82. if (btnItem != null)
  83. {
  84. if (btn != btnItem)
  85. btnItem.IsChecked = false;
  86. else
  87. btnItem.IsChecked = true;
  88. }
  89. }
  90. }
  91. }
  92. }