This commit is contained in:
kwai
2023-03-15 19:35:53 +08:00
parent 035a725da3
commit 70dac7d41c
10 changed files with 124 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner
{
public class NullableToVisibilityConverter : IValueConverter
{
public Visibility NullValue { get; set; } = Visibility.Collapsed;
public Visibility NotNullValue { get; set; } = Visibility.Visible;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? NullValue : NotNullValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
}

View File

@@ -9,7 +9,7 @@
<PackageIconUrl />
<NeutralLanguage />
<Version>1.0.6</Version>
<Description>一个Wpf的流程图控件</Description>
<Description>一个Wpf的思维导图控件</Description>
</PropertyGroup>
<ItemGroup>

View File

@@ -27,15 +27,15 @@ namespace AIStudio.Wpf.Mind.Controls
/// <summary>Identifies the <see cref="Priority"/> dependency property.</summary>
public static readonly DependencyProperty PriorityProperty
= DependencyProperty.Register(nameof(Priority), typeof(double), typeof(PriorityControl));
= DependencyProperty.Register(nameof(Priority), typeof(double?), typeof(PriorityControl));
/// <summary>
/// Whether or not the "popup" menu for this control is currently open
/// </summary>
public double Priority
public double? Priority
{
get => (double)this.GetValue(PriorityProperty);
set => this.SetValue(PriorityProperty, (double)value);
get => (double?)this.GetValue(PriorityProperty);
set => this.SetValue(PriorityProperty, (double?)value);
}
}
}

View File

@@ -4,11 +4,66 @@
<Style x:Key="RateControlStyle" TargetType="{x:Type controls:RateControl}">
<Setter Property="Background" Value="Yellow" />
<Setter Property="Foreground" Value="Green" />
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="3" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:RateControl}">
<Grid>
<Grid x:Name="RootGrid">
<Ellipse Fill="{TemplateBinding Background}"
Stroke="{TemplateBinding BorderBrush}"
StrokeThickness="{TemplateBinding BorderThickness}"
x:Name="border">
</Ellipse>
<Path x:Name="Path" Stretch="Uniform" Fill="{TemplateBinding Foreground}"
RenderTransformOrigin="0.5,0.5"
Data="">
<Path.RenderTransform>
<ScaleTransform ScaleY="-1"/>
</Path.RenderTransform>
</Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Rate" Value="0">
<Setter TargetName="Path" Property="Data" Value="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z"/>
<Setter Property="Background" Value="Red"/>
</Trigger>
<Trigger Property="Rate" Value="0.125">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C13.93 5 15.68 5.78 16.95 7.05L12 12V5Z"/>
<Setter Property="Background" Value="Blue"/>
</Trigger>
<Trigger Property="Rate" Value="0.25">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12H12V5Z"/>
<Setter Property="Background" Value="Green"/>
</Trigger>
<Trigger Property="Rate" Value="0.375">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 13.93 18.22 15.68 16.95 16.95L12 12V5Z"/>
<Setter Property="Background" Value="Orange"/>
</Trigger>
<Trigger Property="Rate" Value="0.5">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19V5Z"/>
<Setter Property="Background" Value="Purple"/>
</Trigger>
<Trigger Property="Rate" Value="0.625">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19C10.07 19 8.32 18.22 7.05 16.95L12 12V5Z"/>
<Setter Property="Background" Value="Gray"/>
</Trigger>
<Trigger Property="Rate" Value="0.75">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19C8.13 19 5 15.87 5 12H12V5Z"/>
<Setter Property="Background" Value="Gray"/>
</Trigger>
<Trigger Property="Rate" Value="0.875">
<Setter TargetName="Path" Property="Data" Value="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19C8.13 19 5 15.87 5 12C5 10.07 5.78 8.32 7.05 7.05L12 12V5Z"/>
<Setter Property="Background" Value="Gray"/>
</Trigger>
<Trigger Property="Rate" Value="1">
<Setter TargetName="Path" Property="Data" Value="m 256,76 c 48.1,0 93.3,18.7 127.3,52.7 34,34 52.7,79.2 52.7,127.3 0,48.1 -18.7,93.3 -52.7,127.3 -34,34 -79.2,52.7 -127.3,52.7 -48.1,0 -93.3,-18.7 -127.3,-52.7 C 94.7,349.3 76,304.1 76,256 76,207.9 94.7,162.7 128.7,128.7 162.7,94.7 207.9,76 256,76 m 0,-28 C 141.1,48 48,141.1 48,256 48,370.9 141.1,464 256,464 370.9,464 464,370.9 464,256 464,141.1 370.9,48 256,48 Z M 362.6,192.9 345,174.8 c -0.7,-0.8 -1.8,-1.2 -2.8,-1.2 -1.1,0 -2.1,0.4 -2.8,1.2 L 217.4,297.7 173,253.3 c -0.8,-0.8 -1.8,-1.2 -2.8,-1.2 -1,0 -2,0.4 -2.8,1.2 l -17.8,17.8 c -1.6,1.6 -1.6,4.1 0,5.7 l 56,56 c 3.6,3.6 8,5.7 11.7,5.7 5.3,0 9.9,-3.9 11.6,-5.5 H 229 L 362.7,198.6 c 1.4,-1.7 1.4,-4.2 -0.1,-5.7 z"/>
<Setter Property="Background" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>

