コード例 #1
0
        public void Render(RenderContext context)
        {
            Point textCoord = context.GetImageCoordinate(Coordinates);

            GlyphFont glyphFont = LetterGlyphTool.GetFont(Font);

            int textHeight = glyphFont.GetTextHeight(Text);
            int textWidth  = glyphFont.GetTextWidth(Text);

            if (Direction == TextDirection.LeftToRight)
            {
                textCoord.Y -= (double)textHeight / 2.0d;
                context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, TextColor, Font, Text);
            }
            else if (Direction == TextDirection.RightToLeft)
            {
                textCoord.Y -= (double)textHeight / 2.0d;
                textCoord.X -= textWidth;
                context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, TextColor, Font, Text);
            }
            else if (Direction == TextDirection.TopToBottom)
            {
                context.Bitmap.DrawStringVertical((int)textCoord.X, (int)textCoord.Y, TextColor, Font, Text, true);
            }
            else
            {
                context.Bitmap.DrawStringVertical((int)textCoord.X, (int)textCoord.Y, TextColor, Font, Text, false);
            }
        }
コード例 #2
0
        public override void Render(RenderContext context)
        {
            base.Render(context);

            /* Draw component name*/
            GlyphFont glyphFont  = LetterGlyphTool.GetFont(AutosarApplication.GetInstance().ComponentNameFont);
            int       width      = glyphFont.GetTextWidth(Name);
            int       textHeight = glyphFont.GetTextHeight(Name);

            Point textCoord = Painter.Center;

            textCoord.Y  = Painter.Top;
            textCoord    = context.GetImageCoordinate(textCoord);
            textCoord.Y += textHeight;
            textCoord.X -= (double)width / 2.0d;
            context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, Colors.Black, AutosarApplication.GetInstance().ComponentNameFont, Name);

            String defName = "<" + this.ComponentDefenition.Name + ">";

            glyphFont = LetterGlyphTool.GetFont(AutosarApplication.GetInstance().ComponentDefinitionNameFont);
            width     = glyphFont.GetTextWidth(defName);

            textCoord    = Painter.Center;
            textCoord.Y  = Painter.Top;
            textCoord    = context.GetImageCoordinate(textCoord);
            textCoord.X -= (double)width / 2.0d;

            context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, Colors.Black, AutosarApplication.GetInstance().ComponentDefinitionNameFont, defName);
        }
コード例 #3
0
ファイル: RenderUtil.cs プロジェクト: Rai-Ka/travellermap
 public Glyph(GlyphFont font, string chars)
     : this()
 {
     Font = font;
     Characters = chars;
     Bias = GlyphBias.None;
     IsHighlighted = false;
 }
コード例 #4
0
 public Glyph(GlyphFont font, string chars)
     : this()
 {
     Font          = font;
     Characters    = chars;
     Bias          = GlyphBias.None;
     IsHighlighted = false;
 }
コード例 #5
0
        public override void Render(RenderContext context)
        {
            base.Render(context);

            PortableFontDesc typefaceFont = AutosarApplication.GetInstance().ComponentNameFont;
            /* Draw component name*/
            GlyphFont glyphFont  = LetterGlyphTool.GetFont(typefaceFont);
            int       width      = glyphFont.GetTextWidth(Name);
            int       textHeight = glyphFont.GetTextHeight(Name);

            Point textCoord = Painter.Center;

            textCoord.Y  = Painter.Top;
            textCoord    = context.GetImageCoordinate(textCoord);
            textCoord.Y += textHeight;
            textCoord.X -= (double)width / 2;
            context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, Colors.Black, AutosarApplication.GetInstance().ComponentNameFont, Name);
        }
