mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
序列化bug修复,近期主要修复bug为主
This commit is contained in:
@@ -17,7 +17,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
public FlowchartViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
|
||||
{
|
||||
Init();
|
||||
Init(true);
|
||||
}
|
||||
public FlowchartViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||
{
|
||||
@@ -39,9 +39,9 @@ namespace AIStudio.Wpf.Flowchart
|
||||
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(bool initNew)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(initNew);
|
||||
|
||||
DesignerItemViewModelBase start = new StartFlowNode() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
|
||||
DiagramViewModel.Add(start);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.Logical
|
||||
{
|
||||
public LogicalViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
|
||||
{
|
||||
Init();
|
||||
Init(true);
|
||||
}
|
||||
public LogicalViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||
{
|
||||
@@ -34,9 +34,9 @@ namespace AIStudio.Wpf.Logical
|
||||
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(bool initNew)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(initNew);
|
||||
|
||||
TimerDesignerItemViewModel timer = new TimerDesignerItemViewModel() { Left = 28, Top = 28 };
|
||||
timer.Value = 1;
|
||||
|
||||
@@ -23,13 +23,13 @@ namespace AIStudio.Wpf.Flowchart
|
||||
public MindViewModel(string title, string status, DiagramType diagramType, MindType mindType) : base(title, status, diagramType)
|
||||
{
|
||||
MindType = mindType;
|
||||
Init();
|
||||
Init(true);
|
||||
}
|
||||
public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||
{
|
||||
foreach (var vm in DiagramViewModels)
|
||||
{
|
||||
vm.Init();
|
||||
vm.Init(false);
|
||||
}
|
||||
|
||||
if (MindDiagramViewModel != null)
|
||||
@@ -66,11 +66,11 @@ namespace AIStudio.Wpf.Flowchart
|
||||
get;
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
protected override void Init(bool initNew)
|
||||
{
|
||||
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
|
||||
{
|
||||
GetDiagramViewModel("页-1", DiagramType),
|
||||
GetDiagramViewModel("页-1", DiagramType, initNew),
|
||||
};
|
||||
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
||||
|
||||
@@ -95,13 +95,13 @@ namespace AIStudio.Wpf.Flowchart
|
||||
MindNode level2node1_3 = new MindNode(DiagramViewModel) { Text = "分支主题3" };
|
||||
level2node1_3.AddTo(level1node, 0, false);
|
||||
|
||||
DiagramViewModel.Init();
|
||||
DiagramViewModel.Init(initNew);
|
||||
}
|
||||
|
||||
protected override DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType)
|
||||
protected override DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType, bool initNew)
|
||||
{
|
||||
var viewmodel = new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType, MindType = MindType, MindTheme = MindTheme };
|
||||
viewmodel.Init();
|
||||
viewmodel.Init(initNew);
|
||||
|
||||
return viewmodel;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public partial class PageViewModel : BindableBase
|
||||
{
|
||||
protected IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
|
||||
|
||||
protected IDiagramServiceProvider _service
|
||||
{
|
||||
get
|
||||
{
|
||||
return DiagramServicesProvider.Instance.Provider;
|
||||
}
|
||||
}
|
||||
|
||||
public PageViewModel(string title, string status, DiagramType diagramType)
|
||||
{
|
||||
Title = title;
|
||||
@@ -53,18 +59,21 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
|
||||
}
|
||||
|
||||
protected virtual void Init()
|
||||
protected virtual void Init(bool initNew)
|
||||
{
|
||||
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
|
||||
{
|
||||
GetDiagramViewModel("页-1", DiagramType),
|
||||
GetDiagramViewModel("页-1", DiagramType,initNew),
|
||||
};
|
||||
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
||||
|
||||
InitDiagramViewModel();
|
||||
}
|
||||
|
||||
public string FileName { get; set; }
|
||||
public string FileName
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
#region 属性
|
||||
|
||||
@@ -113,7 +122,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public DiagramType DiagramType { get; set; }
|
||||
public DiagramType DiagramType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private ObservableCollection<IDiagramViewModel> _diagramViewModels;
|
||||
public ObservableCollection<IDiagramViewModel> DiagramViewModels
|
||||
@@ -239,7 +251,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
|
||||
foreach (var diagramItem in diagramDocument.DiagramItems)
|
||||
{
|
||||
var viewModel = GetDiagramViewModel(diagramItem.Name, diagramItem.DiagramType);
|
||||
var viewModel = GetDiagramViewModel(diagramItem.Name, diagramItem.DiagramType, false);
|
||||
viewModel.ShowGrid = diagramItem.ShowGrid;
|
||||
viewModel.PhysicalGridCellSize = diagramItem.PhysicalGridCellSize;
|
||||
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
|
||||
@@ -255,7 +267,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
Type type = TypeHelper.GetType(diagramItemData.ModelTypeName);
|
||||
DesignerItemViewModelBase itemBase = Activator.CreateInstance(type, viewModel, diagramItemData, ext) as DesignerItemViewModelBase;
|
||||
viewModel.Items.Add(itemBase);
|
||||
viewModel.Items.Add(itemBase);
|
||||
}
|
||||
|
||||
foreach (var connection in diagramItem.Connections)
|
||||
@@ -312,7 +324,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
|
||||
foreach (var viewModel in DiagramViewModels)
|
||||
{
|
||||
DiagramItem diagramItem = new DiagramItem(viewModel);
|
||||
DiagramItem diagramItem = new DiagramItem(viewModel);
|
||||
|
||||
var selectedDesignerItems = viewModel.Items.OfType<DesignerItemViewModelBase>();
|
||||
var selectedConnections = viewModel.Items.OfType<ConnectionViewModel>();
|
||||
@@ -335,7 +347,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
Status = "";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
|
||||
{
|
||||
@@ -405,7 +417,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
}
|
||||
quickThemeViewModel.QuickTheme = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LockAction(LockObject lockObject, string propertyName)
|
||||
{
|
||||
@@ -426,15 +438,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
index = DiagramViewModels.Count;
|
||||
}
|
||||
var page = GetDiagramViewModel(null, DiagramType);
|
||||
var page = GetDiagramViewModel(null, DiagramType, true);
|
||||
DiagramViewModels.Insert(index, page);
|
||||
DiagramViewModel = page;
|
||||
InitDiagramViewModel();
|
||||
}
|
||||
|
||||
protected virtual DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType)
|
||||
protected virtual DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType, bool initNew)
|
||||
{
|
||||
return new DiagramViewModel() { Name = name??NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType };
|
||||
return new DiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType };
|
||||
}
|
||||
|
||||
public void AddCopyPageExecuted(object para)
|
||||
@@ -468,7 +480,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(viewModel.Items, connectionItem.SourceId, connectionItem.SourceType);
|
||||
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id,sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
||||
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
||||
|
||||
DesignerItemViewModelBase sinkItem = DiagramViewModelHelper.GetConnectorDataItem(viewModel.Items, connectionItem.SinkId, connectionItem.SinkType);
|
||||
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||
@@ -578,7 +590,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
|
||||
public void AddBarcodeExecuted(object para)
|
||||
{
|
||||
BarcodeDesignerItemViewModel itemBase = new BarcodeDesignerItemViewModel() { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), para.ToString()), Text="AIStudio.Wpf.DiagramApp" };
|
||||
BarcodeDesignerItemViewModel itemBase = new BarcodeDesignerItemViewModel() { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), para.ToString()), Text = "AIStudio.Wpf.DiagramApp" };
|
||||
DiagramViewModel?.AddItemCommand.Execute(itemBase);
|
||||
if (itemBase.Root != null)
|
||||
{
|
||||
@@ -586,7 +598,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
private Size MeasureString(OutLineTextDesignerItemViewModel itemBase)
|
||||
{
|
||||
var formattedText = new FormattedText(
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
|
||||
{
|
||||
Init();
|
||||
Init(true);
|
||||
}
|
||||
|
||||
public SFCViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||
@@ -48,9 +48,9 @@ namespace AIStudio.Wpf.Flowchart
|
||||
}
|
||||
|
||||
private System.Timers.Timer readDataTimer = new System.Timers.Timer();
|
||||
protected override void Init()
|
||||
protected override void Init(bool initNew)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(initNew);
|
||||
|
||||
SFCStartNode start = new SFCStartNode() { Left = 0, Top = 60, Text = "S0" };
|
||||
DiagramViewModel.Add(start);
|
||||
|
||||
@@ -2167,7 +2167,7 @@
|
||||
</Border>
|
||||
</Fluent:RibbonGroupBox>
|
||||
<Fluent:RibbonGroupBox Header="外观" IsLauncherVisible="True">
|
||||
<Fluent:SplitButton Header="{Binding ElementName=mindtype,Path=SelectedItem,Converter={StaticResource EnumDescriptionConverter}}" GroupName="MindType" Width="70" VerticalAlignment="Top">
|
||||
<Fluent:SplitButton Header="{Binding ElementName=mindtype,Path=SelectedItem,Converter={StaticResource EnumDescriptionConverter}}" GroupName="MindType" Width="70" VerticalAlignment="Top" ClosePopupOnMouseDown="True">
|
||||
<Fluent:SplitButton.LargeIcon>
|
||||
<iconPacks:PackIconRemixIcon Kind="MindMap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:SplitButton.LargeIcon>
|
||||
@@ -2189,7 +2189,7 @@
|
||||
Width="190" />
|
||||
</Fluent:SplitButton.ToolTip>
|
||||
</Fluent:SplitButton>
|
||||
<Fluent:SplitButton Header="{Binding ElementName=mindtheme,Path=SelectedItem,Converter={StaticResource EnumDescriptionConverter}}" Width="50" VerticalAlignment="Top">
|
||||
<Fluent:SplitButton Header="{Binding ElementName=mindtheme,Path=SelectedItem,Converter={StaticResource EnumDescriptionConverter}}" Width="50" VerticalAlignment="Top" ClosePopupOnMouseDown="True">
|
||||
<Fluent:SplitButton.LargeIcon>
|
||||
<iconPacks:PackIconUnicons Kind="Palette" Foreground="{Binding PageViewModel.DiagramViewModel.MindTheme,Converter={StaticResource MindThemeFillBrushConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:SplitButton.LargeIcon>
|
||||
|
||||
@@ -107,18 +107,45 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
[XmlIgnore]
|
||||
public CornerRadius CornerRadius
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
[JsonIgnore]
|
||||
[XmlElement("CornerRadius")]
|
||||
public string XmlCornerRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return SerializeHelper.SerializeCornerRadius(CornerRadius);
|
||||
}
|
||||
set
|
||||
{
|
||||
CornerRadius = SerializeHelper.DeserializeCornerRadius(value);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public Thickness BorderThickness
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
[XmlElement("BorderThickness")]
|
||||
public string XmlBorderThickness
|
||||
{
|
||||
get
|
||||
{
|
||||
return SerializeHelper.SerializeThickness(BorderThickness);
|
||||
}
|
||||
set
|
||||
{
|
||||
BorderThickness = SerializeHelper.DeserializeThickness(value);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<FullyCreatedConnectorInfoItem> Connectors
|
||||
|
||||
@@ -1051,6 +1051,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Mediator.Instance.Register(this);
|
||||
Items.CollectionChanged += Items_CollectionChanged;
|
||||
var zoomValueChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == nameof(ZoomValue)).Throttle(TimeSpan.FromMilliseconds(100)).Subscribe(OnZoomValueChanged);//Sample
|
||||
|
||||
BuildMenuOptions();
|
||||
}
|
||||
public DiagramViewModel(DiagramItem diagramItem) : this()
|
||||
{
|
||||
@@ -1066,11 +1068,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
GridColor = diagramItem.GridColor;
|
||||
AllowDrop = diagramItem.AllowDrop;
|
||||
|
||||
Init();
|
||||
BuildMenuOptions();
|
||||
Init(true);
|
||||
}
|
||||
|
||||
public virtual void Init()
|
||||
public virtual void Init(bool initNew)
|
||||
{
|
||||
DoCommandManager.Init();
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
#endregion
|
||||
|
||||
void Init();
|
||||
void Init(bool initNew);
|
||||
|
||||
void Add(object parameter);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace AIStudio.Wpf.Mind.Controls
|
||||
_diagramViewModel.Items.Clear();
|
||||
_diagramViewModel.ToObject(json);
|
||||
|
||||
_diagramViewModel.Init();
|
||||
_diagramViewModel.Init(true);
|
||||
_diagramViewModel.IsLoading = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,20 +18,34 @@ namespace AIStudio.Wpf.Mind.Models
|
||||
}
|
||||
public MindNodeDesignerItem(MindNode item) : base(item)
|
||||
{
|
||||
MindType = item.MindType;
|
||||
MindTheme = item.MindTheme;
|
||||
Spacing = item.Spacing;
|
||||
Offset = item.Offset;
|
||||
IsExpanded = item.IsExpanded;
|
||||
LinkInfoItem = new LinkInfoItem(item.LinkInfo);
|
||||
ImageInfoItem = new ImageInfoItem(item.ImageInfo);
|
||||
Remark = item.Remark;
|
||||
Priority= item.Priority;
|
||||
Rate=item.Rate;
|
||||
Priority= item.Priority?.ToString();
|
||||
Rate=item.Rate.ToString();
|
||||
if (item.Tags != null)
|
||||
{
|
||||
Tags = new List<string>(item.Tags);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public MindType MindType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public MindTheme MindTheme
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public Size Spacing
|
||||
{
|
||||
@@ -90,18 +104,18 @@ namespace AIStudio.Wpf.Mind.Models
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Remark
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public double? Priority
|
||||
[XmlAttribute]
|
||||
public string Priority
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public double? Rate
|
||||
[XmlAttribute]
|
||||
public string Rate
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,16 @@ namespace AIStudio.Wpf.Mind.Models
|
||||
|
||||
public class MindNodeModel : DiagramNode
|
||||
{
|
||||
public MindType MindType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public MindTheme MindTheme
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Size Spacing
|
||||
{
|
||||
get; set;
|
||||
@@ -30,13 +40,11 @@ namespace AIStudio.Wpf.Mind.Models
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public LinkInfoModel LinkInfoModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public ImageInfoModel ImageInfoModel
|
||||
{
|
||||
get; set;
|
||||
@@ -57,7 +65,6 @@ namespace AIStudio.Wpf.Mind.Models
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<string> Tags
|
||||
{
|
||||
get; set;
|
||||
@@ -66,7 +73,8 @@ namespace AIStudio.Wpf.Mind.Models
|
||||
public override DiagramItemViewModel ToNodel(IDiagramViewModel diagramViewModel)
|
||||
{
|
||||
MindNode mindNode = new MindNode(diagramViewModel);
|
||||
|
||||
mindNode.MindType = MindType;
|
||||
mindNode.MindTheme = MindTheme;
|
||||
mindNode.Spacing = Spacing;
|
||||
mindNode.Offset = Offset;
|
||||
mindNode.IsExpanded = IsExpanded;
|
||||
|
||||
@@ -24,7 +24,10 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _mindType, value);
|
||||
if (!SetProperty(ref _mindType, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(MindType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +40,10 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _mindTheme, value);
|
||||
if (!SetProperty(ref _mindTheme, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(MindTheme));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,15 +371,18 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
public override void Init(bool initNew)
|
||||
{
|
||||
if (Items.Count == 0)
|
||||
if (initNew)
|
||||
{
|
||||
AddRootItem();
|
||||
if (Items.Count == 0)
|
||||
{
|
||||
AddRootItem();
|
||||
}
|
||||
}
|
||||
ResetChildren(RootItems);
|
||||
RootItems?.ForEach(p => p.UpdatedLayout());
|
||||
base.Init();
|
||||
base.Init(initNew);
|
||||
}
|
||||
|
||||
private MindNode AddRootItem()
|
||||
@@ -437,11 +446,13 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
#endregion
|
||||
|
||||
#region 属性改变
|
||||
private bool isSelecting;
|
||||
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);
|
||||
@@ -453,6 +464,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
MindTheme = MindSelectedItem.MindTheme;
|
||||
}
|
||||
}
|
||||
isSelecting = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -1077,6 +1089,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
#region 改变模式,主题
|
||||
private void ExecutedChangeMindTypeCommand(object obj)
|
||||
{
|
||||
if (isSelecting) return;
|
||||
|
||||
var oldMindType = MindType;
|
||||
if (obj is MindType mindType && mindType != oldMindType)
|
||||
{
|
||||
@@ -1103,6 +1117,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
private void ExecutedChangeMindThemeCommand(object obj)
|
||||
{
|
||||
if (isSelecting) return;
|
||||
|
||||
var oldmindTheme = MindTheme;
|
||||
if (obj is MindTheme mindTheme && mindTheme != oldmindTheme)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
@@ -51,6 +53,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
{
|
||||
var mindNodeModel = new MindNodeModel();
|
||||
|
||||
mindNodeModel.MindType = MindType;
|
||||
mindNodeModel.MindTheme = MindTheme;
|
||||
mindNodeModel.Spacing = Spacing;
|
||||
mindNodeModel.Offset = Offset;
|
||||
mindNodeModel.IsExpanded = IsExpanded;
|
||||
@@ -134,6 +138,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
if (designerbase is MindNodeDesignerItem designer)
|
||||
{
|
||||
MindType = designer.MindType;
|
||||
MindTheme = designer.MindTheme;
|
||||
Spacing = designer.Spacing;
|
||||
Offset = designer.Offset;
|
||||
IsExpanded = designer.IsExpanded;
|
||||
@@ -154,8 +160,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
ImageInfo = new ImageInfo(designer.ImageInfoItem?.Url, designer.ImageInfoItem?.Text);
|
||||
}
|
||||
Remark = designer.Remark;
|
||||
Priority = designer.Priority;
|
||||
Rate = designer.Rate;
|
||||
if (double.TryParse(designer.Priority ?? "", out var priority))
|
||||
{
|
||||
Priority = priority;
|
||||
}
|
||||
if (double.TryParse(designer.Rate ?? "", out var rate))
|
||||
{
|
||||
Rate = rate;
|
||||
}
|
||||
if (designer.Tags != null)
|
||||
{
|
||||
Tags = new ObservableCollection<string>(designer.Tags);
|
||||
@@ -456,7 +468,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
public ICommand ImportCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 菜单
|
||||
@@ -497,7 +509,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
menuItem.Text = "导出节点";
|
||||
menuItem.Command = ExportCommand;
|
||||
menuItem.CommandParameter = this;
|
||||
menuOptions.Add(menuItem);
|
||||
menuOptions.Add(menuItem);
|
||||
menuItem = new CinchMenuItem();
|
||||
menuItem.Text = "导入节点";
|
||||
menuItem.Command = ImportCommand;
|
||||
@@ -547,7 +559,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
Root?.Remove(this);
|
||||
Root?.Remove(connectors);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 属性改变
|
||||
@@ -584,7 +596,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
case nameof(NodeLevel):
|
||||
MindLayout?.Appearance(this);
|
||||
break;
|
||||
case nameof(Text):
|
||||
case nameof(Text):
|
||||
case nameof(Rate):
|
||||
case nameof(Priority):
|
||||
case nameof(Remark):
|
||||
@@ -650,7 +662,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
{
|
||||
mindnode.Add(this);
|
||||
}
|
||||
|
||||
|
||||
if (this.Children != null)
|
||||
{
|
||||
foreach (var child in this.Children)
|
||||
@@ -727,7 +739,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
IsSelected = selected;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user