Help on Multiple Resources/Customized Calendar |
Post Reply |
Author | |
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
Posted: 22 February 2008 at 2:07am |
good day!
i am currently evaluating the latest version of the xtremesuite, and this will be my first time using the calendar control. i have spent the last two days reading almost all of the post here in calendar pro sections and im really happy that the control is not that hard to use at all. i just have a question how to customize the calendar control. i have two events table, the first one is the employees schedules (work time and dayoffs/breaks, both recurring) and the other one is the appointment schedules. i have attached an image to easily visualize what im trying to accomplish. basically what i wanted to do is to customized the appointments calendars so that the time blocks from the employees schedules (which is marked in red (dayoffs/breaks)) will not be available (or be marked with black) in the appointments table or will not accept any events. what is the best way of doing it? im finding it hard because the employees schedules are recurring events. any help on this is very much appreciated. thanks. |
|
wlcabral
Groupie Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |
Post Options
Thanks(0)
|
did you try the BeforeEditOperation event ?
|
|
wlcabral
|
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
thanks wlcabral!
the BeforeEditOperation event was the one needed to prevent creating new events on the calendar. My only problem now is how to paint the schedules calendars with black based on the employees schedules painted in red? the events on the employees schedule are recurring events. i think the solution lies within the BeforeDrawDayViewCell event. unfortunately i tried running the calendar sample and that event wasnt even fired so i dont know when to put codes there. and also my conditions will be based on the recurring events from employees schedule. can you give me an idea on how to accomplish this? i hope you have some time to spare. thanks! |
|
wlcabral
Groupie Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |
Post Options
Thanks(0)
|
You can use the LABEL property to determine the background color of the event...
|
|
wlcabral
|
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
it is not the background color of the event im after.. its the background of the cell.
|
|
wlcabral
Groupie Joined: 25 April 2007 Location: Brazil Status: Offline Points: 72 |
Post Options
Thanks(0)
|
You are right !
The BeforeDrawDayViewCell event must be used when you want to change the background's cell color.
The problem is : This event has no effect if your calendar has a Theme (like office 2007)...
|
|
wlcabral
|
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
you are right, the BeforeDrawDayViewCell is not being fired under office2007 theme. is there a workaround?
thanks again. |
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
When using a theme (ex: office2007), we can use BeforeDrawThemeObject event to personalize the cell drawing.
For example to change the background cell for lunch time:
Private Sub Calendar_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal DrawParams As Variant)
Dim pTheme2007 As CalendarThemeOffice2007 Set pTheme2007 = Calendar.Theme If eObjType = xtpCalendarBeforeDraw_DayViewCell Then Dim pCell As CalendarThemeDayViewCellParams Set pCell = DrawParams If Not pCell.Selected Then If TimeValue(pCell.BeginTime) >= CDate("12:00") And TimeValue(pCell.BeginTime) < CDate("14:00") And Weekday(pCell.BeginTime) <> 1 Then pTheme2007.DayView.Day.Group.Cell.WorkCell.BackgroundColor = pTheme2007.DayView.Day.Group.Cell.NonWorkCell.BackgroundColor End If End If End If End Sub
Perhaps, it could help you do the trick.
|
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
thanks for your reply dentor.
but is there a way to to personalize/customize cell drawing after the office2007 theme has been applied? i wanted to personalize the cells after i have added the resources. if its not possible, is there also a way to get the date arrays of the recurring events? maybe i can just use these date arrays to personalize the cells. i just dont know how to get the date arrays of the recurring events. |
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
i tried using your code but its not even being fired. i dont know why
edit: ok. your code worked after setting BeforeDrawThemeObjectFlags = -1 but i really wanted to customize the cells after setting the theme to office2007. i think i could make a workaround if only i could get the date arrays of the recurring events. is this even possible? thanks again! |
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
Hello,
The challenge is that you want to customize a first calendar control (Appointments), from a second table of calendar events (employee schedule).
I think that the best way is to open the Employee Schedule in a calendar control, and use RetrieveDayEvents Method to get all the events of the date concerning (all events recurring or not) and customize the second calendar control (Appointments) with the data retrieve in the first one, with BeforeDrawThemeObject event (do only one RetrieveDaysEvents read for each day).
You can also lock modifying, and creating event to not cover the red block event by testing EndTime and StartTime of the event in the EventAdded or EventChanged events.
|
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
thanks dentor!
could you give me a pseudo code on how to use the RetrieveDayEvents Method on the BeforeDrawThemeObject event? |
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
Hello,
Here some codes to explain more the method:
Calendar1 is the Employees Calendar, Calendar2 is the Appointment Calendar.
' *** Global variables to avoid to read the Employees Calendar every time cell Appointment Calendar is drawing
Dim DtT As Date, StartT As Date, EndT As Date
' *** The BeforeDrawThemeObject Event
Private Sub Calendar2_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal DrawParams As Variant)
Dim pTheme2007 As CalendarThemeOffice2007 Set pTheme2007 = Calendar2.Theme If eObjType = xtpCalendarBeforeDraw_DayViewCell Then
Dim pCell As CalendarThemeDayViewCellParams Set pCell = DrawParams If Not pCell.Selected Then If OnlyDay(DtT) <> OnlyDay(pCell.BeginTime) Then ReadBreaks pCell.BeginTime If pCell.BeginTime >= StartT And pCell.BeginTime < EndT Then pTheme2007.DayView.Day.Group.Cell.WorkCell.BackgroundColor = vbRed End If End If End If End Sub
' *** The sub to retrieve the red time block in the first calendar (red event is supposed to have a label property to 1, this can be changed of course). Only one red time block is supposed by day.
Sub ReadBreaks(Dt As Date)
Dim CollDayEv As CalendarEvents Dim Evt As CalendarEvent Dim i As Long StartT = 0
EndT = 0 DtT = Dt Set CollDayEv = Calendar1.DataProvider.RetrieveDayEvents(Dt) With CollDayEv If .Count > 0 Then For i = 0 To .Count - 1 Set Evt = .Event(i) If Evt.Label = 1 Then StartT = Evt.StartTime EndT = Evt.EndTime Exit For End If Next End If End With End Sub ' *** Just a function to get only the day from date variable.
Function OnlyDay(ByVal Dt As Date) As String
OnlyDay = Format(Dt, "dd/mm/yyyy") End Function |
|
younicke
Senior Member Joined: 11 March 2005 Status: Offline Points: 107 |
Post Options
Thanks(0)
|
thank you very much dentor.
your code will give me a head start on what im trying to accomplish. again thank you! |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |