|
@@ -1,4 +1,5 @@
|
|
-using System;
|
|
|
|
|
|
+using PDF_Office.Helper;
|
|
|
|
+using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
@@ -17,100 +18,45 @@ using System.Windows.Shapes;
|
|
|
|
|
|
namespace PDF_Office.CustomControl.CompositeControl
|
|
namespace PDF_Office.CustomControl.CompositeControl
|
|
{
|
|
{
|
|
- public class AdornerPresenter : Adorner
|
|
|
|
- {
|
|
|
|
- private VisualCollection VisualChildren;
|
|
|
|
- private ContentPresenter Content;
|
|
|
|
- public AdornerPresenter(UIElement adornedElement) : base(adornedElement)
|
|
|
|
- {
|
|
|
|
- VisualChildren = new VisualCollection(this);
|
|
|
|
- Content = new ContentPresenter();
|
|
|
|
- VisualChildren.Add(Content);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected override Size MeasureOverride(Size constraint)
|
|
|
|
- {
|
|
|
|
- Content.Measure(constraint);
|
|
|
|
- return Content.DesiredSize;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected override Size ArrangeOverride(Size finalSize)
|
|
|
|
- {
|
|
|
|
- Content.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
|
|
|
|
- return Content.RenderSize;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected override Visual GetVisualChild(int index)
|
|
|
|
- {
|
|
|
|
- return VisualChildren[index];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected override int VisualChildrenCount
|
|
|
|
- {
|
|
|
|
- get
|
|
|
|
- {
|
|
|
|
- return VisualChildren.Count;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public object VisualContent
|
|
|
|
- {
|
|
|
|
- get
|
|
|
|
- {
|
|
|
|
- return Content.Content;
|
|
|
|
- }
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- Content.Content = value;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// ThicknessContent.xaml 的交互逻辑
|
|
/// ThicknessContent.xaml 的交互逻辑
|
|
/// </summary>
|
|
/// </summary>
|
|
public partial class SlidContent : UserControl
|
|
public partial class SlidContent : UserControl
|
|
{
|
|
{
|
|
|
|
+ #region 定义
|
|
|
|
+
|
|
private AdornerLayer popLayer;
|
|
private AdornerLayer popLayer;
|
|
private AdornerPresenter layerPresent;
|
|
private AdornerPresenter layerPresent;
|
|
private bool layerAdded = false;
|
|
private bool layerAdded = false;
|
|
private Canvas popCanvas;
|
|
private Canvas popCanvas;
|
|
- private SlidContentPop colorPop;
|
|
|
|
- public EventHandler<double> SelectedValueChanged;
|
|
|
|
- public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
- protected void OnPropertyChanged([CallerMemberName] string name = null)
|
|
|
|
- {
|
|
|
|
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
|
|
- }
|
|
|
|
- private Color? _selectedColor;
|
|
|
|
- public Color? SelectedColor
|
|
|
|
|
|
+ private SlidContentPop SlidOpacityPop;
|
|
|
|
+ public event RoutedEventHandler SelectedValueChanged;
|
|
|
|
+
|
|
|
|
+ public double Value
|
|
{
|
|
{
|
|
- get
|
|
|
|
- {
|
|
|
|
- return _selectedColor;
|
|
|
|
- }
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- if (_selectedColor != value)
|
|
|
|
- {
|
|
|
|
- _selectedColor = value;
|
|
|
|
- OnPropertyChanged("SelectedColor");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ get { return (double)GetValue(_valueProperty); }
|
|
|
|
+ set { SetValue(_valueProperty, value); }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ public static readonly DependencyProperty _valueProperty =
|
|
|
|
+ DependencyProperty.Register("Value", typeof(double), typeof(SlidContent), new PropertyMetadata(0.0));
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
public SlidContent()
|
|
public SlidContent()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
Loaded += ColorDropBox_Loaded;
|
|
Loaded += ColorDropBox_Loaded;
|
|
Unloaded += ColorDropBox_Unloaded;
|
|
Unloaded += ColorDropBox_Unloaded;
|
|
MouseDown += ColorDropBox_MouseDown;
|
|
MouseDown += ColorDropBox_MouseDown;
|
|
- colorPop = new SlidContentPop();
|
|
|
|
- colorPop.OpacityValueChangedHandler += colorPop_OpacityValueChangedHandler;
|
|
|
|
|
|
+ SlidOpacityPop = new SlidContentPop();
|
|
|
|
+ SlidOpacityPop.OpacityValueChangedHandler += colorPop_OpacityValueChangedHandler;
|
|
}
|
|
}
|
|
|
|
|
|
private void colorPop_OpacityValueChangedHandler(object sender, double e)
|
|
private void colorPop_OpacityValueChangedHandler(object sender, double e)
|
|
{
|
|
{
|
|
- SelectedValueChanged?.Invoke(this, e);
|
|
|
|
|
|
+ Value = (double)e;
|
|
|
|
+ SelectedValueChanged?.Invoke(this, null);
|
|
}
|
|
}
|
|
|
|
|
|
private void ColorDropBox_Unloaded(object sender, RoutedEventArgs e)
|
|
private void ColorDropBox_Unloaded(object sender, RoutedEventArgs e)
|
|
@@ -143,12 +89,11 @@ namespace PDF_Office.CustomControl.CompositeControl
|
|
AddToLayer(dependencyObject);
|
|
AddToLayer(dependencyObject);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void AddToLayer(DependencyObject dependencyObject = null)
|
|
private void AddToLayer(DependencyObject dependencyObject = null)
|
|
{
|
|
{
|
|
Window parentWnd = Window.GetWindow(this);
|
|
Window parentWnd = Window.GetWindow(this);
|
|
popLayer = AdornerLayer.GetAdornerLayer(parentWnd.Content as UIElement);
|
|
popLayer = AdornerLayer.GetAdornerLayer(parentWnd.Content as UIElement);
|
|
- if (popLayer != null && colorPop != null && !layerAdded)
|
|
|
|
|
|
+ if (popLayer != null && SlidOpacityPop != null && !layerAdded)
|
|
{
|
|
{
|
|
if (layerPresent == null)
|
|
if (layerPresent == null)
|
|
{
|
|
{
|
|
@@ -158,23 +103,21 @@ namespace PDF_Office.CustomControl.CompositeControl
|
|
if (popCanvas == null)
|
|
if (popCanvas == null)
|
|
{
|
|
{
|
|
popCanvas = new Canvas();
|
|
popCanvas = new Canvas();
|
|
- popCanvas.Children.Add(colorPop);
|
|
|
|
|
|
+ popCanvas.Children.Add(SlidOpacityPop);
|
|
layerPresent.VisualContent = popCanvas;
|
|
layerPresent.VisualContent = popCanvas;
|
|
-
|
|
|
|
- // colorPop.ColorSelected += ColorPop_ColorSelected;
|
|
|
|
}
|
|
}
|
|
Point offset = GetOffsetToWindow(dependencyObject);
|
|
Point offset = GetOffsetToWindow(dependencyObject);
|
|
- colorPop.Visibility = Visibility.Visible;
|
|
|
|
- colorPop.Measure(new Size(parentWnd.ActualWidth, parentWnd.ActualHeight));
|
|
|
|
- colorPop.SetValue(Canvas.TopProperty, offset.Y + this.ActualHeight + 2);
|
|
|
|
|
|
+ SlidOpacityPop.Visibility = Visibility.Visible;
|
|
|
|
+ SlidOpacityPop.Measure(new Size(parentWnd.ActualWidth, parentWnd.ActualHeight));
|
|
|
|
+ SlidOpacityPop.SetValue(Canvas.TopProperty, offset.Y + this.ActualHeight + 2);
|
|
|
|
|
|
- if (offset.X + colorPop.DesiredSize.Width + SystemParameters.ResizeFrameVerticalBorderWidth * 2 > parentWnd.ActualWidth)
|
|
|
|
|
|
+ if (offset.X + SlidOpacityPop.DesiredSize.Width + SystemParameters.ResizeFrameVerticalBorderWidth * 2 > parentWnd.ActualWidth)
|
|
{
|
|
{
|
|
- colorPop.SetValue(Canvas.LeftProperty, parentWnd.ActualWidth - colorPop.DesiredSize.Width - 5 - SystemParameters.ResizeFrameVerticalBorderWidth * 2);
|
|
|
|
|
|
+ SlidOpacityPop.SetValue(Canvas.LeftProperty, parentWnd.ActualWidth - SlidOpacityPop.DesiredSize.Width - 5 - SystemParameters.ResizeFrameVerticalBorderWidth * 2);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- colorPop.SetValue(Canvas.LeftProperty, offset.X);
|
|
|
|
|
|
+ SlidOpacityPop.SetValue(Canvas.LeftProperty, offset.X);
|
|
}
|
|
}
|
|
layerAdded = true;
|
|
layerAdded = true;
|
|
}
|
|
}
|
|
@@ -193,7 +136,7 @@ namespace PDF_Office.CustomControl.CompositeControl
|
|
if (popLayer == null)
|
|
if (popLayer == null)
|
|
{
|
|
{
|
|
Window parentWnd = Window.GetWindow(this);
|
|
Window parentWnd = Window.GetWindow(this);
|
|
- if (parentWnd != null && parentWnd.Content is UIElement && colorPop != null)
|
|
|
|
|
|
+ if (parentWnd != null && parentWnd.Content is UIElement && SlidOpacityPop != null)
|
|
{
|
|
{
|
|
parentWnd.AddHandler(MouseDownEvent, new MouseButtonEventHandler((eventsender, param) =>
|
|
parentWnd.AddHandler(MouseDownEvent, new MouseButtonEventHandler((eventsender, param) =>
|
|
{
|
|
{
|
|
@@ -205,14 +148,23 @@ namespace PDF_Office.CustomControl.CompositeControl
|
|
Point clickPoint = param.GetPosition(checkWindow);
|
|
Point clickPoint = param.GetPosition(checkWindow);
|
|
Point leftTop = TransformToVisual(checkWindow).Transform(new Point(0, 0));
|
|
Point leftTop = TransformToVisual(checkWindow).Transform(new Point(0, 0));
|
|
Point rightBottom = TransformToVisual(checkWindow).Transform(new Point(ActualWidth, ActualHeight));
|
|
Point rightBottom = TransformToVisual(checkWindow).Transform(new Point(ActualWidth, ActualHeight));
|
|
- Point popLeftTop = new Point(Canvas.GetLeft(colorPop), Canvas.GetTop(colorPop));
|
|
|
|
- Point popRightBottom = new Point(colorPop.ActualWidth, colorPop.ActualHeight);
|
|
|
|
|
|
+ Point popLeftTop = new Point(Canvas.GetLeft(SlidOpacityPop), Canvas.GetTop(SlidOpacityPop));
|
|
|
|
+ Point popRightBottom = new Point(SlidOpacityPop.ActualWidth, SlidOpacityPop.ActualHeight);
|
|
Rect dropboxRect = new Rect(leftTop.X, leftTop.Y, rightBottom.X - leftTop.X, rightBottom.Y - leftTop.Y);
|
|
Rect dropboxRect = new Rect(leftTop.X, leftTop.Y, rightBottom.X - leftTop.X, rightBottom.Y - leftTop.Y);
|
|
Rect popboxRect = new Rect(popLeftTop.X, popLeftTop.Y, popRightBottom.X, popRightBottom.Y);
|
|
Rect popboxRect = new Rect(popLeftTop.X, popLeftTop.Y, popRightBottom.X, popRightBottom.Y);
|
|
if (dropboxRect.Contains(clickPoint) || popboxRect.Contains(clickPoint))
|
|
if (dropboxRect.Contains(clickPoint) || popboxRect.Contains(clickPoint))
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //如果是有展开的UI,超过悬浮窗口,就判断点击的位置是否为展开的UI上;
|
|
|
|
+ //例如下拉框展开的选项列表UI超出悬浮窗口
|
|
|
|
+ if (SlidOpacityPop != null)
|
|
|
|
+ {
|
|
|
|
+ if (SlidOpacityPop.isOpenLayout)
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
RemoveFromLayer();
|
|
RemoveFromLayer();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -226,27 +178,6 @@ namespace PDF_Office.CustomControl.CompositeControl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void ColorPop_ColorSelected(object sender, Color e)
|
|
|
|
- {
|
|
|
|
- if (SelectedColor != e)
|
|
|
|
- {
|
|
|
|
- //NormalColorRectControl.Visibility = Visibility.Collapsed;
|
|
|
|
- //TransparentRectControl.Visibility = Visibility.Collapsed;
|
|
|
|
- //if (e != Colors.Transparent)
|
|
|
|
- //{
|
|
|
|
- // NormalColorRectControl.Visibility = Visibility.Visible;
|
|
|
|
- // NormalColorRectControl.Fill = new SolidColorBrush(e);
|
|
|
|
- //}
|
|
|
|
- //else
|
|
|
|
- //{
|
|
|
|
- // TransparentRectControl.Visibility = Visibility.Visible;
|
|
|
|
- //}
|
|
|
|
- SelectedColor = e;
|
|
|
|
- // SelectedValueChanged?.Invoke(this, SelectedColor);
|
|
|
|
- }
|
|
|
|
- RemoveFromLayer();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public Point GetOffsetToWindow(DependencyObject dependencyObject = null)
|
|
public Point GetOffsetToWindow(DependencyObject dependencyObject = null)
|
|
{
|
|
{
|
|
Window parentWnd = Window.GetWindow(this);
|
|
Window parentWnd = Window.GetWindow(this);
|
|
@@ -262,21 +193,9 @@ namespace PDF_Office.CustomControl.CompositeControl
|
|
return TransformToAncestor(parentWnd).Transform(new Point(0, 0));
|
|
return TransformToAncestor(parentWnd).Transform(new Point(0, 0));
|
|
}
|
|
}
|
|
|
|
|
|
- public void SetThemeColors(List<Color> themeColorList)
|
|
|
|
- {
|
|
|
|
- if (colorPop != null)
|
|
|
|
- {
|
|
|
|
- // colorPop.ThemeColors.Clear();
|
|
|
|
- //foreach (Color themeColor in themeColorList)
|
|
|
|
- //{
|
|
|
|
- // colorPop.ThemeColors.Add(themeColor);
|
|
|
|
- //}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public void SetSliOpacity(double newopacity)
|
|
public void SetSliOpacity(double newopacity)
|
|
{
|
|
{
|
|
- colorPop.OpacitySlider.Value = newopacity;
|
|
|
|
|
|
+ SlidOpacityPop.OpacitySlider.Value = newopacity;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|