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


C# IGraphics.DrawString方法代码示例

本文整理汇总了C#中IGraphics.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.DrawString方法的具体用法?C# IGraphics.DrawString怎么用?C# IGraphics.DrawString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphics的用法示例。


在下文中一共展示了IGraphics.DrawString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: draw

 public override void draw(IGraphics graphics)
 {
     // DEBUG: should use shapes instead of drawString and handle cut time, etc.
       FinalPoint hotspot = getScreenHotspot();
       graphics.DrawString("" + _topNumber, hotspot.x, hotspot.y + 10);
       graphics.DrawString("" + _bottomNumber, hotspot.x, hotspot.y + 20);
 }
开发者ID:svejdo1,项目名称:niffty,代码行数:7,代码来源:TimeSignature.cs

示例2: draw

 /** Draw this object
  */
 public override void draw(IGraphics graphics)
 {
     FinalPoint hotspot = getScreenHotspot();
       // The hotspot is defined as the center of the text.
       // Debug: need to properly compute the screen dimensions of the text.
       graphics.DrawString
     (_text, hotspot.x - 3 * _text.Length, hotspot.y + 4);
 }
开发者ID:svejdo1,项目名称:niffty,代码行数:10,代码来源:Lyric.cs

示例3: Draw

 public override void Draw(IGraphics graphics)
 {
     int drawX = (int)Math.Round(X);
     int drawY = (int)Math.Round(Y);
     graphics.SetColor(255, 255, 255, 255);
     for (int i = 0; i < message.Length; i++)
     {
         int targetX = drawX - message[i].Length * 8;
         int targetY = drawY - message.Length * 8 + i * 16;
         graphics.DrawString(message[i], targetX, targetY);
     }
 }
开发者ID:sinshu,项目名称:dtf,代码行数:12,代码来源:EndingMessage.cs

示例4: Render


