mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-14 20:06:34 +08:00
添加画布信息视图
This commit is contained in:
@@ -34,6 +34,7 @@ namespace Serein.Workbench
|
||||
collection.AddSingleton<FlowEditViewModel>();
|
||||
|
||||
collection.AddTransient<FlowCanvasViewModel>(); // 画布
|
||||
collection.AddTransient<CanvasInfoViewModel>(); // 画布节点树视图
|
||||
}
|
||||
|
||||
public static void AddWorkbenchServices(this IServiceCollection collection)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.ViewModels;
|
||||
using Serein.Workbench.Views;
|
||||
using System;
|
||||
@@ -19,7 +20,7 @@ namespace Serein.Workbench.Models
|
||||
/// <summary>
|
||||
/// tab 名称
|
||||
/// </summary>
|
||||
public string Name
|
||||
/* public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -34,6 +35,10 @@ namespace Serein.Workbench.Models
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
[ObservableProperty]
|
||||
private FlowCanvasDetails _model;
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -91,7 +91,13 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="4" Background="Azure" Orientation="Horizontal" Margin="3">
|
||||
|
||||
<StackPanel Grid.Row="4" Background="Azure" Orientation="Horizontal" Margin="3">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding NodeModel.IsPublic, Mode=TwoWay}"/>
|
||||
<TextBlock Text="全局公开"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding NodeModel.DebugSetting.IsEnable, Mode=TwoWay}"/>
|
||||
<TextBlock Text="是否使能"/>
|
||||
@@ -107,6 +113,8 @@
|
||||
<CheckBox IsChecked="{Binding NodeModel.DebugSetting.IsInterrupt, Mode=TwoWay}"/>
|
||||
<TextBlock Text="中断节点"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Serein.Workbench.Node.View
|
||||
{
|
||||
Canvas.Children.Remove(BezierLine);
|
||||
var env = Start.MyNode.Env;
|
||||
var canvasGuid = Start.MyNode.CanvasGuid;
|
||||
var canvasGuid = Start.MyNode.CanvasDetails.Guid;
|
||||
if (Start.JunctionType.ToConnectyionType() == JunctionOfConnectionType.Invoke)
|
||||
{
|
||||
env.RemoveConnectInvokeAsync(canvasGuid, Start.MyNode.Guid, End.MyNode.Guid, InvokeType);
|
||||
|
||||
16
Workbench/Node/View/FlowCallNodeControl.xaml
Normal file
16
Workbench/Node/View/FlowCallNodeControl.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<local:NodeControlBase x:Class="Serein.Workbench.Node.View.FlowCallNodeControl"
|
||||
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.Node.View"
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance vm:FlipflopNodeControlViewModel}">
|
||||
<Grid>
|
||||
<!--选择画布-->
|
||||
<!--选择公开的节点-->
|
||||
</Grid>
|
||||
</local:NodeControlBase>
|
||||
36
Workbench/Node/View/FlowCallNodeControl.xaml.cs
Normal file
36
Workbench/Node/View/FlowCallNodeControl.xaml.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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.Node.View
|
||||
{
|
||||
/// <summary>
|
||||
/// FlowCallNodeControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FlowCallNodeControl : NodeControlBase, INodeJunction
|
||||
{
|
||||
public FlowCallNodeControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public JunctionControlBase ExecuteJunction => throw new NotImplementedException();
|
||||
|
||||
public JunctionControlBase NextStepJunction => throw new NotImplementedException();
|
||||
|
||||
public JunctionControlBase[] ArgDataJunction => throw new NotImplementedException();
|
||||
|
||||
public JunctionControlBase ReturnDataJunction => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
18
Workbench/Node/ViewModel/FlowCallNodeControlViewModel.cs
Normal file
18
Workbench/Node/ViewModel/FlowCallNodeControlViewModel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Serein.NodeFlow.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.Node.ViewModel
|
||||
{
|
||||
public partial class FlowCallNodeControlViewModel : NodeControlViewModelBase
|
||||
{
|
||||
public new SingleFlowCallNode NodelModel { get; }
|
||||
public FlowCallNodeControlViewModel(SingleFlowCallNode node) : base(node)
|
||||
{
|
||||
this.NodelModel = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@
|
||||
<Compile Remove="Node\Junction\NodeJunctionViewBase.cs" />
|
||||
<Compile Remove="Node\NodeBase.cs" />
|
||||
<Compile Remove="Node\View\ActionRegionControl.xaml.cs" />
|
||||
<Compile Remove="Node\View\ConditionRegionControl.xaml.cs" />
|
||||
<Compile Remove="Node\View\DllControlControl.xaml.cs" />
|
||||
<Compile Remove="Services\NodeControlService.cs" />
|
||||
<Compile Remove="Themes\ConditionControl.xaml.cs" />
|
||||
<Compile Remove="Themes\ConditionControlModel.cs" />
|
||||
@@ -43,6 +45,8 @@
|
||||
<Page Remove="MainWindow.xaml" />
|
||||
<Page Remove="Node\FlipflopRegionControl.xaml" />
|
||||
<Page Remove="Node\View\ActionRegionControl.xaml" />
|
||||
<Page Remove="Node\View\ConditionRegionControl.xaml" />
|
||||
<Page Remove="Node\View\DllControlControl.xaml" />
|
||||
<Page Remove="Themes\ConditionControl.xaml" />
|
||||
<Page Remove="Themes\ConnectionControl.xaml" />
|
||||
<Page Remove="Themes\ExplicitDataControl.xaml" />
|
||||
|
||||
@@ -36,14 +36,31 @@ namespace Serein.Workbench.Services
|
||||
/// 添加了节点
|
||||
/// </summary>
|
||||
public Action<NodeControlBase> OnCreateNode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查看的画布发生改变
|
||||
/// </summary>
|
||||
public Action<FlowCanvasView> OnViewCanvasChanged{ get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 创建节点相关的属性
|
||||
|
||||
|
||||
private FlowCanvasView currentSelectCanvas;
|
||||
/// <summary>
|
||||
/// 当前查看的画布
|
||||
/// </summary>
|
||||
public FlowCanvasView CurrentSelectCanvas { get; set; }
|
||||
public FlowCanvasView CurrentSelectCanvas { get => currentSelectCanvas; set
|
||||
{
|
||||
if (value == null || value.Equals(currentSelectCanvas))
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentSelectCanvas = value;
|
||||
OnViewCanvasChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前拖动的方法信息
|
||||
@@ -128,7 +145,7 @@ namespace Serein.Workbench.Services
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.Flipflop, typeof(FlipflopNodeControl), typeof(FlipflopNodeControlViewModel));
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.ExpOp, typeof(ExpOpNodeControl), typeof(ExpOpNodeControlViewModel));
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.ExpCondition, typeof(ConditionNodeControl), typeof(ConditionNodeControlViewModel));
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.ConditionRegion, typeof(ConditionRegionControl), typeof(ConditionRegionNodeControlViewModel));
|
||||
//flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.ConditionRegion, typeof(ConditionRegionControl), typeof(ConditionRegionNodeControlViewModel));
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.GlobalData, typeof(GlobalDataControl), typeof(GlobalDataNodeControlViewModel));
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.Script, typeof(ScriptNodeControl), typeof(ScriptNodeControlViewModel));
|
||||
flowEnvironment.NodeMVVMManagement.RegisterUI(NodeControlType.NetScript, typeof(NetScriptNodeControl), typeof(NetScriptNodeControlViewModel));
|
||||
@@ -648,7 +665,7 @@ namespace Serein.Workbench.Services
|
||||
return;
|
||||
}
|
||||
|
||||
_ = flowEnvironment.RemoveNodeAsync(model.CanvasGuid, model.Guid);
|
||||
_ = flowEnvironment.RemoveNodeAsync(model.CanvasDetails.Guid, model.Guid);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -78,14 +78,14 @@ namespace Serein.Workbench.Services
|
||||
{
|
||||
KeysState[(int)key] = true;
|
||||
OnKeyDown?.Invoke(key);
|
||||
Debug.WriteLine($"按键按下事件:{key}");
|
||||
//Debug.WriteLine($"按键按下事件:{key}");
|
||||
}
|
||||
|
||||
public void KeyUp(Key key)
|
||||
{
|
||||
KeysState[(int)key] = false;
|
||||
OnKeyUp?.Invoke(key);
|
||||
Debug.WriteLine($"按键抬起事件:{key}");
|
||||
//Debug.WriteLine($"按键抬起事件:{key}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
41
Workbench/ViewModels/CanvasNodeTreeViewModel.cs
Normal file
41
Workbench/ViewModels/CanvasNodeTreeViewModel.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.Services;
|
||||
using Serein.Workbench.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
internal partial class CanvasInfoViewModel : ObservableObject
|
||||
{
|
||||
private readonly FlowNodeService flowNodeService;
|
||||
|
||||
/// <summary>
|
||||
/// 画布数据实体
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private FlowCanvasDetails _model;
|
||||
|
||||
public CanvasInfoViewModel(FlowNodeService flowNodeService)
|
||||
{
|
||||
this.flowNodeService = flowNodeService;
|
||||
this.flowNodeService.OnViewCanvasChanged += OnViewCanvasChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查看的画布发生改变
|
||||
/// </summary>
|
||||
/// <param name="flowCanvas"></param>
|
||||
private void OnViewCanvasChanged(FlowCanvasView flowCanvas)
|
||||
{
|
||||
if (flowCanvas.DataContext is FlowCanvasViewModel vm)
|
||||
{
|
||||
Model = vm.Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,11 @@ namespace Serein.Workbench.ViewModels
|
||||
/// </summary>
|
||||
public partial class FlowEditViewModel : ObservableObject
|
||||
{
|
||||
public ObservableCollection<FlowEditorTabModel> CanvasTabs { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 画布集合
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<FlowEditorTabModel> _canvasTabs = [];
|
||||
|
||||
/// <summary>
|
||||
/// 当前选择的画布
|
||||
@@ -42,11 +45,8 @@ namespace Serein.Workbench.ViewModels
|
||||
flowNodeService.OnRemoveFlowCanvasView += OnRemoveFlowCanvasView; // 移除了画布
|
||||
this.PropertyChanged += OnPropertyChanged;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnPropertyChanged(object? value, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (this.SelectedTab is null) return;
|
||||
@@ -56,9 +56,13 @@ namespace Serein.Workbench.ViewModels
|
||||
#region 响应环境事件
|
||||
private void OnCreateFlowCanvasView(FlowCanvasView canvas)
|
||||
{
|
||||
var model = new FlowEditorTabModel(canvas);
|
||||
CanvasTabs.Add(model);
|
||||
SelectedTab = model;
|
||||
var tab = new FlowEditorTabModel(canvas);
|
||||
if(canvas is IFlowCanvas flowCanvas)
|
||||
{
|
||||
tab.Model = flowCanvas.Model;
|
||||
}
|
||||
CanvasTabs.Add(tab);
|
||||
SelectedTab = tab;
|
||||
}
|
||||
private void OnRemoveFlowCanvasView(FlowCanvasView canvas)
|
||||
{
|
||||
@@ -102,7 +106,7 @@ namespace Serein.Workbench.ViewModels
|
||||
if (tab != null)
|
||||
{
|
||||
tab.IsEditing = false;
|
||||
if(tab.Name != newName && !string.IsNullOrWhiteSpace(newName)) tab.Name = newName; // 名称合法时设置新名称
|
||||
if(tab.Model.Name != newName && !string.IsNullOrWhiteSpace(newName)) tab.Model.Name = newName; // 名称合法时设置新名称
|
||||
OnPropertyChanged(nameof(CanvasTabs)); // 刷新Tabs集合
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,25 +15,18 @@ namespace Serein.Workbench.ViewModels
|
||||
ServiceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
//private IServiceProvider GetService()
|
||||
//{
|
||||
// var service = new ServiceCollection();
|
||||
// service.AddSingleton<MainViewModel>();
|
||||
// service.AddSingleton<MainMenuBarViewModel>();
|
||||
// service.AddSingleton<FlowWorkbenchViewModel>();
|
||||
// service.AddSingleton<BaseNodesViewModel>();
|
||||
// service.AddSingleton<FlowLibrarysViewModel>();
|
||||
// service.AddTransient<FlowLibraryMethodDetailssViewModel>();
|
||||
// return service.BuildServiceProvider();
|
||||
//}
|
||||
|
||||
|
||||
public MainViewModel MainViewModel => App.GetService<MainViewModel>() ?? throw new NotImplementedException();
|
||||
public MainMenuBarViewModel MainMenuBarViewModel => App.GetService<MainMenuBarViewModel>() ?? throw new NotImplementedException();
|
||||
public FlowWorkbenchViewModel FlowWorkbenchViewModel => App.GetService<FlowWorkbenchViewModel>() ?? throw new NotImplementedException();
|
||||
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 FlowCanvasViewModel FlowCanvasViewModel => App.GetService<FlowCanvasViewModel>() ?? throw new NotImplementedException();
|
||||
public CanvasInfoViewModel CanvasNodeTreeViewModel => App.GetService<CanvasInfoViewModel>() ?? throw new NotImplementedException();
|
||||
|
||||
public IServiceProvider ServiceProvider { get; }
|
||||
}
|
||||
|
||||
96
Workbench/Views/CanvasInfoView.xaml
Normal file
96
Workbench/Views/CanvasInfoView.xaml
Normal file
@@ -0,0 +1,96 @@
|
||||
<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>
|
||||
32
Workbench/Views/CanvasInfoView.xaml.cs
Normal file
32
Workbench/Views/CanvasInfoView.xaml.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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>
|
||||
/// CanvasNodeTreeView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CanvasInfoView : UserControl
|
||||
{
|
||||
private readonly CanvasInfoViewModel ViewModel;
|
||||
public CanvasInfoView()
|
||||
{
|
||||
this.ViewModel = App.GetService<CanvasInfoViewModel>();
|
||||
this.DataContext = this.ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,14 +374,14 @@ namespace Serein.Workbench.Views
|
||||
// 准备放置条件表达式控件
|
||||
if (nodeControl.ViewModel.NodeModel.ControlType == NodeControlType.ExpCondition)
|
||||
{
|
||||
ConditionRegionControl? conditionRegion = WpfFuncTool.GetParentOfType<ConditionRegionControl>(hitElement);
|
||||
/* ConditionRegionControl? conditionRegion = WpfFuncTool.GetParentOfType<ConditionRegionControl>(hitElement);
|
||||
if (conditionRegion is not null)
|
||||
{
|
||||
targetNodeControl = conditionRegion;
|
||||
//// 如果存在条件区域容器
|
||||
//conditionRegion.AddCondition(nodeControl);
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
else
|
||||
@@ -408,13 +408,24 @@ namespace Serein.Workbench.Views
|
||||
/// <param name="key"></param>
|
||||
private void KeyEventService_OnKeyDown(Key key)
|
||||
{
|
||||
if (!flowNodeService.CurrentSelectCanvas.Guid.Equals(Guid))
|
||||
|
||||
if (flowNodeService.CurrentSelectCanvas is null || !flowNodeService.CurrentSelectCanvas.Guid.Equals(Guid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (key == Key.F5)
|
||||
{
|
||||
// F5 调试当前流程
|
||||
_ = flowEnvironment.StartFlowAsync([Guid]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (key == Key.Escape)
|
||||
{
|
||||
// 退出连线、选取状态
|
||||
IsControlDragging = false;
|
||||
IsCanvasDragging = false;
|
||||
SelectionRectangle.Visibility = Visibility.Collapsed;
|
||||
@@ -427,16 +438,33 @@ namespace Serein.Workbench.Views
|
||||
if (selectNodeControls.Count > 0 && key == Key.C && (keyEventService.GetKeyState(Key.LeftCtrl) || keyEventService.GetKeyState(Key.RightCtrl)))
|
||||
{
|
||||
var text = flowNodeService.CpoyNodeInfo([.. selectNodeControls.Select(c => c.ViewModel.NodeModel)]);
|
||||
Clipboard.SetDataObject(text, true); // 复制,持久性设置
|
||||
return;
|
||||
//Clipboard.SetText(text); // 复制,持久性设置
|
||||
try
|
||||
{
|
||||
Clipboard.SetDataObject(text, true); // 复制,持久性设置
|
||||
}
|
||||
catch
|
||||
{
|
||||
Clipboard.SetText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 粘贴节点
|
||||
if (key == Key.V && (keyEventService.GetKeyState(Key.LeftCtrl) || keyEventService.GetKeyState(Key.RightCtrl)))
|
||||
{
|
||||
string clipboardText = Clipboard.GetText(TextDataFormat.Text); // 获取复制的文本
|
||||
var jobject = JObject.Parse(clipboardText);
|
||||
var nodesText = jobject["nodes"]?.ToString();
|
||||
string nodesText = "";
|
||||
try
|
||||
{
|
||||
var jobject = JObject.Parse(clipboardText);
|
||||
nodesText = jobject["nodes"]?.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(nodesText))
|
||||
{
|
||||
|
||||
@@ -596,7 +624,7 @@ namespace Serein.Workbench.Views
|
||||
{
|
||||
NodeControlType nodeControlType = droppedType switch
|
||||
{
|
||||
Type when typeof(ConditionRegionControl).IsAssignableFrom(droppedType) => NodeControlType.ConditionRegion, // 条件区域
|
||||
//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,
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
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:converters="clr-namespace:Serein.Workbench.Tool.Converters"
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance vm:FlowEditViewModel}"
|
||||
xmlns:converters="clr-namespace:Serein.Workbench.Tool.Converters"
|
||||
Background="#E7F0F6">
|
||||
<UserControl.Resources>
|
||||
<converters:InvertableBooleanToVisibilityConverter x:Key="InvertableBooleanToVisibilityConverter"/>
|
||||
@@ -17,19 +17,20 @@
|
||||
<Grid>
|
||||
|
||||
<TabControl SelectedItem="{Binding SelectedTab}"
|
||||
ItemsSource="{Binding CanvasTabs}"
|
||||
SelectionChanged="TabControl_SelectionChanged"
|
||||
x:Name="CanvasTab">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel >
|
||||
<!-- 双击选项卡名称来进入编辑模式 -->
|
||||
<TextBlock Text="{Binding Name}"
|
||||
<TextBlock Text="{Binding Model.Name}"
|
||||
FontSize="18"
|
||||
Visibility="{Binding IsEditing, Converter={StaticResource InvertableBooleanToVisibilityConverter},ConverterParameter=Inverted}"
|
||||
Visibility="{Binding IsEditing, Converter={StaticResource InvertableBooleanToVisibilityConverter},ConverterParameter=Inverted}"
|
||||
PreviewMouseLeftButtonDown="TextBlock_PreviewMouseLeftButtonDown"
|
||||
MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>
|
||||
<!-- 编辑模式下显示TextBox -->
|
||||
<TextBox Text="{Binding Name, Mode=TwoWay}"
|
||||
<TextBox Text="{Binding Model.Name, Mode=TwoWay}"
|
||||
FontSize="18"
|
||||
Visibility="{Binding IsEditing, Converter={StaticResource InvertableBooleanToVisibilityConverter},ConverterParameter=Normal}"
|
||||
KeyDown="TextBox_KeyDown" />
|
||||
@@ -37,10 +38,7 @@
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
|
||||
<!-- Tabs Collection -->
|
||||
<TabControl.ItemsSource>
|
||||
<Binding Path="CanvasTabs" />
|
||||
</TabControl.ItemsSource>
|
||||
|
||||
|
||||
<!-- Content of the Tab (e.g., FlowCanvasView) -->
|
||||
<TabControl.ContentTemplate>
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
<!--流程编辑区-->
|
||||
<local:FlowEditView Grid.Row="1" Grid.Column="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="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" Background="#CCD5F0" />
|
||||
|
||||
<local:CanvasInfoView Grid.Row="1" Grid.Column="4" />
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user