mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-03 23:56:37 +08:00
mind多个根节点的时候,切换模式的修复
This commit is contained in:
@@ -24,10 +24,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _mindType, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(MindType));
|
||||
}
|
||||
SetProperty(ref _mindType, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +37,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _mindTheme, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(MindTheme));
|
||||
}
|
||||
SetProperty(ref _mindTheme, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,24 +304,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _changeMindTypeCommand;
|
||||
public ICommand ChangeMindTypeCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._changeMindTypeCommand ?? (this._changeMindTypeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedChangeMindTypeCommand));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _changeMindThemeCommand;
|
||||
public ICommand ChangeMindThemeCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._changeMindThemeCommand ?? (this._changeMindThemeCommand = new SimpleCommand(ExecuteEnable, this.ExecutedChangeMindThemeCommand));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _clearThemeCommand;
|
||||
public ICommand ClearThemeCommand
|
||||
{
|
||||
@@ -445,27 +421,42 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 属性改变
|
||||
private bool isSelecting;
|
||||
#region 属性改变
|
||||
protected override void DiagramViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
base.DiagramViewModel_PropertyChanged(sender, e);
|
||||
if (e.PropertyName == nameof(MindType))
|
||||
{
|
||||
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
||||
{
|
||||
ChangeMindType((MindType)valuePropertyChangedEventArgs.OldValue, (MindType)valuePropertyChangedEventArgs.NewValue);
|
||||
}
|
||||
}
|
||||
else if (e.PropertyName == nameof(MindTheme))
|
||||
{
|
||||
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
||||
{
|
||||
ChangeMindTheme((MindTheme)valuePropertyChangedEventArgs.OldValue, (MindTheme)valuePropertyChangedEventArgs.NewValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
base.Item_PropertyChanged(sender, e);
|
||||
if (e.PropertyName == "IsSelected")
|
||||
{
|
||||
isSelecting = true;
|
||||
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
||||
{
|
||||
LinkInfo = new LinkInfo(MindSelectedItem?.LinkInfo);
|
||||
ImageInfo = new ImageInfo(MindSelectedItem?.ImageInfo);
|
||||
Remark = MindSelectedItem?.Remark;
|
||||
if (MindSelectedItem != null)
|
||||
{
|
||||
MindType = MindSelectedItem.MindType;
|
||||
MindTheme = MindSelectedItem.MindTheme;
|
||||
}
|
||||
_mindType = MindSelectedItem?.MindType ?? RootItems.FirstOrDefault()?.MindType ?? MindType.Mind;
|
||||
_mindTheme = MindSelectedItem?.MindTheme ?? RootItems.FirstOrDefault()?.MindTheme ?? MindTheme.SkyBlue;
|
||||
RaisePropertyChanged(nameof(MindType));
|
||||
RaisePropertyChanged(nameof(MindTheme));
|
||||
}
|
||||
isSelecting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -711,8 +702,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
{
|
||||
List<MindNode> newitems = new List<MindNode>();
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() =>
|
||||
{
|
||||
() => {
|
||||
var content = window.ContentString;
|
||||
var lines = content.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
MindNode lastnode = node;
|
||||
@@ -1087,76 +1077,79 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
#endregion
|
||||
|
||||
#region 改变模式,主题
|
||||
private void ExecutedChangeMindTypeCommand(object obj)
|
||||
private void ChangeMindType(MindType oldMindType, MindType newMindType)
|
||||
{
|
||||
if (isSelecting) return;
|
||||
|
||||
var oldMindType = MindType;
|
||||
if (obj is MindType mindType && mindType != oldMindType)
|
||||
List<MindNode> roots;
|
||||
if (RootItems.Count == 1)//只有一个的时候
|
||||
{
|
||||
var roots = MindSelectedItems.Select(p => p.RootNode).Distinct().ToList();
|
||||
if (roots.Count > 0)
|
||||
{
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
roots.ForEach(p => p.MindType = mindType);
|
||||
Items.OfType<MindNode>().ToList().ForEach(item => { item.InitLayout(true); });
|
||||
Items.OfType<MindNode>().ToList().ForEach(item => { item.InitConnectionLayout(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
},
|
||||
() => {
|
||||
roots.ForEach(p => p.MindType = oldMindType);
|
||||
Items.OfType<MindNode>().ToList().ForEach(item => { item.InitLayout(true); });
|
||||
Items.OfType<MindNode>().ToList().ForEach(item => { item.InitConnectionLayout(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
});
|
||||
}
|
||||
roots = RootItems.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
roots = MindSelectedItems.Select(p => p.RootNode).Distinct().ToList();
|
||||
}
|
||||
|
||||
if (roots.Count > 0)
|
||||
{
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
roots.ForEach(p => p.MindType = newMindType);
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.InitLayout(true); });
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.InitConnectionLayout(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
},
|
||||
() => {
|
||||
roots.ForEach(p => p.MindType = oldMindType);
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.InitLayout(true); });
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.InitConnectionLayout(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ExecutedChangeMindThemeCommand(object obj)
|
||||
private void ChangeMindTheme(MindTheme oldMindTheme, MindTheme newMindTheme)
|
||||
{
|
||||
if (isSelecting) return;
|
||||
|
||||
var oldmindTheme = MindTheme;
|
||||
if (obj is MindTheme mindTheme && mindTheme != oldmindTheme)
|
||||
List<MindNode> roots;
|
||||
if (RootItems.Count == 1)//只有一个的时候
|
||||
{
|
||||
var roots = MindSelectedItems.Select(p => p.RootNode).Distinct().ToList();
|
||||
if (roots.Count > 0)
|
||||
{
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
var mindThemeModel = MindThemeHelper.GetTheme(mindTheme);
|
||||
if (mindThemeModel?.Dark == true)
|
||||
{
|
||||
PageBackground = Colors.Black;
|
||||
}
|
||||
else
|
||||
{
|
||||
PageBackground = Colors.White;
|
||||
}
|
||||
MindTheme = mindTheme;
|
||||
roots.ForEach(p => p.MindTheme = MindTheme);
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.ThemeChange(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
},
|
||||
() => {
|
||||
var mindThemeModel = MindThemeHelper.GetTheme(oldmindTheme);
|
||||
if (mindThemeModel?.Dark == true)
|
||||
{
|
||||
PageBackground = Colors.Black;
|
||||
}
|
||||
else
|
||||
{
|
||||
PageBackground = Colors.White;
|
||||
}
|
||||
MindTheme = oldmindTheme;
|
||||
roots.ForEach(p => p.MindTheme = MindTheme);
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.ThemeChange(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
});
|
||||
}
|
||||
roots = RootItems.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
roots = MindSelectedItems.Select(p => p.RootNode).Distinct().ToList();
|
||||
}
|
||||
|
||||
if (roots.Count > 0)
|
||||
{
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
var mindThemeModel = MindThemeHelper.GetTheme(newMindTheme);
|
||||
if (mindThemeModel?.Dark == true)
|
||||
{
|
||||
PageBackground = Colors.Black;
|
||||
}
|
||||
else
|
||||
{
|
||||
PageBackground = Colors.White;
|
||||
}
|
||||
roots.ForEach(p => p.MindTheme = newMindTheme);
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.ThemeChange(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
},
|
||||
() => {
|
||||
var mindThemeModel = MindThemeHelper.GetTheme(oldMindTheme);
|
||||
if (mindThemeModel?.Dark == true)
|
||||
{
|
||||
PageBackground = Colors.Black;
|
||||
}
|
||||
else
|
||||
{
|
||||
PageBackground = Colors.White;
|
||||
}
|
||||
roots.ForEach(p => p.MindTheme = oldMindTheme);
|
||||
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.ThemeChange(); });
|
||||
roots.ForEach(p => p.UpdatedLayout());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user