//.........这里部分代码省略.........
                ig.FillRectangle(new HatchBrush(HatchStyle.HorizontalBrick, Color.Linen, Color.Peru), 140,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LightHorizontal, Color.Maroon, Color.Peru), 160,5,20,20);

                ig.FillRectangle(new HatchBrush(HatchStyle.Percent05, Color.CornflowerBlue, Color.LemonChiffon), 000,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent10, Color.CornflowerBlue, Color.LemonChiffon), 020,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent20, Color.CornflowerBlue, Color.LemonChiffon), 040,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent25, Color.CornflowerBlue, Color.LemonChiffon), 060,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent30, Color.CornflowerBlue, Color.LemonChiffon), 080,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent40, Color.CornflowerBlue, Color.LemonChiffon), 100,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent50, Color.CornflowerBlue, Color.LemonChiffon), 120,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent60, Color.CornflowerBlue, Color.LemonChiffon), 140,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent70, Color.CornflowerBlue, Color.LemonChiffon), 160,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent75, Color.CornflowerBlue, Color.LemonChiffon), 180,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent80, Color.CornflowerBlue, Color.LemonChiffon), 200,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent90, Color.CornflowerBlue, Color.LemonChiffon), 220,30,20,20);

            }
            else if (s == "Arcs/Pies")
            {
                //GDI does not seem to draw arcs correctly except when the ellipse is a circle.
                //These arcs demonstrate the problem.  SVGGraphics calculates arcs correctly.
                ig.DrawArc(new Pen(Color.Black, 2), 120+5*3, 120, 110*3, 110, 0, 240);
                ig.DrawArc(new Pen(Color.Black, 2), 120+10*3, 125, 100*3, 100, 0, 210);
                ig.DrawArc(new Pen(Color.Black, 2), 120+15*3, 130, 90*3, 90, 0, 180);
                ig.DrawArc(new Pen(Color.Black, 2), 120+20*3, 135, 80*3, 80, 0, 150);
                ig.DrawArc(new Pen(Color.Black, 2), 120+25*3, 140, 70*3, 70, 0, 120);
                ig.DrawArc(new Pen(Color.Black, 2), 120+30*3, 145, 60*3, 60, 0, 90);
                ig.DrawArc(new Pen(Color.Black, 2), 120+35*3, 150, 50*3, 50, 0, 60);
                ig.DrawArc(new Pen(Color.Black, 2), 120+40*3, 155, 40*3, 40, 0, 270);

                ig.DrawPie(new Pen(Color.Pink, 2), 110, 50, 100, 100, 315, 90);
                ig.DrawPie(new Pen(Color.Purple, 2), 110, 50, 100, 100, 250, -90);
                ig.DrawPie(new Pen(Color.DarkRed, 2), 115, 55, 90, 90, 180, 270);
                ig.DrawPie(new Pen(Color.Red, 2), 120, 60, 80, 80, 45, -270);

            }
            else if (s == "Text")
            {

                Font fnt1 = new Font("Helvetica", 12, FontStyle.Italic | FontStyle.Bold);
                Font fnt2 = new Font(FontFamily.GenericMonospace, 16, FontStyle.Bold);
                Font fnt3 = new Font("", 40, FontStyle.Underline);

                Rectangle rc1 = new Rectangle(30, 30, 220,20);
                StringFormat fmt1= new StringFormat();
                fmt1.Alignment = StringAlignment.Near;

                ig.DrawRectangle(new Pen(Color.Blue),  rc1);
                ig.DrawString("Text...1", fnt1, new SolidBrush(Color.DarkGreen), rc1, fmt1);

                Rectangle rc2 = new Rectangle(0,0, 120,20);
                StringFormat fmt2= new StringFormat();
                fmt2.Alignment = StringAlignment.Center;

                ig.TranslateTransform(30,160);
                ig.RotateTransform(90);

                ig.DrawRectangle(new Pen(Color.Blue),  rc2);
                ig.DrawString("Text...2", fnt2, new SolidBrush(Color.DarkGreen), rc2, fmt2);

                ig.ResetTransform();

                Rectangle rc3 = new Rectangle(30, 90, 300,30);
                StringFormat fmt3= new StringFormat();
                fmt3.Alignment = StringAlignment.Far;

                ig.DrawRectangle(new Pen(Color.Blue),  rc3);
                ig.DrawString("Text...3", fnt3, new SolidBrush(Color.DarkGreen), rc3, fmt3);

                //measurestring
                string mme = "MeasureString Is Impossible To Emulate";
                SizeF siz = ig.MeasureString(mme, fnt1);
                ig.DrawRectangle(new Pen(Color.Red), 20, 200, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1, 150);
                ig.DrawRectangle(new Pen(Color.Orange), 20, 230, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1,  new SizeF(150, 150), new StringFormat(StringFormatFlags.DirectionVertical));
                ig.DrawRectangle(new Pen(Color.Yellow), 20, 200, siz.Width, siz.Height);

            }
            else if (s == "Images")
            {

                Icon ike = new Icon(GetType(), "App.ico");
                ig.DrawIcon(ike, 10,10);
                //ig.DrawIcon(ike, new Rectangle(270, 400, 30, 40));

                Bitmap bmp = new Bitmap(GetType(), "test.bmp");
                ig.DrawImage(bmp, 100f, 150f);
                GraphicsContainer cnt = ig.BeginContainer();
                ig.RotateTransform(5);
                ig.DrawImage(bmp, 160f, 50f, 120f, 70f);
                ig.EndContainer(cnt);
                //ig.DrawImageUnscaled(bmp, 270, 450, 20, 20);

            }
            else
            {

            }
        }
开发者ID:luizcorreia,项目名称:SvgNet,代码行数:101,代码来源:Form1.cs

