Mouse Trails using Basic shapes

Obsessed with mouse trails? Try the following sample applications:
1. Line Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.DrawLine(Pens.Peru,trail.X,trail.Y,trail.X+1,trail.Y+1))                                                                                                                  
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

2. Circle Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.DrawEllipse(Pens.IndianRed,new Rectangle(trail.X,trail.Y,10,10)))                                                                                                                      
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

3. Rectangle Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.DrawRectangle(Pens.Fuchsia,new Rectangle(trail.X,trail.Y,5,5)))                                                                                                                      
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

4. Arc Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.DrawArc(Pens.Violet,new Rectangle(trail.X,trail.Y,5,5),180.0f,-180.0f))                                                                                                                 
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

5. Filled-Arc/FillPie Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.FillPie(Brushes.MidnightBlue,new Rectangle(trail.X,trail.Y,10,10),180.0f,180.0f))                                                                                                                 
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

6. Filled Circle Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.FillEllipse(Brushes.Tomato,new Rectangle(trail.X,trail.Y,10,10)))                                                                                                                 
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

7. Filled Rectangle Mouse Trail
Code:
  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let trailform = new Form(Text="Display Mouse Trail",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let gr=trailform.CreateGraphics()  
  13. trailform.Controls.Add(exitbutton)  
  14. trailform.MouseMove.Add(fun trail->gr.FillRectangle(Brushes.Indigo,new Rectangle(trail.X,trail.Y,20,20)))                                                                                                                 
  15. exitbutton.Click.Add(fun quit->trailform.Close())                                                            
  16. //executes our application  
  17. Application.Run(trailform)  
Output:

Creating a Customized Mouse Pointer

Aside from using pre-defined mouse pointers such as Cursors.Arrow and Cursors.Cross, you can also use customized mouse pointers in Visual F#. Follow these steps for a simple example:

1. Download a cursor creator software such as Axialis CursorWorkShop or Icon Craft.

2. Create a .cur file and name it “pointer.cur”.

3. Start Visual F#>Create a new Project.

4. Enter the following codes:

  1. // Learn more about F# at http://fsharp.net  
  2. //specifies the memory location of the class files  
  3. //that will be needed in our application  
  4. open System.Collections.Generic  
  5. open System  
  6. open System.Windows.Forms  
  7. open System.ComponentModel  
  8. open System.Drawing  
  9. let mouseform = new Form(Text="Cutom Mouse Pointer",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(300, 250),StartPosition=FormStartPosition.CenterScreen)  
  10. //creates our control  
  11. let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(200, 200))  
  12. let customcur=new System.Windows.Forms.Cursor("pointer.cur")  
  13. mouseform.MouseHover.Add(fun cutom->mouseform.Cursor<-customcur)   
  14. mouseform.Controls.Add(exitbutton)                                                                                                  
  15. exitbutton.Click.Add(fun quit->mouseform.Close())                                                            
  16. //executes our application  
  17. Application.Run(mouseform)  

5. Click the Open Folder>bin>debug> then copy and paste pointer.cur.

6. Run your application