Navigation bar
  Home Print document Start Previous page
 42 of 234 
Next page End  

Gravitybox Schedule Primer
Page 40 
1998-2004 Gravitybox Software LLC
reference is executed much faster than looping with an object’s index as in the second
example. This difference becomes more drastic as the number of items in the loop
increases.
Adding
A good place to start adding code is to manually add an
appointment. This may be accomplished in code, with the
ScheduleItems collection’s Add method. A user can add
appointments, if the AllowAdd property of the schedule has
been set to true. If false, user adds are not permitted. The
user may click the mouse’s left mouse button on the starting
time that he wishes the appointment to begin. He must then
drag the mouse the length of the appointment. The times of the schedule are displayed
in the margin of the schedule. The times are clearly marked for the user to know exactly
the position of the mouse. When the mouse button is released, an appointment is
created. This assumes that the user did make a non-zero length appointment. If the
length of his drag was zero minutes, nothing happens.
If the property AllowAddDialog is set to true, the default property box will appear. This
allows the user to modify key properties of the appointment. This dialog is not
configurable by the developer. If special functionality needs to be added to the property
box, a custom screen needs to be constructed and the default property box canceled.
Alternatively, you may use the ScheduleProperties control. This control is discussed
later and may be used to construct a customized property screen. After the user
completes the editing of properties in the default dialog, he will have two options. First
he may press the “Ok” button, at which point the modified appointment information is
saved. If the user presses the “Cancel” button on the property box, no save will be
performed.
If a property box should not be displayed at all, the AllowAddDialog should be set to
false. When the user creates an appointment, it will appear on the schedule with default
appointment values. There will be no text displayed inside of it. The user may modify
the appointment values later by double-clicking the appointment. The event sequence
will follow the order: BeforeAdd, AfterAdd. 
The BeforeAdd event is raised before the appointment is actually added to the
ScheduleItems collection. It will return as parameters the proposed appointment’s date,
room, start time, and length. In addition, there is a Boolean Cancel parameter that will
allow for the cancellation of the Add operation, if so desired. You may add code to this
event to perform whatever error checking you wish. If the AllowAddDialog property is
true, this event may also be used to cancel the dialog by setting the “Cancel” parameter
to false and displaying your own custom dialog. The event may also be used to error
check the parameters and Cancel the addition if necessary. This may be required if the
user tried to create an appointment outside of some bounds that you have set. Perhaps
you wish to cancel all appointments made on weekends.
Quick Tip
When adding many appointments,
toggle the “AutoRedraw” property to
false. This will turn off screen paints
for each object add. When you have
completed the loading, toggle this
property to true, as the screen will
not update when this property is
false. This action will speed your
loads dramatically.
http://www.purepage.com