This commit is contained in:
艾竹
2023-03-25 11:59:31 +08:00
parent 8a2c742ec4
commit b36bd4b228
35 changed files with 344 additions and 296 deletions

View File

@@ -34,15 +34,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new DesignerItemBase(this, Format.ToString()); return new DesignerItemBase(this, Format.ToString());
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
CustomText = true; CustomText = true;
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -35,12 +35,16 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new TextDesignerItem(this); return new TextDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
}
protected override void InitNew()
{
base.InitNew();
FontViewModel.FontFamily = "Arial"; FontViewModel.FontFamily = "Arial";
FontViewModel.FontSize = 36; FontViewModel.FontSize = 36;
} }

View File

@@ -32,11 +32,16 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new PathDesignerItem(this); return new PathDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
this.ShowConnectors = false; this.ShowConnectors = false;
} }
protected override void InitNew()
{
base.InitNew();
}
} }
} }

View File

@@ -35,14 +35,19 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new PersistDesignerItem(this); return new PersistDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
this.ShowConnectors = false; this.ShowConnectors = false;
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -35,15 +35,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new SettingsDesignerItem(this); return new SettingsDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
this.ShowConnectors = false; this.ShowConnectors = false;
} }
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -32,17 +32,15 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
return new DesignerItemBase(this, Answer); return new DesignerItemBase(this, Answer);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
this.ItemWidth = 150;
this.ItemHeight = 80;
InitConnector();
} }
protected override void InitConnector() protected override void InitNew()
{ {
this.ItemWidth = 150;
this.ItemHeight = 80;
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top)); connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom)); connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom));
} }

View File

@@ -35,6 +35,8 @@ namespace AIStudio.Wpf.DiagramDesigner
this.Reserve = reserve; this.Reserve = reserve;
this.CornerRadius = viewmodel.CornerRadius; this.CornerRadius = viewmodel.CornerRadius;
this.BorderThickness = viewmodel.BorderThickness; this.BorderThickness = viewmodel.BorderThickness;
Connectors = new List<FullyCreatedConnectorInfoItem>(viewmodel.Connectors.Select(p => new FullyCreatedConnectorInfoItem(p)));
} }
[XmlAttribute("Left")] [XmlAttribute("Left")]
@@ -117,6 +119,12 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set; get; set;
} }
[XmlArray]
public List<FullyCreatedConnectorInfoItem> Connectors
{
get; set;
}
} }

View File

@@ -12,26 +12,13 @@ namespace AIStudio.Wpf.DiagramDesigner
public MediaDesignerItem(GifImageItemViewModel item) : base(item) public MediaDesignerItem(GifImageItemViewModel item) : base(item)
{ {
Connectors = new List<FullyCreatedConnectorInfoItem>();
foreach (var fullyCreatedConnectorInfo in item.Connectors)
{
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
Connectors.Add(connector);
}
} }
public MediaDesignerItem(MediaItemViewModel item) : base(item) public MediaDesignerItem(MediaItemViewModel item) : base(item)
{ {
Connectors = new List<FullyCreatedConnectorInfoItem>();
foreach (var fullyCreatedConnectorInfo in item.Connectors)
{
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
Connectors.Add(connector);
}
}
[XmlArray] }
public List<FullyCreatedConnectorInfoItem> Connectors { get; set; }
} }
} }

View File

@@ -76,6 +76,11 @@ namespace AIStudio.Wpf.DiagramDesigner
AddLabelCommand = new SimpleCommand(Command_Enable, para => AddLabel()); AddLabelCommand = new SimpleCommand(Command_Enable, para => AddLabel());
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -36,10 +36,13 @@ namespace AIStudio.Wpf.DiagramDesigner
return new ConnectorInfoItemBase(this); return new ConnectorInfoItemBase(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root, initNew);
}
protected override void InitNew()
{ {
base.Init(root);
ColorViewModel = new ColorViewModel() ColorViewModel = new ColorViewModel()
{ {
LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) }, LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) },

View File

@@ -36,17 +36,20 @@ namespace AIStudio.Wpf.DiagramDesigner
return new ConnectorLabelItem(this); return new ConnectorLabelItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
ConnectorWidth = 30;
ConnectorHeight = 30;
DeleteLabelCommand = new SimpleCommand(Command_Enable, DeleteLabel); DeleteLabelCommand = new SimpleCommand(Command_Enable, DeleteLabel);
EditCommand = new SimpleCommand(Command_Enable, ExecuteEditCommand); EditCommand = new SimpleCommand(Command_Enable, ExecuteEditCommand);
} }
protected override void InitNew()
{
ConnectorWidth = 30;
ConnectorHeight = 30;
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -48,9 +48,13 @@ namespace AIStudio.Wpf.DiagramDesigner
return new ConnectorPointItem(this); return new ConnectorPointItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root, initNew);
}
protected override void InitNew()
{ {
base.Init(root);
ColorViewModel = new ColorViewModel() ColorViewModel = new ColorViewModel()
{ {
LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) }, LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) },

View File

@@ -33,9 +33,9 @@ namespace AIStudio.Wpf.DiagramDesigner
return new ConnectorVertexItem(this); return new ConnectorVertexItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
DeleteVertexCommand = new SimpleCommand(Command_Enable, DeleteVertex); DeleteVertexCommand = new SimpleCommand(Command_Enable, DeleteVertex);
} }

View File

@@ -52,9 +52,9 @@ namespace AIStudio.Wpf.DiagramDesigner
return new FullyCreatedConnectorInfoItem(this); return new FullyCreatedConnectorInfoItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
menuOptions = new List<CinchMenuItem>(); menuOptions = new List<CinchMenuItem>();
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand); MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
@@ -62,6 +62,11 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -38,11 +38,12 @@ namespace AIStudio.Wpf.DiagramDesigner
return new DesignerItemBase(this); return new DesignerItemBase(this);
} }
protected override void Init(IDiagramViewModel root) protected override void InitNew()
{ {
base.Init(root); connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Top));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
InitConnector(); connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Left));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Right));
} }
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
@@ -61,17 +62,13 @@ namespace AIStudio.Wpf.DiagramDesigner
this.Icon = designer.Icon; this.Icon = designer.Icon;
this.CornerRadius = designer.CornerRadius; this.CornerRadius = designer.CornerRadius;
this.BorderThickness = designer.BorderThickness; this.BorderThickness = designer.BorderThickness;
foreach (var connector in designer.Connectors)
{
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
AddConnector(fullyCreatedConnectorInfo);
}
} }
} }
protected virtual void InitConnector()
{
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Top));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Left));
connectors.Add(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Right));
}
#region #region
public FullyCreatedConnectorInfo FirstConnector public FullyCreatedConnectorInfo FirstConnector

View File

