当前位置: 首页>>代码示例>>C#>>正文


C# Circuit.MapTerminal方法代码示例

本文整理汇总了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();
        }
开发者ID:alexbv16,项目名称:LiveSPICE,代码行数:88,代码来源:SymbolControl.cs


注:本文中的Circuit.MapTerminal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。