當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。