123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using ComeCapture.Models;
-
- using System.Windows;
- using System.Windows.Controls;
-
- namespace ComeCapture.Controls
- {
- public class ImageEditBar : Control
- {
- static ImageEditBar()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageEditBar), new FrameworkPropertyMetadata(typeof(ImageEditBar)));
- }
-
- public ImageEditBar()
- {
- _Current = this;
- }
-
- #region 属性 Current
-
- private static ImageEditBar _Current = null;
-
- public static ImageEditBar Current
- {
- get => _Current;
- set => _Current = value;
- }
-
- #endregion 属性 Current
-
- #region 定位
-
- public void ResetCanvas()
- {
- ResetCanvasLeft();
- ResetCanvasTop();
- }
-
- #endregion 定位
-
- #region CanvasLeft DependencyProperty
-
- public double CanvasLeft
- {
- get => (double)GetValue(CanvasLeftProperty);
- set => SetValue(CanvasLeftProperty, value);
- }
-
- public static readonly DependencyProperty CanvasLeftProperty =
- DependencyProperty.Register("CanvasLeft", typeof(double), typeof(ImageEditBar),
- new PropertyMetadata(0.0, new PropertyChangedCallback(ImageEditBar.OnCanvasLeftPropertyChanged)));
-
- private static void OnCanvasLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
- {
- if (obj is ImageEditBar)
- {
- (obj as ImageEditBar).OnCanvasLeftValueChanged();
- }
- }
-
- protected void OnCanvasLeftValueChanged()
- {
- }
-
- private void ResetCanvasLeft()
- {
- CanvasLeft = AppModel.Current.MaskRightWidth > JieTuWindow.ScreenWidth - Width ? 0 : JieTuWindow.ScreenWidth - AppModel.Current.MaskRightWidth - Width;
- }
-
- #endregion CanvasLeft DependencyProperty
-
- #region CanvasTop DependencyProperty
-
- public double CanvasTop
- {
- get => (double)GetValue(CanvasTopProperty);
- set => SetValue(CanvasTopProperty, value);
- }
-
- public static readonly DependencyProperty CanvasTopProperty =
- DependencyProperty.Register("CanvasTop", typeof(double), typeof(ImageEditBar),
- new PropertyMetadata(0.0, new PropertyChangedCallback(ImageEditBar.OnCanvasTopPropertyChanged)));
-
- private static void OnCanvasTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
- {
- if (obj is ImageEditBar)
- {
- (obj as ImageEditBar).OnCanvasTopValueChanged();
- }
- }
-
- protected void OnCanvasTopValueChanged()
- {
- }
-
- private void ResetCanvasTop()
- {
- int need = 30 + (SizeColorBar.Current.Selected == Tool.Null ? 0 : 37);
- CanvasTop = AppModel.Current.MaskBottomHeight >= need ? JieTuWindow.ScreenHeight - AppModel.Current.MaskBottomHeight + 5
- : AppModel.Current.MaskTopHeight >= need ? AppModel.Current.MaskTopHeight - 30
- : AppModel.Current.MaskTopHeight;
- }
-
- #endregion CanvasTop DependencyProperty
- }
- }
|