2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Interaction logic for DiagramControl.xaml
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class DiagramControl : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public DiagramControl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2023-01-27 21:29:42 +08:00
|
|
|
|
|
|
|
|
|
|
if (ResourceDictionary != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Resources.MergedDictionaries.Add(ResourceDictionary);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty ResourceDictionaryProperty = DependencyProperty.Register(nameof(ResourceDictionary), typeof(ResourceDictionary), typeof(DiagramControl), new UIPropertyMetadata(null, OnResourceDictionaryChanged));
|
|
|
|
|
|
|
|
|
|
|
|
private static void OnResourceDictionaryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (d is DiagramControl diagram)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.NewValue is ResourceDictionary dictionary)
|
|
|
|
|
|
{
|
|
|
|
|
|
diagram.Resources.MergedDictionaries.Add(dictionary);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ResourceDictionary ResourceDictionary
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return (ResourceDictionary)GetValue(ResourceDictionaryProperty);
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetValue(ResourceDictionaryProperty, value);
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-04 20:21:18 +08:00
|
|
|
|
private IDiagramViewModel DiagramViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return DataContext as IDiagramViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-12 15:26:58 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|