View File

@@ -27,15 +27,15 @@ namespace AIStudio.Wpf.Mind.Controls
/// <summary>Identifies the <see cref="Rate"/> dependency property.</summary>
public static readonly DependencyProperty RateProperty
= DependencyProperty.Register(nameof(Rate), typeof(double), typeof(RateControl));
= DependencyProperty.Register(nameof(Rate), typeof(double?), typeof(RateControl));
/// <summary>
/// Whether or not the "popup" menu for this control is currently open
/// </summary>
public double Rate
public double? Rate
{
get => (double)this.GetValue(RateProperty);
set => this.SetValue(RateProperty, (double)value);
get => (double?)this.GetValue(RateProperty);
set => this.SetValue(RateProperty, (double?)value);
}
}
}

View File

@@ -155,7 +155,7 @@
Width="20"
Height="20"
Command="{Binding AddPriorityCommand}"
CommandParameter="0">
CommandParameter="Null">
<Path Stretch="Uniform" Fill="DarkRed" Data="M966.4 761.6l-140.8 140.8-313.6-320-313.6 320-140.8-140.8 320-313.6-320-313.6 140.8-140.8 313.6 320 313.6-320 140.8 140.8-320 313.6z"></Path>
</Button>
@@ -278,59 +278,70 @@
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="Null">
<Path Stretch="Uniform" Fill="DarkRed" Data="m 256,76 c 48.1,0 93.3,18.7 127.3,52.7 34,34 52.7,79.2 52.7,127.3 0,48.1 -18.7,93.3 -52.7,127.3 -34,34 -79.2,52.7 -127.3,52.7 -48.1,0 -93.3,-18.7 -127.3,-52.7 C 94.7,349.3 76,304.1 76,256 76,207.9 94.7,162.7 128.7,128.7 162.7,94.7 207.9,76 256,76 m 0,-28 C 141.1,48 48,141.1 48,256 48,370.9 141.1,464 256,464 370.9,464 464,370.9 464,256 464,141.1 370.9,48 256,48 Z m 75.3,260.7 -52.7,-52.7 52.7,-52.7 c 6.2,-6.2 6.2,-16.4 0,-22.6 -6.2,-6.2 -16.4,-6.2 -22.6,0 L 256,233.4 203.3,180.7 c -6.2,-6.2 -15.6,-7.1 -22.6,0 -7.1,7.1 -6,16.6 0,22.6 l 52.7,52.7 -52.7,52.7 c -6.7,6.7 -6.4,16.3 0,22.6 6.4,6.4 16.4,6.2 22.6,0 l 52.7,-52.7 52.7,52.7 c 6.2,6.2 16.4,6.2 22.6,0 6.3,-6.2 6.3,-16.4 0,-22.6 z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0">
<Path Stretch="Uniform" Fill="Green" Data="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0.125">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C13.93 5 15.68 5.78 16.95 7.05L12 12V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0.25">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12H12V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0.375">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 13.93 18.22 15.68 16.95 16.95L12 12V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0.5">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Command="{Binding EditCommand}">
Margin="1"
Command="{Binding AddRatioCommand}"
CommandParameter="0.625">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19C10.07 19 8.32 18.22 7.05 16.95L12 12V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0.75">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19C8.13 19 5 15.87 5 12H12V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="0.875">
<Path Stretch="Uniform" Fill="Green" Data="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M12 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C16.42 20 20 16.42 20 12C20 7.58 16.42 4 12 4M12 5C15.87 5 19 8.13 19 12C19 15.87 15.87 19 12 19C8.13 19 5 15.87 5 12C5 10.07 5.78 8.32 7.05 7.05L12 12V5Z"></Path>
</Button>
<Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow"
Margin="1"
Command="{Binding EditCommand}">
Command="{Binding AddRatioCommand}"
CommandParameter="1">
<Path Stretch="Uniform" Fill="Green" Data="m 256,76 c 48.1,0 93.3,18.7 127.3,52.7 34,34 52.7,79.2 52.7,127.3 0,48.1 -18.7,93.3 -52.7,127.3 -34,34 -79.2,52.7 -127.3,52.7 -48.1,0 -93.3,-18.7 -127.3,-52.7 C 94.7,349.3 76,304.1 76,256 76,207.9 94.7,162.7 128.7,128.7 162.7,94.7 207.9,76 256,76 m 0,-28 C 141.1,48 48,141.1 48,256 48,370.9 141.1,464 256,464 370.9,464 464,370.9 464,256 464,141.1 370.9,48 256,48 Z M 362.6,192.9 345,174.8 c -0.7,-0.8 -1.8,-1.2 -2.8,-1.2 -1.1,0 -2.1,0.4 -2.8,1.2 L 217.4,297.7 173,253.3 c -0.8,-0.8 -1.8,-1.2 -2.8,-1.2 -1,0 -2,0.4 -2.8,1.2 l -17.8,17.8 c -1.6,1.6 -1.6,4.1 0,5.7 l 56,56 c 3.6,3.6 8,5.7 11.7,5.7 5.3,0 9.9,-3.9 11.6,-5.5 H 229 L 362.7,198.6 c 1.4,-1.7 1.4,-4.2 -0.1,-5.7 z"></Path>
</Button>
</UniformGrid>

