Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Apply custom theme in code (Read 2740 times)
dimmer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 21
Joined: Jun 27th, 2007
Apply custom theme in code
Feb 11th, 2008 at 12:25pm
Print Post  
Hi

I have made a few custom themes using the theme editor.  They work properly when I apply them using the following code:

Me.calendar.CustomTheme = White1

where White1 is the name of the theme based on white.dll.

I want to give users the option to set a default theme and then apply the theme based on a value returned from an sql table but I'm not sure how to proceed.  For instance, something like the following:

If dr.Read Then
Me.calendar.Theme = drUser("colourScheme")

Thanks for any help...



  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Apply custom theme in code
Reply #1 - Feb 11th, 2008 at 1:47pm
Print Post  
You can do that by saving the full type name of the theme into the database. Then, when reading the theme type, you can create a new Theme object using that type and assign it to the Calendar.CustomTheme property.

The following code illustrates this. The assembly variable identifies the assembly containing your custom themes and myThemeType is a string variable containing the full type name of the theme you want to load:

Code
Select All
calendar1.CustomTheme = CType(assembly.GetType(myThemeType).GetConstructor(Type.EmptyTypes).Invoke(Nothing), MindFusion.Scheduling.WinForms.Theme) 


You can put the appropriate checks to ensure that the theme loads successfully.

Meppy
  
Back to top
 
IP Logged
 
dimmer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 21
Joined: Jun 27th, 2007
Re: Apply custom theme in code
Reply #2 - Feb 11th, 2008 at 5:36pm
Print Post  
Hi Meppy

I think my brain isn't working right today; I'm having trouble getting this to work...

The dll I'm using is named white.dll in a namespace called BrianThemes but I'm not sure how to create a variable to identify the assembly.

Do you have any further suggestions? Thanks a lot...



  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Apply custom theme in code
Reply #3 - Feb 12th, 2008 at 6:08am
Print Post  
I am using the Assembly.LoadFile method for this purpose. You can also use the Assembly.Load and Assembly.GetAssembly depending on where your assembly is located.

Meppy
  
Back to top
 
IP Logged
 
dimmer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 21
Joined: Jun 27th, 2007
Re: Apply custom theme in code
Reply #4 - Feb 18th, 2008 at 12:25pm
Print Post  
Cool; got it using the following:

Dim a As System.Reflection.Assembly
                   a = System.Reflection.Assembly.LoadFile("\\Sbdb5\db_development\calendarTest\customT
hemes\white.dll")
                   Me.calendar.CustomTheme = CType(a.GetType(Me.White1.GetType.FullName.ToString()).GetConstructor(Type.Empty
Types).Invoke(Nothing), MindFusion.Scheduling.WinForms.Theme)

Thank you
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint