CPDFArrowUI.xaml.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  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 Compdfkit_Tools.Common
  17. {
  18. /// <summary>
  19. /// CPDFArrowControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class CPDFArrowUI : UserControl, INotifyPropertyChanged
  22. {
  23. public event EventHandler ArrowChanged;
  24. public event PropertyChangedEventHandler PropertyChanged;
  25. private int _selectedIndex = 1;
  26. public int SelectedIndex
  27. {
  28. get
  29. {
  30. return _selectedIndex;
  31. }
  32. set
  33. {
  34. _selectedIndex = value;
  35. OnPropertyChanged(nameof(SelectedIndex));
  36. OnArrowChanged();
  37. }
  38. }
  39. public CPDFArrowUI()
  40. {
  41. InitializeComponent();
  42. this.DataContext = this;
  43. }
  44. private void OnArrowChanged()
  45. {
  46. ArrowChanged?.Invoke(this, EventArgs.Empty);
  47. }
  48. protected void OnPropertyChanged(string propertyName)
  49. {
  50. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  51. }
  52. public void RotateContent(double angle)
  53. {
  54. try
  55. {
  56. foreach (ComboBoxItem boxItem in ArrowBox.Items)
  57. {
  58. Path drawPath = boxItem.Content as Path;
  59. if (drawPath != null)
  60. {
  61. RotateTransform rotateTransform = new RotateTransform(angle);
  62. rotateTransform.CenterX = boxItem.ActualWidth / 2;
  63. rotateTransform.CenterY = boxItem.ActualHeight / 2;
  64. drawPath.LayoutTransform = rotateTransform;
  65. }
  66. }
  67. }
  68. catch(Exception ex)
  69. {
  70. }
  71. }
  72. }
  73. }