diff --git a/AIStudio.Wpf.DiagramApp/Models/DiagramItem.cs b/AIStudio.Wpf.DiagramApp/Models/DiagramItem.cs
index 1b0b6d8..e72204f 100644
--- a/AIStudio.Wpf.DiagramApp/Models/DiagramItem.cs
+++ b/AIStudio.Wpf.DiagramApp/Models/DiagramItem.cs
@@ -85,7 +85,21 @@ namespace AIStudio.Wpf.DiagramApp.Models
public PageSizeType PageSizeType { get; set; }
[XmlAttribute]
- public double GridMargin { get; set; }
+ public Size GridMarginSize { get; set; }
+
+ [JsonIgnore]
+ [XmlAttribute("GridMarginSize")]
+ public string XmlGridMarginSize
+ {
+ get
+ {
+ return SerializeHelper.SerializeSize(GridMarginSize);
+ }
+ set
+ {
+ GridMarginSize = SerializeHelper.DeserializeSize(value);
+ }
+ }
[XmlIgnore]
public Color GridColor { get; set; }
diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/DiagramsViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/DiagramsViewModel.cs
index 0eb7712..fb3f2c5 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/DiagramsViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/DiagramsViewModel.cs
@@ -250,7 +250,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
viewModel.PageSizeOrientation = diagramItem.PageSizeOrientation;
viewModel.PageSize = diagramItem.PageSize;
viewModel.PageSizeType = diagramItem.PageSizeType;
- viewModel.GridMargin = diagramItem.GridMargin;
+ viewModel.GridMarginSize = diagramItem.GridMarginSize;
viewModel.GridColor = diagramItem.GridColor;
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
@@ -321,7 +321,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
diagramItem.PageSizeOrientation = viewModel.PageSizeOrientation;
diagramItem.PageSize = viewModel.PageSize;
diagramItem.PageSizeType = viewModel.PageSizeType;
- diagramItem.GridMargin = viewModel.GridMargin;
+ diagramItem.GridMarginSize = viewModel.GridMarginSize;
diagramItem.GridColor = viewModel.GridColor;
diagramItem.AddItems(DiagramViewModel.Items);
@@ -496,7 +496,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
diagramItem.PageSizeOrientation = viewModel.PageSizeOrientation;
diagramItem.PageSize = viewModel.PageSize;
diagramItem.PageSizeType = viewModel.PageSizeType;
- diagramItem.GridMargin = viewModel.GridMargin;
+ diagramItem.GridMarginSize = viewModel.GridMarginSize;
diagramItem.GridColor = viewModel.GridColor;
diagramItem.AddItems(DiagramViewModel.Items);
@@ -523,7 +523,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
viewModel.PageSizeOrientation = diagramItem.PageSizeOrientation;
viewModel.PageSize = diagramItem.PageSize;
viewModel.PageSizeType = diagramItem.PageSizeType;
- viewModel.GridMargin = diagramItem.GridMargin;
+ viewModel.GridMarginSize = diagramItem.GridMarginSize;
viewModel.GridColor = diagramItem.GridColor;
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
diff --git a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml
index 2a50018..46dccda 100644
--- a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml
+++ b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml
@@ -1518,7 +1518,13 @@
-
+
+
+
+
+
+
+
= link.SourceConnectorInfo.MiddlePosition.Y ? ConnectorOrientation.Top : ConnectorOrientation.Bottom),
_.GridCellSize,
- _.GridMargin);
+ _.GridMarginSize);
middle.Insert(0, route[0]);
middle.Add(route[1]);
@@ -46,7 +46,7 @@ namespace AIStudio.Wpf.DiagramDesigner
return middle.ToArray();
}
- private static List GetMiddlePoints(PointBase source, ConnectorOrientation sourceOrientation, PointBase sink, ConnectorOrientation sinkOrientation, SizeBase gridCellSize, double gridMargin)
+ private static List GetMiddlePoints(PointBase source, ConnectorOrientation sourceOrientation, PointBase sink, ConnectorOrientation sinkOrientation, SizeBase gridCellSize, SizeBase gridMargin)
{
var points = new List();
@@ -56,8 +56,8 @@ namespace AIStudio.Wpf.DiagramDesigner
if (p0 == p1)
return points;
- var p2 = new PointBase(GetNearestCross(p0.X, p1.X, gridCellSize.Width, gridMargin), GetNearestCross(p0.Y, p1.Y, gridCellSize.Height, gridMargin));
- var p3 = new PointBase(GetNearestCross(p1.X, p0.X, gridCellSize.Width, gridMargin), GetNearestCross(p1.Y, p0.Y, gridCellSize.Height, gridMargin));
+ var p2 = new PointBase(GetNearestCross(p0.X, p1.X, gridCellSize.Width, gridMargin.Width), GetNearestCross(p0.Y, p1.Y, gridCellSize.Height, gridMargin.Height));
+ var p3 = new PointBase(GetNearestCross(p1.X, p0.X, gridCellSize.Width, gridMargin.Width), GetNearestCross(p1.Y, p0.Y, gridCellSize.Height, gridMargin.Height));
if (p2 == p3)
{
points.Add(p0);
@@ -77,10 +77,10 @@ namespace AIStudio.Wpf.DiagramDesigner
return points;
}
- private static PointBase GetFirstSegment(PointBase point, ConnectorOrientation orientation, SizeBase cellSize, double margin)
+ private static PointBase GetFirstSegment(PointBase point, ConnectorOrientation orientation, SizeBase cellSize, SizeBase margin)
{
- double x = ((int)((point.X - margin) / cellSize.Width) + 0.5) * cellSize.Width + margin;
- double y = ((int)((point.Y - margin) / cellSize.Height) + 0.5) * cellSize.Height + margin;
+ double x = ((int)((point.X - margin.Width) / cellSize.Width) + 0.5) * cellSize.Width + margin.Width;
+ double y = ((int)((point.Y - margin.Height) / cellSize.Height) + 0.5) * cellSize.Height + margin.Height;
if (orientation == ConnectorOrientation.Top)
return new PointBase(x, y - 0.5 * cellSize.Height);
else if (orientation == ConnectorOrientation.Bottom)
diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml
index 53ae2a5..484512c 100644
--- a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml
+++ b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml
@@ -942,7 +942,7 @@
Width="{Binding PageSize.Width}"
ShowGrid="{Binding ShowGrid}"
GridCellSize="{Binding GridCellSize}"
- GridMargin="{Binding GridMargin}"
+ GridMarginSize="{Binding GridMarginSize}"
GridColor="{Binding GridColor}"
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
AllowDrop="True">
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
index 5b94250..6e10773 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
@@ -387,18 +387,18 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (Root.GridCellSize.Width > this.ItemWidth)
{
- this.Left = (int)(this.Left / Root.GridCellSize.Width) * Root.GridCellSize.Width + Root.GridMargin + (Root.GridCellSize.Width - this.ItemWidth) / 2;
+ this.Left = (int)(this.Left / Root.GridCellSize.Width) * Root.GridCellSize.Width + Root.GridMarginSize.Width + (Root.GridCellSize.Width - this.ItemWidth) / 2;
}
}
else if (Root.CellHorizontalAlignment == CellHorizontalAlignment.Left)
{
- this.Left = (int)(this.Left / Root.GridCellSize.Width) * Root.GridCellSize.Width + Root.GridMargin;
+ this.Left = (int)(this.Left / Root.GridCellSize.Width) * Root.GridCellSize.Width + Root.GridMarginSize.Width;
}
else if (Root.CellHorizontalAlignment == CellHorizontalAlignment.Right)
{
if (Root.GridCellSize.Width > this.ItemWidth)
{
- this.Left = (int)(this.Left / Root.GridCellSize.Width) * Root.GridCellSize.Width + Root.GridMargin + (Root.GridCellSize.Width - this.ItemWidth);
+ this.Left = (int)(this.Left / Root.GridCellSize.Width) * Root.GridCellSize.Width + Root.GridMarginSize.Width + (Root.GridCellSize.Width - this.ItemWidth);
}
}
@@ -406,18 +406,18 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (Root.GridCellSize.Height > this.ItemHeight)
{
- this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMargin + (Root.GridCellSize.Height - this.ItemHeight) / 2;
+ this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMarginSize.Height + (Root.GridCellSize.Height - this.ItemHeight) / 2;
}
}
else if (Root.CellVerticalAlignment == CellVerticalAlignment.Top)
{
- this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMargin;
+ this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMarginSize.Height;
}
else if (Root.CellVerticalAlignment == CellVerticalAlignment.Bottom)
{
if (Root.GridCellSize.Height > this.ItemHeight)
{
- this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMargin + (Root.GridCellSize.Height - this.ItemHeight);
+ this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMarginSize.Height + (Root.GridCellSize.Height - this.ItemHeight);
}
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs
index 4fcc117..8d11b47 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs
@@ -227,8 +227,8 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
- private double _gridMargin = 28d;
- public double GridMargin
+ private Size _gridMargin = new Size(28, 28);
+ public Size GridMarginSize
{
get
{
@@ -240,6 +240,32 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
+ public double GridMarginWidth
+ {
+ get
+ {
+ return _gridMargin.Width;
+ }
+ set
+ {
+ _gridMargin.Width = value;
+ RaisePropertyChanged(nameof(GridMarginSize));
+ }
+ }
+
+ public double GridMarginHeight
+ {
+ get
+ {
+ return _gridMargin.Height;
+ }
+ set
+ {
+ _gridMargin.Height = value;
+ RaisePropertyChanged(nameof(GridMarginSize));
+ }
+ }
+
private double _zoomValue = 1;
[Browsable(false)]
public double ZoomValue
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs
index b6d6a6a..3714968 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs
@@ -228,7 +228,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
get; set;
}
- double GridMargin
+ Size GridMarginSize
{
get; set;
}
diff --git a/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs b/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
index 678b4b4..fa5629f 100644
--- a/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
+++ b/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
@@ -35,7 +35,7 @@ namespace AIStudio.Wpf.Flowchart.Controls
_diagramViewModel.SetScreenScale();
_diagramViewModel.ShowGrid = true;
_diagramViewModel.GridCellSize = new SizeBase(125 / _diagramViewModel.ScreenScale, 125 / _diagramViewModel.ScreenScale);
- _diagramViewModel.GridMargin = 0d;
+ _diagramViewModel.GridMarginSize = new Size(0, 0);
_diagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
_diagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
_diagramViewModel.PageSizeType = PageSizeType.Custom;