mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-14 13:16:38 +08:00
offset修复一半
This commit is contained in:
@@ -29,7 +29,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
private bool drag;
|
||||
private void DragThumb_DragStarted(object sender, DragStartedEventArgs e)
|
||||
{
|
||||
GetDesignerCanvas(this)?.Focus();
|
||||
GetDesignerCanvas(this)?.Focus();
|
||||
|
||||
drag = false;
|
||||
SelectableDesignerItemViewModelBase designerItem = this.DataContext as SelectableDesignerItemViewModelBase;
|
||||
@@ -61,7 +61,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
|
||||
DiagramViewModel.DoCommandManager.BeginDo = true;
|
||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
{
|
||||
item.SetOldValue(item.TopLeft, nameof(item.TopLeft));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,11 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
|
||||
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
if (drag == false) return;
|
||||
if (drag == false)
|
||||
{
|
||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (designerItems != null)
|
||||
{
|
||||
@@ -84,9 +88,9 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
item.SetCellAlignment();
|
||||
}
|
||||
|
||||
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||
p => new Tuple<PointBase, PointBase>(p.GetOldValue< PointBase >(nameof(p.TopLeft)), p.TopLeft));
|
||||
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
|
||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
||||
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
@@ -110,23 +114,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
drag = true;
|
||||
if (designerItems != null)
|
||||
{
|
||||
double minLeft = double.MaxValue;
|
||||
double minTop = double.MaxValue;
|
||||
|
||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
double left = item.Left;
|
||||
double top = item.Top;
|
||||
minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
|
||||
minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
|
||||
|
||||
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
|
||||
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
|
||||
item.Left += deltaHorizontal;
|
||||
item.Top += deltaVertical;
|
||||
item.Left += e.HorizontalChange;
|
||||
item.Top += e.VerticalChange;
|
||||
}
|
||||
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user