mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
优化了Workbench上的操作。
This commit is contained in:
@@ -32,9 +32,11 @@ namespace Serein.Workbench
|
||||
collection.AddSingleton<BaseNodesViewModel>();
|
||||
collection.AddSingleton<FlowLibrarysViewModel>();
|
||||
collection.AddSingleton<FlowEditViewModel>();
|
||||
collection.AddSingleton<ViewNodeInfoViewModel>();
|
||||
collection.AddSingleton<ViewNodeMethodInfoViewModel>();
|
||||
|
||||
collection.AddTransient<FlowCanvasViewModel>(); // 画布
|
||||
collection.AddTransient<CanvasInfoViewModel>(); // 画布节点树视图
|
||||
collection.AddTransient<ViewCanvasInfoViewModel>(); // 画布节点树视图
|
||||
}
|
||||
|
||||
public static void AddWorkbenchServices(this IServiceCollection collection)
|
||||
@@ -42,6 +44,7 @@ namespace Serein.Workbench
|
||||
collection.AddSingleton<IFlowEEForwardingService, FlowEEForwardingService>(); // 流程事件管理
|
||||
collection.AddSingleton<IKeyEventService, KeyEventService>();// 按键事件管理
|
||||
collection.AddSingleton<IWorkbenchEventService, WorkbenchEventService>(); // 流程事件管理
|
||||
collection.AddSingleton<FlowProjectService>(); // 项目管理
|
||||
collection.AddSingleton<FlowNodeService>(); // 节点操作管理
|
||||
}
|
||||
|
||||
@@ -104,69 +107,45 @@ namespace Serein.Workbench
|
||||
collection.AddViewModelServices();
|
||||
var services = collection.BuildServiceProvider(); // 绑定并返回获取实例的服务接口
|
||||
App.ServiceProvider = services;
|
||||
|
||||
|
||||
|
||||
|
||||
#if DEBUG
|
||||
_ = this.LoadLocalProjectAsync();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task LoadLocalProjectAsync()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
#if DEBUG
|
||||
if (1 == 1)
|
||||
{
|
||||
// 这里是测试代码,可以删除
|
||||
string filePath;
|
||||
filePath = @"C:\Users\Az\source\repos\CLBanyunqiState\CLBanyunqiState\bin\Release\net8.0\PLCproject.dnf";
|
||||
filePath = @"C:\Users\Az\source\repos\CLBanyunqiState\CLBanyunqiState\bin\Release\banyunqi\project.dnf";
|
||||
filePath = @"F:\临时\project\project.dnf";
|
||||
filePath = @"F:\TempFile\flow\qrcode\project.dnf";
|
||||
filePath = @"F:\TempFile\flow\temp2\project.dnf";
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容
|
||||
App.FlowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
|
||||
App.FileDataPath = System.IO.Path.GetDirectoryName(filePath)!; // filePath;//
|
||||
var dir = Path.GetDirectoryName(filePath);
|
||||
App.GetService<IFlowEnvironment>().LoadProject(new FlowEnvInfo { Project = App.FlowProjectData }, App.FileDataPath);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG
|
||||
|
||||
// 这里是测试代码,可以删除
|
||||
private async Task LoadLocalProjectAsync()
|
||||
{
|
||||
var projectService = App.GetService<FlowProjectService>();
|
||||
await Task.Delay(500);
|
||||
if (1 == 1)
|
||||
{
|
||||
string filePath;
|
||||
filePath = @"F:\TempFile\flow\temp2\project.dnf";
|
||||
projectService.LoadLocalProject(filePath);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
public static SereinProjectData? FlowProjectData { get; set; }
|
||||
public static string FileDataPath { get; set; } = "";
|
||||
|
||||
private async void Application_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
// 检查是否传入了参数
|
||||
var projectService = App.GetService<FlowProjectService>();
|
||||
if (e.Args.Length == 1)
|
||||
{
|
||||
// 获取文件路径
|
||||
string filePath = e.Args[0];
|
||||
// 检查文件是否存在
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
if (!System.IO.File.Exists(filePath)) // 检查文件是否存在
|
||||
{
|
||||
MessageBox.Show($"文件未找到:{filePath}");
|
||||
Shutdown(); // 关闭应用程序
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 读取文件内容
|
||||
string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容
|
||||
FlowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
|
||||
FileDataPath = System.IO.Path.GetDirectoryName(filePath) ?? "";
|
||||
projectService.LoadLocalProject(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
<converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<ListBox ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
<ListBox SelectionChanged="ListBox_SelectionChanged"
|
||||
ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}">
|
||||
<ListBox.ItemTemplate>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Workbench.Models;
|
||||
using Serein.Workbench.Services;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -39,9 +40,23 @@ namespace Serein.Workbench.Customs
|
||||
/// <summary>
|
||||
/// FlowMethodInfoListBox.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowMethodInfoListBox : UserControl
|
||||
public partial class FlowMethodInfoListBox : UserControl,System.ComponentModel.INotifyPropertyChanged
|
||||
{
|
||||
private object viewMethodInfo;
|
||||
public object ViewMethodInfo
|
||||
{
|
||||
get => viewMethodInfo;
|
||||
set
|
||||
{
|
||||
if (viewMethodInfo != value)
|
||||
{
|
||||
viewMethodInfo = value;
|
||||
PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(ViewMethodInfo)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public FlowMethodInfoListBox()
|
||||
{
|
||||
@@ -130,5 +145,20 @@ namespace Serein.Workbench.Customs
|
||||
}
|
||||
}
|
||||
|
||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if(sender is ListBox listBox)
|
||||
{
|
||||
if (listBox.SelectedIndex != -1)
|
||||
{
|
||||
var item = listBox.SelectedItem;
|
||||
if (item is MethodDetailsInfo mdInfo)
|
||||
{
|
||||
App.GetService<FlowNodeService>().CurrentMethodDetailsInfo = mdInfo;
|
||||
}
|
||||
}
|
||||
// Serein.Workbench.Models.FlowLibraryInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<StackPanel Grid.Column="1" Grid.RowSpan="2" >
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay}" HorizontalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<local:NextStepJunctionControl Grid.Column="2" MyNode="{Binding NodeModel}" x:Name="NextStepJunctionControl" HorizontalAlignment="Right" Grid.RowSpan="2"/>
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<Border Grid.Column="1" BorderThickness="1" HorizontalAlignment="Stretch">
|
||||
<TextBlock Text="条件节点" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
<local:NextStepJunctionControl Grid.Column="2" MyNode="{Binding NodeModel}" x:Name="NextStepJunctionControl" HorizontalAlignment="Right" Grid.RowSpan="2"/>
|
||||
|
||||
|
||||
@@ -17,13 +17,14 @@ namespace Serein.Workbench.Node.View
|
||||
base.ViewModel = new ConditionNodeControlViewModel (new SingleConditionNode(env));
|
||||
base.ViewModel.IsEnabledOnView = false;
|
||||
DataContext = ViewModel;
|
||||
|
||||
base.ViewModel.NodeModel.DisplayName = "[条件节点]";
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ConditionNodeControl(ConditionNodeControlViewModel viewModel):base(viewModel)
|
||||
{
|
||||
DataContext = viewModel;
|
||||
viewModel.NodeModel.DisplayName = "[条件节点]";
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<Border Grid.Column="1" BorderThickness="1" HorizontalAlignment="Stretch">
|
||||
<TextBlock Text="表达式" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
<local:NextStepJunctionControl Grid.Column="2" MyNode="{Binding NodeModel}" x:Name="NextStepJunctionControl" HorizontalAlignment="Right" Grid.RowSpan="2"/>
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@ namespace Serein.Workbench.Node.View
|
||||
var env = App.GetService<IFlowEnvironment>();
|
||||
ViewModel = new ExpOpNodeControlViewModel(new SingleExpOpNode(env));
|
||||
base.ViewModel.IsEnabledOnView = false;
|
||||
base.ViewModel.NodeModel.DisplayName = "[表达式]";
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
public ExpOpNodeControl(ExpOpNodeControlViewModel viewModel) :base(viewModel)
|
||||
{
|
||||
DataContext = viewModel;
|
||||
viewModel.NodeModel.DisplayName = "[表达式]";
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<Border Grid.Column="1" BorderThickness="1" HorizontalAlignment="Stretch">
|
||||
<TextBlock Text="全局数据节点" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
<local:NextStepJunctionControl Grid.Column="2" MyNode="{Binding NodeModel}" x:Name="NextStepJunctionControl" HorizontalAlignment="Right" Grid.RowSpan="2"/>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Serein.Workbench.Node.View
|
||||
var env = App.GetService<IFlowEnvironment>();
|
||||
base.ViewModel = new GlobalDataNodeControlViewModel(new SingleGlobalDataNode(env));
|
||||
base.ViewModel.IsEnabledOnView = false;
|
||||
base.ViewModel.NodeModel.DisplayName = "[全局数据]";
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -23,6 +24,7 @@ namespace Serein.Workbench.Node.View
|
||||
public GlobalDataControl(GlobalDataNodeControlViewModel viewModel) : base(viewModel)
|
||||
{
|
||||
DataContext = viewModel;
|
||||
viewModel.NodeModel.DisplayName = "[全局数据]";
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace Serein.Workbench.Node.View
|
||||
// 获取 MethodDetailsControl 实例
|
||||
var methodDetailsControl = this.MethodDetailsControl;
|
||||
var itemsControl = FindVisualChild<ItemsControl>(methodDetailsControl); // 查找 ItemsControl
|
||||
if (itemsControl != null)
|
||||
|
||||
if (itemsControl != null && base.ViewModel.NodeModel.MethodDetails != null)
|
||||
{
|
||||
var argDataJunction = new JunctionControlBase[base.ViewModel.NodeModel.MethodDetails.ParameterDetailss.Length];
|
||||
var controls = new List<JunctionControlBase>();
|
||||
|
||||
@@ -27,13 +27,14 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<Border Grid.Column="1" BorderThickness="1" HorizontalAlignment="Stretch">
|
||||
<TextBlock Text="UI控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!--显示UI-->
|
||||
<Border x:Name="EmbedContainer" Width="200" Height="200" Grid.Row="1" BorderBrush="Black" BorderThickness="1">
|
||||
<!--<ContentControl />-->
|
||||
|
||||
</Border>
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Serein.Workbench.Node.View
|
||||
public UINodeControl()
|
||||
{
|
||||
base.ViewModel.IsEnabledOnView = true;
|
||||
base.ViewModel.NodeModel.DisplayName = "[流程UI]";
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -33,6 +34,7 @@ namespace Serein.Workbench.Node.View
|
||||
{
|
||||
ViewModel = viewModel;
|
||||
DataContext = viewModel;
|
||||
ViewModel.NodeModel.DisplayName = "[流程UI]";
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Serein.Workbench.Node.ViewModel;
|
||||
using Serein.Workbench.ViewModels;
|
||||
using Serein.Workbench.Views;
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -20,7 +21,7 @@ namespace Serein.Workbench.Services
|
||||
/// <summary>
|
||||
/// 流程节点管理
|
||||
/// </summary>
|
||||
public class FlowNodeService
|
||||
public class FlowNodeService
|
||||
{
|
||||
|
||||
|
||||
@@ -44,6 +45,16 @@ namespace Serein.Workbench.Services
|
||||
/// </summary>
|
||||
public Action<FlowCanvasView> OnViewCanvasChanged{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 查看的节点发生变化
|
||||
/// </summary>
|
||||
public Action<NodeControlBase> OnViewNodeControlChanged{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 查看方法发生变化
|
||||
/// </summary>
|
||||
public Action<MethodDetailsInfo> OnViewMethodDetailsInfoChanged { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 创建节点相关的属性
|
||||
@@ -64,10 +75,39 @@ namespace Serein.Workbench.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private NodeControlBase? currentSelectNodeControl;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的节点
|
||||
/// </summary>
|
||||
public NodeControlBase? CurrentSelectNodeControl { get => currentSelectNodeControl; set
|
||||
{
|
||||
if (value == null || value.Equals(currentSelectNodeControl))
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentSelectNodeControl = value;
|
||||
OnViewNodeControlChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
private MethodDetailsInfo? currentMethodDetailsInfo;
|
||||
|
||||
/// <summary>
|
||||
/// 当前拖动的方法信息
|
||||
/// </summary>
|
||||
public MethodDetailsInfo? CurrentDragMdInfo { get; set; }
|
||||
public MethodDetailsInfo? CurrentMethodDetailsInfo { get => currentMethodDetailsInfo; set
|
||||
{
|
||||
if (value == null || value.Equals(currentMethodDetailsInfo))
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentMethodDetailsInfo = value;
|
||||
OnViewMethodDetailsInfoChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前需要创建的节点类型
|
||||
@@ -79,10 +119,6 @@ namespace Serein.Workbench.Services
|
||||
/// </summary>
|
||||
public PositionOfUI? CurrentMouseLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的节点
|
||||
/// </summary>
|
||||
public NodeControlBase? CurrentSelectNodeControl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 连接数据
|
||||
@@ -651,7 +687,7 @@ namespace Serein.Workbench.Services
|
||||
string canvasGuid = model.Guid;
|
||||
NodeControlType nodeType = CurrentNodeControlType;
|
||||
PositionOfUI? position = CurrentMouseLocation;
|
||||
MethodDetailsInfo? methodDetailsInfo = CurrentDragMdInfo;
|
||||
MethodDetailsInfo? methodDetailsInfo = CurrentMethodDetailsInfo;
|
||||
|
||||
if (position is null)
|
||||
{
|
||||
|
||||
60
Workbench/Services/FlowProjectService.cs
Normal file
60
Workbench/Services/FlowProjectService.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Newtonsoft.Json;
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Env;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.Services
|
||||
{
|
||||
public class FlowProjectService
|
||||
{
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
|
||||
public SereinProjectData? FlowProjectData { get; set; }
|
||||
public string FileDataPath { get; set; }
|
||||
|
||||
public FlowProjectService(IFlowEnvironment flowEnvironment)
|
||||
{
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
}
|
||||
|
||||
public void LoadLocalProject(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容
|
||||
this.FlowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
|
||||
this.FileDataPath = System.IO.Path.GetDirectoryName(filePath)!; // filePath;//
|
||||
var dir = Path.GetDirectoryName(filePath);
|
||||
var flowEnvInfo = new FlowEnvInfo
|
||||
{
|
||||
Project = FlowProjectData,
|
||||
};
|
||||
flowEnvironment.LoadProject(flowEnvInfo, FileDataPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectProjectFile()
|
||||
{
|
||||
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
openFileDialog.Filter = "流程项目文件|*.dnf|所有文件|*.*";
|
||||
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
openFileDialog.Title = "打开项目文件";
|
||||
openFileDialog.Multiselect = false;
|
||||
|
||||
// 显示文件对话框
|
||||
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
// 获取用户选择的文件路径
|
||||
var projectFile = openFileDialog.FileName;
|
||||
LoadLocalProject(projectFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,13 @@ namespace Serein.Workbench.ViewModels
|
||||
public BaseNodesViewModel BaseNodesViewModel => App.GetService<BaseNodesViewModel>() ?? throw new NotImplementedException();
|
||||
public FlowLibrarysViewModel FlowLibrarysViewModel => App.GetService<FlowLibrarysViewModel>() ?? throw new NotImplementedException();
|
||||
public FlowEditViewModel FlowEditViewModel => App.GetService<FlowEditViewModel>() ?? throw new NotImplementedException();
|
||||
public ViewNodeInfoViewModel NodeInfoViewModel => App.GetService<ViewNodeInfoViewModel>() ?? throw new NotImplementedException();
|
||||
public ViewNodeMethodInfoViewModel ViewNodeMethodInfoViewModel => App.GetService<ViewNodeMethodInfoViewModel>() ?? throw new NotImplementedException();
|
||||
|
||||
|
||||
|
||||
public FlowCanvasViewModel FlowCanvasViewModel => App.GetService<FlowCanvasViewModel>() ?? throw new NotImplementedException();
|
||||
public CanvasInfoViewModel CanvasNodeTreeViewModel => App.GetService<CanvasInfoViewModel>() ?? throw new NotImplementedException();
|
||||
public ViewCanvasInfoViewModel CanvasNodeTreeViewModel => App.GetService<ViewCanvasInfoViewModel>() ?? throw new NotImplementedException();
|
||||
|
||||
public IServiceProvider ServiceProvider { get; }
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
private readonly IFlowEnvironment environment;
|
||||
private readonly FlowNodeService flowNodeService;
|
||||
private readonly FlowProjectService flowProjectService;
|
||||
|
||||
/// <summary>
|
||||
/// 保存项目
|
||||
@@ -61,10 +62,13 @@ namespace Serein.Workbench.ViewModels
|
||||
|
||||
|
||||
|
||||
public MainMenuBarViewModel(IFlowEnvironment environment, FlowNodeService flowNodeService)
|
||||
public MainMenuBarViewModel(IFlowEnvironment environment,
|
||||
FlowNodeService flowNodeService,
|
||||
FlowProjectService flowProjectService)
|
||||
{
|
||||
this.environment = environment;
|
||||
this.flowNodeService = flowNodeService;
|
||||
this.flowProjectService = flowProjectService;
|
||||
SaveProjectCommand = new RelayCommand(SaveProject); // 保存项目
|
||||
LoadLocalProjectCommand = new RelayCommand(LoadLocalProject); // 加载本地项目
|
||||
LoadRemoteProjectCommand = new RelayCommand(LoadRemoteProject); // 加载远程项目
|
||||
@@ -78,12 +82,16 @@ namespace Serein.Workbench.ViewModels
|
||||
|
||||
OpenEnvOutWindowCommand = new RelayCommand(OpenEnvOutWindow); // 打开运行输出窗口
|
||||
OpenDynamicCompilerCommand = new RelayCommand(OpenDynamicCompiler); // 打开动态编译仓库窗口
|
||||
this.flowProjectService = flowProjectService;
|
||||
}
|
||||
|
||||
private void SaveProject() => environment.SaveProject(); // 保存项目
|
||||
private void LoadLocalProject() {
|
||||
//environment.LoadProject(); // 加载项目
|
||||
|
||||
flowProjectService.SelectProjectFile(); //选择项目
|
||||
}
|
||||
|
||||
|
||||
private void LoadRemoteProject()
|
||||
{
|
||||
}
|
||||
@@ -91,7 +99,7 @@ namespace Serein.Workbench.ViewModels
|
||||
|
||||
private void RemoteFlowCanvas() => flowNodeService.RemoveFlowCanvas();
|
||||
|
||||
private void StartFlow() => environment.StartFlowAsync([.. flowNodeService.FlowCanvass.Select(c => c.Guid)]);
|
||||
private void StartUIFlow() => environment.StartFlowAsync([.. flowNodeService.FlowCanvass.Select(c => c.Guid)]);
|
||||
private void StartCurrentCanvasFlow() => environment.StartFlowAsync([flowNodeService.CurrentSelectCanvas.Guid]);
|
||||
private void StopCurrentCanvasFlow() { }
|
||||
private void OpenDynamicCompiler() { }
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
internal partial class CanvasInfoViewModel : ObservableObject
|
||||
internal partial class ViewCanvasInfoViewModel : ObservableObject
|
||||
{
|
||||
private readonly FlowNodeService flowNodeService;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Serein.Workbench.ViewModels
|
||||
[ObservableProperty]
|
||||
private FlowCanvasDetails _model;
|
||||
|
||||
public CanvasInfoViewModel(FlowNodeService flowNodeService)
|
||||
public ViewCanvasInfoViewModel(FlowNodeService flowNodeService)
|
||||
{
|
||||
this.flowNodeService = flowNodeService;
|
||||
this.flowNodeService.OnViewCanvasChanged += OnViewCanvasChanged;
|
||||
@@ -34,5 +34,8 @@ namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
Model = flowCanvas.ViewModel.Model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
46
Workbench/ViewModels/ViewNodeInfoViewModel.cs
Normal file
46
Workbench/ViewModels/ViewNodeInfoViewModel.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.Node.View;
|
||||
using Serein.Workbench.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
internal partial class ViewNodeInfoViewModel : ObservableObject
|
||||
{
|
||||
private readonly FlowNodeService flowNodeService;
|
||||
|
||||
/// <summary>
|
||||
/// 当前预览的节点
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private NodeModelBase viewNodeModel;
|
||||
|
||||
public ViewNodeInfoViewModel(FlowNodeService flowNodeService)
|
||||
{
|
||||
this.flowNodeService = flowNodeService;
|
||||
InitEvent();
|
||||
}
|
||||
|
||||
private void InitEvent()
|
||||
{
|
||||
flowNodeService.OnViewNodeControlChanged += OnViewNodeControlChanged;
|
||||
}
|
||||
private void OnViewNodeControlChanged(NodeControlBase viewNodeControl)
|
||||
{
|
||||
if(viewNodeControl is null)
|
||||
{
|
||||
ViewNodeModel = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewNodeModel = viewNodeControl.ViewModel.NodeModel;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Workbench/ViewModels/ViewNodeMethodInfoViewModel.cs
Normal file
40
Workbench/ViewModels/ViewNodeMethodInfoViewModel.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
internal partial class ViewNodeMethodInfoViewModel : ObservableObject
|
||||
{
|
||||
private readonly FlowNodeService flowNodeService;
|
||||
|
||||
/// <summary>
|
||||
/// 当前预览的节点
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private MethodDetailsInfo mdInfo;
|
||||
|
||||
public ViewNodeMethodInfoViewModel(FlowNodeService flowNodeService)
|
||||
{
|
||||
this.flowNodeService = flowNodeService;
|
||||
|
||||
InitEvent();
|
||||
}
|
||||
private void InitEvent()
|
||||
{
|
||||
flowNodeService.OnViewMethodDetailsInfoChanged += OnViewMethodDetailsInfoChanged;
|
||||
}
|
||||
private void OnViewMethodDetailsInfoChanged(MethodDetailsInfo methodDetailsInfo)
|
||||
{
|
||||
MdInfo = methodDetailsInfo;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,11 @@
|
||||
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!--<nodeView:NetScriptNodeControl x:Name="NetScriptNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>-->
|
||||
<nodeView:FlowCallNodeControl MaxWidth="250" MaxHeight="100" x:Name="FlowCallNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ScriptNodeControl MaxWidth="250" MaxHeight="100" x:Name="ScriptNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:GlobalDataControl MaxWidth="250" MaxHeight="100" x:Name="GlobalDataControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ExpOpNodeControl MaxWidth="250" MaxHeight="100" x:Name="ExpOpNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ConditionNodeControl MaxWidth="250" MaxHeight="100" x:Name="ConditionNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:FlowCallNodeControl MaxWidth="110" MaxHeight="160" x:Name="FlowCallNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ScriptNodeControl MaxWidth="110" MaxHeight="160" x:Name="ScriptNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:GlobalDataControl MaxWidth="110" MaxHeight="160" x:Name="GlobalDataControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ExpOpNodeControl MaxWidth="110" MaxHeight="160" x:Name="ExpOpNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ConditionNodeControl MaxWidth="110" MaxHeight="160" x:Name="ConditionNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<!--<nodeView:ConditionRegionControl x:Name="ConditionRegionControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>-->
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.CanvasInfoView"
|
||||
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:vm="clr-namespace:Serein.Workbench.ViewModels"
|
||||
xmlns:converter="clr-namespace:Serein.Workbench.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="300"
|
||||
d:DataContext="{d:DesignInstance vm:CanvasInfoViewModel}">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
|
||||
<Style x:Key="InfoTipsTextBlock" TargetType="TextBlock">
|
||||
<Setter Property="Width" Value="70"/>
|
||||
<Setter Property="MinWidth" Value="70"/>
|
||||
<Setter Property="MaxHeight" Value="70"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style x:Key="InfoValueTextBox" TargetType="TextBox">
|
||||
<Setter Property="Width" Value="170"/>
|
||||
<Setter Property="MinWidth" Value="170"/>
|
||||
<Setter Property="MaxHeight" Value="170"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="10" >
|
||||
<TextBlock Text="公开节点" HorizontalAlignment="Left"/>
|
||||
<ListBox ItemsSource="{Binding Model.PublicNodes}"
|
||||
Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="2" Margin="10">
|
||||
<TextBlock Text="流程节点" HorizontalAlignment="Left"/>
|
||||
<ListBox ItemsSource="{Binding Model.Nodes}"
|
||||
Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="10">
|
||||
<TextBlock Text="画布信息" HorizontalAlignment="Left"/>
|
||||
<!--<StackPanel Margin="2" Orientation="Horizontal">
|
||||
<TextBlock Text="GUID" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Guid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>-->
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="画布名称" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="尺寸宽度" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Width, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="尺寸高度" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Height, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="预览位置X" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ViewX, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="预览位置Y" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ViewY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -40,6 +40,7 @@ using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
using TextDataFormat = System.Windows.TextDataFormat;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
@@ -119,7 +120,7 @@ namespace Serein.Workbench.Views
|
||||
private readonly TranslateTransform translateTransform;
|
||||
#endregion
|
||||
|
||||
#region 初始化以及相关事件
|
||||
#region 初始化
|
||||
|
||||
public FlowCanvasView(FlowCanvasDetails model)
|
||||
{
|
||||
@@ -128,12 +129,13 @@ namespace Serein.Workbench.Views
|
||||
this.DataContext = vm;
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
flowEnvironment = App.GetService<IFlowEnvironment>();
|
||||
flowNodeService = App.GetService<FlowNodeService>();
|
||||
keyEventService = App.GetService<IKeyEventService>();
|
||||
flowEEForwardingService = App.GetService<IFlowEEForwardingService>();
|
||||
flowNodeService.OnCreateNode += OnCreateNode;
|
||||
keyEventService.OnKeyDown += KeyEventService_OnKeyDown;
|
||||
|
||||
|
||||
//flowEEForwardingService.OnProjectLoaded += FlowEEForwardingService_OnProjectLoaded;
|
||||
|
||||
// 缩放平移容器
|
||||
@@ -144,17 +146,10 @@ namespace Serein.Workbench.Views
|
||||
canvasTransformGroup.Children.Add(translateTransform);
|
||||
FlowChartCanvas.RenderTransform = canvasTransformGroup;
|
||||
SetBinding(model);
|
||||
|
||||
InitEvent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void FlowEEForwardingService_OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||
{
|
||||
RefreshAllLine();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置绑定
|
||||
/// </summary>
|
||||
@@ -162,12 +157,12 @@ namespace Serein.Workbench.Views
|
||||
private void SetBinding(FlowCanvasDetails canvasModel)
|
||||
{
|
||||
Binding bindingScaleX = new(nameof(canvasModel.ScaleX)) { Source = canvasModel, Mode = BindingMode.TwoWay };
|
||||
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleXProperty, bindingScaleX);
|
||||
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleXProperty, bindingScaleX);
|
||||
|
||||
Binding bindingScaleY = new(nameof(canvasModel.ScaleY)){ Source = canvasModel, Mode = BindingMode.TwoWay };
|
||||
Binding bindingScaleY = new(nameof(canvasModel.ScaleY)) { Source = canvasModel, Mode = BindingMode.TwoWay };
|
||||
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleYProperty, bindingScaleY);
|
||||
|
||||
Binding bindingX = new(nameof(canvasModel.ViewX)) { Source = canvasModel, Mode = BindingMode.TwoWay };
|
||||
Binding bindingX = new(nameof(canvasModel.ViewX)) { Source = canvasModel, Mode = BindingMode.TwoWay };
|
||||
BindingOperations.SetBinding(translateTransform, TranslateTransform.XProperty, bindingX);
|
||||
|
||||
Binding bindingY = new(nameof(canvasModel.ViewY)) { Source = canvasModel, Mode = BindingMode.TwoWay };
|
||||
@@ -176,17 +171,114 @@ namespace Serein.Workbench.Views
|
||||
}
|
||||
|
||||
|
||||
private void InitEvent()
|
||||
{
|
||||
flowNodeService.OnCreateNode += OnCreateNode;
|
||||
keyEventService.OnKeyDown += KeyEventService_OnKeyDown;
|
||||
flowEEForwardingService.OnNodeLocated += FlowEEForwardingService_OnNodeLocated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 节点需要定位
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEEForwardingService_OnNodeLocated(NodeLocatedEventArgs eventArgs)
|
||||
{
|
||||
if(!ViewModel.NodeControls.TryGetValue(eventArgs.NodeGuid,out var nodeControl))
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*if (nodeControl.FlowCanvas.Guid.Equals(Guid)) // 防止事件传播到其它画布
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
|
||||
// 获取控件在 FlowChartCanvas 上的相对位置
|
||||
#if false
|
||||
Rect controlBounds = VisualTreeHelper.GetDescendantBounds(nodeControl);
|
||||
Point controlPosition = nodeControl.TransformToAncestor(FlowChartCanvas).Transform(new Point(0, 0));
|
||||
|
||||
// 获取控件在画布上的中心点
|
||||
double controlCenterX = controlPosition.X + controlBounds.Width / 2;
|
||||
double controlCenterY = controlPosition.Y + controlBounds.Height / 2;
|
||||
|
||||
// 考虑缩放因素计算目标位置的中心点
|
||||
double scaledCenterX = controlCenterX * scaleTransform.ScaleX;
|
||||
double scaledCenterY = controlCenterY * scaleTransform.ScaleY;
|
||||
|
||||
// 计算平移偏移量,使得控件在可视区域的中心
|
||||
double translateX = scaledCenterX - this.FlowChartStackPanel.ActualWidth / 2;
|
||||
double translateY = scaledCenterY - FlowChartStackPanel.ActualHeight / 2;
|
||||
|
||||
var translate = this.translateTransform;
|
||||
// 应用平移变换
|
||||
translate.X = 0;
|
||||
translate.Y = 0;
|
||||
translate.X -= translateX;
|
||||
translate.Y -= translateY;
|
||||
#endif
|
||||
|
||||
// 设置RenderTransform以实现移动效果
|
||||
TranslateTransform translateTransform = new TranslateTransform();
|
||||
nodeControl.RenderTransform = translateTransform;
|
||||
ElasticAnimation(nodeControl, translateTransform, 6, 0.5, 0.5);
|
||||
}
|
||||
/// <summary>
|
||||
/// 控件抖动
|
||||
/// 来源:https://www.cnblogs.com/RedSky/p/17705411.html
|
||||
/// 作者:HotSky
|
||||
/// </summary>
|
||||
/// <param name="translate"></param>
|
||||
/// <param name="nodeControl">需要抖动的控件</param>
|
||||
/// <param name="power">抖动第一下偏移量</param>
|
||||
/// <param name="range">减弱幅度(小于等于power,大于0)</param>
|
||||
/// <param name="speed">持续系数(大于0),越大时间越长,</param>
|
||||
private static void ElasticAnimation(NodeControlBase nodeControl, TranslateTransform translate, double power, double range = 1, double speed = 1)
|
||||
{
|
||||
DoubleAnimationUsingKeyFrames animation1 = new DoubleAnimationUsingKeyFrames();
|
||||
for (double i = power, j = 1; i >= 0; i -= range)
|
||||
{
|
||||
animation1.KeyFrames.Add(new LinearDoubleKeyFrame(-i, TimeSpan.FromMilliseconds(j++ * 100 * speed)));
|
||||
animation1.KeyFrames.Add(new LinearDoubleKeyFrame(i, TimeSpan.FromMilliseconds(j++ * 100 * speed)));
|
||||
}
|
||||
translate.BeginAnimation(TranslateTransform.YProperty, animation1);
|
||||
DoubleAnimationUsingKeyFrames animation2 = new DoubleAnimationUsingKeyFrames();
|
||||
for (double i = power, j = 1; i >= 0; i -= range)
|
||||
{
|
||||
animation2.KeyFrames.Add(new LinearDoubleKeyFrame(-i, TimeSpan.FromMilliseconds(j++ * 100 * speed)));
|
||||
animation2.KeyFrames.Add(new LinearDoubleKeyFrame(i, TimeSpan.FromMilliseconds(j++ * 100 * speed)));
|
||||
}
|
||||
translate.BeginAnimation(TranslateTransform.XProperty, animation2);
|
||||
|
||||
animation2.Completed += (s, e) =>
|
||||
{
|
||||
nodeControl.RenderTransform = null; // 或者重新设置为默认值
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载完成后刷新显示
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEEForwardingService_OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||
{
|
||||
RefreshAllLine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前画布创建了节点
|
||||
/// </summary>
|
||||
/// <param name="nodeControl"></param>
|
||||
private void OnCreateNode(NodeControlBase nodeControl)
|
||||
{
|
||||
if (!nodeControl.FlowCanvas.Guid.Equals(Guid))
|
||||
{
|
||||
// 防止事件传播到其它画布
|
||||
return;
|
||||
}
|
||||
if (!nodeControl.FlowCanvas.Guid.Equals(Guid)) // 防止事件传播到其它画布
|
||||
{
|
||||
return;
|
||||
}
|
||||
var p = nodeControl.ViewModel.NodeModel.Position;
|
||||
PositionOfUI position = new PositionOfUI(p.X, p.Y);
|
||||
if (TryPlaceNodeInRegion(nodeControl, position, out var regionControl)) // 判断添加到区域容器
|
||||
@@ -223,14 +315,14 @@ namespace Serein.Workbench.Views
|
||||
// 准备放置条件表达式控件
|
||||
if (nodeControl.ViewModel.NodeModel.ControlType == NodeControlType.ExpCondition)
|
||||
{
|
||||
/* ConditionRegionControl? conditionRegion = WpfFuncTool.GetParentOfType<ConditionRegionControl>(hitElement);
|
||||
if (conditionRegion is not null)
|
||||
{
|
||||
targetNodeControl = conditionRegion;
|
||||
//// 如果存在条件区域容器
|
||||
//conditionRegion.AddCondition(nodeControl);
|
||||
return true;
|
||||
}*/
|
||||
/* ConditionRegionControl? conditionRegion = WpfFuncTool.GetParentOfType<ConditionRegionControl>(hitElement);
|
||||
if (conditionRegion is not null)
|
||||
{
|
||||
targetNodeControl = conditionRegion;
|
||||
//// 如果存在条件区域容器
|
||||
//conditionRegion.AddCondition(nodeControl);
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
|
||||
else
|
||||
@@ -246,11 +338,13 @@ namespace Serein.Workbench.Views
|
||||
}
|
||||
targetNodeControl = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 画布接口实现
|
||||
|
||||
|
||||
|
||||
#region 接口实现
|
||||
private IFlowCanvas Api => this;
|
||||
|
||||
public string Guid
|
||||
@@ -273,7 +367,7 @@ namespace Serein.Workbench.Views
|
||||
}
|
||||
void IFlowCanvas.Add(NodeControlBase nodeControl)
|
||||
{
|
||||
|
||||
|
||||
ViewModel.NodeControls.TryAdd(nodeControl.ViewModel.NodeModel.Guid, nodeControl);
|
||||
|
||||
FlowChartCanvas.Dispatcher.Invoke(() =>
|
||||
@@ -356,7 +450,7 @@ namespace Serein.Workbench.Views
|
||||
//}
|
||||
}
|
||||
}
|
||||
void IFlowCanvas.CreateArgConnection(NodeControlBase fromNodeControl, NodeControlBase toNodeControl,ConnectionArgSourceType type, int index)
|
||||
void IFlowCanvas.CreateArgConnection(NodeControlBase fromNodeControl, NodeControlBase toNodeControl, ConnectionArgSourceType type, int index)
|
||||
{
|
||||
if (fromNodeControl is not INodeJunction IFormJunction || toNodeControl is not INodeJunction IToJunction)
|
||||
{
|
||||
@@ -377,7 +471,8 @@ namespace Serein.Workbench.Views
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(100);
|
||||
await App.UIContextOperation.InvokeAsync(() => {
|
||||
await App.UIContextOperation.InvokeAsync(() =>
|
||||
{
|
||||
Api.CreateArgConnection(fromNodeControl, toNodeControl, type, index);
|
||||
});
|
||||
});
|
||||
@@ -651,7 +746,7 @@ namespace Serein.Workbench.Views
|
||||
if (e.Data.GetData(MouseNodeType.CreateDllNodeInCanvas) is MoveNodeModel nodeModel)
|
||||
{
|
||||
flowNodeService.CurrentNodeControlType = nodeModel.NodeControlType; // 设置基础节点类型
|
||||
flowNodeService.CurrentDragMdInfo = nodeModel.MethodDetailsInfo; // 基础节点不需要参数信息
|
||||
flowNodeService.CurrentMethodDetailsInfo = nodeModel.MethodDetailsInfo; // 基础节点不需要参数信息
|
||||
flowNodeService.CurrentMouseLocation = position; // 设置当前鼠标为止
|
||||
flowNodeService.CreateNode(); // 创建来自DLL加载的方法节点
|
||||
}
|
||||
@@ -674,7 +769,7 @@ namespace Serein.Workbench.Views
|
||||
if (nodeControlType != NodeControlType.None)
|
||||
{
|
||||
flowNodeService.CurrentNodeControlType = nodeControlType; // 设置基础节点类型
|
||||
flowNodeService.CurrentDragMdInfo = null; // 基础节点不需要参数信息
|
||||
flowNodeService.CurrentMethodDetailsInfo = null; // 基础节点不需要参数信息
|
||||
flowNodeService.CurrentMouseLocation = position; // 设置当前鼠标为止
|
||||
flowNodeService.CreateNode(); // 创建基础节点
|
||||
|
||||
@@ -1095,6 +1190,10 @@ namespace Serein.Workbench.Views
|
||||
}
|
||||
if (selectNodeControls.Count == 1)
|
||||
{
|
||||
var nodeConotrol = selectNodeControls[0];
|
||||
// 选取了控件
|
||||
flowNodeService.CurrentSelectNodeControl = nodeConotrol; // 更新选取节点显示
|
||||
App.GetService<FlowNodeService>().CurrentMethodDetailsInfo = nodeConotrol.ViewModel.NodeModel.MethodDetails.ToInfo();
|
||||
// ChangeViewerObjOfNode(selectNodeControls[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="250"/>
|
||||
<ColumnDefinition Width="1.3*"/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="6*"/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
@@ -31,16 +31,34 @@
|
||||
<!--<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" />
|
||||
<local:BaseNodesView Grid.Row="0" Grid.ColumnSpan="1" Margin="5,2,5,2"/>
|
||||
<local:FlowLibrarysView Grid.Row="1" Grid.ColumnSpan="1" Margin="5,2,5,2" />
|
||||
</Grid>
|
||||
<!--功能区和编辑区的分割线-->
|
||||
<GridSplitter Grid.Row="1" Grid.Column="1" Width="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Background="#CCD5F0" />
|
||||
<GridSplitter Grid.Row="1" Grid.Column="1" Width="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Background="#E7F0F6" />
|
||||
<!--流程编辑区-->
|
||||
<local:FlowEditView Grid.Row="1" Grid.Column="2"/>
|
||||
<local:FlowEditView Grid.Row="1" Grid.Column="2" Margin="5,2,5,2"/>
|
||||
<!--编辑区和视图区的分割线-->
|
||||
<GridSplitter Grid.Row="1" Grid.Column="3" Width="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Background="#CCD5F0" />
|
||||
<GridSplitter Grid.Row="1" Grid.Column="3" Width="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Background="#E7F0F6" />
|
||||
|
||||
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="4" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" MaxHeight="400"/>
|
||||
<RowDefinition Height="auto" MaxHeight="400"/>
|
||||
<RowDefinition Height="auto" MaxHeight="400"/>
|
||||
<RowDefinition Height="*" MaxHeight="400"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<local:ViewCanvasInfoView Grid.Row="0" Margin="5,2,5,2"/>
|
||||
<local:ViewNodeInfoView Grid.Row="1" Margin="5,2,5,2"/>
|
||||
<local:ViewNodeMethodInfoView Grid.Row="2" Margin="5,2,5,2"/>
|
||||
</Grid>
|
||||
|
||||
<local:CanvasInfoView Grid.Row="1" Grid.Column="4" />
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
116
Workbench/Views/ViewCanvasInfoView.xaml
Normal file
116
Workbench/Views/ViewCanvasInfoView.xaml
Normal file
@@ -0,0 +1,116 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.ViewCanvasInfoView"
|
||||
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:vm="clr-namespace:Serein.Workbench.ViewModels"
|
||||
xmlns:converter="clr-namespace:Serein.Workbench.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="300"
|
||||
d:DataContext="{d:DesignInstance vm:ViewCanvasInfoViewModel}">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
|
||||
<Style x:Key="InfoTipsTextBlock" TargetType="TextBlock">
|
||||
<Setter Property="Width" Value="70"/>
|
||||
<Setter Property="MinWidth" Value="70"/>
|
||||
<Setter Property="MaxHeight" Value="70"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style x:Key="InfoValueTextBox" TargetType="TextBox">
|
||||
<Setter Property="Width" Value="170"/>
|
||||
<Setter Property="MinWidth" Value="170"/>
|
||||
<Setter Property="MaxHeight" Value="170"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="10" >
|
||||
<TextBlock Text="公开节点" HorizontalAlignment="Left"/>
|
||||
<ListBox ItemsSource="{Binding Model.PublicNodes}"
|
||||
Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding ControlType}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding DisplayName}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="2" Margin="10">
|
||||
<TextBlock Text="流程节点" HorizontalAlignment="Left"/>
|
||||
<ListBox ItemsSource="{Binding Model.Nodes}"
|
||||
Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding ControlType}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding DisplayName}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="10">
|
||||
<TextBlock Text="画布信息" HorizontalAlignment="Left"/>
|
||||
<!--<StackPanel Margin="2" Orientation="Horizontal">
|
||||
<TextBlock Text="GUID" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Guid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>-->
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="画布名称" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="尺寸宽度" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Width, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="尺寸高度" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.Height, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="预览位置X" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ViewX, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="预览位置Y" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ViewY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
51
Workbench/Views/ViewCanvasInfoView.xaml.cs
Normal file
51
Workbench/Views/ViewCanvasInfoView.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
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>
|
||||
/// CanvasNodeTreeView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ViewCanvasInfoView : UserControl
|
||||
{
|
||||
private readonly ViewCanvasInfoViewModel ViewModel;
|
||||
private readonly ViewNodeInfoViewModel NodeInfoViewModel;
|
||||
public ViewCanvasInfoView()
|
||||
{
|
||||
this.ViewModel = App.GetService<ViewCanvasInfoViewModel>();
|
||||
this.NodeInfoViewModel = App.GetService<ViewNodeInfoViewModel>();
|
||||
this.DataContext = this.ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Grid grid && grid.DataContext is NodeModelBase nodeModel)
|
||||
{
|
||||
NodeInfoViewModel.ViewNodeModel = nodeModel;
|
||||
App.GetService<IFlowEnvironment>().NodeLocated(nodeModel.Guid);
|
||||
}
|
||||
|
||||
// 定位节点
|
||||
//if (e.ClickCount == 2)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
Workbench/Views/ViewNodeInfoView.xaml
Normal file
46
Workbench/Views/ViewNodeInfoView.xaml
Normal file
@@ -0,0 +1,46 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.ViewNodeInfoView"
|
||||
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:vm="clr-namespace:Serein.Workbench.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="300"
|
||||
d:DataContext="{d:DesignInstance vm:ViewNodeInfoViewModel}">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
|
||||
<Style x:Key="InfoTipsTextBlock" TargetType="TextBlock">
|
||||
<Setter Property="Width" Value="70"/>
|
||||
<Setter Property="MinWidth" Value="70"/>
|
||||
<Setter Property="MaxHeight" Value="70"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style x:Key="InfoValueTextBox" TargetType="TextBox">
|
||||
<Setter Property="Width" Value="170"/>
|
||||
<Setter Property="MinWidth" Value="170"/>
|
||||
<Setter Property="MaxHeight" Value="170"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<!--<ContentControl />-->
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="10">
|
||||
<TextBlock Text="节点信息" HorizontalAlignment="Left"/>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="节点Guid" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding ViewNodeModel.Guid, Mode=TwoWay}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="节点名称" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding ViewNodeModel.DisplayName, Mode=TwoWay}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -17,15 +17,16 @@ using System.Windows.Shapes;
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// CanvasNodeTreeView.xaml 的交互逻辑
|
||||
/// NodeInfoView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CanvasInfoView : UserControl
|
||||
public partial class ViewNodeInfoView : UserControl
|
||||
{
|
||||
private readonly CanvasInfoViewModel ViewModel;
|
||||
public CanvasInfoView()
|
||||
private readonly ViewNodeInfoViewModel ViewModel;
|
||||
public ViewNodeInfoView()
|
||||
{
|
||||
this.ViewModel = App.GetService<CanvasInfoViewModel>();
|
||||
this.DataContext = this.ViewModel;
|
||||
|
||||
ViewModel = App.GetService<Locator>().NodeInfoViewModel;
|
||||
this.DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
75
Workbench/Views/ViewNodeMethodInfoView.xaml
Normal file
75
Workbench/Views/ViewNodeMethodInfoView.xaml
Normal file
@@ -0,0 +1,75 @@
|
||||
<UserControl x:Class="Serein.Workbench.Views.ViewNodeMethodInfoView"
|
||||
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:vm="clr-namespace:Serein.Workbench.ViewModels"
|
||||
xmlns:converter="clr-namespace:Serein.Workbench.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="350"
|
||||
d:DataContext="{d:DesignInstance vm:ViewNodeMethodInfoViewModel}">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
|
||||
<Style x:Key="InfoTipsTextBlock" TargetType="TextBlock">
|
||||
<Setter Property="Width" Value="70"/>
|
||||
<Setter Property="MinWidth" Value="70"/>
|
||||
<Setter Property="MaxHeight" Value="70"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
<Style x:Key="InfoValueTextBox" TargetType="TextBox">
|
||||
<Setter Property="Width" Value="170"/>
|
||||
<Setter Property="MinWidth" Value="170"/>
|
||||
<Setter Property="MaxHeight" Value="170"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border BorderBrush="Black" BorderThickness="1">
|
||||
<!--<ContentControl />-->
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="10">
|
||||
<TextBlock Text="方法信息" HorizontalAlignment="Left"/>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="程序集" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding MdInfo.AssemblyName}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="方法名称" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding MdInfo.MethodName}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
|
||||
<ListBox ItemsSource="{Binding MdInfo.ParameterDetailsInfos}"
|
||||
Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<!--<Grid >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding}"/>
|
||||
</Grid>-->
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!--参数索引提示-->
|
||||
<TextBlock Text="{Binding Index, StringFormat=[{0}]}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding Name}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text=" : " Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding DataTypeFullName}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding IsParams, StringFormat=[param:{0}]}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
33
Workbench/Views/ViewNodeMethodInfoView.xaml.cs
Normal file
33
Workbench/Views/ViewNodeMethodInfoView.xaml.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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>
|
||||
/// NodeMethodInfoView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ViewNodeMethodInfoView : UserControl
|
||||
{
|
||||
private readonly ViewNodeMethodInfoViewModel ViewModel;
|
||||
|
||||
public ViewNodeMethodInfoView()
|
||||
{
|
||||
ViewModel = App.GetService<Locator>().ViewNodeMethodInfoViewModel;
|
||||
this.DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user