VB.NET - Provide predefined creation settings in a class -


i'm writing theming class called formtheme vb.net form application. contains colour scheme information can applied @ runtime form controls. there 3 ways instantiate object:

public sub new() 

creates new theme default system colours.

public sub new(byval forecolor color, _                       byval backcolor color, _               byval bordercolor color ... ) 

creates new theme provided colours.

public sub new(byref existingtheme formtheme) 

creates new theme doing 'deep copy' of existing theme.

i provide fourth option create theme based on pre-defined settings, example:

public sub new(byval scheme colorscheme) 'usage: dim mytheme new formtheme(colorscheme.night) 

was wondering best way implement this? considered using enum , select case statement in constructor theme based on enum value, work:

enum colorscheme   day   night   city   candy   ... end enum  public sub new(byval scheme colorscheme)   select scheme     case colorscheme.day       'set colors     case colorscheme.night       'set colors     case colorscheme.city       'set colors     ...   end select end sub 

before forge ahead, there more standard or 'better' way of doing this?

looks ways of doing it.

you preload colorsccheme in dictionnary

dim colorschemelist dictionnary(of colorscheme, formtheme) 

loaded in static constructor , them new like

public sub new(byval scheme colorscheme)     new(colorschemelist(scheme)) end sub 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -