Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Help on Multiple Resources/Customized Calendar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help on Multiple Resources/Customized Calendar

 Post Reply Post Reply
Author
Message
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Topic: Help on Multiple Resources/Customized Calendar
    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.

 


Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 6:00am
did you try the  BeforeEditOperation event ?
wlcabral
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 7:53am
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!

Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 8:43am
You can use the LABEL property to determine the background color of the event...
wlcabral
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 9:32am
it is not the background color of the event im after.. its the background of the cell.
Back to Top
wlcabral View Drop Down
Groupie
Groupie
Avatar

Joined: 25 April 2007
Location: Brazil
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote wlcabral Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 12:27pm
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
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 6:33pm
you are right, the BeforeDrawDayViewCell is not being fired under office2007 theme. is there a workaround?

thanks again.
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2008 at 6:12am
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.
 
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2008 at 10:20am
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.
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2008 at 10:26am
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!
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2008 at 5:16am
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.
 
 
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2008 at 6:10am
thanks dentor!

could you give me a pseudo code on how to use the RetrieveDayEvents Method on the BeforeDrawThemeObject event?
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2008 at 8:58am
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
 
 
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2008 at 12:06pm
thank you very much dentor.

your code will give me a head start on what im trying to accomplish.

again thank you!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.184 seconds.