mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
mind
This commit is contained in:
30
AIStudio.Wpf.DiagramDesigner/Converters/ObjectConverter.cs
Normal file
30
AIStudio.Wpf.DiagramDesigner/Converters/ObjectConverter.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// CommandParameter 多参数传递
|
||||
/// </summary>
|
||||
public class ObjectConverter : IMultiValueConverter
|
||||
{
|
||||
#region IMultiValueConverter Members
|
||||
|
||||
public object Convert(object[] values, Type targetType,
|
||||
object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return values?.ToArray();
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes,
|
||||
object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
<ResourceDictionary>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
|
||||
<dd:ObjectConverter x:Key="ObjectConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -119,7 +120,22 @@
|
||||
</StackPanel>
|
||||
</controls:DropDownButton.Content>
|
||||
<controls:DropDownButton.Items>
|
||||
<MenuItem Header="插入链接" Command="{Binding AddLinkCommand}"></MenuItem>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="链接地址:"></TextBlock>
|
||||
<TextBox x:Name="link" Width="300" Text="{Binding SelectedItem.LinkInfo.Link}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="提示文本:"></TextBlock>
|
||||
<TextBox x:Name="linktext" Width="300" Text="{Binding SelectedItem.LinkInfo.Text}"/>
|
||||
</StackPanel>
|
||||
<MenuItem Header="插入链接" Command="{Binding AddLinkCommand}">
|
||||
<MenuItem.CommandParameter>
|
||||
<MultiBinding Converter="{StaticResource ObjectConverter}">
|
||||
<Binding ElementName="link" Path="Text"></Binding>
|
||||
<Binding ElementName="linktext" Path="Text"></Binding>
|
||||
</MultiBinding>
|
||||
</MenuItem.CommandParameter>
|
||||
</MenuItem>
|
||||
<MenuItem Header="移除已有链接" Command="{Binding RemoveLinkCommand}"></MenuItem>
|
||||
</controls:DropDownButton.Items>
|
||||
</controls:DropDownButton>
|
||||
@@ -131,7 +147,22 @@
|
||||
</StackPanel>
|
||||
</controls:DropDownButton.Content>
|
||||
<controls:DropDownButton.Items>
|
||||
<MenuItem Header="插入图片" Command="{Binding AddImageCommand}"></MenuItem>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="文件地址:"></TextBlock>
|
||||
<TextBox x:Name="imageurl" Width="300" Text="{Binding SelectedItem.ImageInfo.Url}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="提示文本:"></TextBlock>
|
||||
<TextBox x:Name="imagetext" Width="300" Text="{Binding SelectedItem.ImageInfo.Text}"/>
|
||||
</StackPanel>
|
||||
<MenuItem Header="插入图片" Command="{Binding AddImageCommand}">
|
||||
<MenuItem.CommandParameter>
|
||||
<MultiBinding Converter="{StaticResource ObjectConverter}">
|
||||
<Binding ElementName="imageurl" Path="Text"></Binding>
|
||||
<Binding ElementName="imagetext" Path="Text"></Binding>
|
||||
</MultiBinding>
|
||||
</MenuItem.CommandParameter>
|
||||
</MenuItem>
|
||||
<MenuItem Header="移除已有图片" Command="{Binding RemoveImageCommand}"></MenuItem>
|
||||
</controls:DropDownButton.Items>
|
||||
</controls:DropDownButton>
|
||||
@@ -457,19 +488,19 @@
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.RowSpan="2" Style="{StaticResource FlatButtonStyle}" Command="{Binding AddChildCommand}">
|
||||
<Button Grid.RowSpan="2" Style="{StaticResource FlatButtonStyle}" >
|
||||
<StackPanel>
|
||||
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M719.329882 422.249412l-255.578353 255.578353 234.315295 234.315294 255.518117-255.638588-234.315294-234.255059zM59.151059 315.813647l298.164706-298.164706a60.235294 60.235294 0 0 1 85.172706 0l596.329411 596.329412a60.235294 60.235294 0 0 1 0 85.172706l-298.164706 298.164706a60.235294 60.235294 0 0 1-85.232941 0l-596.329411-596.329412a60.235294 60.235294 0 0 1 0-85.172706z"></Path>
|
||||
<TextBlock>清除样式</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Grid.Column="1" Style="{StaticResource FlatButtonStyle}" Command="{Binding AddChildCommand}">
|
||||
<Button Grid.Column="1" Style="{StaticResource FlatButtonStyle}" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M701.248 177.6l175.104-113.024 83.456 114.88-131.136 162.304-127.424-164.16z m-133.376-61.568c51.264 6.976 300.608 346.624 294.272 384.704s-145.536 143.68-145.536 143.68L400.64 238.592s116.032-129.6 167.232-122.56zM370.368 288.448l305.024 396.672-187.136 272L65.664 359.04s83.776-3.84 153.536-24.32c45.632-13.504 151.232-46.272 151.168-46.272z"></Path>
|
||||
<TextBlock>复制样式</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Grid.Column="1" Grid.Row="1" Style="{StaticResource FlatButtonStyle}" Command="{Binding AddChildCommand}">
|
||||
<Button Grid.Column="1" Grid.Row="1" Style="{StaticResource FlatButtonStyle}" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M411.880727 905.169455v-279.272728h149.876364v279.272728z m54.272-279.645091v-124.881455h412.904728V325.771636h-64.605091v116.363637h-698.181819v-279.272728h698.181819v116.363637h111.104v268.055273h-412.904728v78.289454z"></Path>
|
||||
<TextBlock>粘贴样式</TextBlock>
|
||||
@@ -609,7 +640,7 @@
|
||||
|
||||
</StackPanel>
|
||||
<Line Grid.Column="4" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
|
||||
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="5" Command="{Binding AddChildCommand}">
|
||||
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="5" >
|
||||
<StackPanel>
|
||||
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M911.958045 890.721335l-241.415018-246.54112a336.369964 336.369964 0 1 0-58.095828 45.158522l247.029321 252.643623a36.859118 36.859118 0 0 0 51.749225 0 37.103218 37.103218 0 0 0 0.7323-51.261025zM176.240286 404.473897a261.431228 261.431228 0 1 1 261.431228 261.431228A261.675328 261.675328 0 0 1 176.240286 404.473897z"></Path>
|
||||
<TextBlock>搜索</TextBlock>
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="image" Source="{Binding Icon}" Stretch="Fill" Width="64" Height="64" Visibility="Collapsed" IsHitTestVisible="False"/>
|
||||
<Image x:Name="image" Source="{Binding ImageInfo.Url}" Stretch="Fill" Width="128" Height="128" Visibility="{Binding ImageInfo.Url,FallbackValue='',Converter={StaticResource NullableToVisibilityConverter}}" IsHitTestVisible="False"/>
|
||||
<Grid Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
@@ -87,8 +87,8 @@
|
||||
IsHitTestVisible="False"/>
|
||||
<dd:TextControl Grid.Column="2" IsHitTestVisible="{Binding IsEditing}"/>
|
||||
<controls:LinkControl Grid.Column="3"
|
||||
Visibility="{Binding LinkInfo,Converter={StaticResource NullableToVisibilityConverter}}"
|
||||
Url="{Binding LinkInfo.Url}"
|
||||
Visibility="{Binding LinkInfo.Link,FallbackValue='',Converter={StaticResource NullableToVisibilityConverter}}"
|
||||
Url="{Binding LinkInfo.Link}"
|
||||
ToolTip="{Binding LinkInfo.Text}" />
|
||||
<controls:RemarkControl Grid.Column="4"
|
||||
Visibility="{Binding Remark,Converter={StaticResource NullableToVisibilityConverter}}"
|
||||
|
||||
@@ -634,12 +634,28 @@ 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" });
|
||||
if (obj is object[] array && array.Length == 2)
|
||||
{
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p =>
|
||||
{
|
||||
if (p.LinkInfo == null)
|
||||
p.LinkInfo = new LinkInfo();
|
||||
|
||||
p.LinkInfo.Link = array[0]?.ToString();
|
||||
p.LinkInfo.Text = array[1]?.ToString();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteRemoveLinkCommand(object obj)
|
||||
{
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p => p.LinkInfo = null);
|
||||
SelectedItems.OfType<MindNode>().ToList().ForEach(p => {
|
||||
if (p.LinkInfo != null)
|
||||
{
|
||||
p.LinkInfo.Link = null; p.LinkInfo.Text = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ExecuteAddImageCommand(object obj)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -227,7 +228,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
#endregion
|
||||
|
||||
#region 附加信息属性
|
||||
private LinkInfo _linkInfo;
|
||||
private LinkInfo _linkInfo = new LinkInfo();
|
||||
public LinkInfo LinkInfo
|
||||
{
|
||||
get
|
||||
@@ -236,11 +237,19 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_linkInfo != null)
|
||||
{
|
||||
_linkInfo.PropertyChanged -= Item_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _linkInfo, value);
|
||||
if (_linkInfo != null)
|
||||
{
|
||||
_linkInfo.PropertyChanged += Item_PropertyChanged; ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ImageInfo _imageInfo;
|
||||
private ImageInfo _imageInfo = new ImageInfo();
|
||||
public ImageInfo ImageInfo
|
||||
{
|
||||
get
|
||||
@@ -249,7 +258,15 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_imageInfo != null)
|
||||
{
|
||||
_imageInfo.PropertyChanged -= Item_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _imageInfo, value);
|
||||
if (_imageInfo != null)
|
||||
{
|
||||
_imageInfo.PropertyChanged += Item_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,24 +521,25 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
break;
|
||||
}
|
||||
case nameof(Rate):
|
||||
case nameof(Priority):
|
||||
case nameof(LinkInfo):
|
||||
case nameof(Priority):
|
||||
case nameof(Remark):
|
||||
case nameof(LinkInfo.Link):
|
||||
{
|
||||
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
||||
{
|
||||
if (valuePropertyChangedEventArgs.OldValue == null && valuePropertyChangedEventArgs.NewValue != null)
|
||||
if (string.IsNullOrEmpty(valuePropertyChangedEventArgs.OldValue?.ToString()) && !string.IsNullOrEmpty(valuePropertyChangedEventArgs.NewValue?.ToString()))
|
||||
{
|
||||
ItemWidth += 24;
|
||||
}
|
||||
else if (valuePropertyChangedEventArgs.OldValue != null && valuePropertyChangedEventArgs.NewValue == null)
|
||||
else if (!string.IsNullOrEmpty(valuePropertyChangedEventArgs.OldValue?.ToString()) && string.IsNullOrEmpty(valuePropertyChangedEventArgs.NewValue?.ToString()))
|
||||
{
|
||||
ItemWidth -= 24;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case nameof(ImageInfo.Url):
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,16 +592,16 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
public class LinkInfo : BindableBase
|
||||
{
|
||||
private string _url;
|
||||
public string Url
|
||||
private string _link;
|
||||
public string Link
|
||||
{
|
||||
get
|
||||
{
|
||||
return _url;
|
||||
return _link;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _url, value);
|
||||
SetProperty(ref _link, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user