|
|
@@ -35,7 +35,6 @@ namespace YSAI.Unility.Windows
|
|
|
|
|
|
//by:Shunnet.top 2022/5/18
|
|
|
*/
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 控件拖动基类
|
|
|
/// </summary>
|
|
|
@@ -61,74 +60,60 @@ namespace YSAI.Unility.Windows
|
|
|
InitMove(); //初始化移动
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 容器边框颜色
|
|
|
/// </summary>
|
|
|
public SolidColorBrush BorderColor = new SolidColorBrush(Colors.Green);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 容器边框线径
|
|
|
/// </summary>
|
|
|
public Thickness BorderWireDiameter = new Thickness(1);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 容器边框透明度
|
|
|
/// </summary>
|
|
|
public double BorderOpacity = 0;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 拖拽装饰器的内圈颜色
|
|
|
/// </summary>
|
|
|
public SolidColorBrush ThumbInnerColor = new SolidColorBrush(Colors.Red);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 拖拽装饰器的外圈颜色
|
|
|
/// </summary>
|
|
|
public SolidColorBrush ThumbOuterColor = new SolidColorBrush(Colors.Red);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 装饰器线径
|
|
|
/// </summary>
|
|
|
public double ThumbWireDiameter = 1;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 装饰器透明度
|
|
|
/// </summary>
|
|
|
public double ThumbOpacity = 0.6;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 拖拽最小的宽
|
|
|
/// </summary>
|
|
|
public double MinWidths = 100;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 拖拽最小的高
|
|
|
/// </summary>
|
|
|
public double MinHeights = 100;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 拖拽最大的宽
|
|
|
/// </summary>
|
|
|
public double MaxWidths = 500;
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 拖拽最大的高
|
|
|
/// </summary>
|
|
|
public double MaxHeights = 500;
|
|
|
|
|
|
#region 私有字段
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 4条边
|
|
|
/// </summary>
|
|
|
- private Thumb LeftThumb, TopThumb, RightThumb, BottomThumb;
|
|
|
-
|
|
|
+ Thumb LeftThumb, TopThumb, RightThumb, BottomThumb;
|
|
|
/// <summary>
|
|
|
/// 4个角
|
|
|
/// </summary>
|
|
|
- private Thumb LefTopThumb, RightTopThumb, RightBottomThumb, LeftbottomThumb;
|
|
|
-
|
|
|
+ Thumb LefTopThumb, RightTopThumb, RightBottomThumb, LeftbottomThumb;
|
|
|
/// <summary>
|
|
|
/// 中间 目前暂不使用
|
|
|
/// </summary>
|
|
|
@@ -136,42 +121,35 @@ namespace YSAI.Unility.Windows
|
|
|
/// <summary>
|
|
|
/// 布局容器,如果不使用布局容器,则需要给上述8个控件布局,实现和Grid布局定位是一样的,会比较繁琐且意义不大。
|
|
|
/// </summary>
|
|
|
- private Grid Llayout;
|
|
|
+ Grid Llayout;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 要拖动的控件
|
|
|
/// </summary>
|
|
|
- private readonly UIElement Controls;
|
|
|
-
|
|
|
+ readonly UIElement Controls;
|
|
|
/// <summary>
|
|
|
/// 窗体的布局容器
|
|
|
/// </summary>
|
|
|
- private readonly FrameworkElement LlayoutContainer;
|
|
|
-
|
|
|
+ readonly FrameworkElement LlayoutContainer;
|
|
|
/// <summary>
|
|
|
/// 鼠标是否按下
|
|
|
/// </summary>
|
|
|
- private bool IsMouseDown = false;
|
|
|
-
|
|
|
+ bool IsMouseDown = false;
|
|
|
/// <summary>
|
|
|
/// 鼠标按下的位置
|
|
|
/// </summary>
|
|
|
- private Point MouseDownPosition;
|
|
|
-
|
|
|
+ Point MouseDownPosition;
|
|
|
/// <summary>
|
|
|
/// 鼠标按下控件的Margin
|
|
|
/// </summary>
|
|
|
- private Thickness MouseDownMargin;
|
|
|
-
|
|
|
- #endregion 私有字段
|
|
|
+ Thickness MouseDownMargin;
|
|
|
+ #endregion
|
|
|
|
|
|
#region 重写方法
|
|
|
-
|
|
|
protected override Visual GetVisualChild(int index)
|
|
|
{
|
|
|
return Llayout;
|
|
|
}
|
|
|
-
|
|
|
protected override int VisualChildrenCount
|
|
|
{
|
|
|
get
|
|
|
@@ -179,18 +157,15 @@ namespace YSAI.Unility.Windows
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
protected override Size ArrangeOverride(Size finalSize)
|
|
|
{
|
|
|
//直接给容器布局,容器内部的装饰器会自动布局。
|
|
|
Llayout?.Arrange(new Rect(new Point(-LeftThumb.Width / 2, -LeftThumb.Height / 2), new Size(finalSize.Width + LeftThumb.Width, finalSize.Height + LeftThumb.Height)));
|
|
|
return finalSize;
|
|
|
}
|
|
|
-
|
|
|
- #endregion 重写方法
|
|
|
+ #endregion
|
|
|
|
|
|
#region 方法
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 初始化拖拽大小
|
|
|
/// </summary>
|
|
|
@@ -288,7 +263,6 @@ namespace YSAI.Unility.Windows
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 装饰器样式
|
|
|
/// </summary>
|
|
|
@@ -297,7 +271,7 @@ namespace YSAI.Unility.Windows
|
|
|
/// <param name="WireDiameter">线径</param>
|
|
|
/// <param name="Opacity">透明度</param>
|
|
|
/// <returns></returns>
|
|
|
- private FrameworkElementFactory GetFactory(System.Windows.Media.Brush InnerColor, System.Windows.Media.Brush OuterColor, double WireDiameter)
|
|
|
+ FrameworkElementFactory GetFactory(System.Windows.Media.Brush InnerColor, System.Windows.Media.Brush OuterColor, double WireDiameter)
|
|
|
{
|
|
|
FrameworkElementFactory Element = new FrameworkElementFactory(typeof(Ellipse)); //绘制椭圆形元素
|
|
|
Element.SetValue(Ellipse.FillProperty, InnerColor); //内圈色
|
|
|
@@ -316,11 +290,9 @@ namespace YSAI.Unility.Windows
|
|
|
Controls.MouseLeftButtonUp += Control_MouseLeftButtonUp; //鼠标左键松开
|
|
|
Controls.MouseMove += Control_MouseMove; //鼠标移动
|
|
|
}
|
|
|
-
|
|
|
- #endregion 方法
|
|
|
+ #endregion
|
|
|
|
|
|
#region 事件
|
|
|
-
|
|
|
//拖拽大小逻辑
|
|
|
private void Control_DragDelta(object sender, DragDeltaEventArgs e)
|
|
|
{
|
|
|
@@ -385,7 +357,6 @@ namespace YSAI.Unility.Windows
|
|
|
MouseDownMargin = c.Margin;
|
|
|
c.CaptureMouse();
|
|
|
}
|
|
|
-
|
|
|
//鼠标左键松开
|
|
|
private void Control_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
@@ -393,7 +364,6 @@ namespace YSAI.Unility.Windows
|
|
|
IsMouseDown = false;
|
|
|
c.ReleaseMouseCapture();
|
|
|
}
|
|
|
-
|
|
|
//鼠标移动
|
|
|
private void Control_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
|
|
{
|
|
|
@@ -418,10 +388,8 @@ namespace YSAI.Unility.Windows
|
|
|
//double ControlBottom = point.Y + c.Height; //下
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- #endregion 事件
|
|
|
+ #endregion
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 控件拖动实现类
|
|
|
/// </summary>
|
|
|
@@ -433,8 +401,7 @@ namespace YSAI.Unility.Windows
|
|
|
/// AdornerLayer:装饰器
|
|
|
/// DragControlsBase:装饰器实现类
|
|
|
/// </summary>
|
|
|
- private readonly Dictionary<UIElement, Tuple<AdornerLayer, DragControlsBase>> DictionaryDataList = new Dictionary<UIElement, Tuple<AdornerLayer, DragControlsBase>>();
|
|
|
-
|
|
|
+ readonly Dictionary<UIElement, Tuple<AdornerLayer, DragControlsBase>> DictionaryDataList = new Dictionary<UIElement, Tuple<AdornerLayer, DragControlsBase>>();
|
|
|
/// <summary>
|
|
|
/// 添加项
|
|
|
/// </summary>
|
|
|
@@ -463,7 +430,6 @@ namespace YSAI.Unility.Windows
|
|
|
}
|
|
|
return Message;
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移除拖动
|
|
|
/// </summary>
|
|
|
@@ -476,7 +442,6 @@ namespace YSAI.Unility.Windows
|
|
|
Delete(Controls); //在集合移除此项
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 删除此项
|
|
|
/// </summary>
|
|
|
@@ -495,10 +460,9 @@ namespace YSAI.Unility.Windows
|
|
|
*/
|
|
|
|
|
|
#region 后端代码
|
|
|
-
|
|
|
/*
|
|
|
/// <summary>
|
|
|
- /// 三合一
|
|
|
+ /// 三合一
|
|
|
/// 单个窗体中只能定义一个布局容器,这个布局容器,不能设置Margin,不能设置固定宽高
|
|
|
/// </summary>
|
|
|
DragControlsAnimate dragControlsAnimate;
|
|
|
@@ -537,7 +501,6 @@ namespace YSAI.Unility.Windows
|
|
|
IsMove = false;
|
|
|
IsDragSize =false;
|
|
|
break;
|
|
|
-
|
|
|
case "ConShow2":
|
|
|
NewControl = InitControls(1);
|
|
|
IsMove = true;
|
|
|
@@ -552,14 +515,12 @@ namespace YSAI.Unility.Windows
|
|
|
/// <param name="dashboardDataMode">图标类型</param>
|
|
|
private Label InitControls(int A)
|
|
|
{
|
|
|
- return new Label() { Background = new SolidColorBrush(A == 0 ? Colors.AliceBlue : Colors.AntiqueWhite), Width = 100, Height = 100,Content= "自定义控件" };
|
|
|
+ return new Label() { Background = new SolidColorBrush(A == 0 ? Colors.AliceBlue : Colors.AntiqueWhite), Width = 100, Height = 100,Content= "自定义控件" };
|
|
|
}
|
|
|
*/
|
|
|
-
|
|
|
- #endregion 后端代码
|
|
|
+ #endregion
|
|
|
|
|
|
#region 前端代码
|
|
|
-
|
|
|
/*
|
|
|
<Window x:Class="WpfApp5.MainWindow"
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
@@ -580,8 +541,7 @@ namespace YSAI.Unility.Windows
|
|
|
</Window>
|
|
|
|
|
|
*/
|
|
|
-
|
|
|
- #endregion 前端代码
|
|
|
+ #endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 拖拽控件动画 控件在拖动过程中显示,拖动完成也显示在拖动结束的位置
|
|
|
@@ -603,55 +563,45 @@ namespace YSAI.Unility.Windows
|
|
|
this.LlayoutContainer = LlayoutContainer;
|
|
|
Windows.SizeChanged += Windwos_SizeChanged;
|
|
|
}
|
|
|
-
|
|
|
#region 私有字段
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 高度偏移
|
|
|
/// 拖动过度时,已经显示了要拖动的控件[半透明状态],鼠标默认是在中心位置,由于窗体样式原因,导致不在中心点位置,所以加上了偏移
|
|
|
/// </summary>
|
|
|
- private double HeightOffset { get; set; }
|
|
|
-
|
|
|
+ double HeightOffset { get; set; }
|
|
|
/// <summary>
|
|
|
/// 宽度偏移
|
|
|
/// 拖动过度时,已经显示了要拖动的控件[半透明状态],鼠标默认是在中心位置,由于窗体样式原因,导致不在中心点位置,所以加上了偏移
|
|
|
/// </summary>
|
|
|
- private double WidthOffset { get; set; }
|
|
|
-
|
|
|
+ double WidthOffset { get; set; }
|
|
|
/// <summary>
|
|
|
/// 界面上已经生成的控件,也就是从哪个控件上拖动的集合
|
|
|
/// </summary>
|
|
|
- private readonly List<FrameworkElement> ShowControlsList = new List<FrameworkElement>();
|
|
|
-
|
|
|
+ readonly List<FrameworkElement> ShowControlsList = new List<FrameworkElement>();
|
|
|
/// <summary>
|
|
|
/// 窗体
|
|
|
/// </summary>
|
|
|
- private readonly FrameworkElement Windows;
|
|
|
-
|
|
|
+ readonly FrameworkElement Windows;
|
|
|
/// <summary>
|
|
|
/// 容器:让控件在这里面拖动
|
|
|
/// </summary>
|
|
|
- private readonly object LlayoutContainer;
|
|
|
-
|
|
|
+ readonly object LlayoutContainer;
|
|
|
/// <summary>
|
|
|
/// 鼠标是否按下
|
|
|
/// </summary>
|
|
|
- private bool IsMouseDown = false;
|
|
|
-
|
|
|
+ bool IsMouseDown = false;
|
|
|
/// <summary>
|
|
|
/// 实时需要拖动的控件
|
|
|
/// </summary>
|
|
|
- private FrameworkElement ControlsObj;
|
|
|
-
|
|
|
+ FrameworkElement ControlsObj;
|
|
|
/// <summary>
|
|
|
/// 拖拽大小与移动
|
|
|
/// </summary>
|
|
|
- private readonly DragControlsHelper dragControlsHelper = new DragControlsHelper();
|
|
|
+ readonly DragControlsHelper dragControlsHelper = new DragControlsHelper();
|
|
|
|
|
|
- #endregion 私有字段
|
|
|
+ #endregion
|
|
|
|
|
|
#region 方法
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 动态修改偏移量
|
|
|
/// </summary>
|
|
|
@@ -684,7 +634,6 @@ namespace YSAI.Unility.Windows
|
|
|
//创建拖动与拖拽大小
|
|
|
dragControlsHelper.Remove(Controls);
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 添加需要拖动的组件
|
|
|
/// </summary>
|
|
|
@@ -697,7 +646,6 @@ namespace YSAI.Unility.Windows
|
|
|
ShowControlsList.Add(ControlsShow);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移除拖动
|
|
|
/// </summary>
|
|
|
@@ -710,7 +658,6 @@ namespace YSAI.Unility.Windows
|
|
|
ShowControlsList.Remove(ControlsShow); //直接移除
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 创建事件
|
|
|
/// </summary>
|
|
|
@@ -725,7 +672,6 @@ namespace YSAI.Unility.Windows
|
|
|
ControlsShow.PreviewMouseLeftButtonUp += ControlsShow_PreviewMouseLeftButtonUp;
|
|
|
ControlsShow.PreviewMouseMove += ControlsShow_PreviewMouseMove;
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移除事件
|
|
|
/// </summary>
|
|
|
@@ -737,7 +683,7 @@ namespace YSAI.Unility.Windows
|
|
|
ControlsShow.PreviewMouseMove -= ControlsShow_PreviewMouseMove;
|
|
|
}
|
|
|
|
|
|
- #endregion 方法
|
|
|
+ #endregion
|
|
|
|
|
|
#region 委托回调事件
|
|
|
|
|
|
@@ -747,7 +693,6 @@ namespace YSAI.Unility.Windows
|
|
|
/// <param name="ShowControl">在哪个控件上触发了拖拽</param>
|
|
|
/// <returns>返回已经创建了新的控件对象 - 是否需要移动 - 是否需要拖拽大小</returns>
|
|
|
public delegate (FrameworkElement NewControl, bool IsMove, bool IsDragSize) dragEvenTrigger(FrameworkElement ShowControl);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 实现委托
|
|
|
/// </summary>
|
|
|
@@ -759,13 +704,11 @@ namespace YSAI.Unility.Windows
|
|
|
/// <param name="Message">消息</param>
|
|
|
/// <param name="element">哪个控件显示的消息</param>
|
|
|
public delegate void messageEvenTrigger(string Message, FrameworkElement element);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 实现委托
|
|
|
/// </summary>
|
|
|
public messageEvenTrigger MessageEvenTrigger;
|
|
|
-
|
|
|
- #endregion 委托回调事件
|
|
|
+ #endregion
|
|
|
|
|
|
#region 执行事件
|
|
|
|
|
|
@@ -802,6 +745,7 @@ namespace YSAI.Unility.Windows
|
|
|
ControlsObj = null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//当在已显示的控件左键点击后
|
|
|
private void ControlsShow_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
@@ -843,8 +787,10 @@ namespace YSAI.Unility.Windows
|
|
|
double Right = Windows.ActualWidth - Left - ControlsObj.Width;
|
|
|
double Bottom = Windows.ActualHeight - Top - ControlsObj.Height;
|
|
|
|
|
|
+
|
|
|
ControlsObj.Margin = new Thickness(Left, Top, Right, Bottom);
|
|
|
|
|
|
+
|
|
|
layout.Children.Add(ControlsObj);
|
|
|
//添加拖拽大小与移动
|
|
|
MessageEvenTrigger(MoveAndDragSizeInsert(ControlsObj, Windows, IsMove, IsDragSize), sender as FrameworkElement);
|
|
|
@@ -857,6 +803,7 @@ namespace YSAI.Unility.Windows
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//当窗体大小改变,布局容器也要跟着改变大小
|
|
|
private void Windwos_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
{
|
|
|
@@ -874,10 +821,11 @@ namespace YSAI.Unility.Windows
|
|
|
layout.Height = window.ActualHeight;
|
|
|
}
|
|
|
}
|
|
|
+ #endregion
|
|
|
|
|
|
- #endregion 执行事件
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 拖拽控件过度动画 使用一个特效控件,在拖动过程中显示,拖动完成隐藏清空 2022.09.15
|
|
|
/// </summary>
|
|
|
@@ -898,55 +846,44 @@ namespace YSAI.Unility.Windows
|
|
|
this.LlayoutContainer = LlayoutContainer;
|
|
|
Windows.SizeChanged += Windwos_SizeChanged;
|
|
|
}
|
|
|
-
|
|
|
#region 私有字段
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 高度偏移
|
|
|
/// 拖动过度时,已经显示了要拖动的控件[半透明状态],鼠标默认是在中心位置,由于窗体样式原因,导致不在中心点位置,所以加上了偏移
|
|
|
/// </summary>
|
|
|
- private double HeightOffset { get; set; }
|
|
|
-
|
|
|
+ double HeightOffset { get; set; }
|
|
|
/// <summary>
|
|
|
/// 宽度偏移
|
|
|
/// 拖动过度时,已经显示了要拖动的控件[半透明状态],鼠标默认是在中心位置,由于窗体样式原因,导致不在中心点位置,所以加上了偏移
|
|
|
/// </summary>
|
|
|
- private double WidthOffset { get; set; }
|
|
|
-
|
|
|
+ double WidthOffset { get; set; }
|
|
|
/// <summary>
|
|
|
/// 界面上已经生成的控件,也就是从哪个控件上拖动的集合
|
|
|
/// </summary>
|
|
|
- private readonly List<FrameworkElement> ShowControlsList = new List<FrameworkElement>();
|
|
|
-
|
|
|
+ readonly List<FrameworkElement> ShowControlsList = new List<FrameworkElement>();
|
|
|
/// <summary>
|
|
|
/// 窗体
|
|
|
/// </summary>
|
|
|
- private readonly FrameworkElement Windows;
|
|
|
-
|
|
|
+ readonly FrameworkElement Windows;
|
|
|
/// <summary>
|
|
|
/// 容器:让控件在这里面拖动
|
|
|
/// </summary>
|
|
|
- private readonly object LlayoutContainer;
|
|
|
-
|
|
|
+ readonly object LlayoutContainer;
|
|
|
/// <summary>
|
|
|
/// 鼠标是否按下
|
|
|
/// </summary>
|
|
|
- private bool IsMouseDown = false;
|
|
|
-
|
|
|
+ bool IsMouseDown = false;
|
|
|
/// <summary>
|
|
|
/// 实时需要拖动的控件
|
|
|
/// </summary>
|
|
|
- private FrameworkElement ControlsObj;
|
|
|
-
|
|
|
+ FrameworkElement ControlsObj;
|
|
|
/// <summary>
|
|
|
/// 拖拽大小与移动
|
|
|
/// </summary>
|
|
|
- private readonly DragControlsHelper dragControlsHelper = new DragControlsHelper();
|
|
|
-
|
|
|
- #endregion 私有字段
|
|
|
+ readonly DragControlsHelper dragControlsHelper = new DragControlsHelper();
|
|
|
+ #endregion
|
|
|
|
|
|
#region 方法
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 动态修改偏移量
|
|
|
/// </summary>
|
|
|
@@ -957,7 +894,6 @@ namespace YSAI.Unility.Windows
|
|
|
this.HeightOffset = HeightOffset;
|
|
|
this.WidthOffset = WidthOffset;
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移动与拖拽大小添加
|
|
|
/// </summary>
|
|
|
@@ -979,7 +915,6 @@ namespace YSAI.Unility.Windows
|
|
|
//创建拖动与拖拽大小
|
|
|
dragControlsHelper.Remove(Controls);
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 添加需要拖动的组件
|
|
|
/// </summary>
|
|
|
@@ -992,7 +927,6 @@ namespace YSAI.Unility.Windows
|
|
|
ShowControlsList.Add(ControlsShow);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移除拖动
|
|
|
/// </summary>
|
|
|
@@ -1005,7 +939,6 @@ namespace YSAI.Unility.Windows
|
|
|
ShowControlsList.Remove(ControlsShow); //直接移除
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 创建事件
|
|
|
/// </summary>
|
|
|
@@ -1020,7 +953,6 @@ namespace YSAI.Unility.Windows
|
|
|
ControlsShow.PreviewMouseLeftButtonUp += ControlsShow_PreviewMouseLeftButtonUp;
|
|
|
ControlsShow.PreviewMouseMove += ControlsShow_PreviewMouseMove;
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移除事件
|
|
|
/// </summary>
|
|
|
@@ -1032,7 +964,7 @@ namespace YSAI.Unility.Windows
|
|
|
ControlsShow.PreviewMouseMove -= ControlsShow_PreviewMouseMove;
|
|
|
}
|
|
|
|
|
|
- #endregion 方法
|
|
|
+ #endregion
|
|
|
|
|
|
#region 委托回调事件
|
|
|
|
|
|
@@ -1042,7 +974,6 @@ namespace YSAI.Unility.Windows
|
|
|
/// <param name="ShowControl">在哪个控件上触发了拖拽</param>
|
|
|
/// <returns>返回已经创建了新的控件对象 - 是否需要移动 - 是否需要拖拽大小</returns>
|
|
|
public delegate (FrameworkElement NewControl, bool IsMove, bool IsDragSize) dragEvenTrigger(FrameworkElement ShowControl);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 实现委托
|
|
|
/// </summary>
|
|
|
@@ -1057,12 +988,10 @@ namespace YSAI.Unility.Windows
|
|
|
/// 按下
|
|
|
/// </summary>
|
|
|
Down,
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 松开
|
|
|
/// </summary>
|
|
|
Up,
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 移动
|
|
|
/// </summary>
|
|
|
@@ -1073,13 +1002,11 @@ namespace YSAI.Unility.Windows
|
|
|
/// 动作事件 告诉外部,按钮目前的状态
|
|
|
/// </summary>
|
|
|
public delegate void actionEvenTrigger(ButtonState state, Button obj);
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 实现委托
|
|
|
/// </summary>
|
|
|
public actionEvenTrigger ActionEvenTrigger;
|
|
|
-
|
|
|
- #endregion 委托回调事件
|
|
|
+ #endregion
|
|
|
|
|
|
#region 执行事件
|
|
|
|
|
|
@@ -1118,12 +1045,13 @@ namespace YSAI.Unility.Windows
|
|
|
ActionEvenTrigger(ButtonState.Up, sender as Button);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//当在已显示的控件左键点击后
|
|
|
private void ControlsShow_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
if (LlayoutContainer.GetType().Equals(typeof(Canvas)))
|
|
|
{
|
|
|
- Canvas layout = LlayoutContainer as Canvas;
|
|
|
+ Canvas? layout = LlayoutContainer as Canvas;
|
|
|
(FrameworkElement element, bool IsMove, bool IsDragSize) = DragEvenTrigger(sender as FrameworkElement);
|
|
|
ControlsObj = element;
|
|
|
if (!layout.Children.Contains(ControlsObj))
|
|
|
@@ -1138,7 +1066,7 @@ namespace YSAI.Unility.Windows
|
|
|
}
|
|
|
else if (LlayoutContainer.GetType().Equals(typeof(Grid)))
|
|
|
{
|
|
|
- Grid layout = LlayoutContainer as Grid;
|
|
|
+ Grid? layout = LlayoutContainer as Grid;
|
|
|
(FrameworkElement element, bool IsMove, bool IsDragSize) = DragEvenTrigger(sender as FrameworkElement);
|
|
|
ControlsObj = element;
|
|
|
if (!layout.Children.Contains(ControlsObj))
|
|
|
@@ -1158,13 +1086,14 @@ namespace YSAI.Unility.Windows
|
|
|
ActionEvenTrigger(ButtonState.Down, sender as Button);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//当窗体大小改变,布局容器也要跟着改变大小
|
|
|
private void Windwos_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
{
|
|
|
- FrameworkElement window = sender as FrameworkElement;
|
|
|
+ FrameworkElement? window = sender as FrameworkElement;
|
|
|
if (LlayoutContainer.GetType().Equals(typeof(Canvas)))
|
|
|
{
|
|
|
- Canvas layout = LlayoutContainer as Canvas;
|
|
|
+ Canvas? layout = LlayoutContainer as Canvas;
|
|
|
layout.Width = window.ActualWidth;
|
|
|
layout.Height = window.ActualHeight;
|
|
|
}
|
|
|
@@ -1176,14 +1105,15 @@ namespace YSAI.Unility.Windows
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 控件消失
|
|
|
/// </summary>
|
|
|
/// <param name="element">控件对象</param>
|
|
|
- private void ControlsVanish(object element)
|
|
|
+ void ControlsVanish(object element)
|
|
|
{
|
|
|
- FrameworkElement fe = element as FrameworkElement;
|
|
|
- double opacity = 1;//记录当前窗体的透明度
|
|
|
+ FrameworkElement? fe = element as FrameworkElement;
|
|
|
+ double opacity = 1;//记录当前窗体的透明度
|
|
|
while (true)
|
|
|
{
|
|
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
|
|
@@ -1195,7 +1125,7 @@ namespace YSAI.Unility.Windows
|
|
|
{
|
|
|
if (LlayoutContainer.GetType().Equals(typeof(Canvas)))
|
|
|
{
|
|
|
- Canvas layout = LlayoutContainer as Canvas;
|
|
|
+ Canvas? layout = LlayoutContainer as Canvas;
|
|
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
|
|
{
|
|
|
layout.Children.Remove(fe);
|
|
|
@@ -1203,7 +1133,7 @@ namespace YSAI.Unility.Windows
|
|
|
}
|
|
|
else if (LlayoutContainer.GetType().Equals(typeof(Grid)))
|
|
|
{
|
|
|
- Grid layout = LlayoutContainer as Grid;
|
|
|
+ Grid? layout = LlayoutContainer as Grid;
|
|
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
|
|
{
|
|
|
layout.Children.Remove(fe);
|
|
|
@@ -1214,7 +1144,7 @@ namespace YSAI.Unility.Windows
|
|
|
Thread.Sleep(1);
|
|
|
}
|
|
|
}
|
|
|
+ #endregion
|
|
|
|
|
|
- #endregion 执行事件
|
|
|
}
|
|
|
}
|