2024-10-22 00:13:13 +08:00
|
|
|
|
using Serein.Library;
|
|
|
|
|
|
using Serein.Library.Api;
|
2024-10-15 21:56:09 +08:00
|
|
|
|
using Serein.Workbench.Node.ViewModel;
|
2024-10-23 19:22:27 +08:00
|
|
|
|
using System.Windows;
|
2024-08-05 10:11:58 +08:00
|
|
|
|
using System.Windows.Controls;
|
2024-10-23 19:22:27 +08:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows.Input;
|
2024-08-05 10:11:58 +08:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
namespace Serein.Workbench.Node.View
|
2024-08-05 10:11:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 节点控件基类(控件)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class NodeControlBase : UserControl, IDynamicFlowNode
|
|
|
|
|
|
{
|
2024-09-12 20:32:54 +08:00
|
|
|
|
public NodeControlViewModelBase ViewModel { get; set; }
|
|
|
|
|
|
|
2024-10-23 19:22:27 +08:00
|
|
|
|
|
2024-08-05 10:11:58 +08:00
|
|
|
|
protected NodeControlBase()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Background = Brushes.Transparent;
|
|
|
|
|
|
}
|
2024-09-12 20:32:54 +08:00
|
|
|
|
protected NodeControlBase(NodeControlViewModelBase viewModelBase)
|
2024-08-05 10:11:58 +08:00
|
|
|
|
{
|
2024-09-12 20:32:54 +08:00
|
|
|
|
ViewModel = viewModelBase;
|
2024-08-05 19:43:57 +08:00
|
|
|
|
this.Background = Brushes.Transparent;
|
2024-10-22 00:13:13 +08:00
|
|
|
|
this.DataContext = viewModelBase;
|
2024-10-23 19:22:27 +08:00
|
|
|
|
SetBinding();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void SetBinding()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 绑定 Canvas.Left
|
|
|
|
|
|
Binding leftBinding = new Binding("X")
|
|
|
|
|
|
{
|
|
|
|
|
|
Source = ViewModel.NodeModel.Position, // 如果 X 属性在当前 DataContext 中
|
|
|
|
|
|
Mode = BindingMode.TwoWay
|
|
|
|
|
|
};
|
|
|
|
|
|
BindingOperations.SetBinding(this, Canvas.LeftProperty, leftBinding);
|
|
|
|
|
|
|
|
|
|
|
|
// 绑定 Canvas.Top
|
|
|
|
|
|
Binding topBinding = new Binding("Y")
|
|
|
|
|
|
{
|
|
|
|
|
|
Source = ViewModel.NodeModel.Position, // 如果 Y 属性在当前 DataContext 中
|
|
|
|
|
|
Mode = BindingMode.TwoWay
|
|
|
|
|
|
};
|
|
|
|
|
|
BindingOperations.SetBinding(this, Canvas.TopProperty, topBinding);
|
2024-08-05 10:11:58 +08:00
|
|
|
|
}
|
2024-10-23 19:22:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-05 10:11:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
|
|
|
|
|
|
//public class FLowNodeObObservableCollection<T> : ObservableCollection<T>
|
|
|
|
|
|
//{
|
2024-08-05 10:11:58 +08:00
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
// public void AddRange(IEnumerable<T> items)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// foreach (var item in items)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// this.Items.Add(item);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add));
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
2024-08-05 10:11:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|