连接点可以添加文字

This commit is contained in:
艾竹
2023-01-22 21:46:59 +08:00
parent ad227aee0c
commit 4c37fb9772
16 changed files with 371 additions and 122 deletions

View File

@@ -18,14 +18,14 @@ namespace AIStudio.Wpf.DiagramDesigner
/// </summary>
public partial class TextControl : UserControl
{
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
"DoubleEdit", typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(
public static readonly DependencyProperty DoubleEditProperty = DependencyProperty.Register(
nameof(DoubleEdit), typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(
true));
public bool DoubleEdit
{
get => (bool)GetValue(TextProperty);
set => SetValue(TextProperty, value);
get => (bool)GetValue(DoubleEditProperty);
set => SetValue(DoubleEditProperty, value);
}
public TextControl()
@@ -48,7 +48,10 @@ namespace AIStudio.Wpf.DiagramDesigner
PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
}
(this.DataContext as SelectableDesignerItemViewModelBase).PropertyChanged += TextControl_PropertyChanged;
if (this.DataContext is ISelectable selectable)
{
selectable.PropertyChanged += TextControl_PropertyChanged;
}
TextControl_PropertyChanged(this.DataContext, new System.ComponentModel.PropertyChangedEventArgs("IsSelected"));
}
@@ -56,9 +59,9 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (e.PropertyName == "IsSelected")
{
if (sender is SelectableDesignerItemViewModelBase itemViewModelBase)
if (sender is ISelectable selectable)
{
if (itemViewModelBase.IsSelected == false)
if (selectable.IsSelected == false)
{
PART_ShowText.Visibility = Visibility.Collapsed;
PART_TextBlock.Visibility = Visibility.Visible;