mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
整理整理
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Commands;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Models;
|
||||
using System.Windows.Input;
|
||||
using ZXing;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class BarcodeDesignerItemData : TitleBindableBase
|
||||
{
|
||||
public BarcodeDesignerItemData()
|
||||
{
|
||||
|
||||
}
|
||||
public BarcodeDesignerItemData(BarcodeDesignerItemViewModel item)
|
||||
{
|
||||
this.Title = "二维码";
|
||||
this.Text = item.Text;
|
||||
this.Icon = item.Icon;
|
||||
this.Margin = item.Margin;
|
||||
this.Format = item.Format;
|
||||
}
|
||||
|
||||
public BarcodeFormat Format { get; set; }
|
||||
|
||||
private string _text;
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _text, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _margin;
|
||||
|
||||
public double Margin
|
||||
{
|
||||
get
|
||||
{
|
||||
return _margin;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _margin, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _icon;
|
||||
public string Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _icon, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _iploadCommand;
|
||||
public ICommand UploadCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._iploadCommand ?? (this._iploadCommand = new DelegateCommand(() => this.Upload()));
|
||||
}
|
||||
}
|
||||
|
||||
private void Upload()
|
||||
{
|
||||
Microsoft.Win32.OpenFileDialog openFile = new Microsoft.Win32.OpenFileDialog();
|
||||
openFile.Filter = "图片|*.bmp;*.jpg;*.jpeg;*.gif;*.png";
|
||||
|
||||
if (openFile.ShowDialog() == true)
|
||||
{
|
||||
Icon = openFile.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner.Services;
|
||||
using ZXing;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class BarcodeDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
private IUIVisualizerService visualiserService;
|
||||
|
||||
public BarcodeDesignerItemViewModel() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BarcodeDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BarcodeDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new DesignerItemBase(this, Format.ToString());
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
||||
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is DesignerItemBase designer)
|
||||
{
|
||||
Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), designer.Reserve.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void AutoSize()
|
||||
{
|
||||
ItemWidth = 140;
|
||||
ItemHeight = 140;
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
EditData();
|
||||
}
|
||||
|
||||
public override bool InitData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Icon))
|
||||
return EditData();
|
||||
return true;
|
||||
}
|
||||
|
||||
public BarcodeFormat Format { get; set; } = BarcodeFormat.QR_CODE;
|
||||
|
||||
private bool _showText;
|
||||
public override bool ShowText
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _showText, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool EditData()
|
||||
{
|
||||
if (IsReadOnly == true) return false;
|
||||
|
||||
BarcodeDesignerItemData data = new BarcodeDesignerItemData(this);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
bool needauto = Text == null;
|
||||
Text = data.Text;
|
||||
Icon = data.Icon;
|
||||
Margin = data.Margin;
|
||||
if (needauto)
|
||||
{
|
||||
AutoSize();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Converters"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Controls"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:Fluent="urn:fluent-ribbon"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||
|
||||
<dd:BoolVisibilityConverter x:Key="BoolVisibilityConverter"/>
|
||||
<converter:DoubleToThickness x:Key="DoubleToThickness"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:BarcodeDesignerItemViewModel}">
|
||||
<Viewbox Stretch="Fill" IsHitTestVisible="False">
|
||||
<controls:Barcode Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" Padding="{Binding Margin,Converter={StaticResource DoubleToThickness}}" Text="{Binding Text}" Icon="{Binding Icon}" Format="{Binding Format}"/>
|
||||
</Viewbox>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- DataTemplate for Popup look and feel -->
|
||||
<DataTemplate DataType="{x:Type viewmodel:BarcodeDesignerItemData}">
|
||||
<Grid Width="550">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0"
|
||||
Content="网页链接"
|
||||
Margin="5" />
|
||||
<DockPanel Grid.Row="1" >
|
||||
<Border BorderThickness="1" BorderBrush="Black" Margin="5" DockPanel.Dock="Right">
|
||||
<controls:Barcode Text="{Binding Text}" Icon="{Binding Icon}" Format="{Binding Format}" Width="140" Height="140" Padding="{Binding Margin,Converter={StaticResource DoubleToThickness}}" />
|
||||
</Border>
|
||||
<TextBox Text="{Binding Text,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" DockPanel.Dock="Left" Margin="5"/>
|
||||
</DockPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<TextBlock Text="边界:" Margin="5" HorizontalAlignment="Center"/>
|
||||
<Fluent:Spinner Margin="5" DockPanel.Dock="Right" Width="60" Size="Small" Value="{Binding Margin}" Maximum="25" Minimum="0" Format="0 px" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Margin="5,5,50,5" Content="上传Logo" Command="{Binding UploadCommand}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,48 @@
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class OutLineTextDesignerItemData : TitleBindableBase
|
||||
{
|
||||
public OutLineTextDesignerItemData()
|
||||
{
|
||||
|
||||
}
|
||||
public OutLineTextDesignerItemData(OutLineTextDesignerItemViewModel item)
|
||||
{
|
||||
this.Title = "矢量文本";
|
||||
this.Text = item.Text;
|
||||
this.FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(item.FontViewModel);
|
||||
}
|
||||
|
||||
private IFontViewModel _fontViewModel;
|
||||
public IFontViewModel FontViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _fontViewModel, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _text;
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _text, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner.Services;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class OutLineTextDesignerItemViewModel : TextDesignerItemViewModel
|
||||
{
|
||||
private IUIVisualizerService visualiserService;
|
||||
public OutLineTextDesignerItemViewModel() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public OutLineTextDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public OutLineTextDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new TextDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
||||
|
||||
FontViewModel.FontFamily = "Arial";
|
||||
FontViewModel.FontSize = 36;
|
||||
}
|
||||
|
||||
public void AutoSize()
|
||||
{
|
||||
var size = MeasureString();
|
||||
ItemWidth = size.Width;
|
||||
ItemHeight = size.Height;
|
||||
}
|
||||
|
||||
private Size MeasureString()
|
||||
{
|
||||
var formattedText = new FormattedText(
|
||||
Text,
|
||||
CultureInfo.CurrentUICulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(new FontFamily(FontViewModel.FontFamily), FontViewModel.FontStyle, FontViewModel.FontWeight, FontViewModel.FontStretch),
|
||||
FontViewModel.FontSize,
|
||||
Brushes.Black);
|
||||
|
||||
return new Size(formattedText.Width, formattedText.Height);
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
EditData();
|
||||
}
|
||||
|
||||
public override bool InitData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
return EditData();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool EditData()
|
||||
{
|
||||
if (IsReadOnly == true) return false;
|
||||
|
||||
OutLineTextDesignerItemData data = new OutLineTextDesignerItemData(this);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
Text = data.Text;
|
||||
FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(data.FontViewModel);
|
||||
AutoSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Controls"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:Fluent="urn:fluent-ribbon"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||
|
||||
<dd:BoolVisibilityConverter x:Key="BoolVisibilityConverter"/>
|
||||
<dd:DoubleToThickness x:Key="DoubleToThickness"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:OutLineTextDesignerItemViewModel}">
|
||||
<Viewbox Stretch="Fill" IsHitTestVisible="False">
|
||||
<controls:OutlineText StrokePosition="Outside"
|
||||
Text="{Binding Text}"
|
||||
FontSize="{Binding FontViewModel.FontSize}"
|
||||
FontFamily="{Binding FontViewModel.FontFamily}"
|
||||
FontWeight="{Binding FontViewModel.FontWeight}"
|
||||
FontStyle="{Binding FontViewModel.FontStyle}"
|
||||
FontStretch="{Binding FontViewModel.FontStretch}"
|
||||
TextDecorations="{Binding FontViewModel.TextDecorations}"
|
||||
Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
StrokeThickness="{Binding ColorViewModel.LineWidth}"
|
||||
Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
|
||||
</Viewbox>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- DataTemplate for Popup look and feel -->
|
||||
<DataTemplate DataType="{x:Type viewmodel:OutLineTextDesignerItemData}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0"
|
||||
Content="添加文本"
|
||||
Margin="5" />
|
||||
<TextBox Grid.Row="1"
|
||||
Text="{Binding Text}"
|
||||
FontSize="{Binding ElementName=comboBoxFontSize,Path=SelectedItem}"
|
||||
FontFamily="{Binding ElementName=comboBoxFontName,Path=SelectedItem}"
|
||||
FontWeight="{Binding ElementName=buttonBold,Path=IsChecked,Converter={dd:ConverterBoolToValueMap Parameter='Regular'}, ConverterParameter='Bold'}"
|
||||
FontStyle="{Binding ElementName=buttonItalic,Path=IsChecked,Converter={dd:ConverterBoolToValueMap Parameter='Normal'}, ConverterParameter='Italic'}"
|
||||
TextDecorations="{Binding ElementName=buttonUnderline,Path=IsChecked,Converter={dd:ConverterBoolToValueMap Parameter='None'}, ConverterParameter='Underline'}"
|
||||
Height="100"
|
||||
Margin="5"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<Fluent:ComboBox x:Name="comboBoxFontName"
|
||||
Margin="5"
|
||||
MinWidth="49"
|
||||
Height="22"
|
||||
BorderBrush="Gainsboro"
|
||||
IsTextSearchEnabled="True"
|
||||
ResizeMode="Vertical"
|
||||
KeyTip="FF"
|
||||
SizeDefinition="Small"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
ItemsSource="{x:Static dd:FontViewModel.FontFamilys}"
|
||||
SelectedItem="{Binding FontViewModel.FontFamily}">
|
||||
<Fluent:ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}"
|
||||
FontFamily="{Binding}" />
|
||||
</DataTemplate>
|
||||
</Fluent:ComboBox.ItemTemplate>
|
||||
</Fluent:ComboBox>
|
||||
<Fluent:ComboBox x:Name="comboBoxFontSize"
|
||||
Margin="5"
|
||||
Width="49"
|
||||
HorizontalAlignment="Left"
|
||||
Height="22"
|
||||
BorderBrush="Gainsboro"
|
||||
IsEditable="True"
|
||||
SizeDefinition="Small"
|
||||
ResizeMode="Vertical"
|
||||
KeyTip="FS"
|
||||
ItemsSource="{x:Static dd:FontViewModel.FontSizes}"
|
||||
SelectedItem="{Binding FontViewModel.FontSize}">
|
||||
<Fluent:ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</Fluent:ComboBox.ItemTemplate>
|
||||
</Fluent:ComboBox>
|
||||
<Fluent:ToggleButton KeyTip="B"
|
||||
x:Name="buttonBold"
|
||||
Icon="pack://application:,,,/AIStudio.Wpf.DiagramDesigner.Additionals;component/Images/Bold.png"
|
||||
HorizontalAlignment="Left"
|
||||
SizeDefinition="Small"
|
||||
IsChecked="{Binding FontViewModel.FontWeight,Converter={dd:ConverterValueMapToBool Parameter='Regular'}, ConverterParameter='Bold'}"/>
|
||||
<Fluent:ToggleButton x:Name="buttonItalic"
|
||||
KeyTip="I"
|
||||
Icon="pack://application:,,,/AIStudio.Wpf.DiagramDesigner.Additionals;component/Images/Italic.png"
|
||||
HorizontalAlignment="Left"
|
||||
SizeDefinition="Small"
|
||||
IsChecked="{Binding FontViewModel.FontStyle,Converter={dd:ConverterValueMapToBool Parameter='Normal'}, ConverterParameter='Italic'}"/>
|
||||
<Fluent:ToggleButton x:Name="buttonUnderline"
|
||||
KeyTip="U"
|
||||
Icon="pack://application:,,,/AIStudio.Wpf.DiagramDesigner.Additionals;component/Images/Underline.png"
|
||||
HorizontalAlignment="Left"
|
||||
SizeDefinition="Small"
|
||||
IsChecked="{Binding FontViewModel.Underline}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class PathItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public PathItemViewModel() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PathItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public PathItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new PathDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
this.ShowConnectors = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels"
|
||||
xmlns:convent="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Converters">
|
||||
<convent:StringPathConverter x:Key="stringPathConverter"/>
|
||||
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
<Brush x:Key="ItemStroke">#FFD69436</Brush>
|
||||
<LinearGradientBrush x:Key="ItemBrush" StartPoint="0,0" EndPoint="0,1">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="#FAFBE9" Offset="0" />
|
||||
<GradientStop Color="Orange" Offset="1" />
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
<Style x:Key="PathItemStyle" TargetType="Path">
|
||||
<!--<Setter Property="Fill" Value="{StaticResource ItemBrush}"/>
|
||||
<Setter Property="Stroke" Value="{StaticResource ItemStroke}"/>-->
|
||||
<Setter Property="Fill" Value="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
|
||||
<Setter Property="Stroke" Value="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"/>
|
||||
<Setter Property="StrokeThickness" Value="1"/>
|
||||
<Setter Property="StrokeLineJoin" Value="Round"/>
|
||||
<Setter Property="Stretch" Value="Fill"/>
|
||||
<Setter Property="IsHitTestVisible" Value="True"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="Data" Value="{Binding Icon,Converter={StaticResource stringPathConverter}}"/>
|
||||
</Style>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:PathItemViewModel}">
|
||||
<Grid>
|
||||
<Path Tag="Process" IsHitTestVisible="False" Style="{StaticResource PathItemStyle}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,33 @@
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the
|
||||
/// ContentControl with the look for this data. This class is also used to allow
|
||||
/// the popup to be cancelled without applying any changes to the calling ViewModel
|
||||
/// whos data will be updated if the PopupWindow.xaml window is closed successfully
|
||||
/// </summary>
|
||||
public class PersistDesignerItemData : TitleBindableBase
|
||||
{
|
||||
|
||||
|
||||
public PersistDesignerItemData(string currentHostUrl)
|
||||
{
|
||||
HostUrl = currentHostUrl;
|
||||
}
|
||||
|
||||
private string _hostUrl = "";
|
||||
public string HostUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _hostUrl;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _hostUrl, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner.Services;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class PersistDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
private IUIVisualizerService visualiserService;
|
||||
|
||||
public PersistDesignerItemViewModel() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PersistDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PersistDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new PersistDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
||||
this.ShowConnectors = false;
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is PersistDesignerItem designer)
|
||||
{
|
||||
this.HostUrl = designer.HostUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string HostUrl { get; set; }
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
PersistDesignerItemData data = new PersistDesignerItemData(HostUrl);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
this.HostUrl = data.HostUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Converters"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Controls"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||
|
||||
<dd:BoolVisibilityConverter x:Key="BoolVisibilityConverter"/>
|
||||
<dd:DoubleToThickness x:Key="DoubleToThickness"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
<ControlTemplate x:Key="infoButtonTemplate" TargetType="Button">
|
||||
<Grid x:Name="grid" Opacity="0.1">
|
||||
<Ellipse Width="16"
|
||||
Height="16"
|
||||
Stroke="Black"
|
||||
StrokeThickness="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Fill="White"/>
|
||||
<Label Content="i"
|
||||
FontWeight="Bold"
|
||||
FontStyle="Italic"
|
||||
HorizontalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
FontSize="12" />
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter TargetName="grid"
|
||||
Property="Opacity"
|
||||
Value="1.0" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
|
||||
</ControlTemplate>
|
||||
|
||||
<!-- DataTemplate for DesignerCanvas look and feel -->
|
||||
<DataTemplate DataType="{x:Type viewmodel:PersistDesignerItemViewModel}">
|
||||
<Grid>
|
||||
<Image IsHitTestVisible="False"
|
||||
Stretch="Fill"
|
||||
Source="/AIStudio.Wpf.DiagramApp;component/Images/Persist.png"
|
||||
Tag="setting" />
|
||||
<Button x:Name="btnSetting" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="5"
|
||||
Template="{StaticResource infoButtonTemplate}"
|
||||
Command="{Binding EditCommand}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- DataTemplate for Popup look and feel -->
|
||||
<DataTemplate DataType="{x:Type viewmodel:PersistDesignerItemData}">
|
||||
<Grid Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Grid.Row="0"
|
||||
Content="HostUrl"
|
||||
Margin="5" />
|
||||
<TextBox Grid.Row="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding HostUrl}"
|
||||
Width="150"
|
||||
Margin="5" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,33 @@
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the
|
||||
/// ContentControl with the look for this data. This class is also used to allow
|
||||
/// the popup to be cancelled without applying any changes to the calling ViewModel
|
||||
/// whos data will be updated if the PopupWindow.xaml window is closed successfully
|
||||
/// </summary>
|
||||
public class SettingsDesignerItemData : TitleBindableBase
|
||||
{
|
||||
|
||||
|
||||
public SettingsDesignerItemData(string currentSetting1)
|
||||
{
|
||||
Setting1 = currentSetting1;
|
||||
}
|
||||
|
||||
private string _setting1 = "";
|
||||
public string Setting1
|
||||
{
|
||||
get
|
||||
{
|
||||
return _setting1;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _setting1, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner.Services;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class SettingsDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
private IUIVisualizerService visualiserService;
|
||||
|
||||
public SettingsDesignerItemViewModel() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SettingsDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SettingsDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new SettingsDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
||||
this.ShowConnectors = false;
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is SettingsDesignerItem designer)
|
||||
{
|
||||
this.Setting = designer.Setting;
|
||||
}
|
||||
}
|
||||
|
||||
public String Setting{ get; set; }
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
SettingsDesignerItemData data = new SettingsDesignerItemData(Setting);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
this.Setting = data.Setting1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Converters"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Controls"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:Fluent="urn:fluent-ribbon"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||
|
||||
<dd:BoolVisibilityConverter x:Key="BoolVisibilityConverter"/>
|
||||
<converter:DoubleToThickness x:Key="DoubleToThickness"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
<ControlTemplate x:Key="infoButtonTemplate" TargetType="Button">
|
||||
<Grid x:Name="grid" Opacity="0.1">
|
||||
<Ellipse Width="16"
|
||||
Height="16"
|
||||
Stroke="Black"
|
||||
StrokeThickness="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Fill="White"/>
|
||||
<Label Content="i"
|
||||
FontWeight="Bold"
|
||||
FontStyle="Italic"
|
||||
HorizontalAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
FontSize="12" />
|
||||
</Grid>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter TargetName="grid"
|
||||
Property="Opacity"
|
||||
Value="1.0" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
|
||||
</ControlTemplate>
|
||||
|
||||
<!-- DataTemplate for DesignerCanvas look and feel -->
|
||||
<DataTemplate DataType="{x:Type viewmodel:SettingsDesignerItemViewModel}">
|
||||
<Grid>
|
||||
<Image IsHitTestVisible="False"
|
||||
Stretch="Fill"
|
||||
Source="/AIStudio.Wpf.DiagramApp;component/Images/Setting.png"
|
||||
Tag="setting" />
|
||||
<Button HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="5"
|
||||
Template="{StaticResource infoButtonTemplate}"
|
||||
Command="{Binding EditCommand}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- DataTemplate for Popup look and feel -->
|
||||
<DataTemplate DataType="{x:Type viewmodel:SettingsDesignerItemData}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Grid.Row="0"
|
||||
Content="Setting1"
|
||||
Margin="5" />
|
||||
<TextBox Grid.Row="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding Setting}"
|
||||
Width="150"
|
||||
Margin="5" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,29 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
public class SvgDesignerItemViewModel: MediaItemViewModel
|
||||
{
|
||||
protected override string Filter { get; set; } = "Svg|*.svg";
|
||||
|
||||
public SvgDesignerItemViewModel() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public SvgDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SvgDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new MediaDesignerItem(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels"
|
||||
xmlns:svg="https://gitee.com/akwkevin/aistudio.-wpf.-test/tree/master/Controls/AIStudio.Wpf.Svg2XamlExtension">
|
||||
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:SvgDesignerItemViewModel}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<svg:PackSvg Width="Auto" Height="Auto" Path="{Binding Icon}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user