Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - HOWTO: Select Same Time Period for Multiple Days
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HOWTO: Select Same Time Period for Multiple Days

 Post Reply Post Reply
Author
Message
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Topic: HOWTO: Select Same Time Period for Multiple Days
    Posted: 03 October 2006 at 11:12am
I'm having a problem figuring out how to select multiple time periods using the calendar control.
 
I can see how the user might select a time period that crosses two dates (select two dates in DatePicker, click on a time on the first date while then holding the SHIFT key down and selecting a time in the second day).
 
But, let's say a user wanted to select the period 8 AM to 11 AM for all days of one week (M - F).  I have no problem selecting M-F in DatePicker, and having the 5 days displayed in the calendar, but I can't get the 8 AM to 11 AM time frame selected for all days.
 
Is there a way to do this?
 
Thanks.
 
Dan
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2006 at 11:33am
BTW, I did figure out how to select M-F in the datepicker, select 8 AM to 11 AM for Monday (and enter description), then COPY the selected event to the other four days of the week.  But is there a quicker way to do this where you enter the description once, and have it automatically copied to the other dates (same description, same time period)?
 
I'm guessing I'll have to provide the user with a command button to do this, but if there's an easier way...
 
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2006 at 5:29pm
Hi,

Unfortunately no multi-time periods selection is not supported (no way to do this).
 
But:
 
1. See recurrence events in calendar. May be this will be useful for you.
 
2. Other way is to create a form (or a context nenu) which helps user to create such duplicated events.
 
3. Also try drag copy events (press Ctrl button and move event by mouse).
 
4. See notifications EventAdded, BeforeEditOperation, etc.
Using them you can show some dialog when new event added and ask user for other days to copy event to, or even copy it automatically for all visible days (or do some other tasks ...).
 
--
WBR,
Serge
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2006 at 5:50pm
Thanks Serge.
 
I think I will just add a button allowing the user to copy selected events to the same time period in any other currently selected days.
 
A related question:
 
I want to give users two ways of quickly selecting a time range on the calendar using a mouse, then creating an event.  The first way is for the user to select the time range, then merely start typing (I see how this is done).
 
For the second way, the user selects a time range, then merely presses their Enter key(no text associated with the event), and the event is created.  Where desired, the user can then select additional time ranges, hit enter, etc. etc.
 
I've been playing with this for awhile (in the CalendarControl_KeyDown event) and I don't see how you can it to work.  Can you give me some clues?
 
Thanks.
 
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2006 at 6:06pm
To expand on my second question a bit...
 
We have no need to point the calendar control to a database.  In our app, we are only using the control to provide users with an easy way to enter their time ("create events" in CJ-speak), then write the time info to our app's database.
 
In testing this without ever pointing the control to a database, I know I've been able to create onscreen events which we can capture by merely typing something after selecting a time range.  So, I'm hoping to also be able to do so when the user just hits the Enter key.  Does this make sense?
 
 
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2006 at 8:34am
Yes, all this does make sense. However, some theory below:

Calendar control has 2 layers:
    Data layer (events collection, and operations on it)
    Visualization layer (displaying, selecting, editing events, etc)
 
Calendar control always works with DataProvider (see corresponding interface).
DataProvider can be: memory, file (xml or binary), MS Access DB, Custom.
By default calendar creates Memory data provider.
 
You can use DataProvider to create/add/delete/change events.
 
------------

On Enter key down, get active selection start/end.
Using data provider create a new event, set its start/end times (also subject or anything) and add your event to the data provider.

I just played a little and think that Shift+Enter or Ctrl+Enter will be better than using simple Enter because Enter key ends subject editing and you override this.
 
EXAMPLE:

Private Sub CalendarControl_KeyDown(KeyCode As Integer, Shift As Integer)
 
    If KeyCode = 13 And CalendarControl.ActiveView.Selection.IsValid _
       And (Shift And vbShiftMask) <> 0 Then
   
        Dim pEvent As CalendarEvent
        Set pEvent = CalendarControl.DataProvider.CreateEvent
       
        pEvent.StartTime = CalendarControl.ActiveView.Selection.Begin
        pEvent.EndTime = CalendarControl.ActiveView.Selection.End
        pEvent.AllDayEvent = CalendarControl.ActiveView.Selection.AllDay
       
        CalendarControl.DataProvider.AddEvent pEvent
    End If
End Sub


--
WBR,
Serge
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2006 at 12:37pm
OK, so it sounds like in my situation I'm using the default data provider (memory), which is fine.
 
I think I'm going to just use the Enter key.  As mentioned earlier, users can either (1) select a time range, then start typing, or (2) just hit the Enter key to select the time range as an event.  In the latter case, the user does not want to attach any kind of description to the related time, just wants to make sure the time is recorded.   Make sense?
 
Thanks, Serge.
 
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2006 at 4:37pm
Yes, why not if this is suitable for you

--
WBR,
Serge
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2006 at 11:20am
Serge, I think I'm now seeing what you meant regarding the Enter key.
 
If the user merely selects a time period on the calendar, then clicks the Enter key, I can handle that in code.
 
If on the other hand, the user selects a time period, then types something, my code for the first scenario is creating another Event, which I don't want.
 
Is there a way to check and see if the user has written something to the selected time period?  It's kind of odd...once the user starts typing, no Event is created I guess until after the user moves off of the selected time period (or presses the Enter key, which is where my problem is).
 
Let me know if I'm not describing my problem well.
 
Thanks!
 
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2006 at 12:04pm
How about the following?
 
Dim m_EditInProgress                As Boolean
 
Private Sub CalendarControl1_BeforeEditOperation(ByVal OpParams As XtremeCalendarControl.CalendarEditOperationParameters, bCancelOperation As Boolean)
    m_EditInProgress = True
    
End Sub
 
Private Sub CalendarControl1_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim pEvent As CalendarEvent
   
    If CalendarControl1.ActiveView.GetSelectedEvents.Count = 0 Then
        If KeyCode = vbKeyReturn And    CalendarControl1.ActiveView.Selection.IsValid Then
            If Not m_EditInProgress Then
                With CalendarControl1
                    Set pEvent = .DataProvider.CreateEvent
                    pEvent.StartTime = .ActiveView.Selection.Begin
                    pEvent.EndTime = .ActiveView.Selection.End
                    pEvent.AllDayEvent = .ActiveView.Selection.AllDay
                    .DataProvider.AddEvent pEvent
                End With
            Else
                m_EditInProgress = False
            End If
        End If
    End If
End Sub
 
Private Sub CalendarControl1_SelectionChanged(ByVal SelType As XtremeCalendarControl.CalendarSelectionChanged)
    
    m_EditInProgress = False  'just to make sure...
End Sub
 
Seems to work OK...
 
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2006 at 12:07pm
Need to delete that "m_EditInProgress = False" in the KeyDown event I think.
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2006 at 4:27am
Yes, you're right.
But you have to reset m_EditInProgress when inplace event editing is finished or canceled.
 
You can do this in EventAdded, EventChanged notifications, and when ESC key is pressed (may be is some other places as well)

--
WBR,
Serge
 
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.203 seconds.