覆盖默认定义

This commit is contained in:
艾竹
2023-01-27 21:29:42 +08:00
parent 6d1960a8df
commit 4feddf8392
14 changed files with 271 additions and 93 deletions

View File

@@ -22,6 +22,36 @@ namespace AIStudio.Wpf.DiagramDesigner
public DiagramControl()
{
InitializeComponent();
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);
}
}
public static readonly DependencyProperty ZoomValueProperty = DependencyProperty.Register(nameof(ZoomValue), typeof(double), typeof(DiagramControl), new UIPropertyMetadata(1d));
@@ -42,6 +72,8 @@ namespace AIStudio.Wpf.DiagramDesigner
{
//DesignerCanvas myDesignerCanvas = sender as DesignerCanvas;
//zoomBox.DesignerCanvas = myDesignerCanvas;
}
private async void ScaleTransform_Changed(object sender, EventArgs e)