Create Circles on Mouse Move in Win Forms:-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int i, j;
public Form1()
{
InitializeComponent();
}
private void
Form1_Load(object sender, EventArgs e)
{
}
private void
Form1_MouseMove(object sender, MouseEventArgs e)
{
Graphics g;
g = this.CreateGraphics();
Font f = new Font("Arial",10);
if (i % 3 == 0)
{
g.FillEllipse(new SolidBrush(Color.Red),
e.X, e.Y, 50, 50);
}
else if (i % 3 == 1)
{
g.FillEllipse(new SolidBrush(Color.White),
e.X, e.Y, 50, 50);
}
else if (i % 3 == 2)
{
g.FillEllipse(new
SolidBrush(Color.Green),
e.X, e.Y, 50, 50);
}
i = i + 1;
this.Text = "Mouse
Position :-" + e.X + ","
+ e.Y;
f.Dispose();
g.Dispose();
}
private void
Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.Refresh();
}
}
}
}
No comments:
Post a Comment