From a3fbb2d8ad3271d51be77cd4e8e1e6a787020383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=89=BE=E7=AB=B9?= Date: Sun, 2 Apr 2023 22:59:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96bug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=8C=E8=BF=91=E6=9C=9F=E4=B8=BB=E8=A6=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbug=E4=B8=BA=E4=B8=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/FlowchartViewModel.cs | 6 +-- .../ViewModels/LogicalViewModel.cs | 6 +-- .../ViewModels/MindViewModel.cs | 16 +++---- .../ViewModels/PageViewModel.cs | 46 ++++++++++++------- .../ViewModels/SFCViewModel.cs | 6 +-- AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml | 4 +- .../Models/Serializables/DesignerItemBase.cs | 31 ++++++++++++- .../BaseViewModel/DiagramViewModel.cs | 7 +-- .../ViewModels/IDiagramViewModel.cs | 2 +- AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs | 2 +- .../Models/MindNodeDesignerItem.cs | 28 ++++++++--- AIStudio.Wpf.Mind/Models/MindNodeModel.cs | 16 +++++-- .../ViewModels/MindDiagramViewModel.cs | 28 ++++++++--- AIStudio.Wpf.Mind/ViewModels/MindNode.cs | 28 +++++++---- 14 files changed, 158 insertions(+), 68 deletions(-) diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs index 7e69a8d..1f784bf 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs @@ -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); diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs index 1d644de..b9a4c26 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs @@ -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; diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs index 59ca897..ef27dd0 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs @@ -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() { - 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; } diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs index 9a493ea..8375d57 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs @@ -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() { - 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 _diagramViewModels; public ObservableCollection DiagramViewModels @@ -239,7 +251,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels List viewModels = new List(); 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(); var selectedConnections = viewModel.Items.OfType(); @@ -335,7 +347,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels Status = ""; return true; - } + } private bool ItemsToDeleteHasConnector(List 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( diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs index 1ada18a..6b5746f 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs @@ -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); diff --git a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml index 95863c2..ecb3c67 100644 --- a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml +++ b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml @@ -2167,7 +2167,7 @@ - + @@ -2189,7 +2189,7 @@ Width="190" /> - + diff --git a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs index bcde36b..d2436b3 100644 --- a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs +++ b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs @@ -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 Connectors diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs index 48dab3c..525b988 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs @@ -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(); } diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs index b7c4756..0d1f244 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs @@ -333,7 +333,7 @@ namespace AIStudio.Wpf.DiagramDesigner } #endregion - void Init(); + void Init(bool initNew); void Add(object parameter); diff --git a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs index 0d630cb..b528a0d 100644 --- a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs +++ b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs @@ -104,7 +104,7 @@ namespace AIStudio.Wpf.Mind.Controls _diagramViewModel.Items.Clear(); _diagramViewModel.ToObject(json); - _diagramViewModel.Init(); + _diagramViewModel.Init(true); _diagramViewModel.IsLoading = false; } diff --git a/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs b/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs index d734e1c..edfe1a0 100644 --- a/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs +++ b/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs @@ -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(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; } diff --git a/AIStudio.Wpf.Mind/Models/MindNodeModel.cs b/AIStudio.Wpf.Mind/Models/MindNodeModel.cs index 3a7f3af..22d9007 100644 --- a/AIStudio.Wpf.Mind/Models/MindNodeModel.cs +++ b/AIStudio.Wpf.Mind/Models/MindNodeModel.cs @@ -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 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; diff --git a/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs b/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs index 5794b85..d4e2081 100644 --- a/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs +++ b/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs @@ -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) { diff --git a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs index f60f64e..60b85da 100644 --- a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs +++ b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs @@ -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(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 }