本文整理汇总了C#中Circuit.MapTerminal方法的典型用法代码示例。如果您正苦于以下问题:C# Circuit.MapTerminal方法的具体用法?C# Circuit.MapTerminal怎么用?C# Circuit.MapTerminal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Circuit
的用法示例。
在下文中一共展示了Circuit.MapTerminal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLayout
public static void DrawLayout(
Circuit.SymbolLayout Layout,
DrawingContext Context, Matrix Tx,
Pen Pen, FontFamily FontFamily, FontWeight FontWeight, double FontSize)
{
Context.PushGuidelineSet(Guidelines);
foreach (Circuit.SymbolLayout.Shape i in Layout.Lines)
Context.DrawLine(
Pen != null ? Pen : MapToPen(i.Edge),
T(Tx, i.x1),
T(Tx, i.x2));
foreach (Circuit.SymbolLayout.Shape i in Layout.Rectangles)
Context.DrawRectangle(
(i.Fill && Pen == null) ? MapToBrush(i.Edge) : null,
Pen != null ? Pen : MapToPen(i.Edge),
new Rect(T(Tx, i.x1), T(Tx, i.x2)));
foreach (Circuit.SymbolLayout.Shape i in Layout.Ellipses)
{
Brush brush = (i.Fill && Pen == null) ? MapToBrush(i.Edge) : null;
Pen pen = Pen != null ? Pen : MapToPen(i.Edge);
Point p1 = T(Tx, i.x1);
Point p2 = T(Tx, i.x2);
Context.DrawEllipse(
brush, pen,
new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2), (p2.X - p1.X) / 2, (p2.Y - p1.Y) / 2);
}
foreach (Circuit.SymbolLayout.Curve i in Layout.Curves)
{
IEnumerator<Circuit.Point> e = i.x.AsEnumerable().GetEnumerator();
if (!e.MoveNext())
return;
Pen pen = Pen != null ? Pen : MapToPen(i.Edge);
Point x1 = T(Tx, e.Current);
while (e.MoveNext())
{
Point x2 = T(Tx, e.Current);
Context.DrawLine(pen, x1, x2);
x1 = x2;
}
}
if (FontFamily != null)
{
// Not sure if this matrix has row or column vectors... want the y axis scaling here.
double scale = Math.Sqrt(Tx.M11 * Tx.M11 + Tx.M21 * Tx.M21);
foreach (Circuit.SymbolLayout.Text i in Layout.Texts)
{
double size;
switch (i.Size)
{
case Circuit.Size.Small: size = 0.5; break;
case Circuit.Size.Large: size = 1.5; break;
default: size = 1.0; break;
}
FormattedText text = new FormattedText(
i.String,
CultureInfo.CurrentUICulture, FlowDirection.LeftToRight,
new Typeface(FontFamily, FontStyles.Normal, FontWeight, FontStretches.Normal), FontSize * scale * size,
Brushes.Black);
Point p = T(Tx, i.x);
Vector p1 = T(Tx, new Circuit.Point(i.x.x - MapAlignment(i.HorizontalAlign), i.x.y + (1 - MapAlignment(i.VerticalAlign)))) - p;
Vector p2 = T(Tx, new Circuit.Point(i.x.x - (1 - MapAlignment(i.HorizontalAlign)), i.x.y + MapAlignment(i.VerticalAlign))) - p;
p1.X *= text.Width; p2.X *= text.Width;
p1.Y *= text.Height; p2.Y *= text.Height;
Rect rc = new Rect(
Math.Min(p.X + p1.X, p.X - p2.X),
Math.Min(p.Y + p1.Y, p.Y - p2.Y),
text.Width,
text.Height);
if (TextOutline != null)
Context.DrawRectangle(null, TextOutline, rc);
Context.DrawText(text, rc.TopLeft);
}
}
foreach (Circuit.Terminal i in Layout.Terminals)
DrawTerminal(Context, T(Tx, Layout.MapTerminal(i)), i.ConnectedTo != null);
Context.Pop();
}