星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using ComeCapture.Models;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. namespace ComeCapture.Controls
  5. {
  6. public class ImageEditBar : Control
  7. {
  8. static ImageEditBar()
  9. {
  10. DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageEditBar), new FrameworkPropertyMetadata(typeof(ImageEditBar)));
  11. }
  12. public ImageEditBar()
  13. {
  14. _Current = this;
  15. }
  16. #region 属性 Current
  17. private static ImageEditBar _Current = null;
  18. public static ImageEditBar Current
  19. {
  20. get => _Current;
  21. set => _Current = value;
  22. }
  23. #endregion 属性 Current
  24. #region 定位
  25. public void ResetCanvas()
  26. {
  27. ResetCanvasLeft();
  28. ResetCanvasTop();
  29. }
  30. #endregion 定位
  31. #region CanvasLeft DependencyProperty
  32. public double CanvasLeft
  33. {
  34. get => (double)GetValue(CanvasLeftProperty);
  35. set => SetValue(CanvasLeftProperty, value);
  36. }
  37. public static readonly DependencyProperty CanvasLeftProperty =
  38. DependencyProperty.Register("CanvasLeft", typeof(double), typeof(ImageEditBar),
  39. new PropertyMetadata(0.0, new PropertyChangedCallback(ImageEditBar.OnCanvasLeftPropertyChanged)));
  40. private static void OnCanvasLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  41. {
  42. if (obj is ImageEditBar)
  43. {
  44. (obj as ImageEditBar).OnCanvasLeftValueChanged();
  45. }
  46. }
  47. protected void OnCanvasLeftValueChanged()
  48. {
  49. }
  50. private void ResetCanvasLeft()
  51. {
  52. CanvasLeft = AppModel.Current.MaskRightWidth > JieTuWindow.ScreenWidth - Width ? 0 : JieTuWindow.ScreenWidth - AppModel.Current.MaskRightWidth - Width;
  53. }
  54. #endregion CanvasLeft DependencyProperty
  55. #region CanvasTop DependencyProperty
  56. public double CanvasTop
  57. {
  58. get => (double)GetValue(CanvasTopProperty);
  59. set => SetValue(CanvasTopProperty, value);
  60. }
  61. public static readonly DependencyProperty CanvasTopProperty =
  62. DependencyProperty.Register("CanvasTop", typeof(double), typeof(ImageEditBar),
  63. new PropertyMetadata(0.0, new PropertyChangedCallback(ImageEditBar.OnCanvasTopPropertyChanged)));
  64. private static void OnCanvasTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  65. {
  66. if (obj is ImageEditBar)
  67. {
  68. (obj as ImageEditBar).OnCanvasTopValueChanged();
  69. }
  70. }
  71. protected void OnCanvasTopValueChanged()
  72. {
  73. }
  74. private void ResetCanvasTop()
  75. {
  76. int need = 30 + (SizeColorBar.Current.Selected == Tool.Null ? 0 : 37);
  77. CanvasTop = AppModel.Current.MaskBottomHeight >= need ? JieTuWindow.ScreenHeight - AppModel.Current.MaskBottomHeight + 5
  78. : AppModel.Current.MaskTopHeight >= need ? AppModel.Current.MaskTopHeight - 30
  79. : AppModel.Current.MaskTopHeight;
  80. }
  81. #endregion CanvasTop DependencyProperty
  82. }
  83. }