@@ -1493,17 +1493,9 @@ namespace AIStudio.Wpf.DiagramDesigner
{ {
if (!selectedConnections.Contains(connection)) if (!selectedConnections.Contains(connection))
{ {
DesignerItemViewModelBase sourceItem = (from item in selectedDesignerItems DesignerItemViewModelBase sourceItem = selectedDesignerItems.FirstOrDefault(p => p.Id == connection.SourceConnectorInfo.DataItem.Id);
where item.Id == connection.SourceConnectorInfo.DataItem.Id DesignerItemViewModelBase sinkItem = selectedDesignerItems.FirstOrDefault(p => p.Id == connection.SinkConnectorInfoFully?.DataItem?.Id);
select item).FirstOrDefault(); if (sourceItem != null && sinkItem != null && BelongToSameGroup(sourceItem, sinkItem))
DesignerItemViewModelBase sinkItem = (from item in selectedDesignerItems
where item.Id == connection.SinkConnectorInfoFully?.DataItem?.Id
select item).FirstOrDefault();
if (sourceItem != null &&
sinkItem != null &&
BelongToSameGroup(sourceItem, sinkItem))
{ {
selectedConnections.Add(connection); selectedConnections.Add(connection);
} }
@@ -1600,11 +1592,11 @@ namespace AIStudio.Wpf.DiagramDesigner
if (mappingOldToNewIDs.ContainsKey(item.ParentId)) if (mappingOldToNewIDs.ContainsKey(item.ParentId))
item.ParentId = mappingOldToNewIDs[item.ParentId]; item.ParentId = mappingOldToNewIDs[item.ParentId];
} }
} }
items.AddRange(connectors); items.AddRange(connectors);
FixConnection(items);
DirectAddItemCommand.Execute(items); DirectAddItemCommand.Execute(items);
FixOtherInfo(items);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -1618,7 +1610,7 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
} }
protected virtual void FixConnection(List<SelectableDesignerItemViewModelBase> items) protected virtual void FixOtherInfo(List<SelectableDesignerItemViewModelBase> items)
{ {
} }
@@ -2521,10 +2513,7 @@ namespace AIStudio.Wpf.DiagramDesigner
foreach (DesignerItemViewModelBase groupRoot in groups) foreach (DesignerItemViewModelBase groupRoot in groups)
{ {
var children = from child in SelectedItems.OfType<DesignerItemViewModelBase>() var children = SelectedItems.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == groupRoot.Id);
where child.ParentId == groupRoot.Id
select child;
foreach (DesignerItemViewModelBase child in children) foreach (DesignerItemViewModelBase child in children)
child.ParentId = Guid.Empty; child.ParentId = Guid.Empty;

View File

@@ -36,17 +36,17 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
this.IsGroup = true; this.IsGroup = true;
this.IsHitTestVisible = true; this.IsHitTestVisible = true;
} }
protected override void InitConnector() protected override void InitNew()
{ {
this.ClearConnectors();
} }
protected override void ExecuteEditCommand(object param) protected override void ExecuteEditCommand(object param)

View File

@@ -42,14 +42,19 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
SelectItemCommand = new SimpleCommand(Command_Enable, ExecuteSelectItemCommand); SelectItemCommand = new SimpleCommand(Command_Enable, ExecuteSelectItemCommand);
EditCommand = new SimpleCommand(Command_Enable, ExecuteEditCommand); EditCommand = new SimpleCommand(Command_Enable, ExecuteEditCommand);
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -29,20 +29,20 @@ namespace AIStudio.Wpf.DiagramDesigner
public SelectableViewModelBase(IDiagramViewModel root) public SelectableViewModelBase(IDiagramViewModel root)
{ {
Init(root); Init(root, true);
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged; (FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
} }
public SelectableViewModelBase(IDiagramViewModel root, SelectableItemBase designer) public SelectableViewModelBase(IDiagramViewModel root, SelectableItemBase designer)
{ {
Init(root); Init(root, false);
LoadDesignerItemViewModel(designer); LoadDesignerItemViewModel(designer);
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged; (FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
} }
public SelectableViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) public SelectableViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType)
{ {
Init(root); Init(root, false);
SelectableItemBase obj = SerializeHelper.DeserializeObject(serializableItem.SerializableTypeName, serializableItem.SerializableString, serializableType); SelectableItemBase obj = SerializeHelper.DeserializeObject(serializableItem.SerializableTypeName, serializableItem.SerializableString, serializableType);
LoadDesignerItemViewModel(obj); LoadDesignerItemViewModel(obj);
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged; (FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
@@ -66,7 +66,7 @@ namespace AIStudio.Wpf.DiagramDesigner
return null; return null;
} }
protected virtual void Init(IDiagramViewModel root) protected virtual void Init(IDiagramViewModel root, bool initNew)
{ {
Root = root; Root = root;
@@ -98,6 +98,16 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
LockObjectViewModel = new LockObjectViewModel(); LockObjectViewModel = new LockObjectViewModel();
if (initNew)
{
InitNew();
}
}
protected virtual void InitNew()
{
} }
protected virtual void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected virtual void LoadDesignerItemViewModel(SelectableItemBase designerbase)
@@ -158,7 +168,7 @@ namespace AIStudio.Wpf.DiagramDesigner
set set
{ {
if (SetProperty(ref _isSelected, value)) if (SetProperty(ref _isSelected, value))
{ {
//如果没有文字,失去焦点自动清除 //如果没有文字,失去焦点自动清除
if (_isSelected == false && string.IsNullOrEmpty(Text)) if (_isSelected == false && string.IsNullOrEmpty(Text))
{ {
@@ -336,7 +346,7 @@ namespace AIStudio.Wpf.DiagramDesigner
protected virtual void ClearText() protected virtual void ClearText()
{ {
} }
public virtual void ClearSelected() public virtual void ClearSelected()
@@ -362,6 +372,11 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
} }
public override string ToString()
{
return $"{Id}-{Text}";
}
public virtual void Dispose() public virtual void Dispose()
{ {
} }

View File

@@ -42,11 +42,10 @@ namespace AIStudio.Wpf.DiagramDesigner
return new MediaDesignerItem(this); return new MediaDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
ClearConnectors();
//propertyChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Left" || o.ToString() == "Top" || o.ToString() == "ItemWidth" || o.ToString() == "ItemHeight").Subscribe(ChangeImageElement); //propertyChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Left" || o.ToString() == "Top" || o.ToString() == "ItemWidth" || o.ToString() == "ItemHeight").Subscribe(ChangeImageElement);
//connectorsChangedSubscription = WhenConnectorsChanged.Subscribe(OnConnectorsChanged); //connectorsChangedSubscription = WhenConnectorsChanged.Subscribe(OnConnectorsChanged);
@@ -55,6 +54,10 @@ namespace AIStudio.Wpf.DiagramDesigner
BuildMenuOptions(); BuildMenuOptions();
} }
protected override void InitNew()
{
this.ClearConnectors();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
@@ -62,12 +65,7 @@ namespace AIStudio.Wpf.DiagramDesigner
if (designerbase is MediaDesignerItem designer) if (designerbase is MediaDesignerItem designer)
{ {
this.Icon = designer.Icon; this.Icon = designer.Icon;
foreach (var connector in designer.Connectors)
{
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
AddConnector(fullyCreatedConnectorInfo);
}
} }
} }

View File

@@ -41,15 +41,31 @@ namespace AIStudio.Wpf.DiagramDesigner
return new ImageDesignerItem(this); return new ImageDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
this.PropertyChanged += ImageItemViewModel_PropertyChanged; this.PropertyChanged += ImageItemViewModel_PropertyChanged;
BuildMenuOptions(); BuildMenuOptions();
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{
base.LoadDesignerItemViewModel(designerbase);
if (designerbase is ImageDesignerItem designer)
{
this.Icon = designer.Icon;
Suffix = Path.GetExtension(this.Icon).ToLower();
}
}
private void ImageItemViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) private void ImageItemViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(ItemWidth) || e.PropertyName == nameof(ItemHeight) || e.PropertyName == nameof(ResizeMargin) || e.PropertyName == nameof(ClipMode)) if (e.PropertyName == nameof(ItemWidth) || e.PropertyName == nameof(ItemHeight) || e.PropertyName == nameof(ResizeMargin) || e.PropertyName == nameof(ClipMode))
@@ -65,6 +81,7 @@ namespace AIStudio.Wpf.DiagramDesigner
} }
} }
#region
private string _suffix; private string _suffix;
public string Suffix public string Suffix
{ {
@@ -113,24 +130,9 @@ namespace AIStudio.Wpf.DiagramDesigner
SetProperty(ref _clipMode, value); SetProperty(ref _clipMode, value);
} }
} }
#endregion
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{
base.LoadDesignerItemViewModel(designerbase);
if (designerbase is ImageDesignerItem designer)
{
this.Icon = designer.Icon;
Suffix = Path.GetExtension(this.Icon).ToLower();
foreach (var connector in designer.Connectors)
{
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
AddConnector(fullyCreatedConnectorInfo);
}
}
}
private void BuildMenuOptions() private void BuildMenuOptions()
{ {
menuOptions = new ObservableCollection<CinchMenuItem>(); menuOptions = new ObservableCollection<CinchMenuItem>();

View File

@@ -16,10 +16,13 @@ namespace AIStudio.Wpf.DiagramDesigner
Top = Math.Max(0, location.Y - ItemHeight / 2); Top = Math.Max(0, location.Y - ItemHeight / 2);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
}
protected override void InitNew()
{
this.ClearConnectors(); this.ClearConnectors();
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true)); this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));

