支持添加中间节点

This commit is contained in:
艾竹
2023-01-21 22:01:10 +08:00
parent c4ab1a6355
commit 2e396d687b
8 changed files with 249 additions and 219 deletions

View File

@@ -17,40 +17,6 @@ namespace AIStudio.Wpf.DiagramDesigner
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.</param>
/// <returns>True if the value was changed, false if the existing value matched the
/// desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(storage, value))
return false;
if (propertyName == "IsSelected")
{
}
else if (this.ContainsProperty("IsReadOnly"))
{
if (object.Equals(this.GetPropertyValue("IsReadOnly"), true))
return false;
}
var old = storage;
storage = value;
RaisePropertyChanged(propertyName, old, value);
return true;
}
private Dictionary<string, object> _oldDic = new Dictionary<string, object>();
public void SetOldValue<T>(T value, string propertyName, string guid = null)
{
@@ -78,6 +44,44 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.</param>
/// <returns>True if the value was changed, false if the existing value matched the
/// desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(storage, value))
return false;
if (propertyName == "IsSelected")
{
}
else if (this.ContainsProperty("IsReadOnly"))
{
if (object.Equals(this.GetPropertyValue("IsReadOnly"), true))
return false;
}
if (propertyName == "Area")
{
}
var old = storage;
storage = value;
RaisePropertyChanged(propertyName, old, value);
return true;
}
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
@@ -93,11 +97,22 @@ namespace AIStudio.Wpf.DiagramDesigner
/// desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
if (propertyName == "IsSelected")
{
}
else if (this.ContainsProperty("IsReadOnly"))
{
if (object.Equals(this.GetPropertyValue("IsReadOnly"), true))
return false;
}
var old = storage;
storage = value;
onChanged?.Invoke();
RaisePropertyChanged(propertyName);
RaisePropertyChanged(propertyName, old, value);
return true;
}