View File

@@ -8,6 +8,7 @@
<dd:DoubleToCornerRadius x:Key="DoubleToCornerRadius"/>
<dd:IntToVisibilityConverter x:Key="IntToVisibilityConverter"/>
<dd:DoubleToThickness x:Key="DoubleToThickness"/>
<dd:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter"/>
<!-- Toggle Button -->
<Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
@@ -76,8 +77,8 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:RateControl Grid.Column="0" />
<controls:PriorityControl Grid.Column="1" Width="20" Height="20" Priority="{Binding Priority}" Visibility="{Binding Priority,Converter={dd:ConverterValueSetToOppositeVisibility},ConverterParameter=0}"/>
<controls:RateControl Grid.Column="0" Width="18" Height="18" Rate="{Binding Rate}" Visibility="{Binding Rate,Converter={StaticResource NullableToVisibilityConverter}}"/>
<controls:PriorityControl Grid.Column="1" Width="18" Height="18" Priority="{Binding Priority}" Visibility="{Binding Priority,Converter={StaticResource NullableToVisibilityConverter}}"/>
<dd:TextControl Grid.Column="2" />
<controls:LinkControl Grid.Column="3"/>
<controls:RemarkControl Grid.Column="4"/>

View File

@@ -659,6 +659,10 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.Priority = priority);
}
else
{
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.Priority = null);
}
}
private void ExecuteAddRatioCommand(object obj)

View File

@@ -265,8 +265,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private double _priority;
public double Priority
private double? _priority;
public double? Priority
{
get
{
@@ -278,8 +278,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private double _rate;
public double Rate
private double? _rate;
public double? Rate
{
get
{

View File

@@ -1,7 +1,7 @@
<Project>
<!-- Project properties -->
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp3.1;net5.0-windows</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0-windows</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">