本文整理汇总了C#中System.Drawing.PointF.Norm方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.Norm方法的具体用法?C# PointF.Norm怎么用?C# PointF.Norm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了PointF.Norm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RebuildGraph
//.........这里部分代码省略.........
}
}
}
// Let Glee calculate a layout
var layout_rnd = new Microsoft.Glee.GraphViewerGdi.GraphRenderer(layout_g);
layout_rnd.CalculateLayout();
// Extract and replicate layout
// Nodes
foreach( var kv in layout_nodes )
kv.Key.Position = this.FromGleePoint(kv.Value.Attr.Pos);
// Edges
foreach( var kv in layout_edges )
{
var edge = kv.Key;
var layout_edge = kv.Value;
var curve = layout_edge.Attr.EdgeCurve as Microsoft.Glee.Splines.Curve;
if( curve != null )
{
var segments = new List<CurveSegment>();
foreach( Microsoft.Glee.Splines.ICurve segment in curve.Segs )
{
if( segment is Microsoft.Glee.Splines.CubicBezierSeg )
{
var b = (Microsoft.Glee.Splines.CubicBezierSeg)segment;
segments.Add(new CurveSegment(new PointF[]
{
this.FromGleePoint(b.B(0)),
this.FromGleePoint(b.B(1)),
this.FromGleePoint(b.B(2)),
this.FromGleePoint(b.B(3)),
}));
}
else // Fallback to linearity, even if it is not a LineSeg.
{
segments.Add(new CurveSegment(new PointF[]
{
this.FromGleePoint(segment.Start),
this.FromGleePoint(segment.End),
}));
}
}
// Snap edge ends to nodes
var e = new PointF(
edge.StartNode.Position.X - segments[0].Points[0].X,
edge.StartNode.Position.Y - segments[0].Points[0].Y);
var diff = e.Norm().Multiply(e.Length() - this.node_radius);
edge.StartPosition = segments[0].Points[0] = segments[0].Points[0].Add(diff);
var seg = segments[segments.Count - 1];
e = new PointF(
edge.EndNode.Position.X - seg.Points[seg.Points.Length - 1].X,
edge.EndNode.Position.Y - seg.Points[seg.Points.Length - 1].Y);
diff = e.Norm().Multiply(e.Length() - this.node_radius);
edge.EndPosition = seg.Points[seg.Points.Length - 1] =
seg.Points[seg.Points.Length - 1].Add(diff);
edge.Segments = segments.ToArray();
}
else
{
// Fallback to line
edge.StartPosition = edge.StartNode.Position;
edge.EndPosition = edge.EndNode.Position;
// Snap edge ends to nodes
var e = new PointF(
edge.EndPosition.X - edge.StartPosition.X,
edge.EndPosition.Y - edge.StartPosition.Y)
.Norm().Multiply(this.node_radius);
edge.StartPosition = edge.StartPosition.Add(e);
edge.EndPosition = edge.EndPosition.Substract(e);
}
// Label
edge.LabelPosition = new PointF(
-(float)layout_edge.Attr.LabelTop,
(float)layout_edge.Attr.LabelLeft);
}
// Add an 'in-edge' to the start state node
var start_edge = new Edge();
start_edge.LinePen = this.edge_pen;
start_edge.EndNode = this.node_map[0];
start_edge.EndPosition = new PointF(
start_edge.EndNode.Position.X - this.node_radius,
start_edge.EndNode.Position.Y);
start_edge.StartPosition = new PointF(
start_edge.EndPosition.X - this.node_diameter,
start_edge.EndPosition.Y);
this.Graph.Edges.Add(start_edge);
}