mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
link
This commit is contained in:
@@ -14,7 +14,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value == null ? NullValue : NotNullValue;
|
||||
return string.IsNullOrEmpty(value?.ToString()) ? NullValue : NotNullValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
||||
@@ -1,12 +1,46 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.Mind.Controls.LinkControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:AIStudio.Wpf.Mind.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.Mind.Controls">
|
||||
|
||||
<Style x:Key="LinkControlStyle" TargetType="{x:Type controls:LinkControl}">
|
||||
<Setter Property="Foreground" Value="Gray"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:LinkControl}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="true">
|
||||
<TextBlock Background="{TemplateBinding Background}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<Hyperlink
|
||||
x:Name="PART_InnerHyperlink"
|
||||
NavigateUri="{Binding RelativeSource= {RelativeSource TemplatedParent}, Path=Url}"
|
||||
TextDecorations ="None"
|
||||
Command="{Binding RelativeSource= {RelativeSource TemplatedParent}, Path=Command}"
|
||||
CommandParameter="{Binding RelativeSource= {RelativeSource TemplatedParent}, Path=CommandParameter}"
|
||||
CommandTarget="{Binding RelativeSource= {RelativeSource TemplatedParent}, Path=CommandTarget}">
|
||||
<Path Width="18" Height="18" Stretch="Uniform" Fill="{Binding RelativeSource= {RelativeSource TemplatedParent}, Path=Foreground}"
|
||||
Data="M48 226Q48 191 72 168 95 144 130 144L165 144Q191 144 211 157 231 170 240 192L129 192Q115 192 106 202 96 211 96 225L96 287Q96 301 106 311 115 320 129 320L240 320Q231 342 211 355 191 368 165 368L130 368Q95 368 72 345 48 321 48 286L48 226ZM464 286Q464 321 441 345 417 368 382 368L347 368Q321 368 301 355 281 342 272 320L383 320Q397 320 407 311 416 301 416 287L416 225Q416 211 407 202 397 192 383 192L272 192Q281 170 301 157 321 144 347 144L382 144Q417 144 441 168 464 191 464 226L464 286ZM144 232L368 232 368 280 144 280 144 232Z"></Path>
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger SourceName="PART_InnerHyperlink" Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type controls:LinkControl}" BasedOn="{StaticResource LinkControlStyle}"/>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -18,11 +20,48 @@ namespace AIStudio.Wpf.Mind.Controls
|
||||
/// <summary>
|
||||
/// LinkControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LinkControl : UserControl
|
||||
[TemplatePart(Name = "PART_InnerHyperlink", Type = typeof(Hyperlink))]
|
||||
public class LinkControl : Control
|
||||
{
|
||||
public LinkControl()
|
||||
public static readonly DependencyProperty UrlProperty =
|
||||
DependencyProperty.Register(nameof(Url), typeof(string), typeof(LinkControl));
|
||||
|
||||
[Category("Common Properties"), Bindable(true)]
|
||||
public string Url
|
||||
{
|
||||
InitializeComponent();
|
||||
get
|
||||
{
|
||||
return GetValue(UrlProperty) as string;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(UrlProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
static LinkControl()
|
||||
{
|
||||
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(
|
||||
typeof(LinkControl),
|
||||
new FrameworkPropertyMetadata(typeof(LinkControl)));
|
||||
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
Hyperlink innerHyperlink = GetTemplateChild("PART_InnerHyperlink") as Hyperlink;
|
||||
if (innerHyperlink != null)
|
||||
{
|
||||
innerHyperlink.Click += new RoutedEventHandler(InnerHyperlink_Click);
|
||||
}
|
||||
}
|
||||
|
||||
void InnerHyperlink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 激活的是当前默认的浏览器
|
||||
Process.Start("explorer.exe", Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,47 +21,36 @@
|
||||
<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"/>
|
||||
<Setter Property="Foreground" Value="DarkRed"/>
|
||||
</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>
|
||||
|
||||
@@ -119,8 +119,8 @@
|
||||
</StackPanel>
|
||||
</controls:DropDownButton.Content>
|
||||
<controls:DropDownButton.Items>
|
||||
<MenuItem Header="插入链接"></MenuItem>
|
||||
<MenuItem Header="移除已有链接"></MenuItem>
|
||||
<MenuItem Header="插入链接" Command="{Binding AddLinkCommand}"></MenuItem>
|
||||
<MenuItem Header="移除已有链接" Command="{Binding RemoveLinkCommand}"></MenuItem>
|
||||
</controls:DropDownButton.Items>
|
||||
</controls:DropDownButton>
|
||||
<controls:DropDownButton>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/DropDownButton.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/MindEditor.xaml"/>
|
||||
<!--<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/LinkControl.xaml"/>-->
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/LinkControl.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/PriorityControl.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/RateControl.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/RemarkControl.xaml"/>
|
||||
|
||||
@@ -55,9 +55,9 @@
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Grid IsHitTestVisible="{Binding IsEditing}">
|
||||
<Border BorderThickness="{Binding BorderThickness}"
|
||||
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
@@ -77,10 +77,15 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<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}}"/>
|
||||
<controls:RateControl Grid.Column="0" Width="20" Height="20" Rate="{Binding Rate}"
|
||||
Visibility="{Binding Rate,Converter={StaticResource NullableToVisibilityConverter}}"/>
|
||||
<controls:PriorityControl Grid.Column="1" Width="20" Height="20" Priority="{Binding Priority}"
|
||||
Visibility="{Binding Priority,Converter={StaticResource NullableToVisibilityConverter}}"/>
|
||||
<dd:TextControl Grid.Column="2" />
|
||||
<controls:LinkControl Grid.Column="3"/>
|
||||
<controls:LinkControl Grid.Column="3"
|
||||
Visibility="{Binding LinkInfo,Converter={StaticResource NullableToVisibilityConverter}}"
|
||||
Url="{Binding LinkInfo.Url}"
|
||||
ToolTip="{Binding LinkInfo.Text}" IsHitTestVisible="True"/>
|
||||
<controls:RemarkControl Grid.Column="4"/>
|
||||
<controls:TagControl Grid.Column="5"/>
|
||||
</Grid>
|
||||
|
||||
@@ -625,12 +625,12 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
private void ExecuteAddLinkCommand(object obj)
|
||||
{
|
||||
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.LinkInfo = new LinkInfo() { Url = "https://naotu.baidu.com", Text = "https://naotu.baidu.com" });
|
||||
}
|
||||
|
||||
private void ExecuteRemoveLinkCommand(object obj)
|
||||
{
|
||||
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.LinkInfo = null);
|
||||
}
|
||||
|
||||
private void ExecuteAddImageCommand(object obj)
|
||||
@@ -667,7 +667,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
private void ExecuteAddRatioCommand(object obj)
|
||||
{
|
||||
|
||||
if (double.TryParse(obj.ToString(), out var rate))
|
||||
{
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.Rate = rate);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.Rate = null);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteAddTagCommand(object obj)
|
||||
|
||||
Reference in New Issue
Block a user