mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
block
This commit is contained in:
48
AIStudio.Wpf.DiagramDesigner/Controls/BlockDragThumb.cs
Normal file
48
AIStudio.Wpf.DiagramDesigner/Controls/BlockDragThumb.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
{
|
||||
public class BlockDragThumb : DragThumb
|
||||
{
|
||||
BlockDesignerItemViewModel DesignerItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataContext as BlockDesignerItemViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
private Point? firstPoint;
|
||||
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseLeftButtonDown(e);
|
||||
if (e.LeftButton == MouseButtonState.Pressed && firstPoint == null)
|
||||
{
|
||||
firstPoint = e.GetPosition(this);
|
||||
DesignerItem.BeforeExecute();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseLeftButtonDown(e);
|
||||
|
||||
if (firstPoint == e.GetPosition(this))
|
||||
{
|
||||
DesignerItem.EditCommand?.Execute(e.GetPosition(this));
|
||||
firstPoint = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -851,12 +851,12 @@
|
||||
</Grid.ContextMenu>
|
||||
|
||||
<!-- PART_DragThumb -->
|
||||
<c:DragThumb x:Name="PART_DragThumb"
|
||||
<c:BlockDragThumb x:Name="PART_DragThumb"
|
||||
Cursor="SizeAll" >
|
||||
<c:DragThumb.InputBindings>
|
||||
<c:BlockDragThumb.InputBindings>
|
||||
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditCommand}" CommandParameter="{Binding }" />
|
||||
</c:DragThumb.InputBindings>
|
||||
</c:DragThumb>
|
||||
</c:BlockDragThumb.InputBindings>
|
||||
</c:BlockDragThumb>
|
||||
|
||||
<Grid RenderTransformOrigin="0.5,0.5" >
|
||||
<!-- PART_ContentPresenter -->
|
||||
|
||||
@@ -423,6 +423,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
#region 执行
|
||||
protected override async void ExecuteEditCommand(object param)
|
||||
{
|
||||
await (this.GetFirst() ?? this).Execute();
|
||||
}
|
||||
|
||||
public async Task Execute()
|
||||
{
|
||||
await BeforeExecute();
|
||||
|
||||
Reference in New Issue
Block a user