mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-03 23:56:37 +08:00
增加自定义 DesignerItemView 样式
This commit is contained in:
@@ -83,7 +83,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BlockItemsContainer _sourceItemsContainer;
|
||||
public BlockItemsContainer SourceItemsContainer
|
||||
{
|
||||
@@ -250,7 +250,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
this.Loaded += DesignerCanvas_Loaded;
|
||||
this.IsVisibleChanged += DesignerCanvas_IsVisibleChanged;
|
||||
this.DataContextChanged += DesignerCanvas_DataContextChanged;
|
||||
this.DataContextChanged += DesignerCanvas_DataContextChanged;
|
||||
}
|
||||
|
||||
private void DesignerCanvas_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
@@ -275,7 +275,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
|
||||
protected void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Mediator.Instance.Register(this);
|
||||
this.Focus();
|
||||
@@ -575,7 +575,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else if (SourceItemsContainer != null)
|
||||
{
|
||||
( _viewModel as IBlockDiagramViewModel).FinishNearBlock(new System.Collections.Generic.List<BlockDesignerItemViewModel> { SourceItemsContainer.DragObject });
|
||||
(_viewModel as IBlockDiagramViewModel).FinishNearBlock(new System.Collections.Generic.List<BlockDesignerItemViewModel> { SourceItemsContainer.DragObject });
|
||||
ExitCursor();
|
||||
}
|
||||
|
||||
@@ -662,7 +662,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
|
||||
if (dragObject != null && (dragObject.ContentType == typeof(BlockDesignerItemViewModel) || dragObject.ContentType.IsSubclassOf(typeof(BlockDesignerItemViewModel))))
|
||||
{
|
||||
var position = e.GetPosition(this);
|
||||
var position = e.GetPosition(this);
|
||||
|
||||
BlockDesignerItemViewModel itemBase = Activator.CreateInstance(dragObject.ContentType) as BlockDesignerItemViewModel;
|
||||
itemBase.Text = dragObject.Text;
|
||||
@@ -682,8 +682,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
itemBase.Top = Math.Max(0, position.Y - itemBase.GetItemHeight() / 2);
|
||||
|
||||
(_viewModel as IBlockDiagramViewModel)?.PreviewNearBlock(new System.Collections.Generic.List<BlockDesignerItemViewModel> { itemBase });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
base.OnDragOver(e);
|
||||
}
|
||||
|
||||
@@ -741,7 +741,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
itemBase.Left = Math.Max(0, position.X - itemBase.GetItemWidth() / 2);
|
||||
itemBase.Top = Math.Max(0, position.Y - itemBase.GetItemHeight() / 2);
|
||||
itemBase.Top = Math.Max(0, position.Y - itemBase.GetItemHeight() / 2);
|
||||
_viewModel.AddCommand.Execute(itemBase);
|
||||
|
||||
if (itemBase is BlockDesignerItemViewModel block)
|
||||
|
||||
Reference in New Issue
Block a user