mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-03 06:21:30 +08:00
offset修复一半
This commit is contained in:
@@ -29,7 +29,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
private bool drag;
|
private bool drag;
|
||||||
private void DragThumb_DragStarted(object sender, DragStartedEventArgs e)
|
private void DragThumb_DragStarted(object sender, DragStartedEventArgs e)
|
||||||
{
|
{
|
||||||
GetDesignerCanvas(this)?.Focus();
|
GetDesignerCanvas(this)?.Focus();
|
||||||
|
|
||||||
drag = false;
|
drag = false;
|
||||||
SelectableDesignerItemViewModelBase designerItem = this.DataContext as SelectableDesignerItemViewModelBase;
|
SelectableDesignerItemViewModelBase designerItem = this.DataContext as SelectableDesignerItemViewModelBase;
|
||||||
@@ -61,7 +61,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
|
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = true;
|
DiagramViewModel.DoCommandManager.BeginDo = true;
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
item.SetOldValue(item.TopLeft, nameof(item.TopLeft));
|
item.SetOldValue(item.TopLeft, nameof(item.TopLeft));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,11 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
|
|
||||||
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
|
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
if (drag == false) return;
|
if (drag == false)
|
||||||
|
{
|
||||||
|
DiagramViewModel.DoCommandManager.BeginDo = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (designerItems != null)
|
if (designerItems != null)
|
||||||
{
|
{
|
||||||
@@ -84,9 +88,9 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
item.SetCellAlignment();
|
item.SetCellAlignment();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
||||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||||
p => new Tuple<PointBase, PointBase>(p.GetOldValue< PointBase >(nameof(p.TopLeft)), p.TopLeft));
|
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
DiagramViewModel.DoCommandManager.BeginDo = false;
|
||||||
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
@@ -110,23 +114,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
drag = true;
|
drag = true;
|
||||||
if (designerItems != null)
|
if (designerItems != null)
|
||||||
{
|
{
|
||||||
double minLeft = double.MaxValue;
|
|
||||||
double minTop = double.MaxValue;
|
|
||||||
|
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
double left = item.Left;
|
item.Left += e.HorizontalChange;
|
||||||
double top = item.Top;
|
item.Top += e.VerticalChange;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,10 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SelectableDesignerItemViewModelBase> designerItems;
|
private List<SelectableDesignerItemViewModelBase> designerItems;
|
||||||
IDiagramViewModel diagarmViewModel;
|
|
||||||
|
|
||||||
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
|
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
|
||||||
{
|
{
|
||||||
DesignerItemViewModelBase designerItem = this.DataContext as DesignerItemViewModelBase;
|
DesignerItemViewModelBase designerItem = this.DataContext as DesignerItemViewModelBase;
|
||||||
diagarmViewModel = designerItem.Root;
|
|
||||||
if (designerItem != null && designerItem.IsSelected)
|
if (designerItem != null && designerItem.IsSelected)
|
||||||
{
|
{
|
||||||
designerItems = designerItem.Root.SelectedItems.ToList();
|
designerItems = designerItem.Root.SelectedItems.ToList();
|
||||||
@@ -55,14 +53,10 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
{
|
{
|
||||||
if (designerItems != null)
|
if (designerItems != null)
|
||||||
{
|
{
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<DesignerItemViewModelBase, Tuple<SizeBase, SizeBase>> infos =
|
Dictionary<DesignerItemViewModelBase, Tuple<SizeBase, SizeBase>> infos =
|
||||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||||
p => new Tuple<SizeBase, SizeBase>(p.GetOldValue<SizeBase>(nameof(p.Size)), p.Size));
|
p => new Tuple<SizeBase, SizeBase>(p.GetOldValue<SizeBase>(nameof(p.Size)), p.Size));
|
||||||
|
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
DiagramViewModel.DoCommandManager.BeginDo = false;
|
||||||
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
@@ -101,13 +95,13 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
case VerticalAlignment.Bottom:
|
case VerticalAlignment.Bottom:
|
||||||
dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
|
dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
|
||||||
scale = (item.ItemHeight - dragDeltaVertical) / item.ItemHeight;
|
scale = (item.ItemHeight - dragDeltaVertical) / item.ItemHeight;
|
||||||
DragBottom(scale, item, diagarmViewModel.SelectionService);
|
DragBottom(scale, item, DiagramViewModel.SelectionService);
|
||||||
break;
|
break;
|
||||||
case VerticalAlignment.Top:
|
case VerticalAlignment.Top:
|
||||||
double top = item.Top;
|
double top = item.Top;
|
||||||
dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
|
dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
|
||||||
scale = (item.ItemHeight - dragDeltaVertical) / item.ItemHeight;
|
scale = (item.ItemHeight - dragDeltaVertical) / item.ItemHeight;
|
||||||
DragTop(scale, item, diagarmViewModel.SelectionService);
|
DragTop(scale, item, DiagramViewModel.SelectionService);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -119,12 +113,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
double left = item.Left;
|
double left = item.Left;
|
||||||
dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
|
dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
|
||||||
scale = (item.ItemWidth - dragDeltaHorizontal) / item.ItemWidth;
|
scale = (item.ItemWidth - dragDeltaHorizontal) / item.ItemWidth;
|
||||||
DragLeft(scale, item, diagarmViewModel.SelectionService);
|
DragLeft(scale, item, DiagramViewModel.SelectionService);
|
||||||
break;
|
break;
|
||||||
case HorizontalAlignment.Right:
|
case HorizontalAlignment.Right:
|
||||||
dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
|
dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
|
||||||
scale = (item.ItemWidth - dragDeltaHorizontal) / item.ItemWidth;
|
scale = (item.ItemWidth - dragDeltaHorizontal) / item.ItemWidth;
|
||||||
DragRight(scale, item, diagarmViewModel.SelectionService);
|
DragRight(scale, item, DiagramViewModel.SelectionService);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -75,11 +75,6 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
|
|
||||||
if (this.designerItems != null)
|
if (this.designerItems != null)
|
||||||
{
|
{
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<DesignerItemViewModelBase, Tuple<double, double>> infos =
|
Dictionary<DesignerItemViewModelBase, Tuple<double, double>> infos =
|
||||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||||
p => new Tuple<double, double>(p.GetOldValue<double>(nameof(p.Angle)), p.Angle));
|
p => new Tuple<double, double>(p.GetOldValue<double>(nameof(p.Angle)), p.Angle));
|
||||||
|
|||||||
@@ -66,9 +66,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
UnDoActionStack = new Stack<Command>();
|
UnDoActionStack = new Stack<Command>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _beginDo;
|
||||||
public bool BeginDo
|
public bool BeginDo
|
||||||
{
|
{
|
||||||
get;set;
|
get
|
||||||
|
{
|
||||||
|
return _beginDo;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_beginDo = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _undoing;
|
private bool _undoing;
|
||||||
@@ -76,7 +84,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (BeginDo == true)
|
if (BeginDo == true)
|
||||||
return;
|
return;
|
||||||
if (_undoing == true)
|
if (_undoing == true)
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -111,7 +119,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
if (!CanUnDo)
|
if (!CanUnDo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_undoing == true)
|
if (_undoing == true)
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,13 +102,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
if (mindNode == null) return;
|
if (mindNode == null) return;
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||||
var size = MeasureOverride(mindNode);
|
var size = MeasureOverride(mindNode);
|
||||||
ArrangeOverride(mindNode);
|
ArrangeOverride(mindNode);
|
||||||
|
|
||||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +144,11 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.DesiredSize.Width / 2 - child.ItemWidth / 2 + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left + child.DesiredSize.Width / 2 - child.ItemWidth / 2, top + child.Spacing.Height);
|
child.DesiredPosition = new PointBase(left + child.DesiredSize.Width / 2 - child.ItemWidth / 2, top + child.Spacing.Height);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
|
|
||||||
left += child.DesiredSize.Width;
|
left += child.DesiredSize.Width;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -159,18 +161,20 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
mindNode.DesiredPosition = mindNode.Position;
|
mindNode.DesiredPosition = mindNode.Position;
|
||||||
|
mindNode.Offset = new PointBase();//修正后归0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double left = mindNode.MiddlePosition.X;
|
double left = mindNode.DesiredMiddlePosition.X;
|
||||||
double top = mindNode.MiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
double top = mindNode.DesiredMiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
top += child.DesiredSize.Height;
|
top += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
if (mindNode == null) return;
|
if (mindNode == null) return;
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||||
|
|
||||||
switch (mindNode.NodeLevel)
|
switch (mindNode.NodeLevel)
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||||
@@ -129,13 +129,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
if (mindNode == null) return;
|
if (mindNode == null) return;
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||||
var size = MeasureOverride(mindNode);
|
var size = MeasureOverride(mindNode);
|
||||||
ArrangeOverride(mindNode);
|
ArrangeOverride(mindNode);
|
||||||
|
|
||||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||||
@@ -184,9 +184,10 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
foreach (var child in tops)
|
foreach (var child in tops)
|
||||||
{
|
{
|
||||||
child.Left = topleft + child.Spacing.Width + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = toptop - child.ItemHeight - child.Spacing.Height + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(topleft + child.Spacing.Width, toptop - child.ItemHeight - child.Spacing.Height);
|
child.DesiredPosition = new PointBase(topleft + child.Spacing.Width, toptop - child.ItemHeight - child.Spacing.Height);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
topleft += child.DesiredSize.Width;
|
topleft += child.DesiredSize.Width;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -207,9 +208,10 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
foreach (var child in bottoms)
|
foreach (var child in bottoms)
|
||||||
{
|
{
|
||||||
child.Left = bottomleft + child.Spacing.Width + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = bottomtop + child.Spacing.Height + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(bottomleft + child.Spacing.Width, bottomtop + child.Spacing.Height);
|
child.DesiredPosition = new PointBase(bottomleft + child.Spacing.Width, bottomtop + child.Spacing.Height);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
bottomleft += child.DesiredSize.Width;
|
bottomleft += child.DesiredSize.Width;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -222,21 +224,23 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
mindNode.DesiredPosition = mindNode.Position;
|
mindNode.DesiredPosition = mindNode.Position;
|
||||||
|
mindNode.Offset = new PointBase();//修正后归0
|
||||||
}
|
}
|
||||||
else if (mindNode.NodeLevel == 1)
|
else if (mindNode.NodeLevel == 1)
|
||||||
{
|
{
|
||||||
if (mindNode.ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
if (mindNode.ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||||
{
|
{
|
||||||
double x0 = mindNode.Left;
|
double x0 = mindNode.DesiredPosition.X;
|
||||||
double y0 = mindNode.Top + mindNode.ItemHeight;
|
double y0 = mindNode.DesiredPosition.Y + mindNode.ItemHeight;
|
||||||
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height) + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = y0 - (h + child.DesiredSize.Height - child.Spacing.Height) + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 - (h + child.DesiredSize.Height - child.Spacing.Height));
|
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 - (h + child.DesiredSize.Height - child.Spacing.Height));
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
h += child.DesiredSize.Height;
|
h += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -250,16 +254,17 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double x0 = mindNode.Left;
|
double x0 = mindNode.DesiredPosition.X;
|
||||||
double y0 = mindNode.Top;
|
double y0 = mindNode.DesiredPosition.Y;
|
||||||
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height) + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = y0 + (h + child.DesiredSize.Height - child.ItemHeight - child.Spacing.Height) + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 + (h + child.DesiredSize.Height - child.ItemHeight - child.Spacing.Height));
|
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 + (h + child.DesiredSize.Height - child.ItemHeight - child.Spacing.Height));
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
h += child.DesiredSize.Height;
|
h += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -274,17 +279,18 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mindNode.GetLevel2Node().ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||||
{
|
{
|
||||||
double left = mindNode.MiddlePosition.X;
|
double left = mindNode.DesiredMiddlePosition.X;
|
||||||
double top = mindNode.MiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
double top = mindNode.DesiredMiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
top += child.DesiredSize.Height;
|
top += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -298,15 +304,16 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double left = mindNode.MiddlePosition.X;
|
double left = mindNode.DesiredMiddlePosition.X;
|
||||||
double bottom = mindNode.MiddlePosition.Y - mindNode.ItemHeight / 2 - mindNode.Spacing.Height;
|
double bottom = mindNode.DesiredMiddlePosition.Y - mindNode.ItemHeight / 2 - mindNode.Spacing.Height;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = bottom - child.Spacing.Height - child.ItemHeight + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left, bottom - child.Spacing.Height - child.ItemHeight);
|
child.DesiredPosition = new PointBase(left, bottom - child.Spacing.Height - child.ItemHeight);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
bottom -= child.DesiredSize.Height;
|
bottom -= child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
|
|||||||
@@ -101,13 +101,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
if (mindNode == null) return;
|
if (mindNode == null) return;
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||||
var size = MeasureOverride(mindNode);
|
var size = MeasureOverride(mindNode);
|
||||||
ArrangeOverride(mindNode);
|
ArrangeOverride(mindNode);
|
||||||
|
|
||||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||||
@@ -126,15 +126,21 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
|
|
||||||
public void ArrangeOverride(MindNode mindNode)
|
public void ArrangeOverride(MindNode mindNode)
|
||||||
{
|
{
|
||||||
double left = mindNode.MiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
if (mindNode.NodeLevel == 0)
|
||||||
double top = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
{
|
||||||
|
mindNode.DesiredPosition = mindNode.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
double left = mindNode.DesiredMiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
||||||
|
double top = mindNode.DesiredMiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.Spacing.Width + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left + child.Spacing.Width, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
child.DesiredPosition = new PointBase(left + child.Spacing.Width, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
top += child.DesiredSize.Height;
|
top += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -144,8 +150,11 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
connector?.SetSinkPort(child.LeftConnector);
|
connector?.SetSinkPort(child.LeftConnector);
|
||||||
connector?.SetVisible(child.Visible);
|
connector?.SetVisible(child.Visible);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mindNode.DesiredPosition = mindNode.Position;
|
if (mindNode.NodeLevel == 0)
|
||||||
|
{
|
||||||
|
mindNode.Offset = new PointBase();//修正后归0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,13 +103,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
if (mindNode == null) return;
|
if (mindNode == null) return;
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||||
var size = MeasureOverride(mindNode);
|
var size = MeasureOverride(mindNode);
|
||||||
ArrangeOverride(mindNode);
|
ArrangeOverride(mindNode);
|
||||||
|
|
||||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||||
@@ -150,9 +150,11 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
double lefttop = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, rights.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
double lefttop = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, rights.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||||
foreach (var child in rights)
|
foreach (var child in rights)
|
||||||
{
|
{
|
||||||
child.Left = left + child.Spacing.Width + child.Offset.X - child.RootNode.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||||
child.Top = lefttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left + child.Spacing.Width, lefttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
child.DesiredPosition = new PointBase(left + child.Spacing.Width, lefttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
lefttop += child.DesiredSize.Height;
|
lefttop += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -168,9 +170,10 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
double righttop = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, lefts.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
double righttop = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, lefts.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||||
foreach (var child in lefts)
|
foreach (var child in lefts)
|
||||||
{
|
{
|
||||||
child.Left = right - child.Spacing.Width - child.ItemWidth + child.Offset.X - child.RootNode.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||||
child.Top = righttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(right - child.Spacing.Width - child.ItemWidth, righttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
child.DesiredPosition = new PointBase(right - child.Spacing.Width - child.ItemWidth, righttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
righttop += child.DesiredSize.Height;
|
righttop += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -182,22 +185,23 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mindNode.DesiredPosition = mindNode.Position;
|
mindNode.DesiredPosition = mindNode.Position;
|
||||||
//mindNode.Offset = new PointBase();
|
mindNode.Offset = new PointBase();//修正后归0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mindNode.GetLevel2Node().ConnectorOrientation == ConnectorOrientation.Left)
|
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.Left)
|
||||||
{
|
{
|
||||||
double left = mindNode.MiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
double left = mindNode.DesiredMiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
||||||
double top = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
double top = mindNode.DesiredMiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.Spacing.Width + child.Offset.X - child.RootNode.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left + child.Spacing.Width, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
child.DesiredPosition = new PointBase(left + child.Spacing.Width, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
top += child.DesiredSize.Height;
|
top += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -211,15 +215,16 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double right = mindNode.MiddlePosition.X - mindNode.ItemWidth / 2 - mindNode.Spacing.Width;
|
double right = mindNode.DesiredMiddlePosition.X - mindNode.ItemWidth / 2 - mindNode.Spacing.Width;
|
||||||
double top = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
double top = mindNode.DesiredMiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = right - child.Spacing.Width - child.ItemWidth + child.Offset.X - child.RootNode.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(right - child.Spacing.Width - child.ItemWidth, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
child.DesiredPosition = new PointBase(right - child.Spacing.Width - child.ItemWidth, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
top += child.DesiredSize.Height;
|
top += child.DesiredSize.Height;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
|
|||||||
@@ -103,13 +103,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
if (mindNode == null) return;
|
if (mindNode == null) return;
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||||
var size = MeasureOverride(mindNode);
|
var size = MeasureOverride(mindNode);
|
||||||
ArrangeOverride(mindNode);
|
ArrangeOverride(mindNode);
|
||||||
|
|
||||||
mindNode.Root.BringToFrontCommand.Execute(new SelectableDesignerItemViewModelBase[] { mindNode });
|
mindNode.Root.BringToFrontCommand.Execute(new SelectableDesignerItemViewModelBase[] { mindNode });
|
||||||
|
|
||||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||||
@@ -128,15 +128,21 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
|
|
||||||
public void ArrangeOverride(MindNode mindNode)
|
public void ArrangeOverride(MindNode mindNode)
|
||||||
{
|
{
|
||||||
double left = mindNode.MiddlePosition.X - Math.Max(mindNode.DesiredSize.Width, mindNode.Children.SumOrDefault(p => p.DesiredSize.Width)) / 2;
|
if (mindNode.NodeLevel == 0)
|
||||||
double top = mindNode.MiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
{
|
||||||
|
mindNode.DesiredPosition = mindNode.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
double left = mindNode.DesiredMiddlePosition.X - Math.Max(mindNode.DesiredSize.Width, mindNode.Children.SumOrDefault(p => p.DesiredSize.Width)) / 2;
|
||||||
|
double top = mindNode.DesiredMiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||||
if (mindNode.Children?.Count > 0)
|
if (mindNode.Children?.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var child in mindNode.Children)
|
foreach (var child in mindNode.Children)
|
||||||
{
|
{
|
||||||
child.Left = left + child.DesiredSize.Width / 2 - child.ItemWidth / 2 + child.Offset.X;
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
|
||||||
child.DesiredPosition = new PointBase(left + child.DesiredSize.Width / 2 - child.ItemWidth / 2, top + child.Spacing.Height);
|
child.DesiredPosition = new PointBase(left + child.DesiredSize.Width / 2 - child.ItemWidth / 2, top + child.Spacing.Height);
|
||||||
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||||
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||||
left += child.DesiredSize.Width;
|
left += child.DesiredSize.Width;
|
||||||
|
|
||||||
ArrangeOverride(child);
|
ArrangeOverride(child);
|
||||||
@@ -151,7 +157,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
|
|
||||||
if (mindNode.NodeLevel == 0)
|
if (mindNode.NodeLevel == 0)
|
||||||
{
|
{
|
||||||
mindNode.DesiredPosition = mindNode.Position;
|
mindNode.Offset = new PointBase();//修正后归0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return GetLevel1Node();
|
return GetLevel0Node();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,11 +242,19 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointBase? DesiredPosition
|
public PointBase DesiredPosition
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PointBase DesiredMiddlePosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new PointBase(this.DesiredPosition.X + ItemWidth / 2, this.DesiredPosition.Y + ItemHeight / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PointBase Offset
|
public PointBase Offset
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -463,6 +471,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
this.Parent = parent;
|
this.Parent = parent;
|
||||||
this.ParentId = parent?.Id ?? Guid.Empty;
|
this.ParentId = parent?.Id ?? Guid.Empty;
|
||||||
|
this.Offset = parent?.Offset ?? new PointBase();
|
||||||
this.InitLayout(true);//因为节点的层级不同的样式,所以需要Parent确定后才能初始化
|
this.InitLayout(true);//因为节点的层级不同的样式,所以需要Parent确定后才能初始化
|
||||||
this.InitConnectLayout();
|
this.InitConnectLayout();
|
||||||
|
|
||||||
@@ -520,7 +529,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
#endregion
|
#endregion
|
||||||
private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (GetLevel1Node()?.LayoutUpdating == true) return;
|
if (GetLevel0Node()?.LayoutUpdating == true) return;
|
||||||
|
|
||||||
switch (e.PropertyName)
|
switch (e.PropertyName)
|
||||||
{
|
{
|
||||||
@@ -529,6 +538,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
||||||
{
|
{
|
||||||
UpdateOffsetX((double)valuePropertyChangedEventArgs.OldValue, (double)valuePropertyChangedEventArgs.NewValue);
|
UpdateOffsetX((double)valuePropertyChangedEventArgs.OldValue, (double)valuePropertyChangedEventArgs.NewValue);
|
||||||
|
Console.WriteLine((sender as MindNode).Text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -615,7 +625,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
IsSelected = selected;
|
IsSelected = selected;
|
||||||
}
|
}
|
||||||
#region 布局相关
|
#region 布局相关
|
||||||
public MindNode GetLevel1Node()
|
public MindNode GetLevel0Node()
|
||||||
{
|
{
|
||||||
var node = this;
|
var node = this;
|
||||||
while (node.Parent is MindNode mindNode)
|
while (node.Parent is MindNode mindNode)
|
||||||
@@ -625,7 +635,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MindNode GetLevel2Node()
|
public MindNode GetLevel1Node()
|
||||||
{
|
{
|
||||||
var node = this;
|
var node = this;
|
||||||
while (node.Parent is MindNode mindNode && mindNode.NodeLevel == 1)
|
while (node.Parent is MindNode mindNode && mindNode.NodeLevel == 1)
|
||||||
@@ -673,7 +683,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
|
|
||||||
public void LayoutUpdated()
|
public void LayoutUpdated()
|
||||||
{
|
{
|
||||||
MindLayout?.LayoutUpdated(GetLevel1Node());
|
MindLayout?.LayoutUpdated(GetLevel0Node());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user