diff --git a/AIStudio.Wpf.DiagramDesigner/Controls/BlockDragThumb.cs b/AIStudio.Wpf.DiagramDesigner/Controls/BlockDragThumb.cs new file mode 100644 index 0000000..56b1385 --- /dev/null +++ b/AIStudio.Wpf.DiagramDesigner/Controls/BlockDragThumb.cs @@ -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; + } + + } + + } +} diff --git a/AIStudio.Wpf.DiagramDesigner/Themes/DiagramControl.xaml b/AIStudio.Wpf.DiagramDesigner/Themes/DiagramControl.xaml index ed3ce7c..21fa8da 100644 --- a/AIStudio.Wpf.DiagramDesigner/Themes/DiagramControl.xaml +++ b/AIStudio.Wpf.DiagramDesigner/Themes/DiagramControl.xaml @@ -851,12 +851,12 @@ - - + - - + + diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs index 83070b6..515c455 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs @@ -423,9 +423,14 @@ namespace AIStudio.Wpf.DiagramDesigner } #region 执行 + protected override async void ExecuteEditCommand(object param) + { + await (this.GetFirst() ?? this).Execute(); + } + public async Task Execute() { - await BeforeExecute(); + await BeforeExecute(); await Executing(); await AfterExecute(); }