group 和 line 优化

This commit is contained in:
kwai
2023-02-10 18:49:02 +08:00
parent 18b6bd7e71
commit cf1bfc7482
7 changed files with 65 additions and 39 deletions

View File

@@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
using AIStudio.Wpf.DiagramDesigner.Models;
namespace AIStudio.Wpf.DiagramDesigner
@@ -12,7 +14,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public GroupDesignerItemViewModel() : this(null)
{
}
public GroupDesignerItemViewModel(IDiagramViewModel root) : base(root)
@@ -34,6 +36,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
base.Init(root);
this.IsGroup = true;
this.IsHitTestVisible = true;
}
@@ -46,6 +49,32 @@ namespace AIStudio.Wpf.DiagramDesigner
{
}
public void Resize()
{
if (this.Root == null) return;
var items = this.Root.Items.Where(p => p.ParentId == Id).OfType<DesignerItemViewModelBase>();
RectangleBase rect = DiagramViewModelHelper.GetBoundingRectangle(items);
this.ItemWidth = rect.Width;
this.ItemHeight = rect.Height;
this.Left = rect.Left;
this.Top = rect.Top;
}
public void AddItem(DesignerItemViewModelBase item)
{
if (this.Root == null) return;
item.ParentId = Id;
if (item.ZIndex > this.ZIndex)
{
var zindex = item.ZIndex;
item.ZIndex = this.ZIndex;
this.ZIndex = zindex;
}
Resize();
}
/// <summary>
/// 打标记使用