添加block快,不需要连接线,直接吸附。

This commit is contained in:
艾竹
2023-05-21 22:06:59 +08:00
parent 2fd8321363
commit fde899cfa9
30 changed files with 680 additions and 338 deletions

View File

@@ -217,7 +217,7 @@
</Border>
<Rectangle Fill="#7F243859" Opacity="0.5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding ShouldInsertAnchor, Converter={StaticResource BooleanToVisibilityConverter}}">
<i:Interaction.Behaviors>
<dd:ControlMouseLeftButtonDownCommandBehavior Command="{Binding AddItemCommand}" />
<dd:ControlMouseLeftButtonDownCommandBehavior Command="{Binding AddCommand}" />
</i:Interaction.Behaviors>
</Rectangle>
</Grid>
@@ -341,6 +341,36 @@
</dd:ConnectorContainer>
</ControlTemplate>
<ControlTemplate x:Key="BlockConnectorDecoratorTemplate"
TargetType="{x:Type Control}">
<Grid Margin="{Binding ConnectorMargin}">
<dd:Connector
Content="{Binding LeftConnector}"
SnapsToDevicePixels="True"
Orientation="Left"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"/>
<dd:Connector
Content="{Binding TopConnector}"
SnapsToDevicePixels="True"
Orientation="Top"
VerticalAlignment="Top"
HorizontalAlignment="Stretch"/>
<dd:Connector
Content="{Binding RightConnector}"
SnapsToDevicePixels="True"
Orientation="Right"
VerticalAlignment="Stretch"
HorizontalAlignment="Right"/>
<dd:Connector
Content="{Binding BottomConnector}"
SnapsToDevicePixels="True"
Orientation="Bottom"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"/>
</Grid>
</ControlTemplate>
<!--基础类型-->
<Style x:Key="designerItemStyle"
TargetType="{x:Type ContentPresenter}">
@@ -773,6 +803,92 @@
</Setter.Value>
</Setter>
</Style>
<!--自带的block基础类型-->
<Style x:Key="blockItemStyle"
TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left"
Value="{Binding Left}" />
<Setter Property="Canvas.Top"
Value="{Binding Top}" />
<Setter Property="Canvas.ZIndex"
Value="{Binding ZIndex}" />
<Setter Property="dd:SelectionProps.EnabledForSelection"
Value="{Binding EnabledForSelection}" />
<Setter Property="Visibility"
Value="{Binding Visible,Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Setter Property="Width"
Value="{Binding ItemWidth}" />
<Setter Property="Height"
Value="{Binding ItemHeight}" />
<Setter Property="MinWidth"
Value="{Binding MinItemWidth}" />
<Setter Property="MinHeight"
Value="{Binding MinItemHeight}" />
<Setter Property="SnapsToDevicePixels"
Value="True" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid x:Name="selectedGrid" IsHitTestVisible="{Binding IsHitTestVisible}" >
<Grid.ContextMenu>
<ContextMenu ItemsSource="{Binding MenuOptions}" Visibility="{Binding ShowMenuOptions,Converter={StaticResource BooleanToVisibilityConverter}}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="MenuItem.Header" Value="{Binding Text}" />
<Setter Property="MenuItem.ItemsSource" Value="{Binding Children}" />
<Setter Property="MenuItem.Command" Value="{Binding Command}" />
<Setter Property="MenuItem.Icon" Value="{Binding Icon}" />
<Setter Property="CommandParameter" Value="{Binding CommandParameter}" />
<Setter Property="MenuItem.IsCheckable" Value="{Binding IsCheckable}" />
<Setter Property="MenuItem.IsChecked" Value="{Binding IsChecked}" />
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</Grid.ContextMenu>
<!-- PART_DragThumb -->
<c:DragThumb x:Name="PART_DragThumb"
Cursor="SizeAll" >
<c:DragThumb.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditCommand}" CommandParameter="{Binding }" />
</c:DragThumb.InputBindings>
</c:DragThumb>
<Grid RenderTransformOrigin="0.5,0.5" >
<!-- PART_ContentPresenter -->
<ContentPresenter x:Name="PART_ContentPresenter"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Content="{TemplateBinding Content}" />
<TextBlock x:Name="PART_Text" Text="{Binding Text}" IsHitTestVisible="False"/>
<!-- PART_ConnectorDecorator -->
<Control x:Name="PART_ConnectorDecorator" Template="{StaticResource BlockConnectorDecoratorTemplate}"/>
</Grid>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Connectors.Count}" Value="0">
<Setter TargetName="PART_ConnectorDecorator" Property="Visibility" Value="Collapsed" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="10" Color="{Binding ColorViewModel.ShadowColor}"/>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ColorViewModel.ShadowColor}" Value="Transparent">
<Setter Property="Effect" Value="{x:Null}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>