mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
把底层再分割一下
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class SelectableDesignerItemViewModelBase : SelectableViewModelBase, ISelectItems, ISelectable, IGroupable
|
||||
{
|
||||
|
||||
public SelectableDesignerItemViewModelBase():base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase(IDiagramViewModel parent, SelectableDesignerItemBase designer):base(parent, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase(IDiagramViewModel parent, string json) : base(parent, json)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
SelectItemCommand = new SimpleCommand(ExecuteSelectItemCommand);
|
||||
EditCommand = new SimpleCommand(ExecuteEditCommand);
|
||||
}
|
||||
|
||||
public virtual bool InitData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public virtual bool EditData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public SimpleCommand SelectItemCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public ICommand EditCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private string _text;
|
||||
[Browsable(true)]
|
||||
[CanDo]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
var text = _text;
|
||||
if (FontViewModel.FontCase == FontCase.Upper)
|
||||
{
|
||||
return text?.ToUpper();
|
||||
}
|
||||
else if (FontViewModel.FontCase == FontCase.Lower)
|
||||
{
|
||||
return text?.ToLower();
|
||||
}
|
||||
else
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _text, value))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_text))
|
||||
{
|
||||
ShowText = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isReadOnlyText = false;
|
||||
public bool IsReadOnlyText
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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 override void AddToSelection(bool selected)
|
||||
{
|
||||
foreach (SelectableDesignerItemViewModelBase item in Parent.SelectedItems.ToList())
|
||||
item.IsSelected = false;
|
||||
|
||||
Parent.SelectedItems.Clear();
|
||||
if (selected == true)
|
||||
{
|
||||
Parent.SelectionService.AddToSelection(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ExecuteEditCommand(object param)
|
||||
{
|
||||
if (IsReadOnly == true) return;
|
||||
|
||||
ShowText = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user