mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-02 15:50:51 +08:00
把底层再分割一下
This commit is contained in:
@@ -10,19 +10,9 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
|
||||
public interface ISelectItems
|
||||
public abstract class SelectableViewModelBase : BindableBase, ISelectable
|
||||
{
|
||||
SimpleCommand SelectItemCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class SelectableViewModelBase : BindableBase, ISelectItems, ISelectable, IGroupable
|
||||
{
|
||||
private IDiagramServiceProvider _service
|
||||
protected IDiagramServiceProvider _service
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -80,8 +70,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
FontViewModel = _service.CopyDefaultFontViewModel();
|
||||
|
||||
LockObjectViewModel = new LockObjectViewModel();
|
||||
SelectItemCommand = new SimpleCommand(ExecuteSelectItemCommand);
|
||||
EditCommand = new SimpleCommand(ExecuteEditCommand);
|
||||
}
|
||||
|
||||
protected virtual void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
||||
@@ -98,36 +86,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
FontViewModel = CopyHelper.Mapper<FontViewModel, FontItem>(designerbase.FontItem);
|
||||
}
|
||||
|
||||
public virtual bool InitData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public virtual bool EditData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<SelectableViewModelBase> SelectedItems
|
||||
{
|
||||
//todo
|
||||
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;
|
||||
@@ -145,19 +107,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
SetProperty(ref _parentId, value);
|
||||
}
|
||||
}
|
||||
public SelectableViewModelBase ParentItem
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool IsGroup
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
protected bool _isSelected;
|
||||
[Browsable(false)]
|
||||
public bool IsSelected
|
||||
public virtual bool IsSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -165,24 +123,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _isSelected, value))
|
||||
{
|
||||
//如果没有文字,失去焦点自动清除
|
||||
if (_isSelected == false && string.IsNullOrEmpty(Text))
|
||||
{
|
||||
ShowText = false;
|
||||
if (this is TextDesignerItemViewModel)
|
||||
{
|
||||
if (ParentItem != null)
|
||||
{
|
||||
ParentItem.OutTextItem = null;
|
||||
}
|
||||
Parent.DirectRemoveItemCommand.Execute(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SetProperty(ref _isSelected, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,19 +212,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
private string _text;
|
||||
[Browsable(true)]
|
||||
[CanDo]
|
||||
public string Text
|
||||
public virtual string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
var text = _text;
|
||||
if (OutTextItem != null)
|
||||
{
|
||||
text = OutTextItem._text;
|
||||
}
|
||||
if (FontViewModel.FontCase == FontCase.Upper)
|
||||
{
|
||||
return text?.ToUpper();
|
||||
@@ -299,81 +235,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
set
|
||||
{
|
||||
if (OutTextItem != null)
|
||||
if (SetProperty(ref _text, value))
|
||||
{
|
||||
OutTextItem.Text = value;
|
||||
}
|
||||
else if (SetProperty(ref _text, value))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_text))
|
||||
{
|
||||
ShowText = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isReadOnlyText = false;
|
||||
public bool IsReadOnlyText
|
||||
|
||||
public virtual void AddToSelection(bool selected)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsReadOnly)
|
||||
return true;
|
||||
return _isReadOnlyText;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _isReadOnlyText, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _showText;
|
||||
public virtual bool ShowText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _showText;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _showText, value);
|
||||
}
|
||||
}
|
||||
|
||||
public DesignerItemViewModelBase OutTextItem
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private void ExecuteSelectItemCommand(object param)
|
||||
{
|
||||
SelectItem((bool)param, !IsSelected);
|
||||
}
|
||||
|
||||
private void SelectItem(bool newselect, bool select)
|
||||
{
|
||||
if (newselect)
|
||||
{
|
||||
foreach (var designerItemViewModelBase in Parent.SelectedItems.ToList())
|
||||
{
|
||||
designerItemViewModelBase._isSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
IsSelected = select;
|
||||
}
|
||||
|
||||
public void AddToSelection(bool selected)
|
||||
{
|
||||
foreach (SelectableViewModelBase item in Parent.SelectedItems.ToList())
|
||||
item.IsSelected = false;
|
||||
|
||||
Parent.SelectedItems.Clear();
|
||||
if (selected == true)
|
||||
{
|
||||
Parent.SelectionService.AddToSelection(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
@@ -384,13 +256,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ExecuteEditCommand(object param)
|
||||
{
|
||||
if (IsReadOnly == true) return;
|
||||
|
||||
ShowText = true;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user