View File

@@ -95,14 +95,19 @@ namespace AIStudio.Wpf.DiagramDesigner
return new LogicalGateDesignerItemBase(this); return new LogicalGateDesignerItemBase(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
ShowRotate = false; ShowRotate = false;
ShowArrow = false; ShowArrow = false;
AddInputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddInput(para)); AddInputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddInput(para));
AddOutputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddOutput(para)); AddOutputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddOutput(para));
base.Init(root); base.Init(root, initNew);
}
protected override void InitNew()
{
base.InitNew();
} }
private void BuildMenuOptions() private void BuildMenuOptions()

View File

@@ -36,13 +36,17 @@ namespace AIStudio.Wpf.DiagramDesigner
return new MediaDesignerItem(this); return new MediaDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
BuildMenuOptions(); BuildMenuOptions();
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
@@ -51,12 +55,6 @@ namespace AIStudio.Wpf.DiagramDesigner
if (designerbase is MediaDesignerItem designer) if (designerbase is MediaDesignerItem designer)
{ {
this.Icon = designer.Icon; this.Icon = designer.Icon;
foreach (var connector in designer.Connectors)
{
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
AddConnector(fullyCreatedConnectorInfo);
}
} }
} }

View File

@@ -16,15 +16,17 @@ namespace AIStudio.Wpf.DiagramDesigner
Top = Math.Max(0, location.Y - ItemHeight / 2); Top = Math.Max(0, location.Y - ItemHeight / 2);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
}
this.ClearConnectors();
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));
protected override void InitNew()
{
ItemWidth = 5; ItemWidth = 5;
ItemHeight = 5; ItemHeight = 5;
this.ClearConnectors();
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));
} }
private bool _showConnectors = false; private bool _showConnectors = false;

View File

@@ -98,16 +98,19 @@ namespace AIStudio.Wpf.DiagramDesigner
Top = ConnectionPoints.Min(p => p.Y); Top = ConnectionPoints.Min(p => p.Y);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand); MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
base.Init(root); base.Init(root, initNew);
this.ClearConnectors();
BuildMenuOptions(); BuildMenuOptions();
} }
protected override void InitNew()
{
this.ClearConnectors();
}
private void ExecuteMenuItemCommand(object obj) private void ExecuteMenuItemCommand(object obj)
{ {
ShowConnectors = (obj as CinchMenuItem).IsChecked; ShowConnectors = (obj as CinchMenuItem).IsChecked;

View File

@@ -35,12 +35,15 @@ namespace AIStudio.Wpf.DiagramDesigner
return new TextDesignerItem(this); return new TextDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
CustomText = true; CustomText = true;
}
protected override void InitNew()
{
this.ItemWidth = 150; this.ItemWidth = 150;
this.ClearConnectors(); this.ClearConnectors();
} }

View File

@@ -40,9 +40,9 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
return new FlowNodeDesignerItem(this); return new FlowNodeDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
ShowRotate = false; ShowRotate = false;
ShowText = true; ShowText = true;
@@ -51,6 +51,11 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -36,13 +36,18 @@ namespace AIStudio.Wpf.Logical.ViewModels
return new LogicalGateDesignerItemBase(this); return new LogicalGateDesignerItemBase(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);
@@ -1040,15 +1045,20 @@ namespace AIStudio.Wpf.Logical.ViewModels
BuildMenuOptions(); BuildMenuOptions();
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand); MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
readDataTimer.Elapsed += timeCycle; readDataTimer.Elapsed += timeCycle;
readDataTimer.Interval = 1000; readDataTimer.Interval = 1000;
} }
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);

View File

