Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom draw with locations (Read 1271 times)
linusmason
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Oct 15th, 2007
Custom draw with locations
Oct 15th, 2007 at 2:23pm
Print Post  
Hi

I can use the custom draw for a calendar in timeline mode to paint the back colour correctly. In vb.net, how do I make this happen separately for each location, as currently it paints all locations the same.

I have the custom draw property set to timetablecell.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Custom draw with locations
Reply #1 - Oct 16th, 2007 at 5:07am
Print Post  
The following code illustrates how to custom-draw cells in the Timetable view with individual colors. The sample draws each cell with a shade of the gray color according to its start time relative to the beginning of the day.

Code
Select All
Private Sub Calendar_Draw(ByVal sender As System.Object, _
	ByVal e As CustomDrawArgs) Handles Calendar.Draw

	' Get the start time of the cell expressed in minutes
	' relative to the beginning of the containing day
	Dim minutes As Double = e.StartTime.TotalMinutes

	' Calculate a color value according to the cell time
	Dim colorChannel As Integer = _
		255 - Math.Min(255, CType(minutes / 1440 * 255, Integer))
	Dim color As Color = color.FromArgb( _
		colorChannel, colorChannel, colorChannel)

	' Create the brush with the calculated color
	Dim brush As Brush = New SolidBrush(color)

	' Paint the cell
	Dim rect As Rectangle = e.Bounds
	rect.Inflate(-1, -1)
	e.Graphics.FillRectangle(brush, rect)

	' Dispose the brush
	brush.Dispose()

End Sub 


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