mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-19 16:06:35 +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);
|
||||
|
||||
Reference in New Issue
Block a user