mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
将部分节点基类与表达式工具类从nodeflow迁移到library,重写了环境与工作台的交互,解耦节点的获取,下一部分将尝试远程登录环境编辑流程。
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
Loaded="Window_Loaded"
|
||||
ContentRendered="Window_ContentRendered"
|
||||
PreviewKeyDown="Window_PreviewKeyDown"
|
||||
PreviewTextInput="Window_PreviewTextInput"
|
||||
Closing="Window_Closing">
|
||||
|
||||
<Window.Resources>
|
||||
@@ -36,40 +35,56 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Grid.ColumnSpan="5" Background="#F5F5F5" Orientation="Horizontal" >
|
||||
<Button x:Name="ButtonDebugRun" Content="运行" Width="100" Margin="10" Click="ButtonDebugRun_Click"></Button>
|
||||
<Button x:Name="ButtonDebugFlipflopNode" Content="结束" Width="100" Margin="10" Click="ButtonDebugFlipflopNode_Click"></Button>
|
||||
<Button x:Name="ButtonStartFlowInSelectNode" Content="从选定节点开始" Width="100" Margin="10" Click="ButtonStartFlowInSelectNode_Click"></Button>
|
||||
<Button x:Name="ButtonResetCanvas" Content="重置画布" Width="100" Margin="10" Click="ButtonResetCanvas_Click"></Button>
|
||||
<Button x:Name="ButtonTestExpObj" Content="测试对象表达式" Width="100" Margin="10" Click="ButtonTestExpObj_Click"></Button>
|
||||
</StackPanel>
|
||||
|
||||
<Menu DockPanel.Dock="Top" Grid.Row="0" Height="20">
|
||||
<MenuItem Header="文件">
|
||||
<!--菜单项为MenuItem,文字使用属性 Header-->
|
||||
<MenuItem Header="保存项目" Click="ButtonSaveFile_Click" ></MenuItem>
|
||||
<MenuItem Header="打开本地文件" Click="OpenLocalProject_Click"></MenuItem>
|
||||
<MenuItem Header="连接远程环境" Click="OpenRemoteProject_Click"></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="调试">
|
||||
<MenuItem Header="运行(从起始节点)" Click="ButtonDebugRun_Click"></MenuItem>
|
||||
<MenuItem Header="运行(从选定节点)" Click="ButtonDebugFlipflopNode_Click"></MenuItem>
|
||||
<MenuItem Header="结束流程" Click="ButtonDebugFlipflopNode_Click"></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="视图">
|
||||
<MenuItem Header="输出窗口" Click="ButtonOpenConsoleOutWindow_Click"></MenuItem>
|
||||
<MenuItem Header="重置画布" Click="ButtonResetCanvas_Click"></MenuItem>
|
||||
</MenuItem>
|
||||
<!--<MenuItem Header="说明"></MenuItem>-->
|
||||
</Menu>
|
||||
|
||||
<DockPanel Grid.Row="1" Grid.Column="0" Background="#F5F5F5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="2*"></RowDefinition>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<!--<RowDefinition Height="3"></RowDefinition>-->
|
||||
<!--<RowDefinition Height="3*"></RowDefinition>-->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Margin="2,2,1,5" Grid.Row="0" >
|
||||
<Button Grid.Row="0" Content="保存项目" Click="ButtonSaveFile_Click" HorizontalAlignment="Left" Margin="5,5,5,5"/>
|
||||
<!--<Button Grid.Row="0" Content="卸载清空" Click="UnloadAllButton_Click" HorizontalAlignment="Right" Margin="5,5,5,5"/>-->
|
||||
</Grid>
|
||||
<!--<Grid Margin="2,2,1,5" Grid.Row="0" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0" Content="保存项目" Click="ButtonSaveFile_Click" HorizontalAlignment="Left" Margin="5,5,5,5"/>
|
||||
--><!--<Button Grid.Column="1" Content="加载项目" Click="ButtonLoadProjectFile_Click" HorizontalAlignment="Left" Margin="5,5,5,5"/>-->
|
||||
<!--<Button Grid.Row="0" Content="卸载清空" Click="UnloadAllButton_Click" HorizontalAlignment="Right" Margin="5,5,5,5"/>--><!--
|
||||
</Grid>-->
|
||||
|
||||
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto">
|
||||
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<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>
|
||||
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto" MaxHeight="400" Grid.RowSpan="2">
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" MaxHeight="400" Grid.RowSpan="2">
|
||||
<StackPanel x:Name="DllStackPanel" Margin="5"/>
|
||||
</ScrollViewer>
|
||||
<!--<GridSplitter Grid.Row="3" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Center" ResizeBehavior="PreviousAndNext" Background="Gray"/>-->
|
||||
|
||||
@@ -255,6 +255,7 @@ namespace Serein.WorkBench
|
||||
#endregion
|
||||
|
||||
#region 运行环境事件
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成
|
||||
/// </summary>
|
||||
@@ -281,19 +282,19 @@ namespace Serein.WorkBench
|
||||
{
|
||||
this.Dispatcher.Invoke(() => {
|
||||
NodeLibrary nodeLibrary = eventArgs.NodeLibrary;
|
||||
List<MethodDetails> methodDetailss = eventArgs.MethodDetailss;
|
||||
List<MethodDetailsInfo> methodDetailss = eventArgs.MethodDetailss;
|
||||
|
||||
var dllControl = new DllControl(nodeLibrary);
|
||||
|
||||
foreach (var methodDetails in methodDetailss)
|
||||
foreach (var methodDetailsInfo in methodDetailss)
|
||||
{
|
||||
switch (methodDetails.MethodDynamicType)
|
||||
switch (methodDetailsInfo.NodeType)
|
||||
{
|
||||
case Library.Enums.NodeType.Action:
|
||||
dllControl.AddAction(methodDetails.Clone()); // 添加动作类型到控件
|
||||
dllControl.AddAction(methodDetailsInfo); // 添加动作类型到控件
|
||||
break;
|
||||
case Library.Enums.NodeType.Flipflop:
|
||||
dllControl.AddFlipflop(methodDetails.Clone()); // 添加触发器方法到控件
|
||||
dllControl.AddFlipflop(methodDetailsInfo); // 添加触发器方法到控件
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -320,20 +321,13 @@ namespace Serein.WorkBench
|
||||
/// <summary>
|
||||
/// 节点连接关系变更
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid"></param>
|
||||
/// <param name="toNodeGuid"></param>
|
||||
/// <param name="connectionType"></param>
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_NodeConnectChangeEvemt(NodeConnectChangeEventArgs eventArgs)
|
||||
{
|
||||
string fromNodeGuid = eventArgs.FromNodeGuid;
|
||||
string toNodeGuid = eventArgs.ToNodeGuid;
|
||||
NodeControlBase? fromNode = GuidToControl(fromNodeGuid);
|
||||
NodeControlBase? toNode = GuidToControl(toNodeGuid);
|
||||
if(fromNode != null && toNode != null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
if (!TryGetControl(fromNodeGuid, out var fromNode)
|
||||
|| !TryGetControl(toNodeGuid, out var toNode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -394,8 +388,6 @@ namespace Serein.WorkBench
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点移除事件
|
||||
/// </summary>
|
||||
@@ -403,7 +395,11 @@ namespace Serein.WorkBench
|
||||
private void FlowEnvironment_NodeRemoteEvent(NodeRemoteEventArgs eventArgs)
|
||||
{
|
||||
var nodeGuid = eventArgs.NodeGuid;
|
||||
NodeControlBase? nodeControl = GuidToControl(nodeGuid);
|
||||
if (!TryGetControl(nodeGuid, out var nodeControl))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodeControl is null) return;
|
||||
if (selectNodeControls.Count > 0)
|
||||
{
|
||||
@@ -494,7 +490,6 @@ namespace Serein.WorkBench
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置了流程起始控件
|
||||
/// </summary>
|
||||
@@ -506,12 +501,10 @@ namespace Serein.WorkBench
|
||||
{
|
||||
string oldNodeGuid = eventArgs.OldNodeGuid;
|
||||
string newNodeGuid = eventArgs.NewNodeGuid;
|
||||
NodeControlBase? newStartNodeControl = GuidToControl(newNodeGuid);
|
||||
if (newStartNodeControl is null) return;
|
||||
if (!TryGetControl(newNodeGuid, out var newStartNodeControl)) return;
|
||||
if (!string.IsNullOrEmpty(oldNodeGuid))
|
||||
{
|
||||
NodeControlBase? oldStartNodeControl = GuidToControl(oldNodeGuid);
|
||||
if (oldStartNodeControl is null) return;
|
||||
if (!TryGetControl(oldNodeGuid, out var oldStartNodeControl)) return;
|
||||
oldStartNodeControl.BorderBrush = Brushes.Black;
|
||||
oldStartNodeControl.BorderThickness = new Thickness(0);
|
||||
}
|
||||
@@ -527,7 +520,6 @@ namespace Serein.WorkBench
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 被监视的对象发生改变
|
||||
/// </summary>
|
||||
@@ -564,7 +556,6 @@ namespace Serein.WorkBench
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点中断状态改变。
|
||||
/// </summary>
|
||||
@@ -572,8 +563,8 @@ namespace Serein.WorkBench
|
||||
private void FlowEnvironment_OnNodeInterruptStateChange(NodeInterruptStateChangeEventArgs eventArgs)
|
||||
{
|
||||
string nodeGuid = eventArgs.NodeGuid;
|
||||
NodeControlBase? nodeControl = GuidToControl(nodeGuid);
|
||||
if (nodeControl is null) return;
|
||||
if (!TryGetControl(nodeGuid, out var nodeControl)) return;
|
||||
|
||||
if (eventArgs.Class == InterruptClass.None)
|
||||
{
|
||||
nodeControl.ViewModel.IsInterrupt = false;
|
||||
@@ -610,8 +601,7 @@ namespace Serein.WorkBench
|
||||
private void FlowEnvironment_OnInterruptTrigger(InterruptTriggerEventArgs eventArgs)
|
||||
{
|
||||
string nodeGuid = eventArgs.NodeGuid;
|
||||
NodeControlBase? nodeControl = GuidToControl(nodeGuid);
|
||||
if (nodeControl is null) return;
|
||||
if (!TryGetControl(nodeGuid, out var nodeControl)) return;
|
||||
if(eventArgs.Type == InterruptTriggerEventArgs.InterruptTriggerType.Exp)
|
||||
{
|
||||
Console.WriteLine($"表达式触发了中断:{eventArgs.Expression}");
|
||||
@@ -639,8 +629,7 @@ namespace Serein.WorkBench
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_OnNodeLocate(NodeLocatedEventArgs eventArgs)
|
||||
{
|
||||
NodeControlBase? nodeControl = GuidToControl(eventArgs.NodeGuid);
|
||||
if (nodeControl is null) return;
|
||||
if (!TryGetControl(eventArgs.NodeGuid, out var nodeControl)) return;
|
||||
//scaleTransform.ScaleX = 1;
|
||||
//scaleTransform.ScaleY = 1;
|
||||
// 获取控件在 FlowChartCanvas 上的相对位置
|
||||
@@ -669,7 +658,6 @@ namespace Serein.WorkBench
|
||||
|
||||
//if (!isInView)
|
||||
//{
|
||||
|
||||
//}
|
||||
// 计算平移偏移量,使得控件在可视区域的中心
|
||||
double translateX = scaledCenterX - FlowChartStackGrid.ActualWidth / 2;
|
||||
@@ -688,6 +676,7 @@ namespace Serein.WorkBench
|
||||
ElasticAnimation(nodeControl, translateTransform, 4,1,0.5);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控件抖动
|
||||
/// 来源:https://www.cnblogs.com/RedSky/p/17705411.html
|
||||
@@ -695,6 +684,7 @@ namespace Serein.WorkBench
|
||||
/// (……太好用了)
|
||||
/// </summary>
|
||||
/// <param name="translate"></param>
|
||||
/// <param name="nodeControl">需要抖动的控件</param>
|
||||
/// <param name="power">抖动第一下偏移量</param>
|
||||
/// <param name="range">减弱幅度(小于等于power,大于0)</param>
|
||||
/// <param name="speed">持续系数(大于0),越大时间越长,</param>
|
||||
@@ -724,26 +714,28 @@ namespace Serein.WorkBench
|
||||
/// <summary>
|
||||
/// Guid 转 NodeControl
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <returns>节点Model</returns>
|
||||
/// <exception cref="ArgumentNullException">无法获取节点、Guid/节点为null时报错</exception>
|
||||
private NodeControlBase? GuidToControl(string nodeGuid)
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="nodeControl"></param>
|
||||
/// <returns></returns>
|
||||
private bool TryGetControl(string nodeGuid,out NodeControlBase nodeControl)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nodeGuid))
|
||||
{
|
||||
return null;
|
||||
throw new ArgumentNullException("not contains - Guid没有对应节点:" + (nodeGuid));
|
||||
nodeControl = null;
|
||||
return false;
|
||||
}
|
||||
if (!NodeControls.TryGetValue(nodeGuid, out NodeControlBase? nodeControl) || nodeControl is null)
|
||||
if (!NodeControls.TryGetValue(nodeGuid, out nodeControl))
|
||||
{
|
||||
return null;
|
||||
|
||||
throw new ArgumentNullException("null - Guid存在对应节点,但节点为null:" + (nodeGuid));
|
||||
nodeControl = null;
|
||||
return false;
|
||||
}
|
||||
return nodeControl;
|
||||
if(nodeControl is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 加载项目文件后触发事件相关方法
|
||||
@@ -906,7 +898,7 @@ namespace Serein.WorkBench
|
||||
|
||||
#endregion
|
||||
|
||||
if (nodeControl?.ViewModel?.Node?.MethodDetails?.ReturnType is Type returnType && returnType != typeof(void))
|
||||
if (nodeControl.ViewModel?.Node?.MethodDetails?.ReturnType is Type returnType && returnType != typeof(void))
|
||||
{
|
||||
contextMenu.Items.Add(CreateMenuItem("查看返回类型", (s, e) =>
|
||||
{
|
||||
@@ -1180,7 +1172,7 @@ namespace Serein.WorkBench
|
||||
if (e.Data.GetData(MouseNodeType.CreateDllNodeInCanvas) is MoveNodeData nodeData)
|
||||
{
|
||||
// 创建DLL文件的节点对象
|
||||
FlowEnvironment.CreateNode(nodeData.NodeControlType, position, nodeData.MethodDetails);
|
||||
FlowEnvironment.CreateNode(nodeData.NodeControlType, position, nodeData.MethodDetailsInfo);
|
||||
}
|
||||
}
|
||||
else if (e.Data.GetDataPresent(MouseNodeType.CreateBaseNodeInCanvas))
|
||||
@@ -1208,8 +1200,7 @@ namespace Serein.WorkBench
|
||||
/// 尝试将节点放置在区域中
|
||||
/// </summary>
|
||||
/// <param name="nodeControl"></param>
|
||||
/// <param name="dropPosition"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
private bool TryPlaceNodeInRegion(NodeControlBase nodeControl, Position position)
|
||||
{
|
||||
@@ -1764,6 +1755,7 @@ namespace Serein.WorkBench
|
||||
/// <param name="e"></param>
|
||||
private void FlowChartCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Console.WriteLine(1);
|
||||
if (!IsSelectControl)
|
||||
{
|
||||
// 进入选取状态
|
||||
@@ -2335,32 +2327,8 @@ namespace Serein.WorkBench
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 卸载DLL文件,清空当前项目
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void UnloadAllButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FlowEnvironment.ClearAll();
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 卸载DLL文件,清空当前项目
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void UnloadAllAssemblies()
|
||||
{
|
||||
DllStackPanel.Children.Clear();
|
||||
FlowChartCanvas.Children.Clear();
|
||||
Connections.Clear();
|
||||
NodeControls.Clear();
|
||||
currentLine = null;
|
||||
startConnectNodeControl = null;
|
||||
MessageBox.Show("所有DLL已卸载。", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
#region 顶部菜单栏 - 调试功能区
|
||||
|
||||
/// <summary>
|
||||
/// 运行测试
|
||||
@@ -2394,7 +2362,7 @@ namespace Serein.WorkBench
|
||||
/// <param name="e"></param>
|
||||
private async void ButtonStartFlowInSelectNode_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(selectNodeControls.Count == 0)
|
||||
if (selectNodeControls.Count == 0)
|
||||
{
|
||||
Console.WriteLine("请至少选择一个节点");
|
||||
}
|
||||
@@ -2409,6 +2377,14 @@ namespace Serein.WorkBench
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 顶部菜单栏 - 项目文件菜单
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存为项目文件
|
||||
/// </summary>
|
||||
@@ -2416,7 +2392,7 @@ namespace Serein.WorkBench
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSaveFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var projectData = FlowEnvironment.SaveProject();
|
||||
var projectData = FlowEnvironment.GetProjectInfo();
|
||||
|
||||
projectData.Basic = new Basic
|
||||
{
|
||||
@@ -2432,10 +2408,10 @@ namespace Serein.WorkBench
|
||||
Versions = "1",
|
||||
};
|
||||
|
||||
foreach(var node in projectData.Nodes)
|
||||
foreach (var node in projectData.Nodes)
|
||||
{
|
||||
|
||||
if(NodeControls.TryGetValue(node.Guid,out var nodeControl))
|
||||
|
||||
if (NodeControls.TryGetValue(node.Guid, out var nodeControl))
|
||||
{
|
||||
Point positionRelativeToParent = nodeControl.TranslatePoint(new Point(0, 0), FlowChartCanvas);
|
||||
node.Position = new Position(positionRelativeToParent.X, positionRelativeToParent.Y);
|
||||
@@ -2481,7 +2457,7 @@ namespace Serein.WorkBench
|
||||
}
|
||||
|
||||
JObject projectJsonData = JObject.FromObject(projectData);
|
||||
savaProjectFile?.Invoke(savePath, projectJsonData.ToString());
|
||||
savaProjectFile?.Invoke(savePath, projectJsonData.ToString());
|
||||
}
|
||||
public static bool SaveContentToFile(out string savePath, out Action<string, string>? savaProjectFile)
|
||||
{
|
||||
@@ -2499,7 +2475,7 @@ namespace Serein.WorkBench
|
||||
// 如果用户选择了文件并点击了保存按钮
|
||||
if (result == true)
|
||||
{
|
||||
savePath = saveFileDialog.FileName;
|
||||
savePath = saveFileDialog.FileName;
|
||||
savaProjectFile = File.WriteAllText;
|
||||
return true;
|
||||
}
|
||||
@@ -2507,18 +2483,57 @@ namespace Serein.WorkBench
|
||||
savaProjectFile = null;
|
||||
return false;
|
||||
}
|
||||
public static string GetRelativePath(string baseDirectory, string fullPath)
|
||||
{
|
||||
Uri baseUri = new(baseDirectory + System.IO.Path.DirectorySeparatorChar);
|
||||
Uri fullUri = new(fullPath);
|
||||
Uri relativeUri = baseUri.MakeRelativeUri(fullUri);
|
||||
return Uri.UnescapeDataString(relativeUri.ToString().Replace('/', System.IO.Path.DirectorySeparatorChar));
|
||||
}
|
||||
|
||||
private void Window_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
/// <summary>
|
||||
/// 打开本地项目文件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OpenLocalProject_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接远程运行环境
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OpenRemoteProject_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var windowEnvRemoteLoginView = new WindowEnvRemoteLoginView((addres,port,token) =>
|
||||
{
|
||||
this.FlowEnvironment.LoadRemoteProject(addres, port, token);
|
||||
});
|
||||
windowEnvRemoteLoginView.Show();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 顶部菜单栏 - 视图管理
|
||||
/// <summary>
|
||||
/// 重置画布
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonResetCanvas_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
translateTransform.X = 0;
|
||||
translateTransform.Y = 0;
|
||||
scaleTransform.ScaleX = 1;
|
||||
scaleTransform.ScaleY = 1;
|
||||
}
|
||||
private void ButtonOpenConsoleOutWindow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
logWindow?.Show();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按键监听。esc取消操作
|
||||
/// </summary>
|
||||
@@ -2596,16 +2611,29 @@ namespace Serein.WorkBench
|
||||
data = SerinExpressionEvaluator.Evaluate(exp,result!, out isChange);
|
||||
Console.WriteLine($"{exp} => {data}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置画布
|
||||
/// 卸载DLL文件,清空当前项目
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonResetCanvas_Click(object sender, RoutedEventArgs e)
|
||||
private void UnloadAllButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
translateTransform.X = 0;
|
||||
translateTransform.Y = 0;
|
||||
FlowEnvironment.ClearAll();
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 卸载DLL文件,清空当前项目
|
||||
/// </summary>
|
||||
private void UnloadAllAssemblies()
|
||||
{
|
||||
DllStackPanel.Children.Clear();
|
||||
FlowChartCanvas.Children.Clear();
|
||||
Connections.Clear();
|
||||
NodeControls.Clear();
|
||||
currentLine = null;
|
||||
startConnectNodeControl = null;
|
||||
MessageBox.Show("所有DLL已卸载。", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Serein.WorkBench.Node.View
|
||||
/// <summary>
|
||||
/// 添加条件控件
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
/// <param name="node"></param>
|
||||
public void AddCondition(NodeControlBase node)
|
||||
{
|
||||
((CompositeConditionNode)ViewModel.Node).AddNode((SingleConditionNode)node.ViewModel.Node);
|
||||
|
||||
@@ -14,22 +14,17 @@
|
||||
<DockPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<!--<RowDefinition Height="*"/>-->
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<!--<ColumnDefinition Width="*" />-->
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--<GroupBox Grid.Row="0" Header="条件" Margin="5">
|
||||
<ListBox x:Name="ConditionsListBox" Background="#A8D8EA"/>
|
||||
</GroupBox>-->
|
||||
<GroupBox Grid.Row="0" Header="动作" Margin="5">
|
||||
<GroupBox x:Name="ActionNodes" Grid.Row="0" Header="动作" Margin="5">
|
||||
<ListBox x:Name="ActionsListBox" Background="#D0F1F9"/>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="1" Header="触发器" Margin="5">
|
||||
<GroupBox x:Name="FlipflopNodes" Grid.Row="1" Header="触发器" Margin="5" >
|
||||
<ListBox x:Name="FlipflopsListBox" Background="#FACFC1"/>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
@@ -53,18 +53,18 @@ namespace Serein.WorkBench.Node.View
|
||||
/// 向动作面板添加类型的文本块
|
||||
/// </summary>
|
||||
/// <param name="type">要添加的类型</param>
|
||||
public void AddAction(MethodDetails md)
|
||||
public void AddAction(MethodDetailsInfo mdInfo)
|
||||
{
|
||||
AddTypeToListBox(md, ActionsListBox);
|
||||
AddTypeToListBox(mdInfo, ActionsListBox);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向触发器面板添加类型的文本块
|
||||
/// </summary>
|
||||
/// <param name="type">要添加的类型</param>
|
||||
public void AddFlipflop(MethodDetails md)
|
||||
public void AddFlipflop(MethodDetailsInfo mdInfo)
|
||||
{
|
||||
AddTypeToListBox(md, FlipflopsListBox);
|
||||
AddTypeToListBox(mdInfo, FlipflopsListBox);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -72,14 +72,14 @@ namespace Serein.WorkBench.Node.View
|
||||
/// </summary>
|
||||
/// <param name="type">要添加的类型</param>
|
||||
/// <param name="panel">要添加到的面板</param>
|
||||
private void AddTypeToListBox(MethodDetails md, ListBox listBox)
|
||||
private void AddTypeToListBox(MethodDetailsInfo mdInfo, ListBox listBox)
|
||||
{
|
||||
// 创建一个新的 TextBlock 并设置其属性
|
||||
TextBlock typeText = new TextBlock
|
||||
{
|
||||
Text = $"{md.MethodTips}",
|
||||
Text = $"{mdInfo.MethodTips}",
|
||||
Margin = new Thickness(10, 2, 0, 0),
|
||||
Tag = md
|
||||
Tag = mdInfo
|
||||
};
|
||||
// 为 TextBlock 添加鼠标左键按下事件处理程序
|
||||
typeText.MouseLeftButtonDown += TypeText_MouseLeftButtonDown;
|
||||
@@ -125,17 +125,17 @@ namespace Serein.WorkBench.Node.View
|
||||
// 获取触发事件的 TextBlock
|
||||
|
||||
|
||||
if (sender is TextBlock typeText && typeText.Tag is MethodDetails md)
|
||||
if (sender is TextBlock typeText && typeText.Tag is MethodDetailsInfo mdInfo)
|
||||
{
|
||||
MoveNodeData moveNodeData = new MoveNodeData
|
||||
{
|
||||
NodeControlType = md.MethodDynamicType switch
|
||||
NodeControlType = mdInfo.NodeType switch
|
||||
{
|
||||
NodeType.Action => NodeControlType.Action,
|
||||
NodeType.Flipflop => NodeControlType.Flipflop,
|
||||
_ => NodeControlType.None,
|
||||
},
|
||||
MethodDetails = md,
|
||||
MethodDetailsInfo = mdInfo,
|
||||
};
|
||||
if(moveNodeData.NodeControlType == NodeControlType.None)
|
||||
{
|
||||
|
||||
@@ -91,7 +91,11 @@ namespace Serein.WorkBench.Themes
|
||||
|
||||
public void ClearObjItem()
|
||||
{
|
||||
DependenciesListBox.Items.Clear();
|
||||
DependenciesListBox.Dispatcher.Invoke(() =>
|
||||
{
|
||||
DependenciesListBox.Items.Clear();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void SortLisbox(ListBox listBox)
|
||||
|
||||
30
WorkBench/Themes/WindowDialogInput.xaml
Normal file
30
WorkBench/Themes/WindowDialogInput.xaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<Window x:Class="Serein.WorkBench.Themes.WindowEnvRemoteLoginView"
|
||||
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.Themes"
|
||||
Title="登录远程环境" Height="150" Width="200">
|
||||
<Grid Margin="0,10,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="地址" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="TextBlockAddres" Grid.Row="0" Grid.Column="1" Text="192.168.1.100"></TextBox>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="端口" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="TextBlockPort" Grid.Row="1" Grid.Column="1" Text="7525"></TextBox>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="密码" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBox x:Name="TextBlockToken" Grid.Row="2" Grid.Column="1" Text="123456"></TextBox>
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" Orientation="Horizontal" Margin="4">
|
||||
<Button Content="测试连接" Margin="2" Click="ButtonTestConnect_Client"></Button>
|
||||
<Button Content="登录环境" Margin="2" Click="ButtonTestLoginEnv_Client"></Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
68
WorkBench/Themes/WindowDialogInput.xaml.cs
Normal file
68
WorkBench/Themes/WindowDialogInput.xaml.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
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.Themes
|
||||
{
|
||||
/// <summary>
|
||||
/// WindowDialogInput.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class WindowEnvRemoteLoginView : Window
|
||||
{
|
||||
private Action<string, int, string> ConnectRemoteFlowEnv;
|
||||
|
||||
/// <summary>
|
||||
/// 弹窗输入
|
||||
/// </summary>
|
||||
/// <param name="connectRemoteFlowEnv"></param>
|
||||
public WindowEnvRemoteLoginView(Action<string, int, string> connectRemoteFlowEnv)
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
InitializeComponent();
|
||||
ConnectRemoteFlowEnv = connectRemoteFlowEnv;
|
||||
}
|
||||
|
||||
private void ButtonTestConnect_Client(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var addres = this.TextBlockAddres.Text;
|
||||
_ = int.TryParse(this.TextBlockPort.Text, out var port);
|
||||
_ = Task.Run(() => {
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
TcpClient tcpClient = new TcpClient();
|
||||
var result = tcpClient.BeginConnect(addres, port, null, null);
|
||||
success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
Console.WriteLine($"无法连接远程:{addres}:{port}");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void ButtonTestLoginEnv_Client(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var addres = this.TextBlockAddres.Text;
|
||||
_ = int.TryParse(this.TextBlockPort.Text, out var port);
|
||||
var token = this.TextBlockToken.Text;
|
||||
ConnectRemoteFlowEnv?.Invoke(addres, port, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user