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


C# Graphics.DrawText方法代码示例

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


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

示例1: DoNoteIds

 public static void DoNoteIds(this WidgetMidiList widget, FloatRect grid, Graphics g)
 {
     var gs = g.Save();
       using (g.Clip = new Region(grid))
       {
     foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 2))))
     {
       var r2=new FloatRect(i.XO-16,grid.Top,32,24);
       g.FillEllipse(Brushes.Black,r2);
       g.DrawText((i.Index / 4).ToString(),Color.White,widget.Font,r2);
     }
     foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 3))))
     {
       var r2=new FloatRect(i.XO-16,grid.Top+32,32,24);
       g.FillEllipse(Brushes.Black,r2);
       g.DrawText((i.Index / 64).ToString(),Color.White,widget.Font,r2);
     }
     g.ResetClip();
       }
       g.Restore(gs);
 }
开发者ID:tfwio,项目名称:modest-smf-vstnet,代码行数:21,代码来源:WidgetMidiList.Painter.cs

示例2: DoVKeys

        public static void DoVKeys(this WidgetMidiList widget, FloatRect grid, Graphics g)
        {
            var gs  = g.Save();
              // Vertical
              using (var linePen = new Pen(Color.Blue, 1)) foreach (var row in widget.GetVLines(widget.LineOffset))
              {
            var r = new FloatRect(widget.Container.X + 12, row.Top, widget.WidthGutter, widget.LineHeight);

            if (row.CanDo)
            {
              // Note-Number + Piano-KeyName
              var str = string.Format("{0:00#} {1,-3}", row.RowIndex, MKeys[row.RowIndex]);

              // create rect, then move x/y and shrinks w/h by one pixel.
              var rc = new FloatRect(grid.Left, row.Top, grid.Width, widget.LineHeight).Shrink(1);

              using (var sb = new SolidBrush(Color.FromArgb(24, row.IsIvory ? Color.White : Color.Black)))
            if (row.IsIvory) g.FillRectangle(sb, rc);

              var r2 = r.Clone();
              r2.Location = r2.Location.NegX(10);
              g.DrawText(str,Color.White,widget.Font,r2,StringAlignment.Near);

            }
              }
              g.Restore(gs);
        }
开发者ID:tfwio,项目名称:modest-smf-vstnet,代码行数:27,代码来源:WidgetMidiList.Painter.cs

示例3: Draw

        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="selected"></param>
        internal virtual void Draw(Graphics g, bool selected)
        {
            if (selected)
            {
                if (selectedImage != null)
                {
                    g.DrawImage(selectedImage, rectangle, rectangle, GraphicsUnit.Pixel);
                }
                else
                {
                    if (selectedBackColor == selectedBackColor2)
                    {
                        using (var brush = new SolidBrush(selectedBackColor))
                        {
                            g.FillRectangle(brush, rectangle);
                        }
                    }
                    else
                    {
                        g.GradientFill(rectangle, selectedBackColor, selectedBackColor2, FillDirection.TopToBottom);
                    }

                    using (var pen = new Pen(selectedBorderColor))
                    {
                        g.DrawRectangle(pen, rectangle.Left, rectangle.Top, rectangle.Width - 1, rectangle.Height - 1);
                    }
                }
            }
            else
            {
                if (image != null)
                {
                    g.DrawImage(selectedImage, rectangle, rectangle, GraphicsUnit.Pixel);
                }
                else
                {
                    if (backColor == backColor2)
                    {
                        using (var brush = new SolidBrush(backColor))
                        {
                            g.FillRectangle(brush, rectangle);
                        }
                    }
                    else
                    {
                        g.GradientFill(rectangle, backColor, backColor2, FillDirection.TopToBottom);
                    }

                    using (var pen = new Pen(borderColor))
                    {
                        g.DrawRectangle(pen, rectangle.Left, rectangle.Top, rectangle.Width - 1, rectangle.Height - 1);
                    }
                }
            }

            g.DrawText(text, font ?? Parent.Font, selected ? selectedForeColor : foreColor, rectangle, ContentAlignmentEx.MiddleCenter);
        }
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:62,代码来源:SipButton.cs


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