mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
重写了节点的view、viewmodel关系,实现了对画布元素的选取功能,重构了底层依赖,添加了对net .Framework4.6.1以上的Framework类库支持
This commit is contained in:
@@ -10,16 +10,10 @@ namespace Serein.WorkBench.Node.View
|
||||
/// </summary>
|
||||
public partial class ActionNodeControl : NodeControlBase
|
||||
{
|
||||
private readonly ActionNodeControlViewModel actionNodeControlViewModel;
|
||||
public ActionNodeControl(SingleActionNode node) : base(node)
|
||||
public ActionNodeControl(ActionNodeControlViewModel viewModel):base(viewModel)
|
||||
{
|
||||
Node = node;
|
||||
actionNodeControlViewModel = new ActionNodeControlViewModel(node);
|
||||
DataContext = actionNodeControlViewModel;
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,21 @@ namespace Serein.WorkBench.Node.View
|
||||
{
|
||||
private Point _dragStartPoint;
|
||||
|
||||
private new readonly CompositeActionNode Node;
|
||||
//private new readonly CompositeActionNode Node;
|
||||
|
||||
public ActionRegionControl() : base()
|
||||
//public override NodeControlViewModel ViewModel { get ; set ; }
|
||||
|
||||
public ActionRegionControl() : base(null)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public ActionRegionControl(CompositeActionNode node) : base(node)
|
||||
{
|
||||
InitializeComponent();
|
||||
Node = node;
|
||||
base.Name = "动作组合节点";
|
||||
}
|
||||
//public ActionRegionControl(CompositeActionNode node)
|
||||
//{
|
||||
// InitializeComponent();
|
||||
// //ViewModel = new NodeControlViewModel(node);
|
||||
// DataContext = ViewModel;
|
||||
// base.Name = "动作组合节点";
|
||||
//}
|
||||
|
||||
public void AddAction(NodeControlBase node, bool isTask = false)
|
||||
{
|
||||
@@ -34,8 +37,8 @@ namespace Serein.WorkBench.Node.View
|
||||
Margin = new Thickness(10, 2, 0, 0),
|
||||
Tag = node.MethodDetails,
|
||||
};*/
|
||||
Node?.AddNode((SingleActionNode)node.Node);
|
||||
ActionsListBox.Items.Add(node);
|
||||
/// Node?.AddNode((SingleActionNode)node.ViewModel.Node);
|
||||
// ActionsListBox.Items.Add(node);
|
||||
}
|
||||
|
||||
/* public async Task ExecuteActions(DynamicContext context)
|
||||
|
||||
@@ -8,24 +8,19 @@ namespace Serein.WorkBench.Node.View
|
||||
/// </summary>
|
||||
public partial class ConditionNodeControl : NodeControlBase
|
||||
{
|
||||
public ConditionNodeControlViewModel ViewModel { get; }
|
||||
|
||||
public ConditionNodeControl() : base()
|
||||
{
|
||||
|
||||
ViewModel = new (new ());
|
||||
// 窗体初始化需要
|
||||
ViewModel = new ConditionNodeControlViewModel (new SingleConditionNode());
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ConditionNodeControl(SingleConditionNode node) : base(node)
|
||||
public ConditionNodeControl(ConditionNodeControlViewModel viewModel):base(viewModel)
|
||||
{
|
||||
Node = node;
|
||||
ViewModel = new ConditionNodeControlViewModel(node);
|
||||
DataContext = ViewModel;
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,9 @@
|
||||
xmlns:local="clr-namespace:Serein.WorkBench.Node.View"
|
||||
MaxWidth="300">
|
||||
<Grid>
|
||||
|
||||
<Border BorderBrush="Black" BorderThickness="1" Padding="10">
|
||||
<StackPanel>
|
||||
<DockPanel Margin="2,2,2,5">
|
||||
<!--<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>-->
|
||||
<TextBlock Text="条件区域" FontWeight="Bold" HorizontalAlignment="Left" FontSize="14" Margin="0,1,0,0"/>
|
||||
<Button Content="编辑" FontWeight="Bold" HorizontalAlignment="Right"/>
|
||||
</DockPanel>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Serein.NodeFlow.Model;
|
||||
using Serein.WorkBench.Node.ViewModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
@@ -12,26 +13,29 @@ namespace Serein.WorkBench.Node.View
|
||||
public partial class ConditionRegionControl : NodeControlBase
|
||||
{
|
||||
private Point _dragStartPoint;
|
||||
|
||||
public ConditionRegionControl() : base()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ConditionRegionControl(CompositeConditionNode node) : base(node)
|
||||
public ConditionRegionControl(ConditionRegionNodeControlViewModel viewModel) : base(viewModel)
|
||||
{
|
||||
Node = node;
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加条件控件
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
public void AddCondition(NodeControlBase node)
|
||||
{
|
||||
((CompositeConditionNode)Node).AddNode((SingleConditionNode)node.Node);
|
||||
((CompositeConditionNode)ViewModel.Node).AddNode((SingleConditionNode)node.ViewModel.Node);
|
||||
|
||||
this.Width += node.Width;
|
||||
this.Height += node.Height;
|
||||
@@ -46,27 +50,27 @@ namespace Serein.WorkBench.Node.View
|
||||
}
|
||||
|
||||
// Mouse event handlers for dragging
|
||||
private void TypeText_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_dragStartPoint = e.GetPosition(null);
|
||||
}
|
||||
//private void TypeText_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
//{
|
||||
// _dragStartPoint = e.GetPosition(null);
|
||||
//}
|
||||
|
||||
private void TypeText_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
Point mousePos = e.GetPosition(null);
|
||||
Vector diff = _dragStartPoint - mousePos;
|
||||
//private void TypeText_MouseMove(object sender, MouseEventArgs e)
|
||||
//{
|
||||
// Point mousePos = e.GetPosition(null);
|
||||
// Vector diff = _dragStartPoint - mousePos;
|
||||
|
||||
if (e.LeftButton == MouseButtonState.Pressed &&
|
||||
(Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
|
||||
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
|
||||
{
|
||||
if (sender is TextBlock typeText)
|
||||
{
|
||||
var dragData = new DataObject(MouseNodeType.RegionType, typeText.Tag);
|
||||
DragDrop.DoDragDrop(typeText, dragData, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (e.LeftButton == MouseButtonState.Pressed &&
|
||||
// (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
|
||||
// Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
|
||||
// {
|
||||
// if (sender is TextBlock typeText)
|
||||
// {
|
||||
// var dragData = new DataObject(MouseNodeType.RegionType, typeText.Tag);
|
||||
// DragDrop.DoDragDrop(typeText, dragData, DragDropEffects.Move);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -86,8 +90,7 @@ namespace Serein.WorkBench.Node.View
|
||||
DragDrop.DoDragDrop(typeText, dragData, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,17 @@ namespace Serein.WorkBench.Node.View
|
||||
/// </summary>
|
||||
public partial class ExpOpNodeControl : NodeControlBase
|
||||
{
|
||||
public ExpOpNodeViewModel ViewModel { get; }
|
||||
|
||||
public ExpOpNodeControl()
|
||||
public ExpOpNodeControl() : base()
|
||||
{
|
||||
ViewModel = new (new());
|
||||
// 窗体初始化需要
|
||||
ViewModel = new ExpOpNodeViewModel(new SingleExpOpNode());
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
public ExpOpNodeControl(SingleExpOpNode node):base(node)
|
||||
public ExpOpNodeControl(ExpOpNodeViewModel viewModel) :base(viewModel)
|
||||
{
|
||||
Node = node;
|
||||
ViewModel = new(node);
|
||||
DataContext = ViewModel;
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,31 +8,10 @@ namespace Serein.WorkBench.Node.View
|
||||
/// </summary>
|
||||
public partial class FlipflopNodeControl : NodeControlBase
|
||||
{
|
||||
private readonly FlipflopNodeControlViewModel viewModel;
|
||||
|
||||
public FlipflopNodeControl(SingleFlipflopNode node) : base(node)
|
||||
public FlipflopNodeControl(FlipflopNodeControlViewModel viewModel) : base(viewModel)
|
||||
{
|
||||
Node = node;
|
||||
viewModel = new FlipflopNodeControlViewModel(node);
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
//private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
//{
|
||||
// var comboBox = sender as ComboBox;
|
||||
// if (comboBox == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// var selectedExplicitData = comboBox.DataContext as ExplicitData;
|
||||
// if (selectedExplicitData == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Console.WriteLine (selectedExplicitData.DataValue, "Selected Value");
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,27 +15,42 @@ namespace Serein.WorkBench.Node.View
|
||||
/// </summary>
|
||||
public abstract class NodeControlBase : UserControl, IDynamicFlowNode
|
||||
{
|
||||
public NodeBase Node { get; set; }
|
||||
public NodeControlViewModelBase ViewModel { get; set; }
|
||||
|
||||
|
||||
protected NodeControlBase()
|
||||
|
||||
{
|
||||
this.Background = Brushes.Transparent;
|
||||
}
|
||||
protected NodeControlBase(NodeBase node)
|
||||
protected NodeControlBase(NodeControlViewModelBase viewModelBase)
|
||||
{
|
||||
ViewModel = viewModelBase;
|
||||
this.Background = Brushes.Transparent;
|
||||
Node = node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract class NodeControlViewModel : INotifyPropertyChanged
|
||||
public abstract class NodeControlViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public NodeControlViewModelBase(NodeBase node)
|
||||
{
|
||||
this.Node = node;
|
||||
MethodDetails = this.Node.MethodDetails;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对应的节点实体类
|
||||
/// </summary>
|
||||
public NodeBase Node { get; set; }
|
||||
|
||||
public MethodDetails methodDetails;
|
||||
/// <summary>
|
||||
/// 表示节点控件是否被选中
|
||||
/// </summary>
|
||||
public bool IsSelect { get; set; } = false;
|
||||
|
||||
private MethodDetails methodDetails;
|
||||
|
||||
|
||||
public MethodDetails MethodDetails
|
||||
|
||||
Reference in New Issue
Block a user