1.
Create a new Visual Studio (2010
or later)
Silverlight Application targeting Silverlight 5.
2.
Build the application and
generate a license for the application using the Solutions
Schedule for Silverlight Product Manager Application that
generates a dbiScheduleSLLicense.dbi file in to the
project’s main folder.
NOTE: Be
sure to shut down the Product Manager Application after
generating the license file.
3.
Add the
dbiScheduleSLLicense.dbi license file to the project and set
its Build Action to Resource.
4.
Instance the dbiScheduleSL in
the main form.
5.
Add a reference to the
dbiScheduleSLDB.dll assembly.
NOTE: By
default this would be in the Components directory of the
installed Solutions Schedule for Silverlight files.
6.
In the dbiScheduleSL tags in
the XAML, set the ListTitle property of the dbiScheduleSL
instance to reflect the type of resource being scheduled and
set the SnapToDivisions property to Absolute …
example …
<my:dbiScheduleSL Margin="10,190,10,10"
Name="DbiScheduleSL1"
ListTitle="Meeting Rooms"
SnapToDivisions="Absolute"
>
7.
Add the resources to be
scheduled to the XAML inside the dbiScheduleSL tags.
example ...
<my:dbiScheduleSL.Items>
<my:dbiListItem>
<my:dbiListItem.Cells>
<my:dbiListCell Text="Meeting Room 1"/>
</my:dbiListItem.Cells>
</my:dbiListItem>
</my:dbiScheduleSL.Items>
8.
Add a schedule object to the
dbiScheduleSL instance in the XAML for the current day to
run from 8:00 am to 6:00 pm showing increments of 15 minutes
(RulerDivisions = 4)… example …
<my:dbiScheduleSL.Schedules>
<my:dbiScheduleObject Start="01/06/2012 8:00 am"
End="01/06/2012 6:00 pm" RulerAlign="Over" TimeType="Hours"
RulerDivisions="4" DisplayTimeLines="True" />
</my:dbiScheduleSL.Schedules>
9.
Add a Calendar Control, one
Button control (content = “Save”), and another Button
control (content = “Load”) to the main form.
10.
In the code behind create a
private variable of type dbiScheduleSLDB in the form’s
class.
example …
[VB.NET]
Private myScheduleXMLDB As dbiScheduleSLDB.dbiScheduleSLDB
[C#]
private dbiScheduleSLDB.dbiScheduleSLDB myScheduleXMLDB;
11.
In the code behind in the
New() event, create an instance of the dbiScheduleSLDB class
hooked to the dbiScheduleSL instance in the assembly.
example …
[VB.NET]
myScheduleXMLDB = New dbiScheduleSLDB.dbiScheduleSLDB(Me.DbiScheduleSL1)
[C#]
myScheduleXMLDB = new dbiScheduleSLDB.dbiScheduleSLDB(DbiScheduleSL1);
12.
Add the code to Save and Load
the contents of the schedule to/from Isolated Storage. NOTE:
In the Load button code, the Calendar is set to the start
date of the first schedule in the schedules collection.
In the click event of the button marked “Save” …
[VB.NET]
Dim
saveError As System.Exception =
myScheduleXMLDB.SaveAll2IsolatedStorage
If saveError Is Nothing Then
MessageBox.Show("Schedule Saved to XML in Isolated
Storage.")
Else
MessageBox.Show("Schedule Save to Isolated Storage
Failed.
" &
saveError.Message)
End If
[C#]
System.Exception saveError;
if (saveError
== null)
{
MessageBox.Show("Schedule Saved to XML in Isolated
Storage.");
}
else
{
MessageBox.Show("Schedule Save to Isolated Storage
Failed.
" +
saveError.Message);
}
In the Click() event of the button marked “Load” …
[VB.NET]
Dim
loadError As System.Exception =
myScheduleXMLDB.LoadAllFromIsolatedStorage
If loadError Is Nothing Then
Me.Calendar1.SelectedDate =
Me.DbiScheduleSL1.Schedules(0).Start.Date
Me.Calendar1.DisplayDate =
Me.DbiScheduleSL1.Schedules(0).Start.Date
MessageBox.Show("Schedule loaded from XML in Isolated
Storage.")
Else
MessageBox.Show("Schedule failed to load from
Isolated Storage ... " & loadError.Message)
End If
[C#]
System.Exception loadError;
loadError =
myScheduleIsolatedDB.LoadAllFromIsolatedStorage();
if (loadError== null)
{
this.Calendar1.DisplayDate =
this.DbiScheduleSL1.Schedules[0].Start.Date;
this.Calendar1.SelectedDate =
this.DbiScheduleSL1.Schedules[0].Start.Date;
MessageBox.Show(Schedule loaded from XML in Isolated
Storage.);
}
else
{
MessageBox.Show(loadError.Message);
}
13.
Add the code to sync up the
calendar control with the schedule being presented in the
dbiScheduleSL control when the user clicks on a date in the
calendar (Calendar->DisplayDateChanged, Calendar->SelectedDatesChanged,
DbiScheduleSL->FirstDraw Events).
[VB.NET]
Private Sub Calendar1_DisplayDateChanged(sender As
System.Object, e As
System.Windows.Controls.CalendarDateChangedEventArgs)
Handles Calendar1.DisplayDateChanged
Me.Calendar1.SelectedDate = Me.Calendar1.SelectedDates(0)
End Sub
Private
Sub Calendar1_SelectedDatesChanged(sender As System.Object,
e As System.Windows.Controls.SelectionChangedEventArgs)
Handles Calendar1.SelectedDatesChanged
Me.Calendar1.DisplayDate = Me.Calendar1.SelectedDates(0)
Me.DbiScheduleSL1.Schedules(0).Start =
Me.Calendar1.DisplayDate.AddHours(8)
Me.DbiScheduleSL1.Schedules(0).End
= Me.Calendar1.DisplayDate.AddHours(18)
End Sub
Private Sub DbiScheduleSL1_FirstDraw(sender As System.Object,
e As Dbi.SLControl.dbiSchedule.FirstDrawEventArgs) Handles
DbiScheduleSL1.FirstDraw
Me.Calendar1.SelectedDate = Me.DbiScheduleSL1.Schedules(0).Start.Date
End Sub
[C#]
private void Calendar1_DisplayDateChanged(object
sender, CalendarDateChangedEventArgs e)
{
this.Calendar1.SelectedDate =
this.Calendar1.SelectedDates[0];
}
private void Calendar1_SelectedDatesChanged(object
sender, SelectionChangedEventArgs e)
{
this.Calendar1 .DisplayDate = Me.Calendar1.SelectedDates[0];
this.DbiScheduleSL1.Schedules[0].Start =
this.Calendar1.DisplayDate.AddHours(8);
this.DbiScheduleSL1.Schedules(0).End =
this.Calendar1.DisplayDate.AddHours(18);
}
private void DbiScheduleSL1_FirstDraw(object sender,
Dbi.SLControl.dbiSchedule.FirstDrawEventArgs e)
{
this.Calendar1.SelectedDate
= this.DbiScheduleSL1.Schedules[0].Start.Date;
}
14.
Run the application.
|