示例5: DrawRole

        private void DrawRole(IGraphics g, Style style, string text, Point firstPoint,
            Point secondPoint, Size capSize)
        {
            float angle = GetAngle(firstPoint, secondPoint);
            Point point = firstPoint;

            if (angle == 0) // Down
            {
                point.X -= capSize.Width / 2 + TextMargin.Width;
                point.Y += style.ShadowOffset.Height + TextMargin.Height;
                stringFormat.Alignment = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Near;
            }
            else if (angle == 90) // Left
            {
                point.X -= TextMargin.Width;
                point.Y += capSize.Width / 2 + TextMargin.Height;
                stringFormat.Alignment = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Near;
            }
            else if (angle == 180) // Up
            {
                point.X -= capSize.Width / 2 + TextMargin.Width;
                point.Y -= TextMargin.Height;
                stringFormat.Alignment = StringAlignment.Far;
                stringFormat.LineAlignment = StringAlignment.Far;
            }
            else // Right
            {
                point.X += style.ShadowOffset.Width + TextMargin.Width;
                point.Y += capSize.Width / 2 + TextMargin.Height;
                stringFormat.Alignment = StringAlignment.Near;
                stringFormat.LineAlignment = StringAlignment.Near;
            }

            textBrush.Color = style.RelationshipTextColor;
            g.DrawString(text, style.RelationshipTextFont, textBrush, point, stringFormat);
        }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:38,代码来源:Generalization.cs

示例6: DrawLevel

 private void DrawLevel(IGraphics graphics)
 {
     if (Level < 10)
     {
         graphics.SetColor(255, 255, 255, 255);
         graphics.DrawString("LEVEL", (FIELD_WIDTH - 7 * 16) / 2, (FIELD_HEIGHT - 16) / 2);
         graphics.SetColor(255, 0, 255, 0);
         graphics.DrawString(Level.ToString(), (FIELD_WIDTH - 7 * 16) / 2 + 6 * 16, (FIELD_HEIGHT - 16) / 2);
     }
     else
     {
         graphics.SetColor(255, 255, 255, 255);
         graphics.DrawString("LEVEL", (FIELD_WIDTH - 8 * 16) / 2, (FIELD_HEIGHT - 16) / 2);
         graphics.SetColor(255, 0, 255, 0);
         graphics.DrawString(Level.ToString(), (FIELD_WIDTH - 8 * 16) / 2 + 6 * 16, (FIELD_HEIGHT - 16) / 2);
     }
 }
开发者ID:sinshu,项目名称:dtf,代码行数:17,代码来源:Game.cs

