mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
快捷键支持
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
@@ -408,6 +407,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public DiagramOption DiagramOption
|
||||
{
|
||||
get; set;
|
||||
} = new DiagramOption();
|
||||
|
||||
/// <summary>
|
||||
/// 用于wpf大小与物理像素之间转换
|
||||
/// </summary>
|
||||
@@ -1460,7 +1464,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
DirectAddItemCommand.Execute(items);
|
||||
|
||||
OffsetX += 10;
|
||||
OffsetY += 10;
|
||||
|
||||
@@ -1476,11 +1480,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
connectionItem.SourceType = System.Type.GetType(connectionItem.SourceTypeName);
|
||||
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(this, connectionItem.SourceId, connectionItem.SourceType);
|
||||
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(items, connectionItem.SourceId, connectionItem.SourceType);
|
||||
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
||||
|
||||
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(this, connectionItem.SinkId, connectionItem.SinkType);
|
||||
DesignerItemViewModelBase sinkItem = DiagramViewModelHelper.GetConnectorDataItem(items, connectionItem.SinkId, connectionItem.SinkType);
|
||||
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkIsPortless);
|
||||
|
||||
@@ -1488,8 +1492,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
connectors.Add(connectionVM);
|
||||
}
|
||||
|
||||
DirectAddItemCommand.Execute(connectors);
|
||||
|
||||
//修复父级的引用
|
||||
foreach (var item in items)
|
||||
{
|
||||
@@ -1499,19 +1501,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
item.ParentId = mappingOldToNewIDs[item.ParentId];
|
||||
}
|
||||
}
|
||||
|
||||
items.AddRange(connectors);
|
||||
|
||||
DirectAddItemCommand.Execute(items);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Windows.MessageBox.Show(e.StackTrace, e.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DesignerItemViewModelBase GetConnectorDataItem(IDiagramViewModel diagramViewModel, Guid conectorDataItemId, Type connectorDataItemType)
|
||||
{
|
||||
DesignerItemViewModelBase dataItem = diagramViewModel.Items.OfType<DesignerItemViewModelBase>().Single(x => x.Id == conectorDataItemId);
|
||||
return dataItem;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
|
||||
{
|
||||
@@ -1678,7 +1678,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else
|
||||
{
|
||||
items = SelectedItems.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == Guid.Empty).ToList();
|
||||
items = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == Guid.Empty).ToList();
|
||||
}
|
||||
|
||||
var groups = items.OfType<DesignerItemViewModelBase>().Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
||||
|
||||
//解除分组
|
||||
if (groupItem == null && groups.Count > 0)
|
||||
{
|
||||
ExecuteUngroupCommand(groups);
|
||||
return;
|
||||
}
|
||||
|
||||
RectangleBase rect = GetBoundingRectangle(items);
|
||||
@@ -1706,9 +1715,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private void ExecuteUngroupCommand(object parameter)
|
||||
{
|
||||
var groups = (from item in SelectedItems.OfType<DesignerItemViewModelBase>()
|
||||
where item.IsGroup && item.ParentId == Guid.Empty
|
||||
select item).ToArray();
|
||||
List<DesignerItemViewModelBase> groups;
|
||||
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
||||
{
|
||||
groups = para.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
groups = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
||||
}
|
||||
|
||||
foreach (DesignerItemViewModelBase groupRoot in groups)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user