VSLab Regression tests and doc

by cisterni 28. September 2008 18:30

I've just added a project for regression tests in VSLab. It is also interesting because it shows very simple viewlets doing simple things and it can also be a good way to learn Viewlet development. So far there are two viewlets checking mouse move and resize events. Here is the code:

#light

open System.Drawing

open VSLab

type ShowStringViewlet() =  inherit Viewlet()

 

  [<DefaultValue>]

  val mutable displayString : string

 

  override self.OnPaint(e) =     let g = e.Graphics

    g.DrawString(self.displayString, self.Font, Brushes.Black, 0.0f, 0.0f)

 

type
MouseMotionViewlet() as x =  inherit ShowStringViewlet()

 

  do x.displayString <- "Move the mouse inside the area"

 

  override self.OnMouseMove(e) =     self.displayString <- sprintf "x: %d, y: %d" (e.X) (e.Y)

    self.Invalidate(new Rectangle(0, 0, 200, 50))

let mmv = new MouseMotionViewlet()

mmv.Show()

mmv.Close()

 

type
ResizeViewlet() as x =  inherit ShowStringViewlet()

 

  do x.displayString <- "Resize the viewlet"

 

  override x.OnSizeChanged (e) =

    x.displayString <- sprintf "Size is (%d, %d)" (x.Width) (x.Height)

let rv = new ResizeViewlet()

rv.Show()

rv.Close()

 

 I hope this can be useful.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

General | Viewlets

Powered by BlogEngine.NET 1.4.0.0
Theme by Mads Kristensen

VSLab blog

VSLab is a Visual Studio extension designed to support Visual Studio interaction from F# interactive. It is a Microsoft product developed at University of Pisa, by a team lead by Antonio Cisternino.

Resources

Recent comments

Comment RSS

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in  anyway.

© Copyright 2008