VB.NET - Provide predefined creation settings in a class

I'm writing a theming class called FormTheme for a VB.NET form application. It contains colour scheme information that can be applied at runtime to form controls. Currently there are three ways to instantiate an object:

Public Sub New()

Creates a new theme with the default system colours.

Public Sub New(ByVal ForeColor As Color, _
                      ByVal BackColor As Color, _
              ByVal BorderColor As Color ... )

Creates a new theme with the provided colours.

Public Sub New(ByRef ExistingTheme As FormTheme)

Creates a new theme by doing a 'deep copy' of an existing theme.

I would like to provide a fourth option to create a theme based on pre-defined settings, for example:

Public Sub New(ByVal scheme As ColorScheme)
'usage: Dim myTheme As New FormTheme(ColorScheme.Night)

Was wondering what would be the best way to implement this? Considered using an Enum and a Select Case statement in the constructor to theme based on the enum value, which would certainly work:

Enum ColorScheme
End Enum

Public Sub New(ByVal scheme as ColorScheme)
  Select scheme
    Case ColorScheme.Day
      'Set colors
    Case ColorScheme.Night
      'Set colors
    Case ColorScheme.City
      'Set colors
  End Select
End Sub

Before I forge ahead, is there a more standard or 'better' way of doing this?


Looks like a good ways of doing it.

You could always preload all the colorsccheme in a dictionnary

Dim colorSchemeList As Dictionnary(Of ColorScheme, FormTheme)

Loaded in a static constructor and them your New would look something like

Public Sub New(ByVal scheme as ColorScheme)
End Sub

Need Your Help

Tracing coordinate of clicked Sprite


Lets say I want a mouse click event listener to trace (console print) the x coordinate of a sprite clicked. this is what Ive got, which is wrong.

How to get CruiseControl.NET working with Mercurial: “Source control failure (GetModifications)”

mercurial continuous-integration cruisecontrol.net

I'm trying to set up CruiseControl.NET 1.5.7256.1 for automatic builds. My project is stored in Mercurial, and I'm using the following ccnet.config: