Demo整理

This commit is contained in:
艾竹
2023-01-25 15:21:20 +08:00
parent 40590bf98d
commit 4c5d535aad
17 changed files with 351 additions and 270 deletions

View File

@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.Flowchart.ViewModels;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
public class DragAndDropViewModel: BindableBase
{
public ToolBoxViewModel ToolBoxViewModel
{
get; private set;
}
public DiagramViewModel DiagramViewModel
{
get; private set;
}
public SelectableDesignerItemViewModelBase SelectedItem
{
get
{
return DiagramViewModel.SelectedItems?.FirstOrDefault();
}
}
private List<SelectOption> _users = new List<SelectOption>()
{
new SelectOption(){ value = "操作员1",text = "操作员1" },
new SelectOption(){ value = "操作员2",text = "操作员2" },
new SelectOption(){ value = "Admin",text = "Admin" },
};
public List<SelectOption> Users
{
get
{
return _users;
}
set
{
_users = value;
}
}
private List<SelectOption> _roles = new List<SelectOption>()
{
new SelectOption(){ value = "操作员",text = "操作员" },
new SelectOption(){ value = "管理员",text = "管理员" },
};
public List<SelectOption> Roles
{
get
{
return _roles;
}
set
{
_roles = value;
}
}
public DragAndDropViewModel()
{
ToolBoxViewModel = new ToolBoxViewModel();
DiagramViewModel = new DiagramViewModel();
DiagramViewModel.ShowGrid = true;
DiagramViewModel.GridCellSize = new Size(100, 100);
DiagramViewModel.GridMarginSize = new Size(0, 0);
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
DiagramViewModel.PageSizeType = PageSizeType.Custom;
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
DiagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
}
private void DiagramViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsSelected")
{
RaisePropertyChanged(nameof(SelectedItem));
}
}
}
}

View File

@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Text;
using AIStudio.Wpf.Flowchart;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
public class FlowchartEditorViewModel : BindableBase
{
private List<SelectOption> _users = new List<SelectOption>()
{
new SelectOption(){ value = "操作员1",text = "操作员1" },
new SelectOption(){ value = "操作员2",text = "操作员2" },
new SelectOption(){ value = "Admin",text = "Admin" },
new SelectOption(){ value = "Bob",text = "Bob" },
new SelectOption(){ value = "Alice",text = "Alice" },
};
public List<SelectOption> Users
{
get
{
return _users;
}
set
{
_users = value;
}
}
private List<SelectOption> _roles = new List<SelectOption>()
{
new SelectOption(){ value = "操作员",text = "操作员" },
new SelectOption(){ value = "管理员",text = "管理员" },
new SelectOption(){ value = "Admin",text = "Admin" },
};
public List<SelectOption> Roles
{
get
{
return _roles;
}
set
{
_roles = value;
}
}
private Func<string> _getDataFunc;
public Func<string> GetDataFunc
{
get
{
return _getDataFunc;
}
set
{
SetProperty(ref _getDataFunc, value);
}
}
private string _inputData;
public string InputData
{
get
{
return _inputData;
}
set
{
SetProperty(ref _inputData, value);
}
}
private string _outputData;
public string OutputData
{
get
{
return _outputData;
}
set
{
SetProperty(ref _outputData, value);
}
}
private string _data = "{}";
public string Data
{
get
{
return _data;
}
set
{
SetProperty(ref _data, value);
}
}
public SimpleCommand GetDataCommand
{
get; private set;
}
public SimpleCommand SetDataCommand
{
get; private set;
}
public FlowchartEditorViewModel()
{
GetDataCommand = new SimpleCommand(GetDataExcute);
SetDataCommand = new SimpleCommand(SetDataExcute);
}
private void GetDataExcute(object obj)
{
OutputData = GetDataFunc();
}
private void SetDataExcute(object obj)
{
Data = "{}";
Data = InputData;
}
}
}