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


C# Graphics.DrawString方法代码示例

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


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

示例1: DrawInput

 private void DrawInput(Graphics g)
 {
     var point = GetPoint();
     g.FillEllipse(Brushes.Chartreuse, point.X, point.Y, 10, 10);
     g.DrawString(string.Format("Frequency: {0,7:####0.0}hz", _frequency), _font, Brushes.BlueViolet, 5f, 5f);
     g.DrawString(string.Format("Volume: {0:0.00}", _volume), _font, Brushes.BlueViolet, 5f, 20f);
 }
开发者ID:nathanchere,项目名称:nFMOD,代码行数:7,代码来源:OscillatorInput.cs

示例2: RepertoryImage

        public static void RepertoryImage(Graphics drawDestination)
        {
            StringFormat itemStringFormat = new StringFormat();
            RectangleF itemBox = new RectangleF(10, 30, 42, 10);
            RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
            itemStringFormat.Alignment = StringAlignment.Center;
            itemStringFormat.LineAlignment = StringAlignment.Far;
            drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
            if (mMscStyle == MscStyle.SDL){
                PointF[] capPolygon = new PointF[3];
                capPolygon[0] = new PointF(61, 40);
                capPolygon[1] = new PointF(53, 44);
                capPolygon[2] = new PointF(53, 36);
                drawDestination.FillPolygon(Brushes.Black,capPolygon);
                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
            }
            else if(mMscStyle == MscStyle.UML2){

                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,43);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,37);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));

            }
            itemStringFormat.Dispose();
        }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:31,代码来源:LostMessageExtension.cs

示例3: Draw

        public void Draw(Graphics g, bool enable)
        {
            Image back = PicLoader.Read("System", "ItemGrid.JPG");
            g.DrawImage(back, x+3, y+3, 32, 32);
            back.Dispose();

            if (itemPos >= 0)
            {
                Font font = new Font("Aril", 11*1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
                if (enable)
                {
                    g.DrawImage(HItemBook.GetHItemImage(UserProfile.InfoBag.Items[itemPos].Type), x + 3, y + 3, 32, 32);
                }
                else
                {
                    Rectangle ret = new Rectangle(x + 3, y + 3, 32, 32);
                    g.DrawImage(HItemBook.GetHItemImage(UserProfile.InfoBag.Items[itemPos].Type), ret, 0, 0, 64, 64, GraphicsUnit.Pixel, HSImageAttributes.ToGray);
                }

                g.DrawString(UserProfile.InfoBag.Items[itemPos].Value.ToString(), font, Brushes.Black, x + 4, y + 4);
                g.DrawString(UserProfile.InfoBag.Items[itemPos].Value.ToString(), font, Brushes.White, x + 3, y + 3);

                if (percent>1)
                {
                    Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black));
                    g.FillRectangle(brush, x, y, 35, 35*percent/100);
                    brush.Dispose();
                }

                font.Dispose();
            }
        }
开发者ID:narlon,项目名称:TOMClassic,代码行数:32,代码来源:MiniItemViewItem.cs