@@ -25,29 +25,8 @@
<Grid Height="100"> <Grid Height="100">
<TabControl> <TabControl>
<TabItem Header="思路" Height="30" Width="50"> <TabItem Header="思路" Height="30" Width="50">
<Grid> <StackPanel Orientation="Horizontal">
<Grid.ColumnDefinitions> <UniformGrid Rows="2">
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<UniformGrid Rows="2" Grid.Row="0" Grid.Column="0" >
<Button Style="{StaticResource FlatButtonStyle}" Command="{Binding UndoCommand}"> <Button Style="{StaticResource FlatButtonStyle}" Command="{Binding UndoCommand}">
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M255.545 8c-66.269.119-126.438 26.233-170.86 68.685L48.971 40.971C33.851 25.851 8 36.559 8 57.941V192c0 13.255 10.745 24 24 24h134.059c21.382 0 32.09-25.851 16.971-40.971l-41.75-41.75c30.864-28.899 70.801-44.907 113.23-45.273 92.398-.798 170.283 73.977 169.484 169.442C423.236 348.009 349.816 424 256 424c-41.127 0-79.997-14.678-110.63-41.556-4.743-4.161-11.906-3.908-16.368.553L89.34 422.659c-4.872 4.872-4.631 12.815.482 17.433C133.798 479.813 192.074 504 256 504c136.966 0 247.999-111.033 248-247.998C504.001 119.193 392.354 7.755 255.545 8z"></Path> <Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M255.545 8c-66.269.119-126.438 26.233-170.86 68.685L48.971 40.971C33.851 25.851 8 36.559 8 57.941V192c0 13.255 10.745 24 24 24h134.059c21.382 0 32.09-25.851 16.971-40.971l-41.75-41.75c30.864-28.899 70.801-44.907 113.23-45.273 92.398-.798 170.283 73.977 169.484 169.442C423.236 348.009 349.816 424 256 424c-41.127 0-79.997-14.678-110.63-41.556-4.743-4.161-11.906-3.908-16.368.553L89.34 422.659c-4.872 4.872-4.631 12.815.482 17.433C133.798 479.813 192.074 504 256 504c136.966 0 247.999-111.033 248-247.998C504.001 119.193 392.354 7.755 255.545 8z"></Path>
</Button> </Button>
@@ -55,8 +34,8 @@
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M256.455 8c66.269.119 126.437 26.233 170.859 68.685l35.715-35.715C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.75c-30.864-28.899-70.801-44.907-113.23-45.273-92.398-.798-170.283 73.977-169.484 169.442C88.764 348.009 162.184 424 256 424c41.127 0 79.997-14.678 110.629-41.556 4.743-4.161 11.906-3.908 16.368.553l39.662 39.662c4.872 4.872 4.631 12.815-.482 17.433C378.202 479.813 319.926 504 256 504 119.034 504 8.001 392.967 8 256.002 7.999 119.193 119.646 7.755 256.455 8z"></Path> <Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M256.455 8c66.269.119 126.437 26.233 170.859 68.685l35.715-35.715C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.75c-30.864-28.899-70.801-44.907-113.23-45.273-92.398-.798-170.283 73.977-169.484 169.442C88.764 348.009 162.184 424 256 424c41.127 0 79.997-14.678 110.629-41.556 4.743-4.161 11.906-3.908 16.368.553l39.662 39.662c4.872 4.872 4.631 12.815-.482 17.433C378.202 479.813 319.926 504 256 504 119.034 504 8.001 392.967 8 256.002 7.999 119.193 119.646 7.755 256.455 8z"></Path>
</Button> </Button>
</UniformGrid> </UniformGrid>
<Line Grid.Column="1" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Rows="2" Grid.Row="0" Grid.Column="2" > <UniformGrid Rows="2">
<Button Style="{StaticResource FlatButtonStyle}" Command="{Binding AddChildCommand}"> <Button Style="{StaticResource FlatButtonStyle}" Command="{Binding AddChildCommand}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M992.9 500.1H355c-19.3 0-35 15.7-35 35V660H182V340.8h427.8c32 0 58-26 58-58V58c0-32-25.9-58-58-58H58C26 0 0 26 0 58v224.8c0 32 26 58 58 58h54V689c0 13.3 7.4 24.8 18.2 30.7 6.3 6.3 15.1 10.3 24.8 10.3h165v145.9c0 19.3 15.7 35 35 35h226c19.3 0 35-15.7 35-35s-15.7-35-35-35H390V570.1h567.9V611c0 19.3 15.7 35 35 35s35-15.7 35-35v-75.9c0-19.3-15.7-35-35-35zM70 70h527.8v200.8H70V70zM989 830h-89v-89c0-19.3-15.7-35-35-35s-35 15.7-35 35v89h-89c-19.3 0-35 15.7-35 35s15.7 35 35 35h89v89c0 19.3 15.7 35 35 35s35-15.7 35-35v-89h89c19.3 0 35-15.7 35-35s-15.7-35-35-35z"></Path> <Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M992.9 500.1H355c-19.3 0-35 15.7-35 35V660H182V340.8h427.8c32 0 58-26 58-58V58c0-32-25.9-58-58-58H58C26 0 0 26 0 58v224.8c0 32 26 58 58 58h54V689c0 13.3 7.4 24.8 18.2 30.7 6.3 6.3 15.1 10.3 24.8 10.3h165v145.9c0 19.3 15.7 35 35 35h226c19.3 0 35-15.7 35-35s-15.7-35-35-35H390V570.1h567.9V611c0 19.3 15.7 35 35 35s35-15.7 35-35v-75.9c0-19.3-15.7-35-35-35zM70 70h527.8v200.8H70V70zM989 830h-89v-89c0-19.3-15.7-35-35-35s-35 15.7-35 35v89h-89c-19.3 0-35 15.7-35 35s15.7 35 35 35h89v89c0 19.3 15.7 35 35 35s35-15.7 35-35v-89h89c19.3 0 35-15.7 35-35s-15.7-35-35-35z"></Path>
@@ -86,8 +65,8 @@
</StackPanel> </StackPanel>
</Button> </Button>
</UniformGrid> </UniformGrid>
<Line Grid.Column="3" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Rows="2" Grid.Row="0" Grid.Column="4" > <UniformGrid Rows="2">
<Button Style="{StaticResource FlatButtonStyle}" Command="{Binding MoveForwardCommand}"> <Button Style="{StaticResource FlatButtonStyle}" Command="{Binding MoveForwardCommand}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M62.5 500L312.5 500L312.5 937.5L687.5 937.5L687.5 500L937.5 500L500 62.5Z"></Path> <Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M62.5 500L312.5 500L312.5 937.5L687.5 937.5L687.5 500L937.5 500L500 62.5Z"></Path>
@@ -101,8 +80,8 @@
</StackPanel> </StackPanel>
</Button> </Button>
</UniformGrid> </UniformGrid>
<Line Grid.Column="5" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Rows="2" Grid.Row="0" Grid.Column="6" > <UniformGrid Rows="2">
<Button Style="{StaticResource FlatButtonStyle}" Command="{Binding EditCommand}"> <Button Style="{StaticResource FlatButtonStyle}" Command="{Binding EditCommand}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M8,12H16V14H8V12M10,20H6V4H13V9H18V12.1L20,10.1V8L14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H10V20M8,18H12.1L13,17.1V16H8V18M20.2,13C20.3,13 20.5,13.1 20.6,13.2L21.9,14.5C22.1,14.7 22.1,15.1 21.9,15.3L20.9,16.3L18.8,14.2L19.8,13.2C19.9,13.1 20,13 20.2,13M20.2,16.9L14.1,23H12V20.9L18.1,14.8L20.2,16.9Z"></Path> <Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M8,12H16V14H8V12M10,20H6V4H13V9H18V12.1L20,10.1V8L14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H10V20M8,18H12.1L13,17.1V16H8V18M20.2,13C20.3,13 20.5,13.1 20.6,13.2L21.9,14.5C22.1,14.7 22.1,15.1 21.9,15.3L20.9,16.3L18.8,14.2L19.8,13.2C19.9,13.1 20,13 20.2,13M20.2,16.9L14.1,23H12V20.9L18.1,14.8L20.2,16.9Z"></Path>
@@ -116,8 +95,8 @@
</StackPanel> </StackPanel>
</Button> </Button>
</UniformGrid> </UniformGrid>
<Line Grid.Column="7" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Rows="1" Grid.Row="0" Grid.Column="8" > <UniformGrid Rows="1">
<controls:DropDownButton> <controls:DropDownButton>
<controls:DropDownButton.Content> <controls:DropDownButton.Content>
<StackPanel> <StackPanel>
@@ -186,8 +165,8 @@
</controls:DropDownButton.Items> </controls:DropDownButton.Items>
</controls:DropDownButton> </controls:DropDownButton>
</UniformGrid> </UniformGrid>
<Line Grid.Column="9" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Columns="5" Grid.Row="0" Grid.Column="10" > <UniformGrid Columns="5">
<Button Style="{StaticResource FlatButtonStyle}" <Button Style="{StaticResource FlatButtonStyle}"
Background="#FFC5BDAE" Background="#FFC5BDAE"
Width="20" Width="20"
@@ -311,8 +290,8 @@
</Path> </Path>
</Button> </Button>
</UniformGrid> </UniformGrid>
<Line Grid.Column="11" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Columns="5" Grid.Row="0" Grid.Column="12" > <UniformGrid Columns="5">
<Button Style="{StaticResource FlatCircleButtonStyle}" <Button Style="{StaticResource FlatCircleButtonStyle}"
Background="Yellow" Background="Yellow"
Width="20" Width="20"
@@ -394,7 +373,7 @@
<Path Stretch="Uniform" Fill="Green" Data="m 256,76 c 48.1,0 93.3,18.7 127.3,52.7 34,34 52.7,79.2 52.7,127.3 0,48.1 -18.7,93.3 -52.7,127.3 -34,34 -79.2,52.7 -127.3,52.7 -48.1,0 -93.3,-18.7 -127.3,-52.7 C 94.7,349.3 76,304.1 76,256 76,207.9 94.7,162.7 128.7,128.7 162.7,94.7 207.9,76 256,76 m 0,-28 C 141.1,48 48,141.1 48,256 48,370.9 141.1,464 256,464 370.9,464 464,370.9 464,256 464,141.1 370.9,48 256,48 Z M 362.6,192.9 345,174.8 c -0.7,-0.8 -1.8,-1.2 -2.8,-1.2 -1.1,0 -2.1,0.4 -2.8,1.2 L 217.4,297.7 173,253.3 c -0.8,-0.8 -1.8,-1.2 -2.8,-1.2 -1,0 -2,0.4 -2.8,1.2 l -17.8,17.8 c -1.6,1.6 -1.6,4.1 0,5.7 l 56,56 c 3.6,3.6 8,5.7 11.7,5.7 5.3,0 9.9,-3.9 11.6,-5.5 H 229 L 362.7,198.6 c 1.4,-1.7 1.4,-4.2 -0.1,-5.7 z"></Path> <Path Stretch="Uniform" Fill="Green" Data="m 256,76 c 48.1,0 93.3,18.7 127.3,52.7 34,34 52.7,79.2 52.7,127.3 0,48.1 -18.7,93.3 -52.7,127.3 -34,34 -79.2,52.7 -127.3,52.7 -48.1,0 -93.3,-18.7 -127.3,-52.7 C 94.7,349.3 76,304.1 76,256 76,207.9 94.7,162.7 128.7,128.7 162.7,94.7 207.9,76 256,76 m 0,-28 C 141.1,48 48,141.1 48,256 48,370.9 141.1,464 256,464 370.9,464 464,370.9 464,256 464,141.1 370.9,48 256,48 Z M 362.6,192.9 345,174.8 c -0.7,-0.8 -1.8,-1.2 -2.8,-1.2 -1.1,0 -2.1,0.4 -2.8,1.2 L 217.4,297.7 173,253.3 c -0.8,-0.8 -1.8,-1.2 -2.8,-1.2 -1,0 -2,0.4 -2.8,1.2 l -17.8,17.8 c -1.6,1.6 -1.6,4.1 0,5.7 l 56,56 c 3.6,3.6 8,5.7 11.7,5.7 5.3,0 9.9,-3.9 11.6,-5.5 H 229 L 362.7,198.6 c 1.4,-1.7 1.4,-4.2 -0.1,-5.7 z"></Path>
</Button> </Button>
</UniformGrid> </UniformGrid>
<Grid Grid.Column="13" > <Grid>
<Border BorderBrush="Gray" BorderThickness="1" CornerRadius="3"> <Border BorderBrush="Gray" BorderThickness="1" CornerRadius="3">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -427,24 +406,10 @@
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
</Grid> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="外观" Height="30" Width="50"> <TabItem Header="外观" Height="30" Width="50">
<Grid> <StackPanel Orientation="Horizontal">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:DropDownButton> <controls:DropDownButton>
<controls:DropDownButton.Content> <controls:DropDownButton.Content>
<Border CornerRadius="3"> <Border CornerRadius="3">
@@ -460,8 +425,8 @@
<MenuItem Header="天盘图" IsCheckable="True" IsEnabled="False" ToolTip="暂未完成" IsChecked="{Binding MindType,Converter={dd:ConverterValueMapToBool Parameter='Celestial'}, ConverterParameter='Celestial'}" /> <MenuItem Header="天盘图" IsCheckable="True" IsEnabled="False" ToolTip="暂未完成" IsChecked="{Binding MindType,Converter={dd:ConverterValueMapToBool Parameter='Celestial'}, ConverterParameter='Celestial'}" />
</controls:DropDownButton.Items> </controls:DropDownButton.Items>
</controls:DropDownButton> </controls:DropDownButton>
<Line Grid.Column="1" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<controls:DropDownButton Grid.Column="2"> <controls:DropDownButton>
<controls:DropDownButton.Content> <controls:DropDownButton.Content>
<Border Background="{Binding MindThemeModel.MindThemeLevel1.FillColor,Converter={StaticResource ColorBrushConverter}}" CornerRadius="3"> <Border Background="{Binding MindThemeModel.MindThemeLevel1.FillColor,Converter={StaticResource ColorBrushConverter}}" CornerRadius="3">
<TextBlock Margin="5" Text="{Binding MindThemeModel.Name}"></TextBlock> <TextBlock Margin="5" Text="{Binding MindThemeModel.Name}"></TextBlock>
@@ -489,15 +454,15 @@
<MenuItem Header="紧凑黄" Background="#e9df98" Margin="1.5" Command="{Binding ChangeMindThemeCommand}" CommandParameter="紧凑冷"/> <MenuItem Header="紧凑黄" Background="#e9df98" Margin="1.5" Command="{Binding ChangeMindThemeCommand}" CommandParameter="紧凑冷"/>
</controls:DropDownButton.Items> </controls:DropDownButton.Items>
</controls:DropDownButton> </controls:DropDownButton>
<Line Grid.Column="3" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding ResetLayoutCommand}"> <Button Style="{StaticResource FlatButtonStyle}" Command="{Binding ResetLayoutCommand}">
<StackPanel> <StackPanel>
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M358.4 0a102.4 102.4 0 0 1 102.4 102.4v819.2a102.4 102.4 0 0 1-102.4 102.4H102.4a102.4 102.4 0 0 1-102.4-102.4V102.4a102.4 102.4 0 0 1 102.4-102.4h256z m0 76.8H102.4a25.6 25.6 0 0 0-25.1904 20.992L76.8 102.4v819.2a25.6 25.6 0 0 0 20.992 25.1904L102.4 947.2h256a25.6 25.6 0 0 0 25.1904-20.992L384 921.6V102.4a25.6 25.6 0 0 0-20.992-25.1904L358.4 76.8z m268.288 547.84a38.4 38.4 0 0 1 50.1248-1.8432l4.1472 3.8912a38.4 38.4 0 0 1 1.8432 50.1248L630.272 742.4h333.7216l4.6592 0.3584c16.7936 2.56 29.696 18.5856 29.696 38.0416 0 21.1968-15.36 38.4-34.3552 38.4h-333.6704l52.4288 65.6384 3.2256 4.6592a38.4 38.4 0 0 1-63.232 43.3152l-102.4-128-3.328-4.9152a38.4 38.4 0 0 1 3.328-43.0592l102.4-128zM921.6 0a102.4 102.4 0 0 1 102.4 102.4v256a102.4 102.4 0 0 1-102.4 102.4h-256a102.4 102.4 0 0 1-102.4-102.4V102.4a102.4 102.4 0 0 1 102.4-102.4h256z m0 76.8h-256a25.6 25.6 0 0 0-25.1904 20.992L640 102.4v256a25.6 25.6 0 0 0 20.992 25.1904L665.6 384h256a25.6 25.6 0 0 0 25.1904-20.992L947.2 358.4V102.4a25.6 25.6 0 0 0-20.992-25.1904L921.6 76.8z"></Path> <Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M358.4 0a102.4 102.4 0 0 1 102.4 102.4v819.2a102.4 102.4 0 0 1-102.4 102.4H102.4a102.4 102.4 0 0 1-102.4-102.4V102.4a102.4 102.4 0 0 1 102.4-102.4h256z m0 76.8H102.4a25.6 25.6 0 0 0-25.1904 20.992L76.8 102.4v819.2a25.6 25.6 0 0 0 20.992 25.1904L102.4 947.2h256a25.6 25.6 0 0 0 25.1904-20.992L384 921.6V102.4a25.6 25.6 0 0 0-20.992-25.1904L358.4 76.8z m268.288 547.84a38.4 38.4 0 0 1 50.1248-1.8432l4.1472 3.8912a38.4 38.4 0 0 1 1.8432 50.1248L630.272 742.4h333.7216l4.6592 0.3584c16.7936 2.56 29.696 18.5856 29.696 38.0416 0 21.1968-15.36 38.4-34.3552 38.4h-333.6704l52.4288 65.6384 3.2256 4.6592a38.4 38.4 0 0 1-63.232 43.3152l-102.4-128-3.328-4.9152a38.4 38.4 0 0 1 3.328-43.0592l102.4-128zM921.6 0a102.4 102.4 0 0 1 102.4 102.4v256a102.4 102.4 0 0 1-102.4 102.4h-256a102.4 102.4 0 0 1-102.4-102.4V102.4a102.4 102.4 0 0 1 102.4-102.4h256z m0 76.8h-256a25.6 25.6 0 0 0-25.1904 20.992L640 102.4v256a25.6 25.6 0 0 0 20.992 25.1904L665.6 384h256a25.6 25.6 0 0 0 25.1904-20.992L947.2 358.4V102.4a25.6 25.6 0 0 0-20.992-25.1904L921.6 76.8z"></Path>
<TextBlock>整理布局</TextBlock> <TextBlock>整理布局</TextBlock>
</StackPanel> </StackPanel>
</Button> </Button>
<Line Grid.Column="5" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<Grid Grid.Column="6" > <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>
@@ -525,8 +490,8 @@
</StackPanel> </StackPanel>
</Button> </Button>
</Grid> </Grid>
<Line Grid.Column="7" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<Grid Grid.Column="8"> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>
@@ -585,7 +550,7 @@
<ScaleTransform ScaleY="-1"/> <ScaleTransform ScaleY="-1"/>
</Path.RenderTransform> </Path.RenderTransform>
</Path> </Path>
</Grid> </Grid>
</controls:ColorPicker.Content> </controls:ColorPicker.Content>
</controls:ColorPicker> </controls:ColorPicker>
@@ -604,31 +569,17 @@
<Path.RenderTransform> <Path.RenderTransform>
<ScaleTransform ScaleY="-1"/> <ScaleTransform ScaleY="-1"/>
</Path.RenderTransform> </Path.RenderTransform>
</Path> </Path>
</Grid> </Grid>
</controls:ColorPicker.Content> </controls:ColorPicker.Content>
</controls:ColorPicker> </controls:ColorPicker>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="视图" Height="30" Width="50"> <TabItem Header="视图" Height="30" Width="50">
<Grid> <StackPanel Orientation="Horizontal">
<Grid.ColumnDefinitions> <controls:DropDownButton>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<controls:DropDownButton Grid.Column="0">
<controls:DropDownButton.Content> <controls:DropDownButton.Content>
<StackPanel> <StackPanel>
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M877.714286 768c0 21.942857-14.628571 36.571429-36.571429 36.571429h-585.142857c-21.942857 0-36.571429-14.628571-36.571429-36.571429v-585.142857c0-21.942857 14.628571-36.571429 36.571429-36.571429h585.142857c21.942857 0 36.571429 14.628571 36.571429 36.571429v585.142857zM841.142857 73.142857h-585.142857C197.485714 73.142857 146.285714 124.342857 146.285714 182.857143v585.142857c0 58.514286 51.2 109.714286 109.714286 109.714286h585.142857c58.514286 0 109.714286-51.2 109.714286-109.714286v-585.142857c0-58.514286-51.2-109.714286-109.714286-109.714286z m-146.285714 365.714286H585.142857V329.142857c0-21.942857-14.628571-36.571429-36.571428-36.571428s-36.571429 14.628571-36.571429 36.571428V438.857143H402.285714c-21.942857 0-36.571429 14.628571-36.571428 36.571428s14.628571 36.571429 36.571428 36.571429H512v109.714286c0 21.942857 14.628571 36.571429 36.571429 36.571428s36.571429-14.628571 36.571428-36.571428V512h109.714286c21.942857 0 36.571429-14.628571 36.571428-36.571429S716.8 438.857143 694.857143 438.857143z"></Path> <Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M877.714286 768c0 21.942857-14.628571 36.571429-36.571429 36.571429h-585.142857c-21.942857 0-36.571429-14.628571-36.571429-36.571429v-585.142857c0-21.942857 14.628571-36.571429 36.571429-36.571429h585.142857c21.942857 0 36.571429 14.628571 36.571429 36.571429v585.142857zM841.142857 73.142857h-585.142857C197.485714 73.142857 146.285714 124.342857 146.285714 182.857143v585.142857c0 58.514286 51.2 109.714286 109.714286 109.714286h585.142857c58.514286 0 109.714286-51.2 109.714286-109.714286v-585.142857c0-58.514286-51.2-109.714286-109.714286-109.714286z m-146.285714 365.714286H585.142857V329.142857c0-21.942857-14.628571-36.571429-36.571428-36.571428s-36.571429 14.628571-36.571429 36.571428V438.857143H402.285714c-21.942857 0-36.571429 14.628571-36.571428 36.571428s14.628571 36.571429 36.571428 36.571429H512v109.714286c0 21.942857 14.628571 36.571429 36.571429 36.571428s36.571429-14.628571 36.571428-36.571428V512h109.714286c21.942857 0 36.571429-14.628571 36.571428-36.571429S716.8 438.857143 694.857143 438.857143z"></Path>
@@ -644,7 +595,7 @@
<MenuItem Header="展开到六级节点" Command="{Binding Expand2LevelCommand}" CommandParameter="6"/> <MenuItem Header="展开到六级节点" Command="{Binding Expand2LevelCommand}" CommandParameter="6"/>
</controls:DropDownButton.Items> </controls:DropDownButton.Items>
</controls:DropDownButton> </controls:DropDownButton>
<controls:DropDownButton Grid.Column="1"> <controls:DropDownButton>
<controls:DropDownButton.Content> <controls:DropDownButton.Content>
<StackPanel> <StackPanel>
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M505.6 454.4l134.4-480 108.8 166.4 204.8-204.8 70.4 70.4-211.2 204.8 172.8 102.4zM512 192h-448v576h768v-345.6l64-12.8v422.4h-896v-704h524.8z"></Path> <Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M505.6 454.4l134.4-480 108.8 166.4 204.8-204.8 70.4 70.4-211.2 204.8 172.8 102.4zM512 192h-448v576h768v-345.6l64-12.8v422.4h-896v-704h524.8z"></Path>
@@ -660,8 +611,8 @@
<MenuItem Header="选择子树" Command="{Binding SelectChildCommand}" /> <MenuItem Header="选择子树" Command="{Binding SelectChildCommand}" />
</controls:DropDownButton.Items> </controls:DropDownButton.Items>
</controls:DropDownButton> </controls:DropDownButton>
<Line Grid.Column="2" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<StackPanel Orientation="Horizontal" Grid.Column="3" > <StackPanel Orientation="Horizontal">
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding CenterMoveCommand}"> <Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding CenterMoveCommand}">
<StackPanel> <StackPanel>
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M256 320c35 0 64 -29 64 -64s-29 -64 -64 -64s-64 29 -64 64s29 64 64 64zM405 107v85h43v-85c0 -23 -20 -43 -43 -43h-85v43h85zM405 448c23 0 43 -20 43 -43v-85h-43v85h-85v43h85zM107 405v-85h-43v85c0 23 20 43 43 43h85v-43h-85zM107 192v-85h85v-43h-85 c-23 0 -43 20 -43 43v85h43z"></Path> <Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M256 320c35 0 64 -29 64 -64s-29 -64 -64 -64s-64 29 -64 64s29 64 64 64zM405 107v85h43v-85c0 -23 -20 -43 -43 -43h-85v43h85zM405 448c23 0 43 -20 43 -43v-85h-43v85h-85v43h85zM107 405v-85h-43v85c0 23 20 43 43 43h85v-43h-85zM107 192v-85h85v-43h-85 c-23 0 -43 20 -43 43v85h43z"></Path>
@@ -691,14 +642,14 @@
</StackPanel> </StackPanel>
</Button> </Button>
</StackPanel> </StackPanel>
<Line Grid.Column="4" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line> <Line X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<Button Style="{StaticResource FlatButtonStyle}" Command="{Binding SearchDownCommand}" CommandParameter="{Binding ElementName=txtsearch,Path=Text}" Grid.Column="5" > <Button Style="{StaticResource FlatButtonStyle}" Command="{Binding SearchDownCommand}" CommandParameter="{Binding ElementName=txtsearch,Path=Text}">
<StackPanel> <StackPanel>
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M911.958045 890.721335l-241.415018-246.54112a336.369964 336.369964 0 1 0-58.095828 45.158522l247.029321 252.643623a36.859118 36.859118 0 0 0 51.749225 0 37.103218 37.103218 0 0 0 0.7323-51.261025zM176.240286 404.473897a261.431228 261.431228 0 1 1 261.431228 261.431228A261.675328 261.675328 0 0 1 176.240286 404.473897z"></Path> <Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M911.958045 890.721335l-241.415018-246.54112a336.369964 336.369964 0 1 0-58.095828 45.158522l247.029321 252.643623a36.859118 36.859118 0 0 0 51.749225 0 37.103218 37.103218 0 0 0 0.7323-51.261025zM176.240286 404.473897a261.431228 261.431228 0 1 1 261.431228 261.431228A261.675328 261.675328 0 0 1 176.240286 404.473897z"></Path>
<TextBlock>搜索</TextBlock> <TextBlock>搜索</TextBlock>
</StackPanel> </StackPanel>
</Button> </Button>
<Border BorderBrush="Gray" Grid.Column="6" BorderThickness="1" CornerRadius="3"> <Border BorderBrush="Gray" BorderThickness="1" CornerRadius="3">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
@@ -730,7 +681,7 @@
<TextBlock Grid.Row="1" Grid.ColumnSpan="3" Text="{Binding SearchInfo}"/> <TextBlock Grid.Row="1" Grid.ColumnSpan="3" Text="{Binding SearchInfo}"/>
</Grid> </Grid>
</Border> </Border>
</Grid> </StackPanel>
</TabItem> </TabItem>
</TabControl> </TabControl>
</Grid> </Grid>

