mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-08 02:06:40 +08:00
sfc界面处理完成,还差顺序逻辑控制过程
This commit is contained in:
@@ -14,6 +14,8 @@ namespace Util.DiagramDesigner
|
||||
IQuickThemeViewModel QuickThemeViewModel { get; }
|
||||
ILockObjectViewModel LockObjectViewModel { get; }
|
||||
SelectableDesignerItemViewModelBase SelectedItem { get; set; }
|
||||
IColorViewModel CopyDefaultColorViewModel();
|
||||
IFontViewModel CopyDefaultFontViewModel();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +45,18 @@ namespace Util.DiagramDesigner
|
||||
RaisePropertyChanged(sender, e.PropertyName);
|
||||
}
|
||||
|
||||
public IColorViewModel CopyDefaultColorViewModel()
|
||||
{
|
||||
var viewModel = GetOldValue<ColorViewModel>(nameof(ColorViewModel));
|
||||
return CopyHelper.Mapper(viewModel);
|
||||
}
|
||||
|
||||
public IFontViewModel CopyDefaultFontViewModel()
|
||||
{
|
||||
var viewModel = GetOldValue<FontViewModel>(nameof(FontViewModel));
|
||||
return CopyHelper.Mapper<FontViewModel, IFontViewModel>(viewModel);
|
||||
}
|
||||
|
||||
private IColorViewModel _colorViewModel;
|
||||
public IColorViewModel ColorViewModel
|
||||
{
|
||||
|
||||
@@ -23,10 +23,7 @@ namespace Util.DiagramDesigner
|
||||
{
|
||||
base.Init();
|
||||
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom));
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left));
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right));
|
||||
InitConnector();
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
||||
@@ -43,7 +40,14 @@ namespace Util.DiagramDesigner
|
||||
this.ItemWidth = designer.ItemWidth;
|
||||
this.ItemHeight = designer.ItemHeight;
|
||||
this.Icon = designer.Icon;
|
||||
}
|
||||
|
||||
protected virtual void InitConnector()
|
||||
{
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom));
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left));
|
||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right));
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo TopConnector
|
||||
@@ -162,6 +166,7 @@ namespace Util.DiagramDesigner
|
||||
}
|
||||
|
||||
public bool ShowRotate { get; set; } = true;
|
||||
public bool ShowArrow { get; set; } = true;
|
||||
|
||||
private double _left;
|
||||
[Browsable(true)]
|
||||
@@ -263,6 +268,11 @@ namespace Util.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接点是否可以按偏移自定义
|
||||
/// </summary>
|
||||
public bool IsRatioConnector { get; set; }
|
||||
|
||||
private ObservableCollection<FullyCreatedConnectorInfo> connectors = new ObservableCollection<FullyCreatedConnectorInfo>();
|
||||
public IEnumerable<FullyCreatedConnectorInfo> Connectors { get { return connectors; } }
|
||||
|
||||
@@ -321,28 +331,40 @@ namespace Util.DiagramDesigner
|
||||
{
|
||||
if (Parent.CellHorizontalAlignment == CellHorizontalAlignment.Center)
|
||||
{
|
||||
this.Left = (int)(this.Left / Parent.GridCellSize.Width) * Parent.GridCellSize.Width + Parent.GridMargin + (Parent.GridCellSize.Width > this.ItemWidth ? (Parent.GridCellSize.Width - this.ItemWidth) / 2 : 0);
|
||||
if (Parent.GridCellSize.Width > this.ItemWidth)
|
||||
{
|
||||
this.Left = (int)(this.Left / Parent.GridCellSize.Width) * Parent.GridCellSize.Width + Parent.GridMargin + (Parent.GridCellSize.Width - this.ItemWidth) / 2;
|
||||
}
|
||||
}
|
||||
else if(Parent.CellHorizontalAlignment == CellHorizontalAlignment.Left)
|
||||
else if (Parent.CellHorizontalAlignment == CellHorizontalAlignment.Left)
|
||||
{
|
||||
this.Left = (int)(this.Left / Parent.GridCellSize.Width) * Parent.GridCellSize.Width + Parent.GridMargin;
|
||||
}
|
||||
else if (Parent.CellHorizontalAlignment == CellHorizontalAlignment.Right)
|
||||
{
|
||||
this.Left = (int)(this.Left / Parent.GridCellSize.Width) * Parent.GridCellSize.Width + Parent.GridMargin + (Parent.GridCellSize.Width > this.ItemWidth ? (Parent.GridCellSize.Width - this.ItemWidth) : 0);
|
||||
if (Parent.GridCellSize.Width > this.ItemWidth)
|
||||
{
|
||||
this.Left = (int)(this.Left / Parent.GridCellSize.Width) * Parent.GridCellSize.Width + Parent.GridMargin + (Parent.GridCellSize.Width - this.ItemWidth);
|
||||
}
|
||||
}
|
||||
|
||||
if (Parent.CellVerticalAlignment == CellVerticalAlignment.Center)
|
||||
{
|
||||
this.Top = (int)(this.Top / Parent.GridCellSize.Height) * Parent.GridCellSize.Height + Parent.GridMargin + (Parent.GridCellSize.Height > this.ItemHeight ? (Parent.GridCellSize.Height - this.ItemHeight) / 2 : 0);
|
||||
{
|
||||
if (Parent.GridCellSize.Height > this.ItemHeight)
|
||||
{
|
||||
this.Top = (int)(this.Top / Parent.GridCellSize.Height) * Parent.GridCellSize.Height + Parent.GridMargin + (Parent.GridCellSize.Height - this.ItemHeight) / 2;
|
||||
}
|
||||
}
|
||||
else if (Parent.CellVerticalAlignment == CellVerticalAlignment.Top)
|
||||
{
|
||||
{
|
||||
this.Top = (int)(this.Top / Parent.GridCellSize.Height) * Parent.GridCellSize.Height + Parent.GridMargin;
|
||||
}
|
||||
else if (Parent.CellVerticalAlignment == CellVerticalAlignment.Bottom)
|
||||
{
|
||||
this.Top = (int)(this.Top / Parent.GridCellSize.Height) * Parent.GridCellSize.Height + Parent.GridMargin + (Parent.GridCellSize.Height > this.ItemHeight ? (Parent.GridCellSize.Height - this.ItemHeight) : 0);
|
||||
{
|
||||
if (Parent.GridCellSize.Height > this.ItemHeight)
|
||||
{
|
||||
this.Top = (int)(this.Top / Parent.GridCellSize.Height) * Parent.GridCellSize.Height + Parent.GridMargin + (Parent.GridCellSize.Height - this.ItemHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace Util.DiagramDesigner
|
||||
protected override void Init()
|
||||
{
|
||||
ShowRotate = false;
|
||||
ShowArrow = false;
|
||||
AddInputCommand = new SimpleCommand(para => ExecuteAddInput(para));
|
||||
AddOutputCommand = new SimpleCommand(para => ExecuteAddOutput(para));
|
||||
|
||||
@@ -217,7 +218,7 @@ namespace Util.DiagramDesigner
|
||||
Input.Add(Input.Count, connector);
|
||||
for (int i = 0; i < Input.Values.Count; i++)
|
||||
{
|
||||
Input[i].YRatio = (i + 1.0) / (Input.Values.Count + 1.0) - connector.ConnectorHeight / 2 / connector.DataItem.ItemHeight;
|
||||
Input[i].YRatio = (i + 1.0) / (Input.Values.Count + 1.0);
|
||||
}
|
||||
AddConnector(connector);
|
||||
}
|
||||
@@ -229,7 +230,7 @@ namespace Util.DiagramDesigner
|
||||
Output.Add(Output.Count, connector);
|
||||
for (int i = 0; i < Output.Values.Count; i++)
|
||||
{
|
||||
Output[i].YRatio = (i + 1.0) / (Output.Values.Count + 1.0) - connector.ConnectorHeight / 2 / connector.DataItem.ItemHeight;
|
||||
Output[i].YRatio = (i + 1.0) / (Output.Values.Count + 1.0);
|
||||
}
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Util.DiagramDesigner
|
||||
|
||||
protected virtual void Init()
|
||||
{
|
||||
ColorViewModel = CopyHelper.Mapper(_service.ColorViewModel);
|
||||
FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(_service.FontViewModel);
|
||||
ColorViewModel = _service.CopyDefaultColorViewModel();
|
||||
FontViewModel = _service.CopyDefaultFontViewModel();
|
||||
|
||||
LockObjectViewModel = new LockObjectViewModel();
|
||||
SelectItemCommand = new SimpleCommand(ExecuteSelectItemCommand);
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Util.DiagramDesigner
|
||||
UpdateConnectionPointsByLine();
|
||||
return;
|
||||
}
|
||||
if (Parent.DiagramType == DiagramType.FlowChart)
|
||||
if (Parent.DiagramType == DiagramType.FlowChart || Parent.DiagramType == DiagramType.SFC)
|
||||
{
|
||||
UpdateConnectionPointsByFlowChart();
|
||||
}
|
||||
@@ -379,6 +379,11 @@ namespace Util.DiagramDesigner
|
||||
this.SinkConnectorInfo = sinkConnectorInfo;
|
||||
PathFinder = new OrthogonalPathFinder();
|
||||
DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
|
||||
|
||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||
{
|
||||
this.ColorViewModel.RightArrowPathStyle = ArrowPathStyle.None;
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleCommand DeleteConnectionCommand { get; set; }
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace Util.DiagramDesigner
|
||||
var attr = property.GetCustomAttributes(typeof(CanDoAttribute), true);
|
||||
if (attr != null && attr.Length != 0)
|
||||
{
|
||||
DoCommandManager.DoNewCommand(sender.ToString(), () => Do(sender, e.PropertyName, valuePropertyChangedEventArgs.NewValue), () => UnDo(sender, e.PropertyName, valuePropertyChangedEventArgs.OldValue), null, false);
|
||||
DoCommandManager.DoNewCommand(sender.ToString() + e.PropertyName, () => Do(sender, e.PropertyName, valuePropertyChangedEventArgs.NewValue), () => UnDo(sender, e.PropertyName, valuePropertyChangedEventArgs.OldValue), null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,12 +704,12 @@ namespace Util.DiagramDesigner
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() =>
|
||||
{
|
||||
double mid = selectedItems.Select(p => p.Top).Average();
|
||||
double mid = selectedItems.Select(p => p.Top + p.ItemHeight / 2).Average();
|
||||
|
||||
foreach (DesignerItemViewModelBase item in selectedItems)
|
||||
{
|
||||
item.SetOldValue(item.Top, nameof(item.Top), guid.ToString());
|
||||
item.Top = mid;
|
||||
item.Top = mid - item.ItemHeight / 2;
|
||||
}
|
||||
},
|
||||
() =>
|
||||
@@ -809,12 +809,12 @@ namespace Util.DiagramDesigner
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() =>
|
||||
{
|
||||
double mid = selectedItems.Select(p => p.Left).Average();
|
||||
double mid = selectedItems.Select(p => p.Left + p.ItemWidth / 2).Average();
|
||||
|
||||
foreach (DesignerItemViewModelBase item in selectedItems)
|
||||
{
|
||||
item.SetOldValue(item.Left, nameof(item.Left), guid.ToString());
|
||||
item.Left = mid;
|
||||
item.Left = mid - item.ItemWidth / 2;
|
||||
}
|
||||
},
|
||||
() =>
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Util.DiagramDesigner
|
||||
Rect GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items);
|
||||
void UpdateZIndex();
|
||||
Size PageSize { get;}
|
||||
PageSizeType PageSizeType { get; set; }
|
||||
bool ShowGrid { get; set; }
|
||||
Size GridCellSize { get; set; }
|
||||
PageSizeOrientation PageSizeOrientation { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user