【C#】【Form】簡易付箋紙を作成する

■ コントロール構成

【1】Form

 * FormBorderStyle = None (Formの枠が消える。×ボタンもなくなる)
 * Opacity = 70% (透明度)
 * TopMost = True (一番上になる)

【2】Textbox

 * Dock = Fill (Formいっぱいに配置する)
 * Multiline = True

【3】colorDialog

 * デフォルト

■ サンプル

public partial class Form1 : Form
{
    private int mouseX;
    private int mouseY;

    public Form1()
    {
        InitializeComponent();
    }

    private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        switch (e.KeyCode)
        {
            case Keys.Escape:
                this.Close();
                break;
            default:
                break;
        }
    }

    private void textBox1_MouseDown(object sender, MouseEventArgs e)
    {
        switch (e.Button)
        {
            case MouseButtons.Left:
                this.mouseX = e.X;
                this.mouseY = e.Y;
                break;
            default:
                break;
        }
    }

    private void textBox1_MouseMove(object sender, MouseEventArgs e)
    {
        switch (e.Button)
        {
            case MouseButtons.Left:
                this.Left += e.X - this.mouseX;
                this.Top += e.Y - this.mouseY;
                break;
            default:
                break;
        }
    }

    private void textBox1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        this.colorDialog1.ShowDialog();
        this.textBox1.BackColor = this.colorDialog1.Color;
    }
}