示例7: DrawTenPower

        /// <summary>
        /// Render the specified <paramref name="text"/> to the specifed
        /// <see cref="Graphics"/> device.  The text, border, and fill options
        /// will be rendered as required.  This special case method will show the
        /// specified text as a power of 10, using the <see cref="Default.SuperSize"/>
        /// and <see cref="Default.SuperShift"/>.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="text">A string value containing the text to be
        /// displayed.  This can be multiple lines, separated by newline ('\n')
        /// characters</param>
        /// <param name="x">The X location to display the text, in screen
        /// coordinates, relative to the horizontal (<see cref="AlignH"/>)
        /// alignment parameter <paramref name="alignH"/></param>
        /// <param name="y">The Y location to display the text, in screen
        /// coordinates, relative to the vertical (<see cref="AlignV"/>
        /// alignment parameter <paramref name="alignV"/></param>
        /// <param name="alignH">A horizontal alignment parameter specified
        /// using the <see cref="AlignH"/> enum type</param>
        /// <param name="alignV">A vertical alignment parameter specified
        /// using the <see cref="AlignV"/> enum type</param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void DrawTenPower( IGraphics g, GraphPane pane, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			float scaleFactor )
        {
            SmoothingMode sModeSave = g.SmoothingMode;
            TextRenderingHint sHintSave = g.TextRenderingHint;
            if ( _isAntiAlias )
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            }

            // make sure the font size is properly scaled
            Remake( scaleFactor, this.Size, ref _scaledSize, ref _font );
            float scaledSuperSize = _scaledSize * Default.SuperSize;
            Remake( scaleFactor, this.Size * Default.SuperSize, ref scaledSuperSize,
                ref _superScriptFont );

            // Get the width and height of the text
            SizeF size10 = g.MeasureString( "10", _font );
            SizeF sizeText = g.MeasureString( text, _superScriptFont );
            SizeF totSize = new SizeF( size10.Width + sizeText.Width,
                                    size10.Height + sizeText.Height * Default.SuperShift );
            float charWidth = g.MeasureString( "x", _superScriptFont ).Width;

            // Save the old transform matrix for later restoration
            Matrix saveMatrix = g.Transform;

            g.Transform = SetupMatrix( g.Transform, x, y, totSize, alignH, alignV, _angle );

            // make a center justified StringFormat alignment
            // for drawing the text
            StringFormat strFormat = new StringFormat();
            strFormat.Alignment = _stringAlignment;

            // Create a rectangle representing the border around the
            // text.  Note that, while the text is drawn based on the
            // TopCenter position, the rectangle is drawn based on
            // the TopLeft position.  Therefore, move the rectangle
            // width/2 to the left to align it properly
            RectangleF rectF = new RectangleF( -totSize.Width / 2.0F, 0.0F,
                totSize.Width, totSize.Height );

            // If the background is to be filled, fill it
            _fill.Draw( g, rectF );

            // Draw the border around the text if required
            _border.Draw( g, pane, scaleFactor, rectF );

            // make a solid brush for rendering the font itself
            using ( SolidBrush brush = new SolidBrush( _fontColor ) )
            {
                // Draw the actual text.  Note that the coordinate system
                // is set up such that 0,0 is at the location where the
                // CenterTop of the text needs to be.
                g.DrawString( "10", _font, brush,
                                ( -totSize.Width + size10.Width ) / 2.0F,
                                sizeText.Height * Default.SuperShift, strFormat );
                g.DrawString( text, _superScriptFont, brush,
                                ( totSize.Width - sizeText.Width - charWidth ) / 2.0F,
                                0.0F,
                                strFormat );
            }

            // Restore the transform matrix back to original
            g.Transform = saveMatrix;
//.........这里部分代码省略.........
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:101,代码来源:FontSpec.cs

示例8: DrawLabel

		private void DrawLabel(IGraphics g, bool onScreen, Style style)
		{
			if (Relationship.Label != null)
			{
				bool horizontal;
				PointF center = GetLineCenter(out horizontal);

				textBrush.Color = style.RelationshipTextColor;
				if (horizontal)
				{
					stringFormat.Alignment = StringAlignment.Center;
					stringFormat.LineAlignment = StringAlignment.Far;
					center.Y -= TextMargin.Height;
				}
				else
				{
					stringFormat.Alignment = StringAlignment.Near;
					stringFormat.LineAlignment = StringAlignment.Center;
					center.X += TextMargin.Width;
				}
				g.DrawString(Relationship.Label, style.RelationshipTextFont,
					textBrush, center, stringFormat);
			}
		}
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:24,代码来源:Connection.cs

