mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-02 15:50:51 +08:00
Boundary画线算法,精度导致的问题修复
This commit is contained in:
@@ -102,6 +102,26 @@ namespace AIStudio.Wpf.Flowchart
|
||||
ConnectionViewModel connector10 = new ConnectionViewModel(coend.BottomConnector, end.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
|
||||
DiagramViewModel.Add(connector10);
|
||||
|
||||
TextDesignerItemViewModel despcription = new TextDesignerItemViewModel()
|
||||
{
|
||||
Name = nameof(despcription),
|
||||
Left = 260,
|
||||
Top = 60,
|
||||
ItemWidth = 300,
|
||||
ItemHeight = 150,
|
||||
Text = @"
|
||||
一个简易的OA审批流程
|
||||
1.主管审批为or审批,任意一个审批即可;
|
||||
2.分管领导为and审批,需要审批两次;
|
||||
3.财务审批为or审批,任意一个审批即可;
|
||||
4.人力审批为or审批,任意一个审批即可;
|
||||
注意:为了模拟审批,双击节点可以进行审批;请双击主管审批、分管领导、财务审批、人力审批、进行效果查看。"
|
||||
};
|
||||
despcription.FontViewModel.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
despcription.FontViewModel.VerticalAlignment = VerticalAlignment.Top;
|
||||
despcription.FontViewModel.FontColor = Colors.Blue;
|
||||
DiagramViewModel.Add(despcription);
|
||||
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,14 @@ namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
get
|
||||
{
|
||||
return SubType.ToEnum<MindType>();
|
||||
if (SubType == null)
|
||||
{
|
||||
return MindType.Mind;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SubType.ToEnum<MindType>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,8 +181,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Geometrys
|
||||
/// <param name='point2'>The second PointBase to compare</param>
|
||||
public static bool Equals(PointBase point1, PointBase point2)
|
||||
{
|
||||
return point1.X.Equals(point2.X) &&
|
||||
point1.Y.Equals(point2.Y);
|
||||
return Math.Abs(point1.X - point2.X) < 0.01f &&
|
||||
Math.Abs(point1.Y - point2.Y) < 0.01f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -53,12 +53,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
var p0 = GetFirstSegment(source, sourceOrientation, gridCellSize, gridMargin);
|
||||
var p1 = GetFirstSegment(sink, sinkOrientation, gridCellSize, gridMargin);
|
||||
|
||||
if (p0 == p1)
|
||||
if (p0.Equals(p1))
|
||||
return points;
|
||||
|
||||
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)
|
||||
if (p2.Equals(p3))
|
||||
{
|
||||
points.Add(p0);
|
||||
points.Add(p2);
|
||||
@@ -93,12 +93,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public static double GetNearestCross(double a, double b, double cellSize, double margin)
|
||||
{
|
||||
if (Math.Abs(a - b) < 0.0001 && (int)((a - margin)/ cellSize) == ((a - margin) / cellSize))
|
||||
if (Math.Abs(a - b) < 0.0001 && (int)(Math.Round((a - margin)/ cellSize, 3)) == (Math.Round((a - margin) / cellSize,3)))
|
||||
return a;
|
||||
else if (a < b)
|
||||
return Math.Ceiling((a - margin) / cellSize) * cellSize + margin;
|
||||
return Math.Ceiling(Math.Round((a - margin) / cellSize, 3)) * cellSize + margin;
|
||||
else
|
||||
return Math.Floor((a - margin) / cellSize) * cellSize + margin;
|
||||
return Math.Floor(Math.Round((a - margin) / cellSize, 3)) * cellSize + margin;
|
||||
}
|
||||
|
||||
public static PointBase SegmentMiddlePoint(PointBase p1, PointBase p2)
|
||||
|
||||
@@ -192,6 +192,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private double _itemWidth = 65;
|
||||
[CanDo]
|
||||
[Browsable(true)]
|
||||
public double ItemWidth
|
||||
{
|
||||
get
|
||||
@@ -210,6 +211,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private double _itemHeight = 65;
|
||||
[CanDo]
|
||||
[Browsable(true)]
|
||||
public double ItemHeight
|
||||
{
|
||||
get
|
||||
@@ -361,6 +363,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private double _left;
|
||||
[CanDo]
|
||||
[Browsable(true)]
|
||||
public double Left
|
||||
{
|
||||
get
|
||||
@@ -375,6 +378,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private double _top;
|
||||
[CanDo]
|
||||
[Browsable(true)]
|
||||
public double Top
|
||||
{
|
||||
get
|
||||
|
||||
@@ -125,6 +125,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.IsGroup = designerbase.IsGroup;
|
||||
this.ZIndex = designerbase.ZIndex;
|
||||
this.Text = designerbase.Text;
|
||||
this.Name = designerbase.Name;
|
||||
|
||||
ColorViewModel = CopyHelper.Mapper(designerbase.ColorItem);
|
||||
FontViewModel = CopyHelper.Mapper<FontViewModel, FontItem>(designerbase.FontItem);
|
||||
|
||||
Reference in New Issue
Block a user