mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-04 08:06:36 +08:00
右键拖动画布
This commit is contained in:
@@ -188,10 +188,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public DesignerCanvas()
|
||||
{
|
||||
this.AllowDrop = true;
|
||||
this.Focusable = true;
|
||||
Mediator.Instance.Register(this);
|
||||
|
||||
_service.PropertyChanged += _service_PropertyChanged;
|
||||
this.Loaded += DesignerCanvas_Loaded;
|
||||
}
|
||||
|
||||
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext dc)
|
||||
@@ -322,9 +328,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (_viewModel.IsReadOnly) return;
|
||||
|
||||
this.Focus();
|
||||
|
||||
if (_service.DrawModeViewModel.CursorMode == CursorMode.Format)
|
||||
{
|
||||
var element = (e.OriginalSource as FrameworkElement);
|
||||
@@ -356,7 +365,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
_viewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
|
||||
}
|
||||
e.Handled = true;
|
||||
//e.Handled = true;
|
||||
|
||||
if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.ConnectingLineSmooth)
|
||||
{
|
||||
@@ -435,7 +444,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
}
|
||||
e.Handled = true;
|
||||
//e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
@@ -499,7 +508,33 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
sourceConnectorInfo = null;
|
||||
|
||||
_service.DrawModeViewModel.ResetDrawMode();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnPreviewKeyDown(e);
|
||||
|
||||
if (_viewModel.IsReadOnly) return;
|
||||
|
||||
e.Handled = _viewModel.ExecuteShortcut(e);
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseWheel(e);
|
||||
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
|
||||
&& Keyboard.IsKeyDown(Key.RightCtrl) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newZoomValue = _viewModel.ZoomValue + (e.Delta > 0 ? 0.1 : -0.1);
|
||||
|
||||
_viewModel.ZoomValue = Math.Max(Math.Min(newZoomValue, _viewModel.MaximumZoomValue), _viewModel.MinimumZoomValue);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size constraint)
|
||||
{
|
||||
@@ -555,7 +590,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.OnDrop(e);
|
||||
|
||||
if (_viewModel.IsReadOnly) return;
|
||||
if (_viewModel.IsReadOnly) return;
|
||||
|
||||
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
|
||||
if (dragObject != null)
|
||||
@@ -620,7 +655,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
_viewModel.AddItemCommand.Execute(itemBase);
|
||||
}
|
||||
}
|
||||
e.Handled = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo FindNearPortToAttachTo()
|
||||
|
||||
Reference in New Issue
Block a user