RadiantQ WPF Gantt
Resource Specific Calendars
Previous Topic  Next Topic 

Resources with custom schedules


Your resource objects could contain information about their custom schedules that can be bound to the gantt. This information could be in any format, but should eventually be converted to a WorkTimeSchedule instance.


a)

There are some built-in utilities that can convert a string representation of this custom schedule (in a predefined format) into a WorkTimeSchedule instance.


So, for example, if your resources are defined as follows:


this.ganttControl.ResourceItemsSource = new List<ResourceInfo>

            {

               new ResourceInfo() { ResourceID = 1, ResourceName = "Resource 1" },

               // The schedule string used here follows a predefined format defined in the GanttControl.ResourceScheduleBinding property's class reference.

               new ResourceInfo() { ResourceID = 2, ResourceName = "Resource 2", CustomScheduleString = "MON 8:00:00 16:00:00; TUE 8:00:00 16:00:00; WED 8:00:00 16:00:00; THU 8:00:00 16:00:00;" }

            };


Then you can setup this binding in the GanttControl:


<Grid.Resources>

            <gantt:StringToWorkTimeScheduleConverter x:Key="stringToWorkTimeScheduleConverter"/>

</Grid.Resources>


<gantt:GanttControl ResourceScheduleBinding="{Binding CustomScheduleString, Converter={StaticResource stringToWorkTimeScheduleConverter}}"

       ..................

                           ></gantt:GanttControl>


The gantt will then use this custom schedule for the resources.


b)

Alternatively if you have a property that exposes a WorkTimeSchedule instance, that can be directly bound to the gantt as follows:


new ResourceInfo() { ResourceID = 2, ResourceName = "Resource 2", CustomSchedule = new WorkTimeSchedule("Custom Schedule", MainWindow.CustomScheduleForRes2) }


// In your MainWindow:

        public static TimePeriodCollection CustomScheduleForRes2(DateTime date)

        {

            // You can choose to take into account holidays here.


            // For better performance cache the intervals for dates instead of creating a new collection every time.

            if ((date.DayOfWeek != DayOfWeek.Saturday) && (date.DayOfWeek != DayOfWeek.Sunday) && (date.DayOfWeek != DayOfWeek.Friday))

            {

                TimePeriodCollection intervals = new TimePeriodCollection();

                intervals.Add(new TimePeriod(date.AddHours(8.0), TimeSpan.FromHours(8)));

                return intervals;

            }

            else

            {

                return null;

            }

        }


<gantt:GanttControl ResourceScheduleBinding="{Binding CustomSchedule}"

       ..................

                           ></gantt:GanttControl>


This is illustrated in the ProjectGantt\Misc\SkeletonWithResource sample.




� RadiantQ 2009 - 2019. All Rights Reserved.