CPDFArrowUI.xaml.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.ComponentModel;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. using System.Windows.Shapes;
  6. namespace Compdfkit_Tools.Common
  7. {
  8. public partial class CPDFArrowUI : UserControl, INotifyPropertyChanged
  9. {
  10. public event EventHandler ArrowChanged;
  11. public event PropertyChangedEventHandler PropertyChanged;
  12. private int _selectedIndex = 1;
  13. public int SelectedIndex
  14. {
  15. get
  16. {
  17. return _selectedIndex;
  18. }
  19. set
  20. {
  21. _selectedIndex = value;
  22. OnPropertyChanged(nameof(SelectedIndex));
  23. OnArrowChanged();
  24. }
  25. }
  26. public CPDFArrowUI()
  27. {
  28. InitializeComponent();
  29. this.DataContext = this;
  30. }
  31. private void OnArrowChanged()
  32. {
  33. ArrowChanged?.Invoke(this, EventArgs.Empty);
  34. }
  35. protected void OnPropertyChanged(string propertyName)
  36. {
  37. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  38. }
  39. public void RotateContent(double angle)
  40. {
  41. try
  42. {
  43. foreach (ComboBoxItem boxItem in ArrowBox.Items)
  44. {
  45. Path drawPath = boxItem.Content as Path;
  46. if (drawPath != null)
  47. {
  48. RotateTransform rotateTransform = new RotateTransform(angle);
  49. rotateTransform.CenterX = boxItem.ActualWidth / 2;
  50. rotateTransform.CenterY = boxItem.ActualHeight / 2;
  51. drawPath.LayoutTransform = rotateTransform;
  52. }
  53. }
  54. }
  55. catch(Exception ex)
  56. {
  57. }
  58. }
  59. }
  60. }