示例9: DrawStatus

 public void DrawStatus(IGraphics graphics)
 {
     graphics.SetColor(255, 128, 192, 255);
     graphics.DrawRectangle(480, 0, 160, 480);
     graphics.SetColor(255, 255, 255, 255);
     graphics.DrawImage(Image.Hud, FIELD_WIDTH + 16 + 2, 32 + 8 + 4, 128, 64, 2, 0);
     graphics.DrawImage(Image.Hud, FIELD_WIDTH + 16 - 2, 32 + 8 - 4, 128, 64, 1, 0);
     graphics.SetColor(255, 255, 255, 255);
     graphics.DrawString("TOP SCORE", (640 - FIELD_WIDTH - 9 * 16) / 2 + FIELD_WIDTH, 128 + 8);
     {
         string s = highScore.ToString();
         graphics.DrawString(s, (640 - FIELD_WIDTH - s.Length * 16) / 2 + FIELD_WIDTH, 160 + 8);
     }
     graphics.DrawString("SCORE", (640 - FIELD_WIDTH - 5 * 16) / 2 + FIELD_WIDTH, 208 + 8);
     {
         string s = score.ToString();
         graphics.DrawString(s, (640 - FIELD_WIDTH - s.Length * 16) / 2 + FIELD_WIDTH, 240 + 8);
     }
     graphics.DrawString("LEVEL", (640 - FIELD_WIDTH - 5 * 16) / 2 + FIELD_WIDTH, 288 + 8);
     {
         string s = Level.ToString();
         graphics.DrawString(s, (640 - FIELD_WIDTH - s.Length * 16) / 2 + FIELD_WIDTH, 320 + 8);
     }
     graphics.DrawString("LEFT", (640 - FIELD_WIDTH - 4 * 16) / 2 + FIELD_WIDTH, 368 + 8);
     {
         int drawX = (640 - FIELD_WIDTH - (left * 40 - 8)) / 2 + FIELD_WIDTH;
         for (int i = 0; i < left; i++)
         {
             graphics.DrawImage(Image.Player, drawX + i * 40, 400 + 8, 32, 32, 0, 0);
         }
     }
 }
开发者ID:sinshu,项目名称:dtf,代码行数:32,代码来源:Game.cs

示例10: DoPaint

 private static void DoPaint(IGraphics g, Label label)
 {
     Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(label.Location) , GraphUtils.ToSizeF2(label.Size) );
     g.FillRectangle(new Brush2(GraphUtils.ToColor2(label.BackColor)), rect.X, rect.Y, label.Width - label.Margin.Left - label.Margin.Right,
         label.Height - label.Margin.Top - label.Margin.Bottom);
     StringFormat2 format = new StringFormat2{Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near};
     g.DrawString(label.Text, GraphUtils.ToFont2(label.Font), new Brush2(GraphUtils.ToColor2(label.ForeColor)), rect, format);
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:8,代码来源:ExportGraphics.cs

示例11: drawUIPaused

        /// <summary>
        /// Draws the user interface when GameState is paused.
        /// </summary>
        /// <param name="g">The green component.</param>
        private void drawUIPaused(IGraphics g)
        {
            //Darkens the screen
            g.DrawARGB (155, 0, 0, 0);
            //Adds text
            paint.TextSize = 100;
            g.DrawString("Resume", 400, 165, paint);
            g.DrawString ("Menu", 400, 360, paint);

            paint.TextSize = 30;
        }
开发者ID:Paludan,项目名称:BeerRun,代码行数:15,代码来源:GameScreen.cs

