mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-03 23:56:37 +08:00
143 lines
8.3 KiB
XML
143 lines
8.3 KiB
XML
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
|
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.Mind.ViewModels">
|
|
|
|
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
|
<dd:DoubleToCornerRadius x:Key="DoubleToCornerRadius"/>
|
|
<dd:IntToVisibilityConverter x:Key="IntToVisibilityConverter"/>
|
|
|
|
<!-- Toggle Button -->
|
|
<Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
|
|
<Setter Property="Focusable" Value="False"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="ToggleButton">
|
|
<Grid Width="17" Height="17" SnapsToDevicePixels="True">
|
|
<Rectangle Width="13" Height="13" Stroke="Gray" RadiusX="6" RadiusY="6" SnapsToDevicePixels="true">
|
|
<Rectangle.Fill>
|
|
<LinearGradientBrush EndPoint="0.5,2" StartPoint="0.5,0">
|
|
<GradientStop Color="White" Offset="0"/>
|
|
<GradientStop Color="Silver" Offset="0.5"/>
|
|
<GradientStop Color="LightGray" Offset="1"/>
|
|
</LinearGradientBrush>
|
|
</Rectangle.Fill>
|
|
</Rectangle>
|
|
<Rectangle x:Name="ExpandPath" Width="1" Height="9" Stroke="Gray" SnapsToDevicePixels="true" />
|
|
<Rectangle Width="9" Height="1" Stroke="Gray" SnapsToDevicePixels="true"/>
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsChecked" Value="True">
|
|
<Setter Property="Visibility" TargetName="ExpandPath" Value="Collapsed"/>
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<ControlTemplate x:Key="MindLevel1NodeStyle" TargetType="{x:Type ContentControl}">
|
|
<Grid >
|
|
<Grid.ContextMenu>
|
|
<ContextMenu ItemsSource="{Binding MenuOptions}">
|
|
<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>
|
|
<Grid IsHitTestVisible="False">
|
|
<Border BorderThickness="1"
|
|
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
|
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
|
CornerRadius="{Binding CornerRadius,Converter={StaticResource DoubleToCornerRadius}}">
|
|
</Border>
|
|
</Grid>
|
|
</Grid>
|
|
</ControlTemplate>
|
|
|
|
<ControlTemplate x:Key="MindLevel2NodeStyle" TargetType="{x:Type ContentControl}">
|
|
<Grid>
|
|
<Grid.ContextMenu>
|
|
<ContextMenu ItemsSource="{Binding MenuOptions}">
|
|
<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>
|
|
<Grid IsHitTestVisible="False">
|
|
<Border BorderThickness="1"
|
|
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
|
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
|
CornerRadius="{Binding CornerRadius,Converter={StaticResource DoubleToCornerRadius}}">
|
|
</Border>
|
|
</Grid>
|
|
<ToggleButton IsChecked="{Binding IsExpanded}" Style="{StaticResource ExpandCollapseToggleStyle}" HorizontalAlignment="Left" Margin="-15,0,0,0" Visibility="{Binding Children.Count,Converter={StaticResource IntToVisibilityConverter}}"/>
|
|
</Grid>
|
|
</ControlTemplate>
|
|
|
|
<ControlTemplate x:Key="MindLevel3NodeStyle" TargetType="{x:Type ContentControl}">
|
|
<Grid>
|
|
<Grid.ContextMenu>
|
|
<ContextMenu ItemsSource="{Binding MenuOptions}">
|
|
<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>
|
|
<Grid IsHitTestVisible="False">
|
|
<Border BorderThickness="0,0,0,1"
|
|
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
|
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
|
|
|
</Border>
|
|
</Grid>
|
|
<ToggleButton IsChecked="{Binding IsExpanded}" Style="{StaticResource ExpandCollapseToggleStyle}" HorizontalAlignment="Left" Margin="-15,0,0,0" Visibility="{Binding Children.Count,Converter={StaticResource IntToVisibilityConverter}}"/>
|
|
</Grid>
|
|
</ControlTemplate>
|
|
|
|
<Style x:Key="MindNodeStyle" TargetType="{x:Type ContentControl}">
|
|
<Setter Property="Template" Value="{StaticResource MindLevel1NodeStyle}" />
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding NodeLevel}" Value="Level1">
|
|
<Setter Property="Template" Value="{StaticResource MindLevel1NodeStyle}" />
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding NodeLevel}" Value="Level2">
|
|
<Setter Property="Template" Value="{StaticResource MindLevel2NodeStyle}" />
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding NodeLevel}" Value="Level3">
|
|
<Setter Property="Template" Value="{StaticResource MindLevel3NodeStyle}" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
|
|
<DataTemplate DataType="{x:Type viewmodel:MindNode}">
|
|
<Grid>
|
|
<ContentControl Style="{StaticResource MindNodeStyle}"/>
|
|
</Grid>
|
|
</DataTemplate>
|
|
|
|
</ResourceDictionary> |