工具栏整理

This commit is contained in:
艾竹
2023-04-02 12:01:46 +08:00
parent 02ebd056b3
commit 0701f25519
30 changed files with 1730 additions and 923 deletions

View File

@@ -18,7 +18,7 @@ using AIStudio.Wpf.DiagramDesigner.Helpers;
using AIStudio.Wpf.DiagramDesigner.Models;
using AIStudio.Wpf.DiagramModels;
using AIStudio.Wpf.DiagramModels.ViewModels;
using AIStudio.Wpf.Flowchart.Models;
using AIStudio.Wpf.Mind.Models;
using AIStudio.Wpf.Mind.Helpers;
using AIStudio.Wpf.Mind.Models;
@@ -96,18 +96,18 @@ namespace AIStudio.Wpf.Mind.ViewModels
public void InitLayout(bool initAppearance)
{
var layout = TypeHelper.GetType(MindType.ToString() + "Layout");
var layout = TypeHelper.GetType(this.MindType.ToString() + "Layout");
MindLayout = layout != null ? (System.Activator.CreateInstance(layout) as IMindLayout) : new MindLayout();
this.PropertyChanged -= this.Item_PropertyChanged;
IsInnerConnector = true;
MindLayout.Appearance(this, MindThemeModel, initAppearance);
MindLayout.Appearance(this, MindTheme, initAppearance);
this.PropertyChanged += this.Item_PropertyChanged;
}
public void ThemeChange()
{
MindThemeHelper.ThemeChange(this, MindThemeModel);
MindThemeHelper.ThemeChange(this, MindTheme);
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
@@ -145,6 +145,32 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
#region
private MindType _mindType = MindType.Mind;
public MindType MindType
{
get
{
return GetLevel0Node()._mindType;
}
set
{
GetLevel0Node()._mindType = value;
}
}
private MindTheme _mindTheme;
public MindTheme MindTheme
{
get
{
return GetLevel0Node()._mindTheme;
}
set
{
GetLevel0Node()._mindTheme = value;
}
}
public IMindLayout MindLayout
{
get; set;
@@ -181,22 +207,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
public MindType MindType
{
get
{
return (Root as IMindDiagramViewModel)?.MindType ?? MindType.Mind;
}
}
public MindThemeModel MindThemeModel
{
get
{
return (Root as IMindDiagramViewModel)?.MindThemeModel ?? MindThemeHelper.GetTheme("天空蓝");
}
}
private bool _isExpanded = true;
public bool IsExpanded
{
@@ -560,62 +570,54 @@ namespace AIStudio.Wpf.Mind.ViewModels
case nameof(NodeLevel):
MindLayout?.Appearance(this);
break;
case nameof(Text):
{
ItemWidth = Math.Max(ItemWidth, GetTextDisplayWidthHelper.GetTextDisplayWidth(Text, new FontFamily(FontViewModel.FontFamily), FontViewModel.FontStyle, FontViewModel.FontWeight, FontViewModel.FontStretch, FontViewModel.FontSize) + 30);
break;
}
case nameof(Text):
case nameof(Rate):
case nameof(Priority):
case nameof(Remark):
{
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
{
if (string.IsNullOrEmpty(valuePropertyChangedEventArgs.OldValue?.ToString()) && !string.IsNullOrEmpty(valuePropertyChangedEventArgs.NewValue?.ToString()))
{
ItemWidth += 24;
}
else if (!string.IsNullOrEmpty(valuePropertyChangedEventArgs.OldValue?.ToString()) && string.IsNullOrEmpty(valuePropertyChangedEventArgs.NewValue?.ToString()))
{
ItemWidth -= 24;
}
}
break;
}
case nameof(LinkInfo):
{
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
{
if (valuePropertyChangedEventArgs.OldValue == null && valuePropertyChangedEventArgs.NewValue != null)
{
ItemWidth += 24;
}
else if (valuePropertyChangedEventArgs.OldValue != null && valuePropertyChangedEventArgs.NewValue == null)
{
ItemWidth -= 24;
}
}
break;
}
case nameof(ImageInfo):
{
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
{
if (valuePropertyChangedEventArgs.OldValue == null && valuePropertyChangedEventArgs.NewValue != null)
{
ItemWidth = Math.Max(ItemWidth, 160);
ItemHeight += 135;
}
else if (valuePropertyChangedEventArgs.OldValue != null && valuePropertyChangedEventArgs.NewValue == null)
{
ItemHeight -= 135;
}
}
SetItemWidthHeight();
break;
}
}
}
private void SetItemWidthHeight()
{
double width = 0;
double height = 0;
width += GetTextDisplayWidthHelper.GetTextDisplayWidth(Text, new FontFamily(FontViewModel.FontFamily), FontViewModel.FontStyle, FontViewModel.FontWeight, FontViewModel.FontStretch, FontViewModel.FontSize) + 30;
width += Rate == null ? 0 : 24;
width += Priority == null ? 0 : 24;
width += Remark == null ? 0 : 24;
width += LinkInfo == null ? 0 : 24;
var defaultTheme = MindThemeHelper.GetNodeDefaultTheme(this);
if (ImageInfo != null)
{
width = Math.Max(width, 160);
height = defaultTheme.ItemHeight / defaultTheme.FontSize * FontViewModel.FontSize + 135;
}
else
{
height = defaultTheme.ItemHeight / defaultTheme.FontSize * FontViewModel.FontSize;
}
ItemWidth = width;
ItemHeight = height;
}
protected override void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(FontViewModel.FontSize))
{
SetItemWidthHeight();
}
}
public override void AddToSelection(bool selected)
{
foreach (SelectableDesignerItemViewModelBase item in Root.SelectedItems.ToList())
@@ -661,9 +663,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
return mindnode;
}
public List<MindNode> GetChildren()
public List<MindNode> GetChildren(bool self = false)
{
List<MindNode> mindnode = new List<MindNode>();
if (self)
{
mindnode.Add(this);
}
if (this.Children != null)
{
foreach (var child in this.Children)