View File

@@ -347,7 +347,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
foreach (var parent in parents) foreach (var parent in parents)
{ {
parent.Children = new System.Collections.ObjectModel.ObservableCollection<MindNode>(Items.OfType<MindNode>().Where(p => p.ParentId == parent.Id)); parent.Children = new System.Collections.ObjectModel.ObservableCollection<MindNode>(Items.OfType<MindNode>().Where(p => p.ParentId == parent.Id));
foreach (var item in Items.OfType<MindNode>().Where(p => p.ParentId == parent.Id)) foreach (var item in Items.OfType<MindNode>().Where(p => p.ParentId == parent.Id).ToList())
{ {
item.Parent = parent; item.Parent = parent;
item.InitLayout(false); item.InitLayout(false);
@@ -426,7 +426,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
if (items?.Count == 0) if (items?.Count == 0)
{ {
var node = new MindNode(this) { Text = "分支主题" }; var node = new MindNode(this) { Text = $"分支主题{parent.Children.Count + 1}"};
items.Add(node); items.Add(node);
} }
@@ -463,14 +463,15 @@ namespace AIStudio.Wpf.Mind.ViewModels
else else
{ {
node = SelectedItem as MindNode; node = SelectedItem as MindNode;
} }
if (items?.Count == 0)
{
items.Add(new MindNode(this) { Text = "分支主题" });
}
if (node.Parent is MindNode parent) if (node.Parent is MindNode parent)
{ {
if (items?.Count == 0)
{
items.Add(new MindNode(this) { Text = $"分支主题{parent.Children.Count + 1}" });
}
DoCommandManager.DoNewCommand(this.ToString(), DoCommandManager.DoNewCommand(this.ToString(),
() => { () => {
int index = parent.Children.IndexOf(node); int index = parent.Children.IndexOf(node);
@@ -510,15 +511,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
pear = SelectedItem as MindNode; pear = SelectedItem as MindNode;
} }
if (items?.Count == 0)
{
var node = new MindNode(this) { Text = "分支主题" };
items.Add(node);
}
if (pear.Parent is MindNode parent) if (pear.Parent is MindNode parent)
{ {
if (items?.Count == 0)
{
var node = new MindNode(this) { Text = $"分支主题{parent.Children.Count + 1}" };
items.Add(node);
}
DoCommandManager.DoNewCommand(this.ToString(), DoCommandManager.DoNewCommand(this.ToString(),
() => { () => {
int index = parent.Children.IndexOf(pear); int index = parent.Children.IndexOf(pear);
@@ -667,22 +667,24 @@ namespace AIStudio.Wpf.Mind.ViewModels
#endregion #endregion
#region , #region ,
protected override void FixConnection(List<SelectableDesignerItemViewModelBase> items) protected override void FixOtherInfo(List<SelectableDesignerItemViewModelBase> items)
{ {
List<MindNode> parents = new List<MindNode>(); List<MindNode> parents = new List<MindNode>();
foreach (var item in items.OfType<MindNode>()) foreach (var item in items.OfType<MindNode>())
{ {
var parent = Items.OfType<MindNode>().FirstOrDefault(p => p.Id == item.ParentId); var parent = Items.OfType<MindNode>().FirstOrDefault(p => p.Id == item.ParentId);
if (parent != null) if (parent != null && !items.Contains(parent))
{ {
parents.Add(parent); parents.Add(parent);
} }
else else if (item.ParentId == Guid.Empty)
{ {
parents.Add(item); parents.Add(item);
item.InitLayout(false);
} }
} }
ResetChildren(parents); ResetChildren(parents);
parents.ForEach(p => p.LayoutUpdated());
} }
#endregion #endregion

View File

@@ -46,14 +46,34 @@ namespace AIStudio.Wpf.Mind.ViewModels
InitLayout(false); InitLayout(false);
} }
public override SelectableItemBase GetSerializableObject() public override SelectableItemBase GetSerializableObject()
{ {
return new MindNodeDesignerItem(this); return new MindNodeDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) public override DiagramNode ToDiagram()
{ {
base.Init(root); var mindNodeModel = new MindNodeModel();
mindNodeModel.Spacing = Spacing;
mindNodeModel.Offset = Offset;
mindNodeModel.IsExpanded = IsExpanded;
mindNodeModel.LinkInfoModel = new LinkInfoModel(LinkInfo);
mindNodeModel.ImageInfoModel = new ImageInfoModel(ImageInfo);
mindNodeModel.Remark = Remark;
mindNodeModel.Priority = Priority;
mindNodeModel.Rate = Rate;
if (Tags != null)
{
mindNodeModel.Tags = new List<string>(Tags);
}
return mindNodeModel;
}
protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root, initNew);
EnabledForConnection = false; EnabledForConnection = false;
AlwayForResized = true; AlwayForResized = true;
@@ -71,6 +91,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
ImageInfo = new ImageInfo(); ImageInfo = new ImageInfo();
} }
protected override void InitNew()
{
this.ClearConnectors();
}
public void InitLayout(bool initAppearance) public void InitLayout(bool initAppearance)
{ {
var layout = GlobalType.AllTypes.Where(p => typeof(IMindLayout).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == MindType.ToString() + "Layout"); var layout = GlobalType.AllTypes.Where(p => typeof(IMindLayout).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == MindType.ToString() + "Layout");
@@ -108,26 +133,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
} }
} }
} }
public override DiagramNode ToDiagram()
{
var mindNodeModel = new MindNodeModel();
mindNodeModel.Spacing = Spacing;
mindNodeModel.Offset = Offset;
mindNodeModel.IsExpanded = IsExpanded;
mindNodeModel.LinkInfoModel = new LinkInfoModel(LinkInfo);
mindNodeModel.ImageInfoModel = new ImageInfoModel(ImageInfo);
mindNodeModel.Remark = Remark;
mindNodeModel.Priority = Priority;
mindNodeModel.Rate = Rate;
if (Tags != null)
{
mindNodeModel.Tags = new List<string>(Tags);
}
return mindNodeModel;
}
#region #region
public IMindLayout MindLayout public IMindLayout MindLayout
{ {
@@ -462,7 +467,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
} }
item.Parent = this; item.Parent = this;
item.ParentId = this.Id; item.ParentId = this.Id;
item.InitLayout(true); item.InitLayout(true);//因为节点的层级不同的样式所以需要Parent确定后才能初始化
ConnectionViewModel connector = MindLayout?.GetOrSetConnectionViewModel(this, item); ConnectionViewModel connector = MindLayout?.GetOrSetConnectionViewModel(this, item);
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { item, connector }); Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { item, connector });
@@ -498,10 +503,16 @@ namespace AIStudio.Wpf.Mind.ViewModels
public void InitConnectLayout() public void InitConnectLayout()
{ {
var connector = Root?.Items.OfType<ConnectionViewModel>().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this); var connector = Root?.Items.OfType<ConnectionViewModel>().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this);
var newconnecter = MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector); if (connector != null)
if (connector == null)
{ {
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { newconnecter }); MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
}
else if (ParentNode != null)
{
connector = MindLayout?.GetOrSetConnectionViewModel(ParentNode, this, null);
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { connector });
connector.ZIndex = -1;
connector.IsSelected = false;
} }
} }
#endregion #endregion
@@ -510,6 +521,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
{ {
if (GetLevel1Node()?.LayoutUpdating == true) return; if (GetLevel1Node()?.LayoutUpdating == true) return;
if (Root == null) return;
switch (e.PropertyName) switch (e.PropertyName)
{ {
case nameof(IsExpanded): case nameof(IsExpanded):

View File

@@ -35,12 +35,17 @@ namespace AIStudio.Wpf.SFC.ViewModels
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
CustomText = true; CustomText = true;
} }
protected override void InitNew()
{
base.InitNew();
}
private ObservableCollection<LinkPoint> _linkPoint = new ObservableCollection<LinkPoint>(); private ObservableCollection<LinkPoint> _linkPoint = new ObservableCollection<LinkPoint>();
public ObservableCollection<LinkPoint> LinkPoint public ObservableCollection<LinkPoint> LinkPoint
{ {

View File

@@ -42,19 +42,24 @@ namespace AIStudio.Wpf.SFC.ViewModels
return new SFCNodeDesignerItem(this); return new SFCNodeDesignerItem(this);
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
IsInnerConnector = true; IsInnerConnector = true;
ShowRotate = false; ShowRotate = false;
ShowArrow = false; ShowArrow = false;
ShowText = true; ShowText = true;
IsReadOnlyText = true; IsReadOnlyText = true;
base.Init(root); base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
} }
protected override void InitNew()
{
ClearConnectors();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase) protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{ {
base.LoadDesignerItemViewModel(designerbase); base.LoadDesignerItemViewModel(designerbase);
@@ -102,11 +107,6 @@ namespace AIStudio.Wpf.SFC.ViewModels
} }
} }
protected override void InitConnector()
{
ClearConnectors();
}
public Dictionary<int, FullyCreatedConnectorInfo> Input { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>(); public Dictionary<int, FullyCreatedConnectorInfo> Input { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>();
public Dictionary<int, FullyCreatedConnectorInfo> Output { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>(); public Dictionary<int, FullyCreatedConnectorInfo> Output { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>();
public Dictionary<int, FullyCreatedConnectorInfo> Action { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>(); public Dictionary<int, FullyCreatedConnectorInfo> Action { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>();

View File

@@ -34,9 +34,9 @@ namespace AIStudio.Wpf.SFC.ViewModels
} }
protected override void Init(IDiagramViewModel root) protected override void Init(IDiagramViewModel root, bool initNew)
{ {
base.Init(root); base.Init(root, initNew);
CustomText = true; CustomText = true;
if (diChangedSubscription != null) if (diChangedSubscription != null)
@@ -47,6 +47,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
diChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Value").Throttle(TimeSpan.FromSeconds(random.Next(1,10))).Subscribe(OnValueChanged);//Sample diChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Value").Throttle(TimeSpan.FromSeconds(random.Next(1,10))).Subscribe(OnValueChanged);//Sample
} }
protected override void InitNew()
{
base.InitNew();
}
/// <summary> /// <summary>
/// 输入 /// 输入
/// </summary> /// </summary>