mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
调整了一下各种命令的位置,便于其他应用调用
This commit is contained in:
@@ -5,19 +5,30 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
|
||||
public interface ISelectItems
|
||||
{
|
||||
SimpleCommand SelectItemCommand { get; }
|
||||
SimpleCommand SelectItemCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class SelectableDesignerItemViewModelBase : BindableBase, ISelectItems, ISelectable, IGroupable
|
||||
{
|
||||
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
|
||||
private IDiagramServiceProvider _service
|
||||
{
|
||||
get
|
||||
{
|
||||
return DiagramServicesProvider.Instance.Provider;
|
||||
}
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase()
|
||||
{
|
||||
@@ -32,6 +43,37 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase(IDiagramViewModel parent, string json)
|
||||
{
|
||||
Init();
|
||||
LoadDesignerItemViewModel(parent, JsonConvert.DeserializeObject(json, ToXmlType()) as SelectableDesignerItemBase);
|
||||
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
public virtual SelectableDesignerItemBase ToXmlObject()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual SerializableItem ToSerializabObject()
|
||||
{
|
||||
var obj = ToXmlObject();
|
||||
if (obj != null)
|
||||
{
|
||||
return new SerializableItem() { TypeName = this.GetType().FullName, ObjectJson = obj.ToJson() };
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual Type ToXmlType()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual void Init()
|
||||
{
|
||||
ColorViewModel = _service.CopyDefaultColorViewModel();
|
||||
@@ -68,13 +110,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public List<SelectableDesignerItemViewModelBase> SelectedItems
|
||||
{
|
||||
//todo
|
||||
get { return Parent.SelectedItems; }
|
||||
get
|
||||
{
|
||||
return Parent.SelectedItems;
|
||||
}
|
||||
}
|
||||
|
||||
public IDiagramViewModel Parent { get; set; }
|
||||
public SimpleCommand SelectItemCommand { get; private set; }
|
||||
public ICommand EditCommand { get; private set; }
|
||||
public Guid Id { get; set; }
|
||||
public IDiagramViewModel Parent
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public SimpleCommand SelectItemCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public ICommand EditCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public Guid Id
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private Guid _parentId;
|
||||
public Guid ParentId
|
||||
@@ -88,9 +145,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
SetProperty(ref _parentId, value);
|
||||
}
|
||||
}
|
||||
public SelectableDesignerItemViewModelBase ParentItem { get; set; }
|
||||
public SelectableDesignerItemViewModelBase ParentItem
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool IsGroup { get; set; }
|
||||
public bool IsGroup
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
[Browsable(false)]
|
||||
@@ -203,7 +266,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public ILockObjectViewModel LockObjectViewModel { get; set; }
|
||||
public ILockObjectViewModel LockObjectViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
private string _text;
|
||||
@@ -275,7 +341,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase OutTextItem { get; set; }
|
||||
public DesignerItemViewModelBase OutTextItem
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private void ExecuteSelectItemCommand(object param)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user