示例12: Draw

        public void Draw(IGraphics g)
        {
            g.BeginEntity (this);

            var now = DateTime.Now;

            var r = Math.Min (Width / 2, Height / 2);
            var center = new System.Drawing.PointF (Width / 2, Height / 2);

            //
            // Draw the face
            //
            g.SetColor (BackColor);
            g.FillOval (center.X - r, center.Y - r, 2 * r, 2 * r);
            g.SetColor (BorderColor);
            g.DrawOval (center.X - r + 4, center.Y - r + 4, 2 * r - 8, 2 * r - 8, 8);

            g.SetColor (FaceColor);
            for (var i = 0; i < 12; i++) {
                var angle = (i / 12.0) * 2 * Math.PI;
                g.DrawLine (
                    center.X + 0.75f * r * (float)Math.Cos (angle),
                    center.Y + 0.75f * r * (float)Math.Sin (angle),
                    center.X + 0.9f * r * (float)Math.Cos (angle),
                    center.Y + 0.9f * r * (float)Math.Sin (angle),
                    7);
            }
            g.SetFont (LabelFont);
            var textWidth = g.GetFontMetrics ().StringWidth ("Cross Graphics");
            g.DrawString ("Cross Graphics", center.X - textWidth / 2, center.Y + 0.25f * r);

            //
            // Draw the hour hand
            //
            g.SetColor (Colors.DarkGray);
            var h = now.Hour + now.Minute / 60.0;
            var hAngle = h > 12 ?
                ((h - 12) / 12.0 * 2 * Math.PI - Math.PI /2) :
                (h / 12.0 * 2 * Math.PI - Math.PI / 2);
            g.DrawLine (
                center.X + -0.1f * r * (float)Math.Cos (hAngle),
                center.Y + -0.1f * r * (float)Math.Sin (hAngle),
                center.X + 0.65f * r * (float)Math.Cos (hAngle),
                center.Y + 0.65f * r * (float)Math.Sin (hAngle),
                7);

            //
            // Draw the minute hand
            //
            g.SetColor (Colors.DarkGray);
            var m = now.Minute + now.Second / 60.0;
            var mAngle = (m / 60.0) * 2 * Math.PI - Math.PI / 2;
            g.DrawLine (
                center.X + -0.15f * r * (float)Math.Cos (mAngle),
                center.Y + -0.15f * r * (float)Math.Sin (mAngle),
                center.X + 0.85f * r * (float)Math.Cos (mAngle),
                center.Y + 0.85f * r * (float)Math.Sin (mAngle),
                5);

            //
            // Draw the second hand
            //
            g.SetColor (Colors.Red);
            var sAngle = (now.Second / 60.0) * 2 * Math.PI - Math.PI / 2;
            g.DrawLine (
                center.X + -0.15f * r * (float)Math.Cos (sAngle),
                center.Y + -0.15f * r * (float)Math.Sin (sAngle),
                center.X + 0.85f * r * (float)Math.Cos (sAngle),
                center.Y + 0.85f * r * (float)Math.Sin (sAngle),
                1);

            //
            // Draw the pin
            //
            g.SetColor (Colors.Black);
            g.FillOval (center.X - 5, center.Y - 5, 10, 10);
        }
开发者ID:JoeStrout,项目名称:CrossGraphics,代码行数:77,代码来源:Clock.cs

