Next VSLab release upcoming

by cisterni 19. January 2009 22:51

Ok, we are close to a new release of VSLab. It will contain two major changes that are very very important. The first one is, as far as I know, the first implementation of Lightweight Controls for Windows Forms, made available for programming viewlets with ease but also available to all .NET applications. Wonder why are Lightweight Controls so important? Let's start with an example in C#:

    public partial class Form1 : Form    {

        public Form1()        {


            var lc = new LightweightContainer();

            var lb = new LightweightButton();

            var rb = new RoundButton();

            var rb2 = new RoundButton();

            lc.Dock = DockStyle.Fill;

            lb.Position = new Point(0, 0);

            lb.Text = "Hello World";

            lc.BackColor = Color.AliceBlue;


            rb.Position = new Point(0, 100);

            rb.Size = new Size(50, 50);

            rb.Text = "Hello with very long text";


            rb2.Position = new Point(0, 110);

            rb2.Size = new Size(50, 50);

            rb2.Text = "Hello 2";





This is a simple code meant for creating three buttons into a canvas. The LightweightContainer class is a sort of panel capable of hosting lightweight controls (classes derived from LightweightControl). The library features a number of predefined controls such as buttons (in Vista style) and scrollbars. In the example the lb variable holds an instance of a LightweightButton. The lightweight control container is docked within the form. The other two buttons are instances of RoundButton class which is a simple example of how to write a lightweight control:

    public class RoundButton : LightweightControl    {

        public string Text = "";

         public override void OnMouseMove(MouseEventArgs e)        {


            BackColor = Color.Red;



        public override void OnClick(EventArgs e)        {


            Position = new Point(Position.X, Position.Y + 10);



         public override void OnPaint(PaintEventArgs e)        {

            var g = e.Graphics;

            using (var b = new SolidBrush(Color.FromArgb(40, BackColor)))            {

                g.FillEllipse(b, e.ClipRectangle);

                g.DrawEllipse(Pens.Black, e.ClipRectangle);

                var sf = new StringFormat();

                sf.Alignment = StringAlignment.Center;

                sf.LineAlignment = StringAlignment.Center;

                g.DrawString(Text, Font, Brushes.Black, new RectangleF(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height), sf);




 The RoundButton is written as a standard UserControl except for the fact that it inherits from LightweightControl (and that not all the features of UserControl are available). The output is shown in the following picture: 

Here is a more complete screenshot of one of our regression tests running inside VSLab:

Lightweight controls are important for viewlets because it is not possible using the standard controls, therefore having user control abstractions makes viewlet development a lot easier. One of the example is the addition of a button over the Chart and the 3D Chart viewlets as shown in this screenshot:

The other important update in this new release is the implementation of double buffering for Viewlets (the Chart viewlet sample does not flicker anymore once enabled) which has been challenging to implement because of the internals of VSLab. The overall code has been cleaned up and reviewed in order to offer a more consistent programming API.

Now we are getting back to the original ideas of featuring new viewlets for data visualization and system shell replacement. In the meantime we are using VSLab in projects involving biomedical engineers.

Currently rated 5.0 by 1 people

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

Tags: ,

General | Shell | Viewlets

Lightweight controls, VSLab and F#

by cisterni 5. January 2009 11:14

November and december have been busy months and time was short to find enough time to write about VSLab. However, things are going on and we are planning a new release of VSLab soon. The major contribution is from Giacomo Righetti, who has spent time for building a framework of lightweight controls using a former definition from me. Lightweight controls are missing from Windows Forms, and now you can have them in F# (and .NET languages). Giacomo implemented a set of predefined controls such as buttons, scrollbars, and many others so that viewlet development becomes easier. The VSLab shell project is also going on, and actually I have configured my Acer aspire one to start VSLab as a system shell :) I don't really miss Windows explorer... (ok, ok, I know I'm a little bit biased!).

Be the first to rate this post

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


Design | General

VSLab Viewlets and lightweight controls

by cisterni 10. September 2008 21:13

Back to normal work, still fixes to do for the CTP update rush, but I'm finally able to restart the work I stopped to update the code base. A major update that is available in the current release of VSLab though not entirely defined is the support for lightweight controls. The inner working of VSLab requires (have a look to the white paper discussing the implementation) the use of Windows Form instead than WPF for developing viewlets. I hope to circumvent this limitation some day, but this is the current situation. Moreover you cannot aggregate user controls when developing viewlets, again for core reasons (essentially VSLab runs in the F# interactive process and draws in toolwindows owned by the VS process). This is the reason for implementing lightweight controls for Windows Forms: this kind of controls are available on other systems such as Java AWT and offer a mean to have logical controls without having to pay for GUI window peers.

The ViewletControls project contains the panel responsible for implementing the lightweight controls abstractions, still under definiton and debugging. The Viewlet class already inherits from this container nonetheless. We are defining basic controls to ease the implementation of viewlets, though we believe that drawing should remain the core of viewlet development since the composition is obtained through the toolwindows in Visual Studio and dialogs can be opened directly from F# without having to fill the viewlet area with controls.

Another feature recently introduced for viewlets is the Windows caret support. It is now possible to display the Windows caret at (x, y) to have input directly in the viewlet toolwindow without having to resort to textboxes.

I love this part, reimplement controls is always a good opportunity to remember the good old days.

The lightweight controls also will include a timer to express animations easily using yield expressions (continuations) using a single timer. The library has been designed after another library designed for Web applications and recalls features available in the WPF framework. Future posts will discuss with examples the usage and the implementation of this library.


Currently rated 5.0 by 2 people

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

Tags: , ,

Design | General

Powered by BlogEngine.NET
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.


Recent comments

Comment RSS


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

© Copyright 2008