mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-13 13:09:28 +08:00
Merge branch 'master' of https://gitee.com/akwkevin/aistudio.-wpf.-diagram
This commit is contained in:
@@ -35,7 +35,10 @@
|
||||
<Canvas x:Name="rootCanvas">
|
||||
<Path x:Name="line" StrokeThickness="{Binding ColorViewModel.LineWidth}"
|
||||
StrokeDashArray="{Binding ColorViewModel.LineDashStyle,Converter={StaticResource LineDashConverter}}"
|
||||
Style="{StaticResource LineStyle}">
|
||||
Style="{StaticResource LineStyle}"
|
||||
StrokeLineJoin="Round"
|
||||
StrokeStartLineCap="Round"
|
||||
StrokeEndLineCap="Round">
|
||||
<Path.Data>
|
||||
<MultiBinding Converter="{x:Static s:ConnectionPathConverter.Instance}">
|
||||
<Binding Path="PathGeneratorResult"/>
|
||||
|
||||
@@ -161,11 +161,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return _selectedItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.PropertyChanged -= ViewModel_PropertyChanged;
|
||||
}
|
||||
{
|
||||
if (SetProperty(ref _selectedItem, value))
|
||||
{
|
||||
if (_selectedItem == null)
|
||||
@@ -183,10 +179,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
LockObjectViewModel = _selectedItem.LockObjectViewModel;
|
||||
}
|
||||
}
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
set
|
||||
{
|
||||
if (value <= 0) return;
|
||||
|
||||
if (this is GroupDesignerItemViewModel && value < 70)
|
||||
{
|
||||
|
||||
}
|
||||
SetProperty(ref _itemWidth, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public Func<KeyEventArgs, bool> Group
|
||||
{
|
||||
get; set;
|
||||
} = e => e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift) && e.Key == Key.G;
|
||||
} = e => e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.G;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,7 +778,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
private void Add(SelectableDesignerItemViewModelBase item)
|
||||
{
|
||||
item.Root = this;
|
||||
item.ZIndex = Items.Count;
|
||||
item.ZIndex = Items.Any() ? Items.Max(p => p.ZIndex) + 1 : 0;
|
||||
if (item.Id == Guid.Empty)
|
||||
{
|
||||
item.Id = Guid.NewGuid();
|
||||
@@ -1690,24 +1690,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return;
|
||||
}
|
||||
|
||||
RectangleBase rect = GetBoundingRectangle(items);
|
||||
RectangleBase rect = DiagramViewModelHelper.GetBoundingRectangle(items);
|
||||
|
||||
if (groupItem == null)
|
||||
{
|
||||
groupItem = new GroupDesignerItemViewModel();
|
||||
}
|
||||
groupItem.IsGroup = true;
|
||||
groupItem.ItemWidth = rect.Width;
|
||||
groupItem.ItemHeight = rect.Height;
|
||||
groupItem.Left = rect.Left;
|
||||
groupItem.Top = rect.Top;
|
||||
groupItem.ZIndex = Items.Count;
|
||||
|
||||
DirectAddItemCommand.Execute(groupItem);
|
||||
|
||||
foreach (DesignerItemViewModelBase item in items)
|
||||
item.ParentId = groupItem.Id;
|
||||
|
||||
groupItem.Resize();
|
||||
|
||||
ClearSelectedItemsCommand.Execute(null);
|
||||
//groupItem.IsSelected = true;
|
||||
SelectionService.AddToSelection(groupItem);
|
||||
@@ -1826,25 +1822,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
public RectangleBase GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items)
|
||||
{
|
||||
double x1 = Double.MaxValue;
|
||||
double y1 = Double.MaxValue;
|
||||
double x2 = Double.MinValue;
|
||||
double y2 = Double.MinValue;
|
||||
|
||||
foreach (DesignerItemViewModelBase item in items)
|
||||
{
|
||||
x1 = Math.Min(item.Left, x1);
|
||||
y1 = Math.Min(item.Top, y1);
|
||||
|
||||
x2 = Math.Max(item.Left + item.ItemWidth, x2);
|
||||
y2 = Math.Max(item.Top + item.ItemHeight, y2);
|
||||
}
|
||||
|
||||
return new RectangleBase(new PointBase(x1, y1), new PointBase(x2, y2));
|
||||
}
|
||||
|
||||
#region 用于wpf大小与物理像素之间转换
|
||||
public void SetScreenScale()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
@@ -12,5 +13,24 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
DesignerItemViewModelBase dataItem = items.OfType<DesignerItemViewModelBase>().Single(x => x.Id == conectorDataItemId);
|
||||
return dataItem;
|
||||
}
|
||||
|
||||
public static RectangleBase GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items)
|
||||
{
|
||||
double x1 = Double.MaxValue;
|
||||
double y1 = Double.MaxValue;
|
||||
double x2 = Double.MinValue;
|
||||
double y2 = Double.MinValue;
|
||||
|
||||
foreach (DesignerItemViewModelBase item in items)
|
||||
{
|
||||
x1 = Math.Min(item.Left, x1);
|
||||
y1 = Math.Min(item.Top, y1);
|
||||
|
||||
x2 = Math.Max(item.Left + item.ItemWidth, x2);
|
||||
y2 = Math.Max(item.Top + item.ItemHeight, y2);
|
||||
}
|
||||
|
||||
return new RectangleBase(new PointBase(x1, y1), new PointBase(x2, y2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
/// 打标记使用
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
### 3.箭头改进,箭头按照连线的实际角度显示(即0-360度),还支持自定义的箭头path。
|
||||
### 4.新增快捷键自定义扩展,用户可根据自己的习惯定义快捷键。
|
||||
### 5.封装了一个标准的工作流控件FlowchartEditor,具体使用可以参照开源权限管理框架种的用法: https://gitee.com/akwkevin/aistudio.-wpf.-aclient
|
||||
|
||||
nuget地址:
|
||||
|
||||
### 6.连接上添加动画:路径动画效果和线条流动效果。
|
||||
### 7.改变结构,使用户更容易自定义自己的样式,覆盖系统默认样式。
|
||||
### 8.从Blazor.Diagrams种引入PortlessLinks(直接连接两个node,不需要port),自动连接节点Snapping,按距离最近连接ReconnectLinksToClosestPorts
|
||||
|
||||
Reference in New Issue
Block a user