Csharp/CSharp Tutorial/2D/Hotkey

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Draw String"s Hotkey

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Text;    //  necessary for HotkeyPrefix
public class DrawStringHotkey : Form
{
  public DrawStringHotkey()
  {
    ResizeRedraw = true;
  }
  protected override void OnPaint(PaintEventArgs e)
  {
    base.OnPaint(e);
    Graphics g = e.Graphics;
    StringFormat fmt = new StringFormat();
    fmt.Alignment = StringAlignment.Center;
    fmt.HotkeyPrefix = HotkeyPrefix.Show;
    Brush b = new SolidBrush(ForeColor);
    g.DrawString("&Do It!", Font, b, ClientSize.Width / 2, 50, fmt);
  }
  static void Main() 
  {
    Application.Run(new DrawStringHotkey());
  }
}