可以切换主题

This commit is contained in:
艾竹
2023-03-11 22:27:23 +08:00
parent 84f413320f
commit fb7858fe74
22 changed files with 1061 additions and 208 deletions

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.Helpers;
namespace AIStudio.Wpf.Mind.ViewModels
{
@@ -14,6 +15,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
get; set;
}
MindThemeModel MindThemeModel
{
get; set;
}
MindNode RootItem
{
get;
@@ -29,7 +35,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
get;
}
SimpleCommand AddPeerCommand
SimpleCommand AddPearCommand
{
get;
}
@@ -54,6 +60,26 @@ namespace AIStudio.Wpf.Mind.ViewModels
get;
}
SimpleCommand SelectBrotherCommand
{
get;
}
SimpleCommand SelectPearCommand
{
get;
}
SimpleCommand SelectRouteCommand
{
get;
}
SimpleCommand SelectChildCommand
{
get;
}
SimpleCommand Expand2Level1Command
{
get;

View File

@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Documents;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.Helpers;
namespace AIStudio.Wpf.Mind.ViewModels
{
@@ -25,6 +26,18 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private MindThemeModel _mindThemeModel = MindThemeHelper.GetTheme("SkyBlue");
public MindThemeModel MindThemeModel
{
get
{
return _mindThemeModel;
}
set
{
SetProperty(ref _mindThemeModel, value);
}
}
public MindNode RootItem
{
get
@@ -53,12 +66,12 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addPeerCommand;
public SimpleCommand AddPeerCommand
private SimpleCommand _AddPearCommand;
public SimpleCommand AddPearCommand
{
get
{
return this._addPeerCommand ?? (this._addPeerCommand = new SimpleCommand(MindLevelEnable, this.ExecuteAddPeerCommand));
return this._AddPearCommand ?? (this._AddPearCommand = new SimpleCommand(MindLevelEnable, this.ExecuteAddPearCommand));
}
}
@@ -89,6 +102,42 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _selectBrotherCommand;
public SimpleCommand SelectBrotherCommand
{
get
{
return this._selectBrotherCommand ?? (this._selectBrotherCommand = new SimpleCommand(MindLevelEnable, ExecuteSelectBrotherCommand));
}
}
private SimpleCommand _selectPearCommand;
public SimpleCommand SelectPearCommand
{
get
{
return this._selectPearCommand ?? (this._selectPearCommand = new SimpleCommand(MindLevelEnable, ExecuteSelectPearCommand));
}
}
private SimpleCommand _selectRouteCommand;
public SimpleCommand SelectRouteCommand
{
get
{
return this._selectRouteCommand ?? (this._selectRouteCommand = new SimpleCommand(MindLevelEnable, ExecuteSelectRouteCommand));
}
}
private SimpleCommand _selectChildCommand;
public SimpleCommand SelectChildCommand
{
get
{
return this._selectChildCommand ?? (this._selectChildCommand = new SimpleCommand(MindLevelEnable, ExecuteSelectChildCommand));
}
}
private SimpleCommand _addLinkCommand;
public SimpleCommand AddLinkCommand
{
@@ -175,7 +224,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._changeMindTypeCommand ?? (this._changeMindTypeCommand = new SimpleCommand(MindExecuteEnable, this.ExecutedChangeMindTypeCommand));
return this._changeMindTypeCommand ?? (this._changeMindTypeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedChangeMindTypeCommand));
}
}
@@ -184,7 +233,34 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._changeMindThemeCommand ?? (this._changeMindThemeCommand = new SimpleCommand(MindExecuteEnable, this.ExecutedChangeMindThemeCommand));
return this._changeMindThemeCommand ?? (this._changeMindThemeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedChangeMindThemeCommand));
}
}
private SimpleCommand _clearThemeCommand;
public SimpleCommand ClearThemeCommand
{
get
{
return this._clearThemeCommand ?? (this._clearThemeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedClearThemeCommand));
}
}
private SimpleCommand _copyThemeCommand;
public SimpleCommand CopyThemeCommand
{
get
{
return this._copyThemeCommand ?? (this._copyThemeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedCopyThemeCommand));
}
}
private SimpleCommand _pasteThemeCommand;
public SimpleCommand PasteThemeCommand
{
get
{
return this._pasteThemeCommand ?? (this._pasteThemeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedPasteThemeCommand));
}
}
@@ -193,7 +269,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._expand2Level1Command ?? (this._expand2Level1Command = new SimpleCommand(MindExecuteEnable, this.ExecutedExpand2Level1Command));
return this._expand2Level1Command ?? (this._expand2Level1Command = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2Level1Command));
}
}
@@ -202,7 +278,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._expand2Level2Command ?? (this._expand2Level2Command = new SimpleCommand(MindExecuteEnable, this.ExecutedExpand2Level2Command));
return this._expand2Level2Command ?? (this._expand2Level2Command = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2Level2Command));
}
}
@@ -211,7 +287,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._expand2Level3Command ?? (this._expand2Level3Command = new SimpleCommand(MindExecuteEnable, this.ExecutedExpand2Level3Command));
return this._expand2Level3Command ?? (this._expand2Level3Command = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2Level3Command));
}
}
@@ -220,7 +296,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._expand2Level4Command ?? (this._expand2Level4Command = new SimpleCommand(MindExecuteEnable, this.ExecutedExpand2Level4Command));
return this._expand2Level4Command ?? (this._expand2Level4Command = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2Level4Command));
}
}
@@ -229,7 +305,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._expand2Level5Command ?? (this._expand2Level5Command = new SimpleCommand(MindExecuteEnable, this.ExecutedExpand2Level5Command));
return this._expand2Level5Command ?? (this._expand2Level5Command = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2Level5Command));
}
}
@@ -238,7 +314,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get
{
return this._expand2Level6Command ?? (this._expand2Level6Command = new SimpleCommand(MindExecuteEnable, this.ExecutedExpand2Level6Command));
return this._expand2Level6Command ?? (this._expand2Level6Command = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2Level6Command));
}
}
#endregion
@@ -370,7 +446,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
public void ExecuteAddPeerCommand(object parameter)
public void ExecuteAddPearCommand(object parameter)
{
List<MindNode> items = new List<MindNode>();
if (parameter is MindNode pear)
@@ -539,52 +615,52 @@ namespace AIStudio.Wpf.Mind.ViewModels
private void ExecuteAddLinkCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteRemoveLinkCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteAddImageCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteRemoveImageCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteAddRemarkCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteRemoveRemarkCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteAddPriorityCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteAddRatioCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteAddTagCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecuteRemoveTagCommand(object obj)
{
throw new NotImplementedException();
}
private void ExecutedChangeMindTypeCommand(object obj)
@@ -599,44 +675,106 @@ namespace AIStudio.Wpf.Mind.ViewModels
private void ExecutedChangeMindThemeCommand(object obj)
{
if (obj is string mindThemeModel)
{
MindThemeModel = MindThemeHelper.GetTheme(mindThemeModel);
if (mindThemeModel.StartsWith("CoolLightYellow"))
{
PageBackground = Colors.Black;
}
else
{
PageBackground = Colors.White;
}
Items.OfType<MindNode>().ToList().ForEach(item => { item.ThemeChange(); });
RootItem?.LayoutUpdated();
}
}
private void ExecutedClearThemeCommand(object parameter)
{
List<MindNode> nodes = new List<MindNode>();
if (parameter is MindNode node1)
{
nodes.Add(node1);
}
else if (parameter is IEnumerable<MindNode> para)
{
nodes.AddRange(para);
}
else
{
nodes.AddRange(SelectedItems.OfType<MindNode>());
}
if (nodes.Any())
{
DoCommandManager.DoNewCommand(this.ToString(),
() => {
foreach (var node in nodes)
{
node.ThemeChange();
}
RootItem.LayoutUpdated();
},
() => {
//ToDo
});
}
}
private void ExecutedCopyThemeCommand(object parameter)
{
if (parameter is MindNode node)
{
}
else
{
node = SelectedItem as MindNode;
}
if (node != null)
{
}
}
private void ExecutedPasteThemeCommand(object parameter)
{
}
private void ExecutedExpand2Level1Command(object obj)
{
throw new NotImplementedException();
}
private void ExecutedExpand2Level2Command(object obj)
{
throw new NotImplementedException();
}
private void ExecutedExpand2Level3Command(object obj)
{
throw new NotImplementedException();
}
private void ExecutedExpand2Level4Command(object obj)
{
throw new NotImplementedException();
}
private void ExecutedExpand2Level5Command(object obj)
{
throw new NotImplementedException();
}
private void ExecutedExpand2Level6Command(object obj)
{
throw new NotImplementedException();
}
#endregion
protected override void ExecutedInitLayoutCommand(object obj)
{
}
protected override void ExecutedResetLayoutCommand(object obj)
{
foreach (var item in Items.OfType<MindNode>())

View File

@@ -59,7 +59,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
AddChildCommand = (Root as IMindDiagramViewModel)?.AddChildCommand;
AddParentCommand = (Root as IMindDiagramViewModel)?.AddParentCommand;
AddPeerCommand = (Root as IMindDiagramViewModel)?.AddPeerCommand;
AddPearCommand = (Root as IMindDiagramViewModel)?.AddPearCommand;
DeleteCommand = (Root as IMindDiagramViewModel)?.DeleteCommand;
MoveForwardCommand = (Root as IMindDiagramViewModel)?.MoveForwardCommand;
MoveBackCommand = (Root as IMindDiagramViewModel)?.MoveBackCommand;
@@ -72,12 +72,17 @@ namespace AIStudio.Wpf.Mind.ViewModels
MindLayout = layout != null ? (System.Activator.CreateInstance(layout) as IMindLayout) : new MindLayout();
IsInnerConnector = true;
MindLayout.Appearance(this, initAppearance);
MindLayout.Appearance(this, MindThemeModel, initAppearance);
this.PropertyChanged -= this.Item_PropertyChanged;
this.PropertyChanged += this.Item_PropertyChanged;
}
public void ThemeChange()
{
MindThemeHelper.ThemeChange(this, MindThemeModel);
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{
base.LoadDesignerItemViewModel(designerbase);
@@ -138,6 +143,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
public MindThemeModel MindThemeModel
{
get
{
return (Root as IMindDiagramViewModel)?.MindThemeModel ?? MindThemeHelper.GetTheme("SkyBlue");
}
}
private bool _isExpanded = true;
public bool IsExpanded
{
@@ -303,7 +316,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
get; private set;
}
public SimpleCommand AddPeerCommand
public SimpleCommand AddPearCommand
{
get; private set;
}
@@ -335,7 +348,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
menuOptions.Add(menuItem);
menuItem = new CinchMenuItem();
menuItem.Text = "同级";
menuItem.Command = AddPeerCommand;
menuItem.Command = AddPearCommand;
menuItem.CommandParameter = this;
menuOptions.Add(menuItem);
menuItem = new CinchMenuItem();
@@ -431,7 +444,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
break;
}
case nameof(NodeLevel):
MindLayout?.Appearance(this, false);
MindLayout?.Appearance(this);
break;
case nameof(Left):
{