mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-07 17:56:35 +08:00
小优化
This commit is contained in:
@@ -162,7 +162,7 @@
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type model:MultipleDesignerItemToolBoxData}">
|
||||
<Grid ToolTip="{Binding Description}">
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
|
||||
@@ -173,7 +173,7 @@
|
||||
StrokeDashArray="2"
|
||||
Fill="Transparent"
|
||||
SnapsToDevicePixels="true"/>
|
||||
<Viewbox Stretch="Uniform" Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Viewbox Stretch="Uniform" Margin="2">
|
||||
<ItemsControl ItemsSource="{Binding SelectableDesignerItemViewModels}"
|
||||
Width="{Binding CanvasWidth}"
|
||||
Height="{Binding CanvasHeight}">
|
||||
|
||||
@@ -572,10 +572,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (dragObject.DesignerItem is SerializableObject serializableObject)
|
||||
{
|
||||
var designerItems = serializableObject.ToObject();
|
||||
var minleft = designerItems.OfType<DesignerItemViewModelBase>().Min(p => p.Left);
|
||||
var mintop = designerItems.OfType<DesignerItemViewModelBase>().Min(p => p.Top);
|
||||
var maxright = designerItems.OfType<DesignerItemViewModelBase>().Max(p => p.Left + p.ItemWidth);
|
||||
var maxbottom = designerItems.OfType<DesignerItemViewModelBase>().Max(p => p.Top + p.ItemHeight);
|
||||
var itemswidth = maxright - minleft;
|
||||
var itemsheight = maxbottom - mintop;
|
||||
|
||||
foreach (var item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
item.Left += position.X;
|
||||
item.Top += position.Y;
|
||||
item.Left += position.X - itemswidth / 2;
|
||||
item.Top += position.Y - itemsheight / 2;
|
||||
}
|
||||
_viewModel.AddItemCommand.Execute(designerItems);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user