示例4: RepertoryImage

 public static void RepertoryImage(Graphics drawDestination, ItemPos position)
 {
     StringFormat itemStringFormat = new StringFormat();
     if (position == ItemPos.Left){
         drawDestination.DrawLine(Pens.DarkGray,70,10,70,70);
         RectangleF itemBox = new RectangleF(15, 12, 60, 14);
         itemStringFormat.Alignment = StringAlignment.Near;
         itemStringFormat.LineAlignment = StringAlignment.Near;
         drawDestination.DrawLine(Pens.Black,15,30,70,30);
         drawDestination.DrawLine(Pens.Black,11,26,19,34);
         drawDestination.DrawLine(Pens.Black,11,34,19,26);
         drawDestination.DrawString("StopTimer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     }
     else if (position == ItemPos.Right){
         drawDestination.DrawLine(Pens.DarkGray,10,10,10,70);
         RectangleF itemBox = new RectangleF(11, 12, 60, 14);
         itemStringFormat.Alignment = StringAlignment.Near;
         itemStringFormat.LineAlignment = StringAlignment.Near;
         drawDestination.DrawLine(Pens.Black,10,30,65,30);
         drawDestination.DrawLine(Pens.Black,61,26,69,34);
         drawDestination.DrawLine(Pens.Black,61,34,69,26);
         drawDestination.DrawString("StopTimer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     }
     itemStringFormat.Dispose();
 }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:25,代码来源:StopTimerExtension.cs

示例5: Draw

        public override void Draw(Graphics g, int target)
        {
            Image head = PicLoader.Read("NPC", string.Format("{0}.PNG", Figue));
            int ty = Y + 50;
            int ty2 = ty;
            if (target == Id)
            {
                g.DrawImage(head, X - 5, ty - 5, Width*5/4, Width * 5 / 4);
                ty2 -= 2;
            }
            else
            {
                g.DrawImage(head, X, ty, Width, Width);
            }

            head.Dispose();

            Font font = new Font("΢ÈíÑźÚ", 12*1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
            g.DrawString(Name, font, Brushes.Black, X + 3, Y + Height + 30);
            g.DrawString(Name, font, Brushes.White, X, Y + Height + 27);
            font.Dispose();

            if (taskFinishs.Count > 0)
            {
                Image img = PicLoader.Read("System", "MarkTaskEnd.PNG");
                g.DrawImage(img, X + 15, ty2 - 35, 21, 30);
                img.Dispose();
            }
            else if (taskAvails.Count > 0)
            {
                Image img = PicLoader.Read("System", "MarkTaskBegin.PNG");
                g.DrawImage(img, X + 15, ty2 - 35, 24, 30);
                img.Dispose();
            }
        }
开发者ID:narlon,项目名称:TOMClassic,代码行数:35,代码来源:SceneNPC.cs

示例6: Draw

        public override void Draw(Graphics g)
        {
            System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
             rect.Offset(Offset.X, Offset.Y);

             using(GraphicsPath objGP = new GraphicsPath())
             {
            objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
            objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);

            objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
            objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
            objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
            objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
            objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner

            objGP.CloseFigure();

            g.FillPath(Fill, objGP);
            g.DrawPath(Stroke, objGP);
             }

            #if !PocketPC
             g.DrawString(Marker.ToolTipText, Font, Brushes.Navy, rect, Format);
            #else
             g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
            #endif
        }
开发者ID:ravcio,项目名称:MapNet,代码行数:31,代码来源:GMapBaloonToolTip.cs

示例7: DrawRect

        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            Graphics g = new Graphics();

            g.Clear(Color.White);

            int width = 30;
            int height = 128;
            int y = 10;
            // Create opaque color maps with alpha = 255:
            ColorMap cm = new ColorMap();
            Font aFont = new Font("Arial", 20, FontStyle.Bold);
            g.DrawString("OPAQUE COLOR", aFont, Brushes.Black, 10, 60);
            DrawColorBar(g, 10, y, width, height, cm, "Spring");
            DrawColorBar(g, 10 + 40, y, width, height, cm, "Summer");
            DrawColorBar(g, 10 + 2 * 40, y, width, height, cm, "Autumn");
            DrawColorBar(g, 10 + 3 * 40, y, width, height, cm, "Winter");
            DrawColorBar(g, 10 + 4 * 40, y, width, height, cm, "Jet");
            DrawColorBar(g, 10 + 5 * 40, y, width, height, cm, "Gray");
            DrawColorBar(g, 10 + 6 * 40, y, width, height, cm, "Hot");
            DrawColorBar(g, 10 + 7 * 40, y, width, height, cm, "Cool");

            y = y + 150;
            // Create transparent color maps with alpha = 150:
            ColorMap cm1 = new ColorMap(64, 150);
            g.DrawString("TRANSPARENT COLOR", aFont, Brushes.Black, 10, 210);
            DrawColorBar(g, 10, y, width, height, cm1, "Spring");
            DrawColorBar(g, 10 + 40, y, width, height, cm1, "Summer");
            DrawColorBar(g, 10 + 2 * 40, y, width, height, cm1, "Autumn");
            DrawColorBar(g, 10 + 3 * 40, y, width, height, cm1, "Winter");
            DrawColorBar(g, 10 + 4 * 40, y, width, height, cm1, "Jet");
            DrawColorBar(g, 10 + 5 * 40, y, width, height, cm1, "Gray");
            DrawColorBar(g, 10 + 6 * 40, y, width, height, cm1, "Hot");
            DrawColorBar(g, 10 + 7 * 40, y, width, height, cm1, "Cool");
        }
开发者ID:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:35,代码来源:DrawingView.cs

示例8: PaintValue

 /// <summary>
 /// Implement the display of the value's representation.</summary>
 /// <param name="g">The Graphics object</param>
 /// <param name="area">Rectangle delimiting area to paint</param>
 public override void PaintValue(Graphics g, Rectangle area)
 {
     if (ReadOnly)
         g.DrawString(Value, Theme.Font, Theme.ReadonlyBrush, area.Left + Theme.Padding.Left, area.Top); 
     else
         g.DrawString(Value, Theme.Font, Theme.TextBrush, area.Left + Theme.Padding.Left, area.Top); 
 }
开发者ID:sbambach,项目名称:ATF,代码行数:11,代码来源:StringDataEditor.cs

示例9: Draw

        public override void Draw(Graphics g, Pen p)
        {
            base.Draw(g, p);

            var r = this.RectangleF;

            var sText = g.MeasureString(this.ColouredPlace.ColorSetName, new Font("Arial", 8));
            g.FillRectangle(Brushes.Gray, r.Right, r.Top - sText.Height, sText.Width, sText.Height);

            g.DrawString(
                this.ColouredPlace.ColorSetName,
                new Font("Arial", 8),
                Brushes.Blue,
                r.Right,
                r.Top - sText.Height
            );

            var tokensString = this.ColouredPlace.Tokens.ToString();
            var f = new Font("", 7);
            sText = g.MeasureString(tokensString, f);

            g.FillRectangle(Brushes.Green, r.Right, r.Bottom, sText.Width, sText.Height);
            g.DrawString(
                tokensString,
                new Font("", 7),
                Brushes.Black,
                r.Right,
                r.Bottom
            );
        }
开发者ID:THROYAN,项目名称:PetriNetEditor,代码行数:30,代码来源:ColouredPlaceWrapper.cs

示例10: ShowInformation

        internal void ShowInformation(Graphics graphics)
        {
            Rectangle rectOutline = new Rectangle((int)(_gameState.TotalWindowArea.Width/2-_gameState.GameArea.Width/2+2),
                                                  (int)(_gameState.TotalWindowArea.Height/2 + _gameState.GameArea.Height/2 - _gameState.GameArea.Height/3),
                                                  150,
                                                  40);
            graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rectOutline);

            Rectangle rectBackground = new Rectangle(rectOutline.X + 1, rectOutline.Y + 1,
                                                     rectOutline.Width - 1, rectOutline.Height - 1);
            graphics.FillRectangle(new SolidBrush(Color.Gray), rectBackground);

            //Spell Name
            if (this.hidden != true)
            {
                graphics.DrawString(spellName, new Font("Arial", 8, FontStyle.Bold), new SolidBrush(Color.BlanchedAlmond),
                                   rectBackground.X, rectBackground.Y + 5);
            }
            else
                graphics.DrawString("???", new Font("Arial", 8, FontStyle.Bold), new SolidBrush(Color.BlanchedAlmond),
                                   rectBackground.X, rectBackground.Y + 5);
            //Spell Cost
            graphics.DrawString(Spell.GetManaCost().ToString(), new Font("Arial", 8), new SolidBrush(Color.BlanchedAlmond),
                                rectBackground.X, rectBackground.Y + 20);
        }
开发者ID:brianmego,项目名称:Personal-Projects,代码行数:25,代码来源:SpellButton.cs

示例11: Draw

        // Draw is fired with each paint event of the main form
        public void Draw(Graphics graphics, int frame, bool gameOver)
        {
            graphics.FillRectangle(Brushes.Black, formArea);

            stars.Draw(graphics);
            foreach (Invader invader in invaders)
                invader.Draw(graphics, frame);
            playerShip.Draw(graphics);
            foreach (Shot shot in playerShots)
                shot.Draw(graphics);
            foreach (Shot shot in invaderShots)
                shot.Draw(graphics);

            graphics.DrawString(("Score: " + score.ToString()),
                statsFont, Brushes.Yellow, scoreLocation);
            graphics.DrawString(("Lives: " + livesLeft.ToString()),
                statsFont, Brushes.Yellow, livesLocation);
            graphics.DrawString(("Wave: " + wave.ToString()),
                statsFont, Brushes.Yellow, waveLocation);
            if (gameOver)
            {
                graphics.DrawString("GAME OVER", messageFont, Brushes.Red,
                    (formArea.Width / 4), formArea.Height / 3);
            }
        }
开发者ID:northerner,项目名称:Lab-3---Invaders,代码行数:26,代码来源:Game.cs

示例12: RepertoryImage

 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(5, 15, 30, 15);
     RectangleF itemBox2 = new RectangleF(5, 35, 70, 15);
     itemStringFormat.Alignment = StringAlignment.Near;
     itemStringFormat.LineAlignment = StringAlignment.Near;
     PointF[] statePolygon = new PointF[5];
     statePolygon[0] = new PointF(5,15);
     statePolygon[1] = new PointF(40,15);
     statePolygon[2] = new PointF(40,25);
     statePolygon[3] = new PointF(35,30);
     statePolygon[4] = new PointF(5,30);
     drawDestination.FillPolygon(Brushes.White,statePolygon);
     drawDestination.DrawPolygon(Pens.LightGray,statePolygon);
     drawDestination.DrawRectangle(Pens.LightGray,5,15,70,50);
     drawDestination.DrawString("frag",new Font("Arial",8,FontStyle.Regular),Brushes.LightGray,itemBox,itemStringFormat);
     Pen rPen = new Pen(Color.Black);
     float[] pattern = {4f,4f};
     rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
     rPen.DashPattern = pattern;
     itemStringFormat.Alignment = StringAlignment.Center;
     drawDestination.DrawString("separator",new Font("Arial",8,FontStyle.Italic),Brushes.Black,itemBox2,itemStringFormat);
     drawDestination.DrawLine(rPen, 5, 50, 75, 50);
     rPen.Dispose();
     itemStringFormat.Dispose();
 }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:27,代码来源:InLineSeperatorExtension.cs

示例13: FillRectangleWithNumeric

 public static void FillRectangleWithNumeric(Graphics g, int x, int y ,int w, int h, string text, string upperText)
 {
     g.FillRectangle(ComputingHelper.getRandomBrush(), x, y ,w, h);
     g.DrawRectangle(Pens.Black, x, y, w, h);
     g.DrawString(text, SystemFonts.DefaultFont, Brushes.Black, x + w / 2, y + h / 2);
     g.DrawString(upperText, SystemFonts.DefaultFont, Brushes.Black, x, y );
 }
开发者ID:swstwix,项目名称:AlgoVisualization,代码行数:7,代码来源:ComputingHelper.cs

示例14: DrawNeuron

        private static void DrawNeuron(this Network network, Neuron neuron, Graphics graphic)
        {
            Pen pen = new Pen(Color.Black);
            Point point = Translate(network, neuron);
            Size size = new Size(10, 10);
            Rectangle r = new Rectangle(point, size);

            Color color = Blend(Color.Gray, Color.Red, (neuron.Signal - 0.5));

            Brush brush = new SolidBrush(color);
            graphic.FillEllipse(brush, r);
            graphic.DrawEllipse(pen, r);

            // Draw signal text
            Font font = new Font(FontFamily.GenericSerif, 8);
            Brush fontbrush = new SolidBrush(Color.DarkBlue);
            point = point.Shift(0, 10);

            graphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
            graphic.DrawString(neuron.Signal.ToString("f2"), font, fontbrush, point);

            // Draw Error:
            point = point.Shift(0, 10);
            fontbrush = new SolidBrush(Color.Red);
            graphic.DrawString(neuron.ErrorGradient.ToString("f2"), font, fontbrush, point);
        }
开发者ID:nagyistoce,项目名称:VisualNeuralNetwork,代码行数:26,代码来源:NetworkImaging.cs

示例15: DrawBarcodeText

        private void DrawBarcodeText(ref Graphics g, string messagetext, int textlength, SolidBrush ForeBrush, int sfheight, bool texttostretch, int textalignment)
        {
            string s = "";
            messagetext = messagetext.Trim();
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            if (texttostretch)
            {
                for (int i = 0; i < messagetext.Length; i++)
                {
                    s = "" + messagetext[i];
                    Rectangle layoutRectangle = new Rectangle(this.leftmargin + ((i * textlength) / messagetext.Length), (this.topmargin + this.barheight) + this.textmargin, textlength / messagetext.Length, 2 * sfheight);
                    g.DrawString(s, this.txtFont, ForeBrush, layoutRectangle, format);
                }
            }
            else
            {
                Rectangle rectangle2 = new Rectangle(this.leftmargin, (this.topmargin + this.barheight) + this.textmargin, textlength, 2 * sfheight);
                switch (textalignment)
                {
                    case 0:
                        format.Alignment = StringAlignment.Near;
                        g.DrawString(messagetext, this.txtFont, ForeBrush, rectangle2, format);
                        return;

                    case 2:
                        format.Alignment = StringAlignment.Far;
                        g.DrawString(messagetext, this.txtFont, ForeBrush, rectangle2, format);
                        return;
                }
                format.Alignment = StringAlignment.Center;
                g.DrawString(messagetext, this.txtFont, ForeBrush, rectangle2, format);
            }
        }
开发者ID:sidneylimafilho,项目名称:InfoControl,代码行数:34,代码来源:LinearImage.cs


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