mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-08 00:46:34 +08:00
重构中day1,写了很多,不知道怎么说清楚
This commit is contained in:
23
Workbench/Views/BaseNodesView.xaml
Normal file
23
Workbench/Views/BaseNodesView.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.BaseNodesView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
xmlns:nodeView="clr-namespace:Serein.Workbench.Node.View"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150" d:DesignWidth="400">
|
||||
<Grid>
|
||||
<!--暂时隐藏基础面板 Visibility="Collapsed" -->
|
||||
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!--<nodeView:NetScriptNodeControl x:Name="NetScriptNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>-->
|
||||
<nodeView:ScriptNodeControl x:Name="ScriptNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:GlobalDataControl x:Name="GlobalDataControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ExpOpNodeControl x:Name="ExpOpNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ConditionNodeControl x:Name="ConditionNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<!--<nodeView:ConditionRegionControl x:Name="ConditionRegionControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>-->
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
57
Workbench/Views/BaseNodesView.xaml.cs
Normal file
57
Workbench/Views/BaseNodesView.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// BaseNodesView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class BaseNodesView : UserControl
|
||||
{
|
||||
public BaseNodesView()
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().BaseNodesViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 基础节点的拖拽放置创建
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BaseNodeControl_PreviewMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is UserControl control)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
// 创建一个 DataObject 用于拖拽操作,并设置拖拽效果
|
||||
var dragData = new DataObject(MouseNodeType.CreateBaseNodeInCanvas, control.GetType());
|
||||
try
|
||||
{
|
||||
DragDrop.DoDragDrop(control, dragData, DragDropEffects.Move);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SereinEnv.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Workbench/Views/FlowCanvasView.xaml
Normal file
121
Workbench/Views/FlowCanvasView.xaml
Normal file
@@ -0,0 +1,121 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.FlowCanvasView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
xmlns:tool="clr-namespace:Serein.Workbench.Tool.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<tool:RightThumbPositionConverter x:Key="RightThumbPositionConverter" />
|
||||
<tool:BottomThumbPositionConverter x:Key="BottomThumbPositionConverter" />
|
||||
<tool:VerticalCenterThumbPositionConverter x:Key="VerticalCenterThumbPositionConverter" />
|
||||
<tool:HorizontalCenterThumbPositionConverter x:Key="HorizontalCenterThumbPositionConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
|
||||
|
||||
<StackPanel x:Name="FlowChartStackPanel"
|
||||
ClipToBounds="True">
|
||||
<!-- 虚拟化 VirtualizingStackPanel.IsVirtualizing="True" -->
|
||||
<Canvas
|
||||
x:Name="FlowChartCanvas"
|
||||
Background="#E1FBEA"
|
||||
AllowDrop="True"
|
||||
Width="1920"
|
||||
Height="1080"
|
||||
MouseLeftButtonDown ="FlowChartCanvas_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="FlowChartCanvas_MouseLeftButtonUp"
|
||||
MouseDown="FlowChartCanvas_MouseDown"
|
||||
MouseUp="FlowChartCanvas_MouseUp"
|
||||
MouseMove="FlowChartCanvas_MouseMove"
|
||||
MouseWheel="FlowChartCanvas_MouseWheel"
|
||||
Drop="FlowChartCanvas_Drop"
|
||||
DragOver="FlowChartCanvas_DragOver"
|
||||
>
|
||||
|
||||
<Rectangle x:Name="SelectionRectangle"
|
||||
Stroke="Blue"
|
||||
StrokeThickness="2"
|
||||
Fill="LightBlue"
|
||||
Opacity="0.2"
|
||||
Panel.ZIndex="999999"
|
||||
Visibility="Collapsed"/>
|
||||
|
||||
<!-- Top-Left Thumb -->
|
||||
<!--<Thumb x:Name="TopLeftThumb"
|
||||
Width="10" Height="10"
|
||||
DragDelta="Thumb_DragDelta_TopLeft"
|
||||
Cursor="SizeNWSE"
|
||||
Canvas.Left="0" Canvas.Top="0"/>-->
|
||||
|
||||
<!-- Top-Right Thumb -->
|
||||
<!--<Thumb x:Name="TopRightThumb"
|
||||
Width="10" Height="10"
|
||||
DragDelta="Thumb_DragDelta_TopRight"
|
||||
Cursor="SizeNESW"
|
||||
Canvas.Left="{Binding ActualWidth, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource RightThumbPositionConverter}}"
|
||||
Canvas.Top="0"/>-->
|
||||
|
||||
<!-- Bottom-Left Thumb -->
|
||||
<!--<Thumb x:Name="BottomLeftThumb"
|
||||
Width="10" Height="10"
|
||||
DragDelta="Thumb_DragDelta_BottomLeft"
|
||||
Cursor="SizeNESW"
|
||||
Canvas.Left="0"
|
||||
Canvas.Top="{Binding ActualHeight, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource BottomThumbPositionConverter}}"/>-->
|
||||
|
||||
<!-- Left Thumb -->
|
||||
<!--<Thumb x:Name="LeftThumb"
|
||||
Width="10" Height="10"
|
||||
DragDelta="Thumb_DragDelta_Left"
|
||||
Cursor="SizeWE"
|
||||
Canvas.Left="0"
|
||||
Canvas.Top="{Binding ActualHeight, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource VerticalCenterThumbPositionConverter}}"/>-->
|
||||
|
||||
<!-- Right Thumb -->
|
||||
|
||||
<!-- Top Thumb -->
|
||||
<!--<Thumb x:Name="TopThumb"
|
||||
Width="10" Height="10"
|
||||
DragDelta="Thumb_DragDelta_Top"
|
||||
Cursor="SizeNS"
|
||||
Canvas.Left="{Binding ActualWidth, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource HorizontalCenterThumbPositionConverter}}"
|
||||
Canvas.Top="0"/>-->
|
||||
|
||||
<!-- Bottom Thumb -->
|
||||
<!-- Bottom-Right Thumb -->
|
||||
<Thumb x:Name="BottomRightThumb"
|
||||
Width="15" Height="15"
|
||||
DragDelta="Thumb_DragDelta_BottomRight"
|
||||
Cursor="SizeNWSE"
|
||||
Canvas.Left="{Binding ActualWidth, Converter={StaticResource RightThumbPositionConverter}, ElementName=FlowChartCanvas, Mode=OneWay}"
|
||||
Canvas.Top="{Binding ActualHeight, Converter={StaticResource BottomThumbPositionConverter}, ElementName=FlowChartCanvas, Mode=OneWay}"/>
|
||||
|
||||
<!--Canvas.Left="{Binding ActualWidth, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource RightThumbPositionConverter}}"
|
||||
Canvas.Top="{Binding ActualHeight, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource VerticalCenterThumbPositionConverter}}"-->
|
||||
<Thumb x:Name="RightThumb" Width="5" Cursor="SizeWE" Canvas.Top="0" Canvas.Right="0" DragDelta="Thumb_DragDelta_Right">
|
||||
<Thumb.Template>
|
||||
<ControlTemplate>
|
||||
<Border Background="#B1B9F8" Width="5" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}" />
|
||||
</ControlTemplate>
|
||||
</Thumb.Template>
|
||||
</Thumb>
|
||||
|
||||
<!--Canvas.Left="{Binding ActualWidth, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource HorizontalCenterThumbPositionConverter}}"
|
||||
Canvas.Top="{Binding ActualHeight, ElementName=FlowChartCanvas, Mode=OneWay, Converter={StaticResource BottomThumbPositionConverter}}"-->
|
||||
<Thumb x:Name="BottomThumb" Height="5" Cursor="SizeNS" Canvas.Bottom="0" Canvas.Left="0" DragDelta="Thumb_DragDelta_Bottom">
|
||||
<Thumb.Template>
|
||||
<ControlTemplate>
|
||||
<Border Background="#B1B9F8" Height="5" Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}" />
|
||||
</ControlTemplate>
|
||||
</Thumb.Template>
|
||||
</Thumb>
|
||||
</Canvas>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
686
Workbench/Views/FlowCanvasView.xaml.cs
Normal file
686
Workbench/Views/FlowCanvasView.xaml.cs
Normal file
@@ -0,0 +1,686 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Workbench.Node.View;
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// FlowCanvasView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowCanvasView : UserControl
|
||||
{
|
||||
private FlowCanvasViewModel ViewModel;
|
||||
/// <summary>
|
||||
/// 存储所有的连接。考虑集成在运行环境中。
|
||||
/// </summary>
|
||||
private List<ConnectionControl> Connections { get; } = [];
|
||||
|
||||
#region 与画布相关的字段
|
||||
|
||||
/// <summary>
|
||||
/// 标记是否正在尝试选取控件
|
||||
/// </summary>
|
||||
private bool IsSelectControl;
|
||||
/// <summary>
|
||||
/// 标记是否正在进行连接操作
|
||||
/// </summary>
|
||||
//private bool IsConnecting;
|
||||
/// <summary>
|
||||
/// 标记是否正在拖动控件
|
||||
/// </summary>
|
||||
private bool IsControlDragging;
|
||||
/// <summary>
|
||||
/// 标记是否正在拖动画布
|
||||
/// </summary>
|
||||
private bool IsCanvasDragging;
|
||||
private bool IsSelectDragging;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选取的控件
|
||||
/// </summary>
|
||||
private readonly List<NodeControlBase> selectNodeControls = [];
|
||||
|
||||
/// <summary>
|
||||
/// 记录开始拖动节点控件时的鼠标位置
|
||||
/// </summary>
|
||||
private Point startControlDragPoint;
|
||||
/// <summary>
|
||||
/// 记录移动画布开始时的鼠标位置
|
||||
/// </summary>
|
||||
private Point startCanvasDragPoint;
|
||||
/// <summary>
|
||||
/// 记录开始选取节点控件时的鼠标位置
|
||||
/// </summary>
|
||||
private Point startSelectControolPoint;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 记录开始连接的文本块
|
||||
/// </summary>
|
||||
//private NodeControlBase? startConnectNodeControl;
|
||||
/// <summary>
|
||||
/// 当前正在绘制的连接线
|
||||
/// </summary>
|
||||
//private Line? currentLine;
|
||||
/// <summary>
|
||||
/// 当前正在绘制的真假分支属性
|
||||
/// </summary>
|
||||
//private ConnectionInvokeType currentConnectionType;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 组合变换容器
|
||||
/// </summary>
|
||||
private readonly TransformGroup canvasTransformGroup;
|
||||
/// <summary>
|
||||
/// 缩放画布
|
||||
/// </summary>
|
||||
private readonly ScaleTransform scaleTransform;
|
||||
/// <summary>
|
||||
/// 平移画布
|
||||
/// </summary>
|
||||
private readonly TranslateTransform translateTransform;
|
||||
#endregion
|
||||
|
||||
private IFlowEnvironment EnvDecorator;
|
||||
public FlowCanvasView()
|
||||
{
|
||||
ViewModel = App.GetService<Locator>().FlowCanvasViewModel;
|
||||
|
||||
EnvDecorator = App.GetService<IFlowEnvironment>();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
#region 缩放平移容器
|
||||
canvasTransformGroup = new TransformGroup();
|
||||
scaleTransform = new ScaleTransform();
|
||||
translateTransform = new TranslateTransform();
|
||||
canvasTransformGroup.Children.Add(scaleTransform);
|
||||
canvasTransformGroup.Children.Add(translateTransform);
|
||||
FlowChartCanvas.RenderTransform = canvasTransformGroup;
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标在画布移动。
|
||||
/// 选择控件状态下,调整选择框大小
|
||||
/// 连接状态下,实时更新连接线的终点位置。
|
||||
/// 移动画布状态下,移动画布。
|
||||
/// </summary>
|
||||
private void FlowChartCanvas_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
var myData = GlobalJunctionData.MyGlobalConnectingData;
|
||||
if (myData.IsCreateing && e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
|
||||
if (myData.Type == JunctionOfConnectionType.Invoke)
|
||||
{
|
||||
ViewModel.IsConnectionInvokeNode = true; // 正在连接节点的调用关系
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewModel.IsConnectionArgSourceNode = true; // 正在连接节点的调用关系
|
||||
}
|
||||
var currentPoint = e.GetPosition(FlowChartCanvas);
|
||||
currentPoint.X -= 2;
|
||||
currentPoint.Y -= 2;
|
||||
myData.UpdatePoint(currentPoint);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (IsCanvasDragging && e.MiddleButton == MouseButtonState.Pressed) // 正在移动画布(按住中键)
|
||||
{
|
||||
Point currentMousePosition = e.GetPosition(this);
|
||||
double deltaX = currentMousePosition.X - startCanvasDragPoint.X;
|
||||
double deltaY = currentMousePosition.Y - startCanvasDragPoint.Y;
|
||||
|
||||
translateTransform.X += deltaX;
|
||||
translateTransform.Y += deltaY;
|
||||
|
||||
startCanvasDragPoint = currentMousePosition;
|
||||
|
||||
foreach (var line in Connections)
|
||||
{
|
||||
line.RefreshLine(); // 画布移动时刷新所有连接线
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSelectControl) // 正在选取节点
|
||||
{
|
||||
IsSelectDragging = e.LeftButton == MouseButtonState.Pressed;
|
||||
// 获取当前鼠标位置
|
||||
Point currentPoint = e.GetPosition(FlowChartCanvas);
|
||||
|
||||
// 更新选取矩形的位置和大小
|
||||
double x = Math.Min(currentPoint.X, startSelectControolPoint.X);
|
||||
double y = Math.Min(currentPoint.Y, startSelectControolPoint.Y);
|
||||
double width = Math.Abs(currentPoint.X - startSelectControolPoint.X);
|
||||
double height = Math.Abs(currentPoint.Y - startSelectControolPoint.Y);
|
||||
|
||||
Canvas.SetLeft(SelectionRectangle, x);
|
||||
Canvas.SetTop(SelectionRectangle, y);
|
||||
SelectionRectangle.Width = width;
|
||||
SelectionRectangle.Height = height;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 放置操作,根据拖放数据创建相应的控件,并处理相关操作
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FlowChartCanvas_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var canvasDropPosition = e.GetPosition(FlowChartCanvas); // 更新画布落点
|
||||
PositionOfUI position = new PositionOfUI(canvasDropPosition.X, canvasDropPosition.Y);
|
||||
if (e.Data.GetDataPresent(MouseNodeType.CreateDllNodeInCanvas))
|
||||
{
|
||||
if (e.Data.GetData(MouseNodeType.CreateDllNodeInCanvas) is MoveNodeData nodeData)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await EnvDecorator.CreateNodeAsync(nodeData.NodeControlType, position, nodeData.MethodDetailsInfo); // 创建DLL文件的节点对象
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (e.Data.GetDataPresent(MouseNodeType.CreateBaseNodeInCanvas))
|
||||
{
|
||||
if (e.Data.GetData(MouseNodeType.CreateBaseNodeInCanvas) is Type droppedType)
|
||||
{
|
||||
NodeControlType nodeControlType = droppedType switch
|
||||
{
|
||||
Type when typeof(ConditionRegionControl).IsAssignableFrom(droppedType) => NodeControlType.ConditionRegion, // 条件区域
|
||||
Type when typeof(ConditionNodeControl).IsAssignableFrom(droppedType) => NodeControlType.ExpCondition,
|
||||
Type when typeof(ExpOpNodeControl).IsAssignableFrom(droppedType) => NodeControlType.ExpOp,
|
||||
Type when typeof(GlobalDataControl).IsAssignableFrom(droppedType) => NodeControlType.GlobalData,
|
||||
Type when typeof(ScriptNodeControl).IsAssignableFrom(droppedType) => NodeControlType.Script,
|
||||
Type when typeof(NetScriptNodeControl).IsAssignableFrom(droppedType) => NodeControlType.NetScript,
|
||||
_ => NodeControlType.None,
|
||||
};
|
||||
if (nodeControlType != NodeControlType.None)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await EnvDecorator.CreateNodeAsync(nodeControlType, position); // 创建基础节点对象
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.ERROR, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拖动效果,根据拖放数据是否为指定类型设置拖放效果
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FlowChartCanvas_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(MouseNodeType.CreateDllNodeInCanvas)
|
||||
|| e.Data.GetDataPresent(MouseNodeType.CreateBaseNodeInCanvas))
|
||||
{
|
||||
e.Effects = DragDropEffects.Move;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effects = DragDropEffects.None;
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在画布中尝试选取控件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FlowChartCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (GlobalJunctionData.MyGlobalConnectingData.IsCreateing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsSelectControl)
|
||||
{
|
||||
// 进入选取状态
|
||||
IsSelectControl = true;
|
||||
IsSelectDragging = false; // 初始化为非拖动状态
|
||||
|
||||
// 记录鼠标起始点
|
||||
startSelectControolPoint = e.GetPosition(FlowChartCanvas);
|
||||
|
||||
// 初始化选取矩形的位置和大小
|
||||
Canvas.SetLeft(SelectionRectangle, startSelectControolPoint.X);
|
||||
Canvas.SetTop(SelectionRectangle, startSelectControolPoint.Y);
|
||||
SelectionRectangle.Width = 0;
|
||||
SelectionRectangle.Height = 0;
|
||||
|
||||
// 显示选取矩形
|
||||
SelectionRectangle.Visibility = Visibility.Visible;
|
||||
SelectionRectangle.ContextMenu ??= ConfiguerSelectionRectangle();
|
||||
|
||||
// 捕获鼠标,以便在鼠标移动到Canvas外部时仍能处理事件
|
||||
FlowChartCanvas.CaptureMouse();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果已经是选取状态,单击则认为结束框选
|
||||
CompleteSelection();
|
||||
}
|
||||
|
||||
e.Handled = true; // 防止事件传播影响其他控件
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在画布中释放鼠标按下,结束选取状态 / 停止创建连线,尝试连接节点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FlowChartCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (IsSelectControl)
|
||||
{
|
||||
// 松开鼠标时判断是否为拖动操作
|
||||
if (IsSelectDragging)
|
||||
{
|
||||
// 完成拖动框选
|
||||
CompleteSelection();
|
||||
}
|
||||
|
||||
// 释放鼠标捕获
|
||||
FlowChartCanvas.ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
// 创建连线
|
||||
if (GlobalJunctionData.MyGlobalConnectingData is ConnectingData myData && myData.IsCreateing)
|
||||
{
|
||||
|
||||
if (myData.IsCanConnected)
|
||||
{
|
||||
var canvas = this.FlowChartCanvas;
|
||||
var currentendPoint = e.GetPosition(canvas); // 当前鼠标落点
|
||||
var changingJunctionPosition = myData.CurrentJunction.TranslatePoint(new Point(0, 0), canvas);
|
||||
var changingJunctionRect = new Rect(changingJunctionPosition, new Size(myData.CurrentJunction.Width, myData.CurrentJunction.Height));
|
||||
|
||||
if (changingJunctionRect.Contains(currentendPoint)) // 可以创建连接
|
||||
{
|
||||
#region 方法调用关系创建
|
||||
if (myData.Type == JunctionOfConnectionType.Invoke)
|
||||
{
|
||||
this.EnvDecorator.ConnectInvokeNodeAsync(myData.StartJunction.MyNode.Guid, myData.CurrentJunction.MyNode.Guid,
|
||||
myData.StartJunction.JunctionType,
|
||||
myData.CurrentJunction.JunctionType,
|
||||
myData.ConnectionInvokeType);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 参数来源关系创建
|
||||
else if (myData.Type == JunctionOfConnectionType.Arg)
|
||||
{
|
||||
var argIndex = 0;
|
||||
if (myData.StartJunction is ArgJunctionControl argJunction1)
|
||||
{
|
||||
argIndex = argJunction1.ArgIndex;
|
||||
}
|
||||
else if (myData.CurrentJunction is ArgJunctionControl argJunction2)
|
||||
{
|
||||
argIndex = argJunction2.ArgIndex;
|
||||
}
|
||||
|
||||
this.EnvDecorator.ConnectArgSourceNodeAsync(myData.StartJunction.MyNode.Guid, myData.CurrentJunction.MyNode.Guid,
|
||||
myData.StartJunction.JunctionType,
|
||||
myData.CurrentJunction.JunctionType,
|
||||
myData.ConnectionArgSourceType,
|
||||
argIndex);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
EndConnection();
|
||||
}
|
||||
|
||||
}
|
||||
e.Handled = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region 拖动画布实现缩放平移效果
|
||||
private void FlowChartCanvas_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
IsCanvasDragging = true;
|
||||
startCanvasDragPoint = e.GetPosition(this);
|
||||
FlowChartCanvas.CaptureMouse();
|
||||
e.Handled = true; // 防止事件传播影响其他控件
|
||||
}
|
||||
|
||||
private void FlowChartCanvas_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (IsCanvasDragging)
|
||||
{
|
||||
IsCanvasDragging = false;
|
||||
FlowChartCanvas.ReleaseMouseCapture();
|
||||
}
|
||||
}
|
||||
|
||||
// 单纯缩放画布,不改变画布大小
|
||||
private void FlowChartCanvas_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
// if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
|
||||
{
|
||||
if (e.Delta < 0 && scaleTransform.ScaleX < 0.05) return;
|
||||
if (e.Delta > 0 && scaleTransform.ScaleY > 2.0) return;
|
||||
// 获取鼠标在 Canvas 内的相对位置
|
||||
var mousePosition = e.GetPosition(FlowChartCanvas);
|
||||
|
||||
// 缩放因子,根据滚轮方向调整
|
||||
//double zoomFactor = e.Delta > 0 ? 0.1 : -0.1;
|
||||
double zoomFactor = e.Delta > 0 ? 1.1 : 0.9;
|
||||
|
||||
// 当前缩放比例
|
||||
double oldScale = scaleTransform.ScaleX;
|
||||
double newScale = oldScale * zoomFactor;
|
||||
//double newScale = oldScale + zoomFactor;
|
||||
// 更新缩放比例
|
||||
scaleTransform.ScaleX = newScale;
|
||||
scaleTransform.ScaleY = newScale;
|
||||
|
||||
// 计算缩放前后鼠标相对于 Canvas 的位置差异
|
||||
// double offsetX = mousePosition.X - (mousePosition.X * zoomFactor);
|
||||
// double offsetY = mousePosition.Y - (mousePosition.Y * zoomFactor);
|
||||
|
||||
// 更新 TranslateTransform,确保以鼠标位置为中心进行缩放
|
||||
translateTransform.X -= (mousePosition.X * (newScale - oldScale));
|
||||
translateTransform.Y -= (mousePosition.Y * (newScale - oldScale));
|
||||
}
|
||||
}
|
||||
|
||||
// 设置画布宽度高度
|
||||
private void InitializeCanvas(double width, double height)
|
||||
{
|
||||
FlowChartCanvas.Width = width;
|
||||
FlowChartCanvas.Height = height;
|
||||
}
|
||||
|
||||
|
||||
#region 动态调整区域大小
|
||||
//private void Thumb_DragDelta_TopLeft(object sender, DragDeltaEventArgs e)
|
||||
//{
|
||||
// // 从左上角调整大小
|
||||
// double newWidth = Math.Max(FlowChartCanvas.ActualWidth - e.HorizontalChange, 0);
|
||||
// double newHeight = Math.Max(FlowChartCanvas.ActualHeight - e.VerticalChange, 0);
|
||||
|
||||
// FlowChartCanvas.Width = newWidth;
|
||||
// FlowChartCanvas.Height = newHeight;
|
||||
|
||||
// Canvas.SetLeft(FlowChartCanvas, Canvas.GetLeft(FlowChartCanvas) + e.HorizontalChange);
|
||||
// Canvas.SetTop(FlowChartCanvas, Canvas.GetTop(FlowChartCanvas) + e.VerticalChange);
|
||||
//}
|
||||
|
||||
//private void Thumb_DragDelta_TopRight(object sender, DragDeltaEventArgs e)
|
||||
//{
|
||||
// // 从右上角调整大小
|
||||
// double newWidth = Math.Max(FlowChartCanvas.ActualWidth + e.HorizontalChange, 0);
|
||||
// double newHeight = Math.Max(FlowChartCanvas.ActualHeight - e.VerticalChange, 0);
|
||||
|
||||
// FlowChartCanvas.Width = newWidth;
|
||||
// FlowChartCanvas.Height = newHeight;
|
||||
|
||||
// Canvas.SetTop(FlowChartCanvas, Canvas.GetTop(FlowChartCanvas) + e.VerticalChange);
|
||||
//}
|
||||
|
||||
//private void Thumb_DragDelta_BottomLeft(object sender, DragDeltaEventArgs e)
|
||||
//{
|
||||
// // 从左下角调整大小
|
||||
// double newWidth = Math.Max(FlowChartCanvas.ActualWidth - e.HorizontalChange, 0);
|
||||
// double newHeight = Math.Max(FlowChartCanvas.ActualHeight + e.VerticalChange, 0);
|
||||
|
||||
// FlowChartCanvas.Width = newWidth;
|
||||
// FlowChartCanvas.Height = newHeight;
|
||||
|
||||
// Canvas.SetLeft(FlowChartCanvas, Canvas.GetLeft(FlowChartCanvas) + e.HorizontalChange);
|
||||
//}
|
||||
|
||||
private void Thumb_DragDelta_BottomRight(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
// 获取缩放后的水平和垂直变化
|
||||
double horizontalChange = e.HorizontalChange * scaleTransform.ScaleX;
|
||||
double verticalChange = e.VerticalChange * scaleTransform.ScaleY;
|
||||
|
||||
// 计算新的宽度和高度,确保不会小于400
|
||||
double newWidth = Math.Max(FlowChartCanvas.ActualWidth + horizontalChange, 400);
|
||||
double newHeight = Math.Max(FlowChartCanvas.ActualHeight + verticalChange, 400);
|
||||
|
||||
newHeight = newHeight < 400 ? 400 : newHeight;
|
||||
newWidth = newWidth < 400 ? 400 : newWidth;
|
||||
|
||||
InitializeCanvas(newWidth, newHeight);
|
||||
|
||||
//// 从右下角调整大小
|
||||
//double newWidth = Math.Max(FlowChartCanvas.ActualWidth + e.HorizontalChange * scaleTransform.ScaleX, 0);
|
||||
//double newHeight = Math.Max(FlowChartCanvas.ActualHeight + e.VerticalChange * scaleTransform.ScaleY, 0);
|
||||
|
||||
//newWidth = newWidth < 400 ? 400 : newWidth;
|
||||
//newHeight = newHeight < 400 ? 400 : newHeight;
|
||||
|
||||
//if (newWidth > 400 && newHeight > 400)
|
||||
//{
|
||||
// FlowChartCanvas.Width = newWidth;
|
||||
// FlowChartCanvas.Height = newHeight;
|
||||
|
||||
// double x = e.HorizontalChange > 0 ? -0.5 : 0.5;
|
||||
// double y = e.VerticalChange > 0 ? -0.5 : 0.5;
|
||||
|
||||
// double deltaX = x * scaleTransform.ScaleX;
|
||||
// double deltaY = y * scaleTransform.ScaleY;
|
||||
// Test(deltaX, deltaY);
|
||||
//}
|
||||
}
|
||||
|
||||
//private void Thumb_DragDelta_Left(object sender, DragDeltaEventArgs e)
|
||||
//{
|
||||
// // 从左侧调整大小
|
||||
// double newWidth = Math.Max(FlowChartCanvas.ActualWidth - e.HorizontalChange, 0);
|
||||
|
||||
// FlowChartCanvas.Width = newWidth;
|
||||
// Canvas.SetLeft(FlowChartCanvas, Canvas.GetLeft(FlowChartCanvas) + e.HorizontalChange);
|
||||
//}
|
||||
|
||||
private void Thumb_DragDelta_Right(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
//从右侧调整大小
|
||||
// 获取缩放后的水平变化
|
||||
double horizontalChange = e.HorizontalChange * scaleTransform.ScaleX;
|
||||
|
||||
// 计算新的宽度,确保不会小于400
|
||||
double newWidth = Math.Max(FlowChartCanvas.ActualWidth + horizontalChange, 400);
|
||||
|
||||
newWidth = newWidth < 400 ? 400 : newWidth;
|
||||
InitializeCanvas(newWidth, FlowChartCanvas.Height);
|
||||
|
||||
}
|
||||
|
||||
//private void Thumb_DragDelta_Top(object sender, DragDeltaEventArgs e)
|
||||
//{
|
||||
// // 从顶部调整大小
|
||||
// double newHeight = Math.Max(FlowChartCanvas.ActualHeight - e.VerticalChange, 0);
|
||||
|
||||
// FlowChartCanvas.Height = newHeight;
|
||||
// Canvas.SetTop(FlowChartCanvas, Canvas.GetTop(FlowChartCanvas) + e.VerticalChange);
|
||||
//}
|
||||
|
||||
private void Thumb_DragDelta_Bottom(object sender, DragDeltaEventArgs e)
|
||||
{
|
||||
// 获取缩放后的垂直变化
|
||||
double verticalChange = e.VerticalChange * scaleTransform.ScaleY;
|
||||
// 计算新的高度,确保不会小于400
|
||||
double newHeight = Math.Max(FlowChartCanvas.ActualHeight + verticalChange, 400);
|
||||
newHeight = newHeight < 400 ? 400 : newHeight;
|
||||
InitializeCanvas(FlowChartCanvas.Width, newHeight);
|
||||
}
|
||||
|
||||
|
||||
private void Test(double deltaX, double deltaY)
|
||||
{
|
||||
//Console.WriteLine((translateTransform.X, translateTransform.Y));
|
||||
//translateTransform.X += deltaX;
|
||||
//translateTransform.Y += deltaY;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// 完成选取操作
|
||||
/// </summary>
|
||||
private void CompleteSelection()
|
||||
{
|
||||
IsSelectControl = false;
|
||||
|
||||
// 隐藏选取矩形
|
||||
SelectionRectangle.Visibility = Visibility.Collapsed;
|
||||
|
||||
// 获取选取范围
|
||||
Rect selectionArea = new Rect(Canvas.GetLeft(SelectionRectangle),
|
||||
Canvas.GetTop(SelectionRectangle),
|
||||
SelectionRectangle.Width,
|
||||
SelectionRectangle.Height);
|
||||
|
||||
// 处理选取范围内的控件
|
||||
// selectNodeControls.Clear();
|
||||
foreach (UIElement element in FlowChartCanvas.Children)
|
||||
{
|
||||
Rect elementBounds = new Rect(Canvas.GetLeft(element), Canvas.GetTop(element),
|
||||
element.RenderSize.Width, element.RenderSize.Height);
|
||||
|
||||
if (selectionArea.Contains(elementBounds))
|
||||
{
|
||||
if (element is NodeControlBase control)
|
||||
{
|
||||
if (!selectNodeControls.Contains(control))
|
||||
{
|
||||
selectNodeControls.Add(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 选中后的操作
|
||||
SelectedNode();
|
||||
}
|
||||
|
||||
|
||||
private void SelectedNode()
|
||||
{
|
||||
|
||||
if (selectNodeControls.Count == 0)
|
||||
{
|
||||
//Console.WriteLine($"没有选择控件");
|
||||
SelectionRectangle.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
}
|
||||
if (selectNodeControls.Count == 1)
|
||||
{
|
||||
// ChangeViewerObjOfNode(selectNodeControls[0]);
|
||||
}
|
||||
|
||||
//Console.WriteLine($"一共选取了{selectNodeControls.Count}个控件");
|
||||
foreach (var node in selectNodeControls)
|
||||
{
|
||||
//node.ViewModel.IsSelect =true;
|
||||
// node.ViewModel.CancelSelect();
|
||||
node.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFC700"));
|
||||
node.BorderThickness = new Thickness(4);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结束连接操作,清理状态并移除虚线。
|
||||
/// </summary>
|
||||
private void EndConnection()
|
||||
{
|
||||
Mouse.OverrideCursor = null; // 恢复视觉效果
|
||||
ViewModel.IsConnectionArgSourceNode = false;
|
||||
ViewModel.IsConnectionInvokeNode = false;
|
||||
GlobalJunctionData.OK();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建菜单子项
|
||||
/// </summary>
|
||||
/// <param name="header"></param>
|
||||
/// <param name="handler"></param>
|
||||
/// <returns></returns>
|
||||
public static MenuItem CreateMenuItem(string header, RoutedEventHandler handler)
|
||||
{
|
||||
var menuItem = new MenuItem { Header = header };
|
||||
menuItem.Click += handler;
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ContextMenu ConfiguerSelectionRectangle()
|
||||
{
|
||||
var contextMenu = new ContextMenu();
|
||||
contextMenu.Items.Add(CreateMenuItem("删除", (s, e) =>
|
||||
{
|
||||
if (selectNodeControls.Count > 0)
|
||||
{
|
||||
foreach (var node in selectNodeControls.ToArray())
|
||||
{
|
||||
var guid = node?.ViewModel?.NodeModel?.Guid;
|
||||
if (!string.IsNullOrEmpty(guid))
|
||||
{
|
||||
EnvDecorator.RemoveNodeAsync(guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectionRectangle.Visibility = Visibility.Collapsed;
|
||||
}));
|
||||
return contextMenu;
|
||||
// nodeControl.ContextMenu = contextMenu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
13
Workbench/Views/FlowEditView.xaml
Normal file
13
Workbench/Views/FlowEditView.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.FlowEditView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Background="#FFD3D3D3">
|
||||
<Grid>
|
||||
<local:FlowCanvasView></local:FlowCanvasView>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
31
Workbench/Views/FlowEditView.xaml.cs
Normal file
31
Workbench/Views/FlowEditView.xaml.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// FlowEditView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowEditView : UserControl
|
||||
{
|
||||
public FlowEditView()
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().FlowEditViewModel;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Workbench/Views/FlowLibrarysView.xaml
Normal file
92
Workbench/Views/FlowLibrarysView.xaml
Normal file
@@ -0,0 +1,92 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.FlowLibrarysView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
xmlns:converter="clr-namespace:Serein.Workbench.Converters"
|
||||
xmlns:custom="clr-namespace:Serein.Workbench.Customs"
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance vm:FlowLibrarysViewModel}"
|
||||
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<ScrollViewer>
|
||||
<ItemsControl ItemsSource="{Binding FlowLibraryInfos}">
|
||||
<ItemsControl.ItemTemplate >
|
||||
<DataTemplate>
|
||||
<Grid Margin="6,6,2,10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding LibraryName}" ></TextBlock>
|
||||
<TextBlock Text="{Binding FilePath}" Margin="6,0,0,0"></TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<!--<custom:FlowMethodInfoListBox Grid.Row="1" Nodes="{Binding ActionNodes}" BackgroundColor="#D0F1F9"/>
|
||||
<custom:FlowMethodInfoListBox Grid.Row="2" Nodes="{Binding FlipflopNodes}" BackgroundColor="#FACFC1"/>
|
||||
<custom:FlowMethodInfoListBox Grid.Row="3" Nodes="{Binding UINodes}" BackgroundColor="#FFFBD7"/>-->
|
||||
|
||||
<ListBox Grid.Row="1" Margin="6,2,2,2" ItemsSource="{Binding ActionNodes}"
|
||||
Visibility="{Binding ActionNodes, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
Background="#D0F1F9">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="2" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding NodeType}"></TextBlock>
|
||||
<TextBlock Text="{Binding AnotherName}" Margin="4,0,0,0"></TextBlock>
|
||||
<TextBlock Text="{Binding MethodName}" Margin="6,0,0,0"></TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<ListBox Grid.Row="2" Margin="6,2,2,2" ItemsSource="{Binding FlipflopNodes}"
|
||||
Visibility="{Binding FlipflopNodes, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
Background="#FACFC1">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="2" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding NodeType}"></TextBlock>
|
||||
<TextBlock Text="{Binding AnotherName}" Margin="4,0,0,0"></TextBlock>
|
||||
<TextBlock Text="{Binding MethodName}" Margin="6,0,0,0"></TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<ListBox Grid.Row="3" Margin="6,2,2,2" ItemsSource="{Binding UINodes}"
|
||||
Visibility="{Binding UINodes, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
Background="#FFFBD7">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="2" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding NodeType}"></TextBlock>
|
||||
<TextBlock Text="{Binding AnotherName}" Margin="4,0,0,0"></TextBlock>
|
||||
<TextBlock Text="{Binding MethodName}" Margin="6,0,0,0"></TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
30
Workbench/Views/FlowLibrarysView.xaml.cs
Normal file
30
Workbench/Views/FlowLibrarysView.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// FlowLibrarysView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowLibrarysView : UserControl
|
||||
{
|
||||
public FlowLibrarysView()
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().FlowLibrarysViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Workbench/Views/FlowWorkbenchView.xaml
Normal file
40
Workbench/Views/FlowWorkbenchView.xaml
Normal file
@@ -0,0 +1,40 @@
|
||||
<Window x:Class="Serein.Workbench.Views.FlowWorkbenchView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
mc:Ignorable="d"
|
||||
Loaded="Window_Loaded"
|
||||
Title="FlowWorkbenchView" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="250"/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--顶部菜单栏-->
|
||||
<local:MainMenuBarView Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5"/>
|
||||
|
||||
<!--左侧功能区-->
|
||||
<Grid Grid.Row="1" Grid.Column="0" >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<!--<RowDefinition Height="3"></RowDefinition>-->
|
||||
<!--<RowDefinition Height="3*"></RowDefinition>-->
|
||||
</Grid.RowDefinitions>
|
||||
<local:BaseNodesView Grid.Row="0" Grid.ColumnSpan="1" Margin="0,0,0,15"/>
|
||||
<local:FlowLibrarysView Grid.Row="1" Grid.ColumnSpan="1" Margin="0,0,0,15"/>
|
||||
</Grid>
|
||||
|
||||
<!--流程编辑区-->
|
||||
<local:FlowEditView Grid.Row="1" Grid.Column="2"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
45
Workbench/Views/FlowWorkbenchView.xaml.cs
Normal file
45
Workbench/Views/FlowWorkbenchView.xaml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// FlowWorkbenchView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowWorkbenchView : Window
|
||||
{
|
||||
public FlowWorkbenchView()
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().FlowWorkbenchViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.MaxHeight = SystemParameters.PrimaryScreenHeight;
|
||||
this.WindowState = WindowState.Maximized;
|
||||
// 设置全屏
|
||||
/*this.WindowState = System.Windows.WindowState.Normal;
|
||||
this.WindowStyle = System.Windows.WindowStyle.None;
|
||||
this.ResizeMode = System.Windows.ResizeMode.NoResize;
|
||||
this.Topmost = true;
|
||||
|
||||
this.Left = 0.0;
|
||||
this.Top = 0.0;
|
||||
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
|
||||
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Workbench/Views/MainMenuBarView.xaml
Normal file
37
Workbench/Views/MainMenuBarView.xaml
Normal file
@@ -0,0 +1,37 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.MainMenuBarView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="70" d:DesignWidth="350">
|
||||
<Grid >
|
||||
<Menu DockPanel.Dock="Top" Grid.Row="0" Grid.ColumnSpan="5" Height="20">
|
||||
<MenuItem Header="项目">
|
||||
<MenuItem Header="保存项目" ></MenuItem>
|
||||
<MenuItem Header="打开本地文件" ></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="拓展">
|
||||
<MenuItem Header="动态编译" ></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="调试">
|
||||
<MenuItem Header="运行(从起始节点)"></MenuItem>
|
||||
<MenuItem Header="运行(从选定节点)" ></MenuItem>
|
||||
<MenuItem Header="结束流程" ></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="视图">
|
||||
<MenuItem Header="输出窗口" ></MenuItem>
|
||||
<MenuItem Header="重置画布"></MenuItem>
|
||||
<MenuItem Header="定位节点" ></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="远程">
|
||||
<MenuItem Header="启动远程服务"></MenuItem>
|
||||
|
||||
<MenuItem Header="连接远程环境"></MenuItem>
|
||||
</MenuItem>
|
||||
<!--<MenuItem Header="说明"></MenuItem>-->
|
||||
</Menu>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
30
Workbench/Views/MainMenuBarView.xaml.cs
Normal file
30
Workbench/Views/MainMenuBarView.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// MainMenuBarView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainMenuBarView : UserControl
|
||||
{
|
||||
public MainMenuBarView()
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().MainViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Workbench/Views/MainView.xaml
Normal file
13
Workbench/Views/MainView.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.MainView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
30
Workbench/Views/MainView.xaml.cs
Normal file
30
Workbench/Views/MainView.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// MainView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().MainViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user