Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic VB.Net code for coloring cells and prob with darg (Read 2507 times)
bxsl
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 28
Joined: Oct 10th, 2006
VB.Net code for coloring cells and prob with darg
Jan 6th, 2007 at 11:11am
Print Post  
Do you have any VB.net code on how to color cells in a timetable? I would like to be able to set different times of the day in different colors, Also with the drag and drop demo if you have 2 or more contacts displayed and you try the drag when you drag a new item onto the control as you drag it over the contact it paints on all the contacts not just the one you hover over with the mouse
  
Back to top
WWW  
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: VB.Net code for coloring cells and prob with d
Reply #1 - Jan 8th, 2007 at 6:06am
Print Post  
The 'Zones' sample demonstrates how to use custom drawing in order to paint different cells in the timetable in different colors. You can find this sample in the 'Samples/VB.NET' sub-folder of your installation directory or download it from the following link:

https://mindfusion.org/_samples/_sample_Zones2.zip

As for the 'Drag & Drop' sample, it might require minor modifications in order to work with grouped timetables. Here is a modified version of the sample:

https://mindfusion.org/_samples/_sample_DragDrop.zip

Meppy
  
Back to top
 
IP Logged
 
bxsl
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 28
Joined: Oct 10th, 2006
Re: VB.Net code for coloring cells and prob with d
Reply #2 - Jan 8th, 2007 at 9:35am
Print Post  
Do you have any vb code for how the coloring is done in the main demo that comes with the install? I like the way in this that you can still see the time lines, in the zones demo they are gone.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: VB.Net code for coloring cells and prob with d
Reply #3 - Jan 8th, 2007 at 10:46am
Print Post  
Here is a fragment of the Calendar.Draw event handler body from the Demo application, translated in VB:

Code
Select All
If e.Element = CustomDrawElements.TimetableCell Then

    ' Draw all workig cells in a custom fashion
    If e.Date.DayOfWeek <> DayOfWeek.Saturday And _
     e.Date.DayOfWeek <> DayOfWeek.Sunday Then

	  ' Check if this cell is selected
	  Dim d As DateTime = e.Date.Add(e.StartTime)
	  Dim selected As Boolean = Calendar1.Selection.Contains(d)

	  If TimeSpan.Compare(e.StartTime, TimeSpan.FromHours(Calendar1.TimetableSettings.WorkTimeEndHour)) < 0 And _
	   TimeSpan.Compare(e.EndTime, TimeSpan.FromHours(Calendar1.TimetableSettings.WorkTimeStartHour)) > 0 Then

		Dim brush As Brush = Nothing
		If selected Then

		    brush = New HatchBrush(HatchStyle.Percent50, _
		     Color.Goldenrod, Color.Yellow)

		Else

		    brush = New HatchBrush(HatchStyle.Percent50, _
		     Color.Yellow, Color.White)

		    Dim bounds As Rectangle = e.Bounds
		    bounds.Inflate(-1, -1)

		    e.Graphics.FillRectangle(brush, bounds)

		    brush.Dispose()

		End If

	  End If

    End If

End If 



The sample demonstrates how to preserve the cell lines during custom drawing.

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