[Color=Blue]using[/Color] System;
[Color=Blue]using[/Color] System[Color=Red].[/Color]Drawing;
[Color=Blue]using[/Color] System[Color=Red].[/Color]Windows[Color=Red].[/Color]Forms;
namespace WindowsFormsApplication1
[B]{[/B]
[Color=Blue]public[/Color] [Color=Blue]partial[/Color] [Color=Blue]class[/Color] Form1 [Color=Red]:[/Color] Form
[B]{[/B]
[Color=Green]// Location and size of bulls-eye[/Color]
[Color=Blue]const[/Color] [Color=Blue]int[/Color] originX [Color=Red]=[/Color] 100;
[Color=Blue]const[/Color] [Color=Blue]int[/Color] originY [Color=Red]=[/Color] 100;
[Color=Blue]const[/Color] [Color=Blue]int[/Color] outerRadius [Color=Red]=[/Color] 10;
[Color=Blue]const[/Color] [Color=Blue]int[/Color] innerRadius [Color=Red]=[/Color] 2;
[Color=Blue]protected[/Color] [Color=Blue]override[/Color] [Color=Blue]void[/Color] OnPaint[B]([/B]PaintEventArgs e[B])[/B] [B]{[/B]
base[Color=Red].[/Color]OnPaint[B]([/B]e[B])[/B];
[Color=Green]// Draw our bulls-eye[/Color]
e[Color=Red].[/Color]Graphics[Color=Red].[/Color]DrawEllipse[B]([/B]Pens[Color=Red].[/Color]Black, [Color=Blue]new[/Color] [Color=Blue]Rectangle[/Color][B]([/B]originX [Color=Red]-[/Color] outerRadius, originY [Color=Red]-[/Color] outerRadius, outerRadius [Color=Red]*[/Color] 2, outerRadius [Color=Red]*[/Color] 2[B])[/B][B])[/B];
e[Color=Red].[/Color]Graphics[Color=Red].[/Color]FillEllipse[B]([/B]Brushes[Color=Red].[/Color]Red, [Color=Blue]new[/Color] [Color=Blue]Rectangle[/Color][B]([/B]originX [Color=Red]-[/Color] innerRadius, originY [Color=Red]-[/Color] innerRadius, innerRadius [Color=Red]*[/Color] 2, innerRadius [Color=Red]*[/Color] 2[B])[/B][B])[/B];
[B]}[/B]
[Color=Blue]protected[/Color] [Color=Blue]override[/Color] [Color=Blue]void[/Color] OnMouseMove[B]([/B]MouseEventArgs e[B])[/B] [B]{[/B]
base[Color=Red].[/Color]OnMouseMove[B]([/B]e[B])[/B];
[Color=Green]// X and Y Distance from bulls-eye[/Color]
[Color=Blue]int[/Color] dx [Color=Red]=[/Color] e[Color=Red].[/Color]X [Color=Red]-[/Color] originX;
[Color=Blue]int[/Color] dy [Color=Red]=[/Color] e[Color=Red].[/Color]Y [Color=Red]-[/Color] originY;
[Color=Green]// Distance formula: Dist = Sqrt(dX ^ 2 + dY ^ 2)[/Color]
var dist [Color=Red]=[/Color] Math[Color=Red].[/Color]Sqrt[B]([/B]dx [Color=Red]*[/Color] dx [Color=Red]+[/Color] dy [Color=Red]*[/Color] dy[B])[/B];
[Color=Green]// Show Dist[/Color]
[Color=Blue]this[/Color][Color=Red].[/Color]Text [Color=Red]=[/Color] dist[Color=Red].[/Color]ToString[B]([/B][Color=DarkRed]"0.00"[/Color][B])[/B];
[B]}[/B]
[B]}[/B]
[B]}[/B]