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