示例13: DrawGroupBox

 private void DrawGroupBox(IGraphics g)
 {
     // Get windows to draw the GroupBox
     Rectangle bounds = new Rectangle(ClientRectangle.X + Margin.Left, ClientRectangle.Y + Margin.Top + Padding.Top,
         ClientRectangle.Width - Margin.Left - Margin.Right,
         ClientRectangle.Height - Margin.Top - Margin.Bottom - Padding.Top);
     g.DrawRectangle(BackColor != SystemColors.Control ? SystemPens.Control : new Pen(Color.Black), bounds.X, bounds.Y,
         bounds.Width, bounds.Height, 5, RectangleCorners.All);
     // Text Formating positioning & Size
     int iTextPos = (bounds.X + 8) + mToggleRect.Width + 2;
     int iTextSize = (int) g.MeasureString(Text, Font).Width;
     iTextSize = iTextSize < 1 ? 1 : iTextSize;
     int iEndPos = iTextPos + iTextSize + 1;
     // Draw a line to cover the GroupBox border where the text will sit
     if (g is CGraphics){
         g.DrawLine(SystemPens.Control, iTextPos, bounds.Y, iEndPos, bounds.Y);
     }
     // Draw the GroupBox text
     using (SolidBrush drawBrush = new SolidBrush(Color.FromArgb(0, 70, 213))){
         g.DrawString(Text, Font, drawBrush, iTextPos, bounds.Y - (Font.Height*0.5f));
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:22,代码来源:CollapsibleGroupBox.cs

示例14: Draw

        public void Draw(IGraphics g)
        {
            if (Font != null) {
                g.SetFont (Font);
            }
            g.SetColor (Colors.Gray);
            var border = Frame;
            border.Y += PaddingTop;
            border.Height -= PaddingTop + PaddingBottom;

            border.Inflate (-1, -1);
            g.DrawRoundedRect (border, 5, 1);

            var inner = border;
            inner.Inflate (-2, -2);

            if (Checked) {
                g.FillRoundedRect (inner, 3);
                g.SetColor (Colors.Black);
            }

            if (!string.IsNullOrEmpty (Title)) {
                var fm = g.GetFontMetrics ();
                var sw = fm.StringWidth (Title);

                g.DrawString (Title, inner.X + (inner.Width - sw)/2, inner.Y + (inner.Height - fm.Height)/2);
            }
        }
开发者ID:Clancey,项目名称:CrossGraphics,代码行数:28,代码来源:Canvas.cs

示例15: Draw

 public void Draw(IGraphics graphics)
 {
     graphics.SetColor(128, 0, 0, 0);
     graphics.DrawRectangle(0, 0, Game.FieldWidth, Game.FieldHeight);
     if (nameEntry)
     {
         if (nameEntryEndTicks <= 30)
         {
             if (!nameEntryFinished)
             {
                 int drawX = (int)Math.Round(selectorX) - 8;
                 int drawY = (int)Math.Round(selectorY) - 8 + 8;
                 graphics.SetColor(255, 0, 255, 0);
                 graphics.DrawImage(Image.Hud, drawX, drawY, 32, 32, 1, 7);
             }
             graphics.SetColor(255, 255, 255, 255);
             graphics.DrawString("NAME ENTRY", (Game.FieldWidth - 16 * 10) / 2, 128 + 8);
             for (int row = 0; row < 4; row++)
             {
                 int drawY = 176 + row * 32;
                 for (int col = 0; col < 10; col++)
                 {
                     if (!nameEntryFinished)
                     {
                         if (row == selectedRow && col == selectedCol)
                         {
                             graphics.SetColor(255, 0, 255, 0);
                         }
                         else
                         {
                             graphics.SetColor(255, 255, 255, 255);
                         }
                     }
                     else
                     {
                         graphics.SetColor(255, 255, 255, 255);
                     }
                     int drawX = (Game.FieldWidth - (32 * 10 - 16)) / 2 + col * 32;
                     graphics.DrawCharacter(CHARACTERS[row * 10 + col], drawX, drawY + 8);
                 }
             }
             if (!nameEntryFinished)
             {
                 graphics.SetColor(255, 0, 255, 0);
                 graphics.DrawString(name, (Game.FieldWidth - name.Length * 16) / 2 - 8, 320 + 8);
                 if (ticks % 2 == 0)
                 {
                     graphics.SetColor(255, 0, 255, 0);
                     graphics.DrawImage(Image.Hud, (Game.FieldWidth - name.Length * 16) / 2 - 8 + name.Length * 16, 320 + 8, 16, 16, 3, 2);
                 }
             }
             else
             {
                 graphics.SetColor(255, 255, 255, 255);
                 graphics.DrawString(name, (Game.FieldWidth - name.Length * 16) / 2, 320 + 8);
             }
         }
         else
         {
             if (!ending)
             {
                 graphics.SetColor(255, 255, 0, 0);
                 graphics.DrawString("GAME OVER", (Game.FieldWidth - 16 * 9) / 2, (Game.FieldHeight - 16) / 2);
             }
             else
             {
                 graphics.SetColor(255, 255, 255, 255);
                 graphics.DrawString("THE END", (Game.FieldWidth - 16 * 7) / 2, (Game.FieldHeight - 16) / 2);
             }
         }
     }
     else
     {
         if (!ending)
         {
             graphics.SetColor(255, 255, 0, 0);
             graphics.DrawString("GAME OVER", (Game.FieldWidth - 16 * 9) / 2, (Game.FieldHeight - 16) / 2);
         }
         else
         {
             graphics.SetColor(255, 255, 255, 255);
             graphics.DrawString("THE END", (Game.FieldWidth - 16 * 7) / 2, (Game.FieldHeight - 16) / 2);
         }
     }
 }
开发者ID:sinshu,项目名称:dtf,代码行数:85,代码来源:GameOver.cs


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