コード例 #6
0
        public Boundary GetBoundary(RenderContext context)
        {
            Boundary boundary = new Boundary();

            Point imageCoord = context.GetImageCoordinate(Coordinates);

            if (Font == null)
            {
                return(boundary);
            }
            GlyphFont glyphFont = LetterGlyphTool.GetFont(Font);

            int textHeight = glyphFont.GetTextHeight(Text);
            int textWidth  = glyphFont.GetTextWidth(Text);

            if (Direction == TextDirection.LeftToRight)
            {
                Point topLeftImageCoord = new Point();
                topLeftImageCoord.X = imageCoord.X;
                topLeftImageCoord.Y = (double)imageCoord.Y - (double)textHeight / 2;

                Point bottomRightImageCoord = new Point();
                bottomRightImageCoord.X = (double)imageCoord.X + (double)textWidth;
                bottomRightImageCoord.Y = (double)imageCoord.Y + (double)textHeight / 2;

                Point topLeftWorldCoord     = context.GetWorldCoordinate(topLeftImageCoord);
                Point bottomRightWorldCoord = context.GetWorldCoordinate(bottomRightImageCoord);

                boundary.Left   = topLeftWorldCoord.X;
                boundary.Top    = topLeftWorldCoord.Y;
                boundary.Right  = bottomRightWorldCoord.X;
                boundary.Bottom = bottomRightWorldCoord.Y;
            }
            else if (Direction == TextDirection.RightToLeft)
            {
                Point topLeftImageCoord = new Point();
                topLeftImageCoord.X = imageCoord.X - textWidth;
                topLeftImageCoord.Y = (double)imageCoord.Y - (double)textHeight / 2;

                Point bottomRightImageCoord = new Point();
                bottomRightImageCoord.X = imageCoord.X;
                bottomRightImageCoord.Y = (double)imageCoord.Y + (double)textHeight / 2;

                Point topLeftWorldCoord     = context.GetWorldCoordinate(topLeftImageCoord);
                Point bottomRightWorldCoord = context.GetWorldCoordinate(bottomRightImageCoord);

                boundary.Left   = topLeftWorldCoord.X;
                boundary.Top    = topLeftWorldCoord.Y;
                boundary.Right  = bottomRightWorldCoord.X;
                boundary.Bottom = bottomRightWorldCoord.Y;
            }
            else if (Direction == TextDirection.TopToBottom)
            {
                Point topLeftImageCoord = new Point();
                topLeftImageCoord.X = (double)imageCoord.X - (double)textHeight / 2;
                topLeftImageCoord.Y = imageCoord.Y;

                Point bottomRightImageCoord = new Point();
                bottomRightImageCoord.X = (double)imageCoord.X + (double)textHeight / 2;
                bottomRightImageCoord.Y = imageCoord.Y + textWidth;

                Point topLeftWorldCoord     = context.GetWorldCoordinate(topLeftImageCoord);
                Point bottomRightWorldCoord = context.GetWorldCoordinate(bottomRightImageCoord);

                boundary.Left   = topLeftWorldCoord.X;
                boundary.Top    = topLeftWorldCoord.Y;
                boundary.Right  = bottomRightWorldCoord.X;
                boundary.Bottom = bottomRightWorldCoord.Y;
            }
            else
            {
                Point topLeftImageCoord = new Point();
                topLeftImageCoord.X = (double)imageCoord.X - (double)textHeight / 2;
                topLeftImageCoord.Y = imageCoord.Y - textWidth;

                Point bottomRightImageCoord = new Point();
                bottomRightImageCoord.X = (double)imageCoord.X + (double)textHeight / 2;
                bottomRightImageCoord.Y = imageCoord.Y;

                Point topLeftWorldCoord     = context.GetWorldCoordinate(topLeftImageCoord);
                Point bottomRightWorldCoord = context.GetWorldCoordinate(bottomRightImageCoord);

                boundary.Left   = topLeftWorldCoord.X;
                boundary.Top    = topLeftWorldCoord.Y;
                boundary.Right  = bottomRightWorldCoord.X;
                boundary.Bottom = bottomRightWorldCoord.Y;
            }

            return(boundary);
        }
コード例 #7
0
 public static void StringWidth(String str, GlyphFont font)
 {
 }