mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-12 12:39:25 +08:00
添加画布信息视图
This commit is contained in:
@@ -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集合
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user