Sie sind auf Seite 1von 3

using

using
using
using
using
using

System;
System.Drawing;
System.Collections;
System.ComponentModel;
System.Windows.Forms;
System.Data;

namespace MouseCursors
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
Cursor[] acursor =
{
Cursors.AppStarting,
Cursors.Default,
Cursors.HSplit,
Cursors.NoMove2D,
Cursors.PanEast,
Cursors.PanNW,
Cursors.PanSW,
Cursors.SizeNESW,
Cursors.SizeWE,
Cursors.WaitCursor
};

Cursors.Arrow,
Cursors.Hand,
Cursors.IBeam,
Cursors.NoMoveHoriz,
Cursors.PanNE,
Cursors.PanSE,
Cursors.PanWest,
Cursors.SizeNS,
Cursors.UpArrow,

Cursors.Cross,
Cursors.Help,
Cursors.No,
Cursors.NoMoveVert,
Cursors.PanNorth,
Cursors.PanSouth,
Cursors.SizeAll,
Cursors.SizeNWSE,
Cursors.VSplit,

string[] astrCursor =
{
"AppStarting",
"Arrow",
"Cross",
"Default",
"Hand",
"Help",
"HSplit",
"IBeam",
"No",
"NoMove2D",
"NoMoveHoriz",
"NoMoveVert",
"PanEast",
"PanNE",
"PanNorth",
"PanNW",
"PanSE",
"PanSouth",
"PanSW",
"PanWest",
"SizeAll",
"SizeNESW",
"SizeNS",
"SizeNWSE",
"SizeWE",
"UpArrow",
"VSplit",
"WaitCursor"
};
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeCompon
ent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Mouse Cursors";
this.Paint += new System.Windows.Forms.PaintEventHandler
(this.Form1_Paint);
this.MouseMove += new System.Windows.Forms.MouseEventHan
dler(this.Form1_MouseMove);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_MouseMove(object sender, System.Windows.Forms
.MouseEventArgs e)
{
int x = e.X/(ClientSize.Width/4);
int y = e.Y/(ClientSize.Height/7);
// Determine which rectangle mouse is in (column
and row)
Cursor.Current = acursor[4 * y + x]; // Set the corresp
onding cursor
}
private void Form1_Paint(object sender, System.Windows.Forms.Pai
ntEventArgs e)

{
Graphics g = e.Graphics;
Brush brush = new SolidBrush(ForeColor);
Pen pen = new Pen(ForeColor);
for (int y = 0; y < 7; y++)
for (int x = 0; x < 4; x++)
{
Rectangle rect = Rectangle.FromLTRB(
x*ClientSize.Width/4,
y*ClientSize.Height/7,
(x+1)*ClientSize.Width/4,
(y+1)*ClientSize.Height/7); //
FromLTRB -- Left, Right, Top, Bottom...
// Divide client area into 7 X 4 grid of rectangles
g.DrawRectangle(pen, rect);
g.DrawString(astrCursor[4 * y + x], // D
raw cursor name inside each rectangle
Font, brush, rect);
}
}
}
}

Das könnte Ihnen auch gefallen