Solutions Schedule WPF - Gantt style drag and drop multi resource scheduling How To ...
Implement a WPF Multi-Resource Scheduler
         
         













 
  1. Create a new VS 2010/2012 WPF Application targeting .NET Framework 4 Client Profile.
  2. Instance the dbiScheduleWPF control in the main form.

  3. Add a reference to the dbiScheduleWPFDB.dll assembly. NOTE: By default this would be in the Components directory of the installed Solutions Schedule for WPF files.

  4. In the dbiScheduleWPF tags in the XAML, set the ListTitle property of the dbiScheduleWPF instance to reflect the type of resource being scheduled and set the SnapToDivisions property to Absolute...
    example...
    <my:dbiScheduleWPF Margin="18,14,46,15" Name="dbiScheduleWPF1" ListTitle="Meeting Rooms" SnapToDivisions="Absolute" />

  5. Add the resources to be scheduled to the XAML inside the dbiScheduleWPF tags.
    example ...
       <my:dbiScheduleWPF.Items>
        <my:dbiListItem>
         <my:dbiListItem.Cells>
          <my:dbiListCell Text="Meeting Room 1"/>
        </my:dbiListItem.Cells>
       </my:dbiListItem>
       <my:dbiListItem>
        <my:dbiListItem.Cells>
         <my:dbiListCell Text="Meeting Room 2"/>
        </my:dbiListItem.Cells>
       </my:dbiListItem>
       <my:dbiListItem>
        <my:dbiListItem.Cells>
          <my:dbiListCell Text="Meeting Room 3"/>
         </my:dbiListItem.Cells>
         </my:dbiListItem>
       </my:dbiScheduleWPF.Items>

  6. Add a schedule object to the dbiScheduleWPF 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:dbiScheduleWPF.Schedules>
    <my:dbiScheduleObject Start="12/12/2012 8:00 am" End="12/12/2012 6:00 pm" RulerAlign="Over" TimeType="Hours" RulerDivisions="4" DisplayTimeLines="True" />
    </my:dbiScheduleWPF.Schedules>

  7. Add a Date Picker Control, one Button control (content = "Save"), and another Button control (content = "Load") to the main form. Set the Load button to be disabled.

  8. In the code behind create a private variable of type dbiScheduleWPFDB in the form’s class.
    example...
    [VB.NET]
    Private myScheduleXMLDB As dbiScheduleWPFDB.dbiScheduleWPFDB
    [C#]
    private dbiScheduleWPFDB.dbiScheduleWPFDB myScheduleXMLDB;

  9.  In the code behind in the New() event, create an instance of the dbiScheduleWPFDB class hooked to the dbiScheduleWPF instance in the assembly.
    example...
    [VB.NET]
    myScheduleXMLDB = New dbiScheduleWPFDB.dbiScheduleWPFDB(Me.DbiScheduleWPF1)
    [C#]
    myScheduleXMLDB = new dbiScheduleWPFDB.dbiScheduleWPFDB(dbiScheduleWPF1);

  10. Add the code to Save and Load the contents of the schedule to/from the application’s running directory. NOTE: In the Load button code, the Date Picker is set to the start date of the first schedule in the schedules collection
    NOTE: In the Save button code, the Load button is enabled if the Save is successful.
    In the click event of the button marked "Save"...

    [VB.NET]
    Dim saveError As System.Exception = myScheduleXMLDB.SaveAll2XMLDB
    If saveError Is Nothing Then
    MessageBox.Show("Schedule Saved to XML in " + myScheduleXMLDB.StorageDatabaseDirectory )
    Me.buttonLoad.IsEnabled = True
    Else
    MessageBox.Show("Schedule Save to XML Database Failed. " + saveError.Message)
    End If
    [C#]
    System.Exception saveError = myScheduleXMLDB.SaveAll2XMLDB() ;
    if (saveError == null)
    {
    MessageBox.Show("Schedule Saved to XML in " + myScheduleXMLDB.StorageDatabaseDirectory);
    this.buttonLoad.IsEnabled = true;
    }
    else
    {
    MessageBox.Show("Schedule Save to XML Database Failed. " + saveError.Message);
    }

  11. In the Click() event of the button marked "Load"...
    [VB.NET]
    Dim loadError As System.Exception = myScheduleXMLDB.LoadAllFromXMLDB
    If loadError Is Nothing Then
    Me. datePicker1.SelectedDate = Me.DbiScheduleWPF1.Schedules(0).Start.Date
    Me. datePicker1.DisplayDate = Me.DbiScheduleWPF1.Schedules(0).Start.Date
    MessageBox.Show("Schedule loaded from XML in " + myScheduleXMLDB.StorageDatabaseDirectory)
    Else
    MessageBox.Show("Schedule Load from " + myScheduleXMLDB.StorageDatabaseDirectory + " failed ... " + vbCrLf + loadError.Message)
    End If

    [C#]
    System.Exception loadError;
    loadError = myScheduleXMLDB.LoadAllFromXMLDB();
    if (loadError== null)
    {
    this.datePicker1.DisplayDate = this.dbiScheduleWPF1.Schedules[0].Start.Date;
    this.datePicker1.SelectedDate = this.dbiScheduleWPF1.Schedules[0].Start.Date;
    MessageBox.Show("Schedule loaded from XML in " + myScheduleXMLDB.StorageDatabaseDirectory);
    }
    else
    {
    MessageBox.Show("Schedule Load from " + myScheduleXMLDB.StorageDatabaseDirectory + " failed ... " + Environment.NewLine + loadError.Message);
    }

  12. Add the code to sync up the calendar control with the schedule being presented in the dbiScheduleWPF control when the user clicks on a date in the date picker (DatePicker ->SelectedDateChanged).
    [VB.NET]
    Private Sub datePicker1_SelectedDateChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs)
    Me.dbiScheduleWPF1.Schedules(0).Start = Me.datePicker1.SelectedDate.Value.AddHours(8)
    Me.dbiScheduleWPF1.Schedules(0).End = Me.datePicker1.SelectedDate.Value.AddHours(18)
    End Sub

    [C#]
    private void datePicker1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
    {
    this.dbiScheduleWPF1.Schedules[0].Start = this.datePicker1.SelectedDate.Value.AddHours(8);
    this.dbiScheduleWPF1.Schedules[0].End = this.datePicker1.SelectedDate.Value.AddHours(18);
    }

  13. Add the code to set the date picker control to date of the schedule object loaded in to the dbiScheduleWPF control when the application starts using the dbiScheduleWPF->FirstDraw event...
    [VB.NET]
    Private Sub dbiScheduleWPF1_FirstDraw(sender As System.Object, e As Dbi.WpfControl.dbiSchedule.FirstDrawEventArgs)
    Me.datePicker1.SelectedDate = Me.dbiScheduleWPF1.Schedules(0).Start.Date
    End Sub

    [C#]
    private void dbiScheduleWPF1_FirstDraw(object sender, Dbi.WpfControl.dbiSchedule.FirstDrawEventArgs e)
    {
    this.datePicker1.SelectedDate = this.dbiScheduleWPF1.Schedules[0].Start.Date;
    }

  14. Run the application.

 















         
       
         
    Have a Great Programming Day!  
       
       
       
       
       
DBI Support Products Downloads  Purchase
Customers Support Request Warehouse Scheduling Framework Trial Downloads Order Page
News Releases FAQ Studio Controls for .NET Academic Licensing
Contact Us License Registration Studio Controls for COM Legacy Activations
Updates Solutions Schedule for .NET
Utilities Solutions Schedule for COM
Support Policies Staff Scheduler
Product Life Support Extractor - Text Analytics
Platform Products
Contact Us
 
   
all rights reserved  |  copyright  1996 - 2016  |  Terms of Use