diff --git a/wpf/Gantt/Auto-Update-Hierarchy_images/Auto-Update-Hierarchy_img1.png b/wpf/Gantt/Auto-Update-Hierarchy_images/Auto-Update-Hierarchy_img1.png deleted file mode 100644 index 94ffb6c192..0000000000 Binary files a/wpf/Gantt/Auto-Update-Hierarchy_images/Auto-Update-Hierarchy_img1.png and /dev/null differ diff --git a/wpf/Gantt/Auto-Update-Hierarchy_images/gantt-control-auto-updated-hierarchy.png b/wpf/Gantt/Auto-Update-Hierarchy_images/gantt-control-auto-updated-hierarchy.png new file mode 100644 index 0000000000..f7f199af36 Binary files /dev/null and b/wpf/Gantt/Auto-Update-Hierarchy_images/gantt-control-auto-updated-hierarchy.png differ diff --git a/wpf/Gantt/Baseline-Support_images/Baseline-Chart_img4.png b/wpf/Gantt/Baseline-Support_images/Baseline-Chart_img4.png deleted file mode 100644 index 3e805cea40..0000000000 Binary files a/wpf/Gantt/Baseline-Support_images/Baseline-Chart_img4.png and /dev/null differ diff --git a/wpf/Gantt/Baseline-Support_images/Baseline-Support_img1.png b/wpf/Gantt/Baseline-Support_images/Baseline-Support_img1.png deleted file mode 100644 index 3fccda2a31..0000000000 Binary files a/wpf/Gantt/Baseline-Support_images/Baseline-Support_img1.png and /dev/null differ diff --git a/wpf/Gantt/Baseline-Support_images/Baseline-Support_img2.png b/wpf/Gantt/Baseline-Support_images/Baseline-Support_img2.png deleted file mode 100644 index 8e5a667518..0000000000 Binary files a/wpf/Gantt/Baseline-Support_images/Baseline-Support_img2.png and /dev/null differ diff --git a/wpf/Gantt/Baseline-Support_images/gantt-control-add-new-column.png b/wpf/Gantt/Baseline-Support_images/gantt-control-add-new-column.png new file mode 100644 index 0000000000..4ed5f0034c Binary files /dev/null and b/wpf/Gantt/Baseline-Support_images/gantt-control-add-new-column.png differ diff --git a/wpf/Gantt/Baseline-Support_images/gantt-control-baseline-chart.png b/wpf/Gantt/Baseline-Support_images/gantt-control-baseline-chart.png new file mode 100644 index 0000000000..af9005bfed Binary files /dev/null and b/wpf/Gantt/Baseline-Support_images/gantt-control-baseline-chart.png differ diff --git a/wpf/Gantt/Baseline-Support_images/gantt-control-baseline-grid.png b/wpf/Gantt/Baseline-Support_images/gantt-control-baseline-grid.png new file mode 100644 index 0000000000..515f112b8c Binary files /dev/null and b/wpf/Gantt/Baseline-Support_images/gantt-control-baseline-grid.png differ diff --git a/wpf/Gantt/Baseline-Support_images/Baseline-Support_img3.png b/wpf/Gantt/Baseline-Support_images/gantt-control-project-statistics.png similarity index 100% rename from wpf/Gantt/Baseline-Support_images/Baseline-Support_img3.png rename to wpf/Gantt/Baseline-Support_images/gantt-control-project-statistics.png diff --git a/wpf/Gantt/Calendar-Customization_images/Calendar-Customization_img1.png b/wpf/Gantt/Calendar-Customization_images/Calendar-Customization_img1.png deleted file mode 100644 index 8942e3bd87..0000000000 Binary files a/wpf/Gantt/Calendar-Customization_images/Calendar-Customization_img1.png and /dev/null differ diff --git a/wpf/Gantt/Calendar-Customization_images/gantt-control-calendar-customization.png b/wpf/Gantt/Calendar-Customization_images/gantt-control-calendar-customization.png new file mode 100644 index 0000000000..6f6de38b52 Binary files /dev/null and b/wpf/Gantt/Calendar-Customization_images/gantt-control-calendar-customization.png differ diff --git a/wpf/Gantt/Custom-Schedule_images/Custom-Schedule_img1.png b/wpf/Gantt/Custom-Schedule_images/Custom-Schedule_img1.png deleted file mode 100644 index d03c71e2da..0000000000 Binary files a/wpf/Gantt/Custom-Schedule_images/Custom-Schedule_img1.png and /dev/null differ diff --git a/wpf/Gantt/Custom-Schedule_images/Custom-Schedule_img2.png b/wpf/Gantt/Custom-Schedule_images/Custom-Schedule_img2.png deleted file mode 100644 index 3899f57294..0000000000 Binary files a/wpf/Gantt/Custom-Schedule_images/Custom-Schedule_img2.png and /dev/null differ diff --git a/wpf/Gantt/Custom-Schedule_images/gantt-control-custom-datetime-schedule.png b/wpf/Gantt/Custom-Schedule_images/gantt-control-custom-datetime-schedule.png new file mode 100644 index 0000000000..0dbbc8fe6d Binary files /dev/null and b/wpf/Gantt/Custom-Schedule_images/gantt-control-custom-datetime-schedule.png differ diff --git a/wpf/Gantt/Custom-Schedule_images/gantt-control-custom-numeric-schedule.png b/wpf/Gantt/Custom-Schedule_images/gantt-control-custom-numeric-schedule.png new file mode 100644 index 0000000000..3a46ece2e3 Binary files /dev/null and b/wpf/Gantt/Custom-Schedule_images/gantt-control-custom-numeric-schedule.png differ diff --git a/wpf/Gantt/CustomToolTip_images/CustomToolTip_img1.png b/wpf/Gantt/CustomToolTip_images/CustomToolTip_img1.png deleted file mode 100644 index 76784ae71a..0000000000 Binary files a/wpf/Gantt/CustomToolTip_images/CustomToolTip_img1.png and /dev/null differ diff --git a/wpf/Gantt/CustomToolTip_images/gantt-control-custom-tooltip.png b/wpf/Gantt/CustomToolTip_images/gantt-control-custom-tooltip.png new file mode 100644 index 0000000000..16f075887b Binary files /dev/null and b/wpf/Gantt/CustomToolTip_images/gantt-control-custom-tooltip.png differ diff --git a/wpf/Gantt/Data-Binding_images/Data-Binding_img1.png b/wpf/Gantt/Data-Binding_images/Data-Binding_img1.png deleted file mode 100644 index 85ab3204b1..0000000000 Binary files a/wpf/Gantt/Data-Binding_images/Data-Binding_img1.png and /dev/null differ diff --git a/wpf/Gantt/Data-Binding_images/Data-Binding_img2.png b/wpf/Gantt/Data-Binding_images/Data-Binding_img2.png deleted file mode 100644 index 5bd837e62e..0000000000 Binary files a/wpf/Gantt/Data-Binding_images/Data-Binding_img2.png and /dev/null differ diff --git a/wpf/Gantt/Data-Binding_images/gantt-control-external-property-binding.png b/wpf/Gantt/Data-Binding_images/gantt-control-external-property-binding.png new file mode 100644 index 0000000000..939062976c Binary files /dev/null and b/wpf/Gantt/Data-Binding_images/gantt-control-external-property-binding.png differ diff --git a/wpf/Gantt/Data-Binding_images/gantt-control-taskdetails-binding.png b/wpf/Gantt/Data-Binding_images/gantt-control-taskdetails-binding.png new file mode 100644 index 0000000000..0a1e1640b0 Binary files /dev/null and b/wpf/Gantt/Data-Binding_images/gantt-control-taskdetails-binding.png differ diff --git a/wpf/Gantt/Dependency-Relationship_images/Dependency-Relationship_img5.png b/wpf/Gantt/Dependency-Relationship_images/Dependency-Relationship_img5.png deleted file mode 100644 index 85ab3204b1..0000000000 Binary files a/wpf/Gantt/Dependency-Relationship_images/Dependency-Relationship_img5.png and /dev/null differ diff --git a/wpf/Gantt/Dependency-Relationship_images/Dependency-Relationship_img6.png b/wpf/Gantt/Dependency-Relationship_images/Dependency-Relationship_img6.png deleted file mode 100644 index 0a9b7ee85d..0000000000 Binary files a/wpf/Gantt/Dependency-Relationship_images/Dependency-Relationship_img6.png and /dev/null differ diff --git a/wpf/Gantt/Dependency-Relationship_images/Predecessors AutoMode.png b/wpf/Gantt/Dependency-Relationship_images/Predecessors AutoMode.png deleted file mode 100644 index a0844c10fa..0000000000 Binary files a/wpf/Gantt/Dependency-Relationship_images/Predecessors AutoMode.png and /dev/null differ diff --git a/wpf/Gantt/Dependency-Relationship_images/Predecessors ManualMode.png b/wpf/Gantt/Dependency-Relationship_images/Predecessors ManualMode.png deleted file mode 100644 index 7050fb24c5..0000000000 Binary files a/wpf/Gantt/Dependency-Relationship_images/Predecessors ManualMode.png and /dev/null differ diff --git a/wpf/Gantt/Dependency-Relationship_images/gantt-control-dependency-relationship.png b/wpf/Gantt/Dependency-Relationship_images/gantt-control-dependency-relationship.png new file mode 100644 index 0000000000..d612340c76 Binary files /dev/null and b/wpf/Gantt/Dependency-Relationship_images/gantt-control-dependency-relationship.png differ diff --git a/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessor-editing.png b/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessor-editing.png new file mode 100644 index 0000000000..67a1e33b7b Binary files /dev/null and b/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessor-editing.png differ diff --git a/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessors-in-auto-mode.png b/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessors-in-auto-mode.png new file mode 100644 index 0000000000..a46ab469c1 Binary files /dev/null and b/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessors-in-auto-mode.png differ diff --git a/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessors-in-manual-mode.png b/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessors-in-manual-mode.png new file mode 100644 index 0000000000..2e9d8d8755 Binary files /dev/null and b/wpf/Gantt/Dependency-Relationship_images/gantt-control-predecessors-in-manual-mode.png differ diff --git a/wpf/Gantt/Getting-Started_images/Getting-Started_img1.png b/wpf/Gantt/Getting-Started_images/Getting-Started_img1.png deleted file mode 100644 index deeb6dd95c..0000000000 Binary files a/wpf/Gantt/Getting-Started_images/Getting-Started_img1.png and /dev/null differ diff --git a/wpf/Gantt/Getting-Started_images/Getting-Started_img2.png b/wpf/Gantt/Getting-Started_images/Getting-Started_img2.png deleted file mode 100644 index 1160365441..0000000000 Binary files a/wpf/Gantt/Getting-Started_images/Getting-Started_img2.png and /dev/null differ diff --git a/wpf/Gantt/Getting-Started_images/Getting-Started_img3.png b/wpf/Gantt/Getting-Started_images/Getting-Started_img3.png deleted file mode 100644 index 3cad3d9b45..0000000000 Binary files a/wpf/Gantt/Getting-Started_images/Getting-Started_img3.png and /dev/null differ diff --git a/wpf/Gantt/Getting-Started_images/Getting-Started_img4.png b/wpf/Gantt/Getting-Started_images/Getting-Started_img4.png index f119980188..2e69971fd5 100644 Binary files a/wpf/Gantt/Getting-Started_images/Getting-Started_img4.png and b/wpf/Gantt/Getting-Started_images/Getting-Started_img4.png differ diff --git a/wpf/Gantt/Getting-Started_images/gantt-control-appearance-and-structure.png b/wpf/Gantt/Getting-Started_images/gantt-control-appearance-and-structure.png new file mode 100644 index 0000000000..82d00c4637 Binary files /dev/null and b/wpf/Gantt/Getting-Started_images/gantt-control-appearance-and-structure.png differ diff --git a/wpf/Gantt/Getting-Started_images/gantt-control-gantt-chart.png b/wpf/Gantt/Getting-Started_images/gantt-control-gantt-chart.png new file mode 100644 index 0000000000..7a51f5d089 Binary files /dev/null and b/wpf/Gantt/Getting-Started_images/gantt-control-gantt-chart.png differ diff --git a/wpf/Gantt/Getting-Started_images/gantt-control-gantt-grid.png b/wpf/Gantt/Getting-Started_images/gantt-control-gantt-grid.png new file mode 100644 index 0000000000..11eeff1335 Binary files /dev/null and b/wpf/Gantt/Getting-Started_images/gantt-control-gantt-grid.png differ diff --git a/wpf/Gantt/Holiday-Customization_images/Holiday-Customization_images_img1.png b/wpf/Gantt/Holiday-Customization_images/Holiday-Customization_images_img1.png deleted file mode 100644 index 918431d688..0000000000 Binary files a/wpf/Gantt/Holiday-Customization_images/Holiday-Customization_images_img1.png and /dev/null differ diff --git a/wpf/Gantt/Holiday-Customization_images/gantt-control-holiday-customization.png b/wpf/Gantt/Holiday-Customization_images/gantt-control-holiday-customization.png new file mode 100644 index 0000000000..6f0403b161 Binary files /dev/null and b/wpf/Gantt/Holiday-Customization_images/gantt-control-holiday-customization.png differ diff --git a/wpf/Gantt/Overview_images/Overview_img1.png b/wpf/Gantt/Overview_images/Overview_img1.png deleted file mode 100644 index 15cf513e4f..0000000000 Binary files a/wpf/Gantt/Overview_images/Overview_img1.png and /dev/null differ diff --git a/wpf/Gantt/Overview_images/gantt-control-overview.png b/wpf/Gantt/Overview_images/gantt-control-overview.png new file mode 100644 index 0000000000..08f79b30c7 Binary files /dev/null and b/wpf/Gantt/Overview_images/gantt-control-overview.png differ diff --git a/wpf/Gantt/auto-update-hierarchy.md b/wpf/Gantt/auto-update-hierarchy.md index 57c3883189..819cf90dde 100644 --- a/wpf/Gantt/auto-update-hierarchy.md +++ b/wpf/Gantt/auto-update-hierarchy.md @@ -45,110 +45,168 @@ To use the auto updating hierarchy support in an application: 1. Create a simple class structure for business objects. {% capture codesnippet1 %} -{% highlight c# %} -public class Task : NotificationObject +{% highlight c# tabtitle="Task.cs" %} + +public class Task : INotifyPropertyChanged { + /// + /// Holds the start date and end date value. + /// + private DateTime startDate, endDate; + + /// + /// Holds the duration value. + /// + private TimeSpan duration; + + /// + /// Holds the progress value. + /// + private double progress; + + /// + /// Holds the id value. + /// + private int id; + + /// + /// Holds the name value. + /// + private string name; + + /// + /// Holds the collection value. + /// + private ObservableCollection childCollection; + public Task() { - ChildTask = new ObservableCollection(); + this.ChildCollection = new ObservableCollection(); } - //No need to do the calculation for end date when the duration is changed - public TimeSpan Duration + /// + /// Property for Start Date. + /// + public DateTime StartDate { get { - return duration; + return this.startDate; } set { - duration = value; - RaisePropertyChanged("Duration"); + this.startDate = value; + OnPropertyChanged("StartDate"); } } - //No need to do the calculation for duration when the end date is changed. + /// + /// Property for Finish Date. + /// public DateTime EndDate { get { - return endDate; + return this.endDate; } set { - endDate = value; - RaisePropertyChanged("EndDate"); + this.endDate = value; + OnPropertyChanged("EndDate"); } } - //No need to do the calculation for duration when the starting date is changed - public DateTime StDate + /// + /// Property for duration value. + /// + public TimeSpan Duration { get { - return stDate; + return this.duration; } set { - stDate = value; - RaisePropertyChanged("StDate"); + this.duration = value; + OnPropertyChanged("Duration"); } } - //No need to hook the collection based on the changes made in child nodes to listen and refresh the parent nodes. - public ObservableCollection ChildTask + /// + /// Property for ID value. + /// + public int ID { get { - return childTask; + return this.id; } set { - childTask = value; - RaisePropertyChanged("ChildTask"); + this.id = value; + OnPropertyChanged("ID"); } } - + + /// + /// Property for Name. + /// public string Name { get { - return name; + return this.name; } set { - name = value; - RaisePropertyChanged("Name"); + this.name = value; + OnPropertyChanged("Name"); } } - public int Id + /// + /// Property to define progress value. + /// + public double Progress { get { - return id; + return this.progress; } set { - id = value; - RaisePropertyChanged("Id"); + this.progress = value; + OnPropertyChanged("Progress"); } } - public double Complete + /// + /// Property to add child collection. + /// + public ObservableCollection ChildCollection { get { - return Math.Round(complete, 2); + return this.childCollection; } set { - complete = value; - RaisePropertyChanged("Complete"); + this.childCollection = value; + OnPropertyChanged("ChildCollection"); + } + } + + private void OnPropertyChanged(string propName) + { + if (this.PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propName)); } } + + public event PropertyChangedEventHandler PropertyChanged; } - + {% endhighlight %} {% endcapture %} {{ codesnippet1 | OrderList_Indent_Level_1 }} @@ -156,95 +214,111 @@ public class Task : NotificationObject 2. Create a collection of business objects to bind them as ItemsSource for the Gantt control. {% capture codesnippet2 %} -{% highlight c# %} -TaskDetails = new ObservableCollection(); -TaskDetails = GetData(); - -ObservableCollection GetData() +{% highlight c# tabtitle="ViewModel.cs" %} + +public class ViewModel { - ObservableCollection data = new ObservableCollection(); - data.Add( - new Task() - { - Id = 1, - Name = "Analysis/Planning", - StDate = new DateTime(2012, 7, 3), - EndDate = new DateTime(2012, 8, 14), - Complete = 40d - }); - data[0].ChildTask.Add( - (new Task() - { - Id = 2, - Name = "Identify Components to be Localized", - StDate = new DateTime(2012, 7, 3), - EndDate = new DateTime(2012, 7, 5), - Complete = 20d - })); - data[0].ChildTask.Add( - (new Task() - { - Id = 3, - Name = "Ensure file localizability", - StDate = new DateTime(2012, 7, 6), - EndDate = new DateTime(2012, 7, 7), - Complete = 20d - })); - data.Add( - new Task() - { - Id = 8, - Name = "Production", - StDate = new DateTime(2012, 7, 3), - EndDate = new DateTime(2012, 7, 14), - Complete = 40d - }); - data[1].ChildTask.Add( - (new Task() - { - Id = 9, - Name = "Software Components", - StDate = new DateTime(2012, 7, 3), - EndDate = new DateTime(2012, 7, 5), - Complete = 20d, - })); - data[1].ChildTask.Add( - (new Task() - { - Id = 10, - Name = "Localization Component - User Interface", - StDate = new DateTime(2012, 7, 6), - EndDate = new DateTime(2012, 7, 7), - Complete = 20d - })); - data.Add( - new Task() - { - Id = 13, - Name = "Quality Assurance", - StDate = new DateTime(2012, 7, 3), - EndDate = new DateTime(2012, 7, 12), - Complete = 40d, - }); - data[2].ChildTask.Add( - (new Task() - { - Id = 14, - Name = "Review project information", - StDate = new DateTime(2012, 7, 3), - EndDate = new DateTime(2012, 7, 15), - Complete = 20d - })); - data[2].ChildTask.Add( - (new Task() - { - Id = 15, - Name = "Localization Component", - StDate = new DateTime(2012, 7, 6), - EndDate = new DateTime(2012, 7, 8), - Complete = 20d - })); + /// + /// Property to add child collection. + /// + public ObservableCollection TaskCollection { get; set; } + + public ViewModel() + { + this.TaskCollection = this.GetDataSource(); + } + + /// + /// Method to get data source. + /// + private ObservableCollection GetDataSource() + { + ObservableCollection taskDetails = new ObservableCollection(); + taskDetails.Add(new Task() + { + ID = 1, + Name = "Analysis/Planning", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 8, 14), + Progress = 40d + }); + + taskDetails[0].ChildCollection.Add((new Task() + { + ID = 2, + Name = "IDentify Components to be Localized", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 5), + Progress = 20d + })); + + taskDetails[0].ChildCollection.Add((new Task() + { + ID = 3, + Name = "Ensure file localizability", + StartDate = new DateTime(2012, 7, 6), + EndDate = new DateTime(2012, 7, 7), + Progress = 20d + })); + + taskDetails.Add(new Task() + { + ID = 8, + Name = "Production", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 14), + Progress = 40d + }); + + taskDetails[1].ChildCollection.Add((new Task() + { + ID = 9, + Name = "Software Components", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 5), + Progress = 20d, + })); + + taskDetails[1].ChildCollection.Add((new Task() + { + ID = 10, + Name = "Localization Component - User Interface", + StartDate = new DateTime(2012, 7, 6), + EndDate = new DateTime(2012, 7, 7), + Progress = 20d + })); + + taskDetails.Add(new Task() + { + ID = 13, + Name = "Quality Assurance", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 12), + Progress = 40d, + }); + + taskDetails[2].ChildCollection.Add((new Task() + { + ID = 14, + Name = "Review project information", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 15), + Progress = 20d + })); + + taskDetails[2].ChildCollection.Add((new Task() + { + ID = 15, + Name = "Localization Component", + StartDate = new DateTime(2012, 7, 6), + EndDate = new DateTime(2012, 7, 8), + Progress = 20d + })); + + return taskDetails; + } } + {% endhighlight %} {% endcapture %} {{ codesnippet2 | OrderList_Indent_Level_1 }} @@ -252,21 +326,31 @@ ObservableCollection GetData() 3. Set the collection as ItemsSource of the Gantt control. {% capture codesnippet3 %} +{% tabs %} {% highlight xaml %} - - - - - + + + + + + + + {% endhighlight %} +{% highlight c# %} +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; +{% endhighlight %} +{% endtabs %} {% endcapture %} {{ codesnippet3 | OrderList_Indent_Level_1 }} @@ -281,50 +365,87 @@ To use your own logics in business objects: public class Task : NotificationObject { + /// + /// Holds the start date and end date value. + /// + private DateTime startDate, endDate; + + /// + /// Holds the duration value. + /// + private TimeSpan duration; + + /// + /// Holds the progress value. + /// + private double progress; + + /// + /// Holds the id value. + /// + private int id; + + /// + /// Holds the name value. + /// + private string name; + + /// + /// Holds the collection value. + /// + private ObservableCollection childCollection; + public Task() { - ChildTask = new ObservableCollection(); + this.ChildCollection = new ObservableCollection(); } - - public TimeSpan Duration + + /// + /// Property for duration value. + /// + public TimeSpan Duration { get { - if (childTask != null && childTask.Count >= 1) + if (this.childCollection != null && this.childCollection.Count >= 1) { var sum = new TimeSpan(0, 0, 0, 0); - sum = childTask.Aggregate(sum, (current, task) => current + task.Duration); + sum = this.childCollection.Aggregate(sum, (current, task) => current + task.Duration); return sum; } /// The difference between the end date and starting date is calculated exactly. - duration = endDate.Subtract(stDate); + duration = endDate.Subtract(startDate); return duration; } set { - if (childTask != null && childTask.Count >= 1) + if (this.childCollection != null && this.childCollection.Count >= 1) { var sum = new TimeSpan(0, 0, 0, 0); - sum = childTask.Aggregate(sum, (current, task) => current + task.Duration); + sum = this.childCollection.Aggregate(sum, (current, task) => current + task.Duration); duration = sum; return; } + duration = value; /// The end date is calculated to make the change in end date based on duration. The duration is interlinked with the starting date and end date, so it will affect the both based on the changes. - EndDate = stDate.AddDays(Double.Parse(duration.TotalDays.ToString())); + EndDate = startDate.AddDays(Double.Parse(duration.TotalDays.ToString())); } } - - public DateTime EndDate + + /// + /// Property for Finish Date. + /// + public DateTime EndDate { get { return endDate; } set { - if (childTask != null && childTask.Count >= 1) + if (this.childCollection != null && this.childCollection.Count >= 1) { /// If this task is a parent task, then it should have the maximum end time to compare the date with maximum date of its child tasks. - if (value >= childTask.Max(s => s.EndDate) && endDate != value) + if (value >= this.childCollection.Max(s => s.EndDate) && endDate != value) endDate = value; } else @@ -334,31 +455,37 @@ public class Task : NotificationObject RaisePropertyChanged("Duration"); } } - - public DateTime StDate + + /// + /// Property for Start Date. + /// + public DateTime StartDate { get { - return stDate; + return startDate; } set { /// If this task is a parent task, then it should have the minimum starting time to compare the date with minimum date of its child tasks. - if (childTask != null && childTask.Count >= 1) + if (this.childCollection != null && this.childCollection.Count >= 1) { - if (value <= childTask.Min(s => s.stDate) && stDate != value) - stDate = value; + if (value <= this.childCollection.Min(s => s.startDate) && startDate != value) + startDate = value; } else - stDate = value; - RaisePropertyChanged("StDate"); + startDate = value; + RaisePropertyChanged("startDate"); /// The changed duration is invoked to notify the change in duration based on the new start date. RaisePropertyChanged("Duration"); } } - - public string Name + + /// + /// Property for Name value. + /// + public string Name { get { return name; } set @@ -367,8 +494,11 @@ public class Task : NotificationObject RaisePropertyChanged("Name"); } } - - public int Id + + /// + /// Property for ID value. + /// + public int Id { get { return id; } set @@ -377,55 +507,63 @@ public class Task : NotificationObject RaisePropertyChanged("Id"); } } - - public ObservableCollection ChildTask + + /// + /// Property to add child collection. + /// + public ObservableCollection ChildCollection { get { - if (childTask == null) + if (this.childCollection == null) { - childTask = new ObservableCollection(); + this.childCollection = new ObservableCollection(); /// The changed collection of child tasks is hooked to listen and refresh the parent node based on the changes made in child des. - childTask.CollectionChanged += ChildNodesCollectionChanged; + this.childCollection.CollectionChanged += ChildNodesCollectionChanged; } - return childTask; + + return this.childCollection; } set { - childTask = value; + this.childCollection = value; ///The changed collection of child tasks is hooked to listen and refresh the parent node based on the changes made in child nodes. - childTask.CollectionChanged += ChildNodesCollectionChanged; + this.childCollection.CollectionChanged += ChildNodesCollectionChanged; if (value.Count > 0) { - childTask.ToList().ForEach(n => + this.childCollection.ToList().ForEach(n => { /// To listen the changes made in child tasks. n.PropertyChanged += ChildNodePropertyChanged; }); UpdateData(); } - RaisePropertyChanged("ChildTask"); + + RaisePropertyChanged("this.ChildCollection"); } } - - void ChildNodePropertyChanged(object sender, PropertyChangedEventArgs e) + + void ChildNodePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != null) - if (e.PropertyName == "StDate" || e.PropertyName == "EndDate" || e.PropertyName == "Complete") + if (e.PropertyName == "startDate" || e.PropertyName == "EndDate" || e.PropertyName == "Complete") { UpdateData(); } } - - private void UpdateData() + + /// + /// Method to update data source. + /// + private void UpdateData() { /// Update the starting date and end date based on the changes made in the date of child tasks. - StDate = childTask.Select(c => c.StDate).Min(); - EndDate = childTask.Select(c => c.EndDate).Max(); - Complete = (childTask.Aggregate(0d, (cur, task) => cur + task.Complete)) / childTask.Count; + StartDate = this.childCollection.Select(c => c.startDate).Min(); + EndDate = this.childCollection.Select(c => c.EndDate).Max(); + progress = (this.childCollection.Aggregate(0d, (cur, task) => cur + task.progress)) / this.childCollection.Count; } - - public void ChildNodesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + + public void ChildNodesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { @@ -450,162 +588,109 @@ public class Task : NotificationObject 2. Create a collection of business objects to bind it as ItemsSource of the Gantt control. {% capture codesnippet5 %} -{% highlight c# %} - -TaskDetails = new ObservableCollection(); - -TaskDetails = GetData(); - -ObservableCollection GetData() - +{% highlight c# tabtitle="ViewModel.cs" %} + +public class ViewModel { + /// + /// Property to add child collection. + /// + public ObservableCollection TaskCollection { get; set; } - ObservableCollection data = new ObservableCollection(); - - data.Add(new Task() - - { - - Id = 1, - - Name = "Analysis/Planning", - - StDate = new DateTime(2012, 7, 3), - - EndDate = new DateTime(2012, 8, 14), - - Complete = 40d - - }); - - data[0].ChildTask.Add((new Task() - + public ViewModel() { - - Id = 2, - - Name = "Identify Components to be Localized", - - StDate = new DateTime(2012, 7, 3), - - EndDate = new DateTime(2012, 7, 5), - - Complete = 20d - - })); - - data[0].ChildTask.Add((new Task() - - { - - Id = 3, - - Name = "Ensure file localizability", - - StDate = new DateTime(2012, 7, 6), - - EndDate = new DateTime(2012, 7, 7), - - Complete = 20d - - })); - - data.Add(new Task() - - { - - Id = 8, - - Name = "Production", - - StDate = new DateTime(2012, 7, 3), - - EndDate = new DateTime(2012, 7, 14), - - Complete = 40d - - }); - - data[1].ChildTask.Add((new Task() - - { - - Id = 9, - - Name = "Software Components", - - StDate = new DateTime(2012, 7, 3), - - EndDate = new DateTime(2012, 7, 5), - - Complete = 20d, - - })); - - data[1].ChildTask.Add((new Task() - - { - - Id = 10, - - Name = "Localization Component - User Interface", - - StDate = new DateTime(2012, 7, 6), - - EndDate = new DateTime(2012, 7, 7), - - Complete = 20d - - })); - - data.Add(new Task() - - { - - Id = 13, - - Name = "Quality Assurance", - - StDate = new DateTime(2012, 7, 3), - - EndDate = new DateTime(2012, 7, 12), - - Complete = 40d, - - }); - - data[2].ChildTask.Add((new Task() - - { - - Id = 14, - - Name = "Review project information", - - StDate = new DateTime(2012, 7, 3), - - EndDate = new DateTime(2012, 7, 15), - - Complete = 20d - - })); - - data[2].ChildTask.Add((new Task() - + this.TaskCollection = this.GetDataSource(); + } + + /// + /// Method to get data source. + /// + private ObservableCollection GetDataSource() { - - Id = 15, - - Name = "Localization Component", - - StDate = new DateTime(2012, 7, 6), - - EndDate = new DateTime(2012, 7, 8), - - Complete = 20d - - })); - + ObservableCollection taskDetails = new ObservableCollection(); + taskDetails.Add(new Task() + { + ID = 1, + Name = "Analysis/Planning", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 8, 14), + Progress = 40d + }); + + taskDetails[0].ChildCollection.Add((new Task() + { + ID = 2, + Name = "IDentify Components to be Localized", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 5), + Progress = 20d + })); + + taskDetails[0].ChildCollection.Add((new Task() + { + ID = 3, + Name = "Ensure file localizability", + StartDate = new DateTime(2012, 7, 6), + EndDate = new DateTime(2012, 7, 7), + Progress = 20d + })); + + taskDetails.Add(new Task() + { + ID = 8, + Name = "Production", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 14), + Progress = 40d + }); + + taskDetails[1].ChildCollection.Add((new Task() + { + ID = 9, + Name = "Software Components", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 5), + Progress = 20d, + })); + + taskDetails[1].ChildCollection.Add((new Task() + { + ID = 10, + Name = "Localization Component - User Interface", + StartDate = new DateTime(2012, 7, 6), + EndDate = new DateTime(2012, 7, 7), + Progress = 20d + })); + + taskDetails.Add(new Task() + { + ID = 13, + Name = "Quality Assurance", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 12), + Progress = 40d, + }); + + taskDetails[2].ChildCollection.Add((new Task() + { + ID = 14, + Name = "Review project information", + StartDate = new DateTime(2012, 7, 3), + EndDate = new DateTime(2012, 7, 15), + Progress = 20d + })); + + taskDetails[2].ChildCollection.Add((new Task() + { + ID = 15, + Name = "Localization Component", + StartDate = new DateTime(2012, 7, 6), + EndDate = new DateTime(2012, 7, 8), + Progress = 20d + })); + + return taskDetails; + } } {% endhighlight %} @@ -617,35 +702,40 @@ ObservableCollection GetData() N> If you use the TaskDetails class as your business object, then you should not set the UseAutoUpdateHierarchy property as false. {% capture codesnippet6 %} +{% tabs %} {% highlight xaml %} - - - - - + + + + + + + + {% endhighlight %} +{% highlight c# %} +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; +{% endhighlight %} +{% endtabs %} {% endcapture %} {{ codesnippet6 | OrderList_Indent_Level_1 }} Output: The corresponding output for the code is as follows. - - - -![Auto-Update-Hierarchy_img1](Auto-Update-Hierarchy_images/Auto-Update-Hierarchy_img1.png) - - +![gantt-control-auto-updated-hierarchy](Auto-Update-Hierarchy_images/gantt-control-auto-updated-hierarchy.png) Gantt Control with Auto Updated Hierarchy {:.caption} diff --git a/wpf/Gantt/baseline-support.md b/wpf/Gantt/baseline-support.md index eb8a80abcd..0b817b6311 100644 --- a/wpf/Gantt/baseline-support.md +++ b/wpf/Gantt/baseline-support.md @@ -65,43 +65,618 @@ The following codes illustrate this: {% tabs %} {% highlight xaml %} - - - - - - + + + + + + + + + {% endhighlight %} {% highlight c# %} +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; + +{% endhighlight %} + +{% highlight c# tabtitle="Task.cs" %} + +public class Task : INotifyPropertyChanged +{ + /// + /// Holds the start date and end date value. + /// + private DateTime startDate, endDate; + + /// + /// Holds the duration value. + /// + private TimeSpan duration; + + /// + /// Holds the progress value. + /// + private double progress; + + /// + /// Holds the id value. + /// + private int id; + + /// + /// Holds the name value. + /// + private string name; + + /// + /// Holds the cost value. + /// + private Double cost; + + /// + /// Holds the baselineStart value. + /// + private DateTime baselineStart; + + /// + /// Holds the baselineEnd value. + /// + private DateTime baselineEnd; + + /// + /// Holds the baselineCost value. + /// + private Double baselineCost; + + /// + /// Holds the collection value. + /// + private ObservableCollection childCollection; + + /// + /// Holds the resource value. + /// + private ObservableCollection resource; + + /// + /// Holds the predecessor value. + /// + private ObservableCollection predecessor; + + public Task() + { + this.ChildCollection = new ObservableCollection(); + this.Predecessor = new ObservableCollection(); + this.Resource = new ObservableCollection(); + } + + /// + /// Property for Start Date. + /// + public DateTime StartDate + { + get + { + return this.startDate; + } + set + { + this.startDate = value; + OnPropertyChanged("StartDate"); + } + } + + /// + /// Property for Finish Date. + /// + public DateTime EndDate + { + get + { + return this.endDate; + } + set + { + this.endDate = value; + OnPropertyChanged("EndDate"); + } + } + + /// + /// Property for duration value. + /// + public TimeSpan Duration + { + get + { + return this.duration; + } + set + { + this.duration = value; + OnPropertyChanged("Duration"); + } + } + + /// + /// Property for ID value. + /// + public int ID + { + get + { + return this.id; + } + set + { + this.id = value; + OnPropertyChanged("ID"); + } + } + + /// + /// Property for Name. + /// + public string Name + { + get + { + return this.name; + } + set + { + this.name = value; + OnPropertyChanged("Name"); + } + } + + /// + /// Property to define progress value. + /// + public double Progress + { + get + { + return this.progress; + } + set + { + this.progress = value; + OnPropertyChanged("Progress"); + } + } + + /// + /// Gets or sets cost. + /// + public Double Cost + { + get + { + return this.cost; + } + set + { + this.cost = value; + OnPropertyChanged("Cost"); + } + } + + /// + /// Gets or sets the Baseline start. + /// + public DateTime BaselineStart + { + get + { + return this.baselineStart; + } + set + { + this.baselineStart = value; + OnPropertyChanged("BaselineStart"); + } + } + + /// + /// Gets or sets the Baseline end. + /// + public DateTime BaselineEnd + { + get + { + return this.baselineEnd; + } + set + { + this.baselineEnd = value; + OnPropertyChanged("BaselineEnd"); + } + } + + /// + /// Gets or sets cost. + /// + public Double BaselineCost + { + get + { + return this.baselineCost; + } + set + { + this.baselineCost = value; + OnPropertyChanged("BaselineCost"); + } + } + + /// + /// Property to add child collection. + /// + public ObservableCollection ChildCollection + { + get + { + return this.childCollection; + } + set + { + this.childCollection = value; + OnPropertyChanged("ChildCollection"); + } + } + + /// + /// Property to define resource value. + /// + public ObservableCollection Resource + { + get + { + return this.resource; + } + set + { + this.resource = value; + OnPropertyChanged("Resource"); + } + } + + /// + /// Property to define predecessor value. + /// + public ObservableCollection Predecessor + { + get + { + return this.predecessor; + } + set + { + this.predecessor = value; + OnPropertyChanged("Predecessor"); + } + } + + private void OnPropertyChanged(string propName) + { + if (this.PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propName)); + } + } + + public event PropertyChangedEventHandler PropertyChanged; +} + +{% endhighlight %} +{% highlight c# tabtitle="ViewModel.cs" %} + +public class ViewModel +{ + public ViewModel() + { + this.taskDetails = this.GetTaskDetails(); + } + + /// + /// Holds the task details value. + /// + private ObservableCollection taskDetails; + + /// + /// Gets or sets the task collection. + /// + /// The task collection. + public ObservableCollection TaskDetails + { + get + { + return taskDetails; + } + set + { + this.taskDetails = value; + } + } + + /// + /// Gets the task details. + /// + /// + ObservableCollection GetTaskDetails() + { + var taskDetails = new ObservableCollection(); + + // Collection to Strore the Required Resources. + ObservableCollection ResidentialConstructionResources = new ObservableCollection(); + ResidentialConstructionResources = GetResources(); + + // Adding Tasks + + taskDetails.Add(new Task() { ID = 1, Name = "Residential Construction (2500 sq.ft)", StartDate = new DateTime(2012, 3, 1), EndDate = new DateTime(2012, 3, 15), BaselineStart = new DateTime(2012, 3, 1), BaselineEnd = new DateTime(2012, 3, 14), Progress = 0d, Cost = 500, BaselineCost = 833d, }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 2, Name = "General Considerations", StartDate = new DateTime(2012, 7, 3), EndDate = new DateTime(2012, 7, 14), BaselineStart = new DateTime(2012, 7, 3), BaselineEnd = new DateTime(2012, 7, 14), Progress = 0d, Cost = 89, BaselineCost = 833d, }); + + taskDetails[0].ChildCollection[0].ChildCollection.Add(new Task() { ID = 3, Name = "Finalize and Approve Plans", StartDate = new DateTime(2012, 3, 1), EndDate = new DateTime(2012, 3, 15), BaselineStart = new DateTime(2012, 3, 2), BaselineEnd = new DateTime(2012, 3, 16), Progress = 0d, Cost = 500, BaselineCost = 833d, }); + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection.Add(new Task() { ID = 4, Name = "Review and Finalize Site Plans", StartDate = new DateTime(2012, 3, 1), EndDate = new DateTime(2012, 3, 20), BaselineStart = new DateTime(2012, 3, 1), BaselineEnd = new DateTime(2012, 3, 20), Progress = 0d, Cost = 500, BaselineCost = 833d, }); + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection.Add(new Task() { ID = 5, Name = "Sign contract and Proceed", StartDate = new DateTime(2012, 3, 20), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 19), BaselineEnd = new DateTime(2012, 3, 21), Progress = 0d, Cost = 500, BaselineCost = 833d, }); + + taskDetails[0].ChildCollection[0].ChildCollection.Add(new Task() { ID = 6, Name = "Contracts and Agreements", StartDate = new DateTime(2012, 3, 22), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 20), BaselineEnd = new DateTime(2012, 3, 21), Progress = 0d, Cost = 20d, BaselineCost = 14 }); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection.Add((new Task() { ID = 7, Name = "Lot Sale Agreement", StartDate = new DateTime(2012, 3, 22), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 20), BaselineEnd = new DateTime(2012, 3, 20), Progress = 0d, Cost = 20d, BaselineCost = 14 })); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection.Add((new Task() { ID = 8, Name = "Construction Agreement", StartDate = new DateTime(2012, 3, 22), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 21), BaselineEnd = new DateTime(2012, 3, 21), Progress = 0d, Cost = 33d, BaselineCost = 12 })); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection.Add((new Task() { ID = 9, Name = "Contract Specifications", StartDate = new DateTime(2012, 3, 22), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 20), BaselineEnd = new DateTime(2012, 3, 20), Progress = 0d, Cost = 30d, BaselineCost = 50 })); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection.Add((new Task() { ID = 10, Name = "Contract Site Plan", StartDate = new DateTime(2012, 3, 22), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 20), BaselineEnd = new DateTime(2012, 3, 20), Progress = 0d, Cost = 360d, BaselineCost = 100 })); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection.Add((new Task() { ID = 11, Name = "Financing", StartDate = new DateTime(2012, 3, 22), EndDate = new DateTime(2012, 3, 22), BaselineStart = new DateTime(2012, 3, 20), BaselineEnd = new DateTime(2012, 3, 20), Progress = 0d, Cost = 39d, BaselineCost = 16 })); + + taskDetails[0].ChildCollection[0].ChildCollection.Add(new Task() { ID = 12, Name = "Apply Permits", StartDate = new DateTime(2012, 3, 23), EndDate = new DateTime(2012, 3, 24), BaselineStart = new DateTime(2012, 3, 22), BaselineEnd = new DateTime(2012, 3, 23), Progress = 0d, Cost = 53d, BaselineCost = 65 }); + taskDetails[0].ChildCollection[0].ChildCollection[2].ChildCollection.Add((new Task() { ID = 13, Name = "Foundation Permit", StartDate = new DateTime(2012, 3, 23), EndDate = new DateTime(2012, 3, 24), BaselineStart = new DateTime(2012, 3, 22), BaselineEnd = new DateTime(2012, 3, 23), Progress = 0d, Cost = 53d, BaselineCost = 65 })); + taskDetails[0].ChildCollection[0].ChildCollection[2].ChildCollection.Add((new Task() { ID = 14, Name = "Electrical Permit", StartDate = new DateTime(2012, 3, 24), EndDate = new DateTime(2012, 3, 25), BaselineStart = new DateTime(2012, 3, 24), BaselineEnd = new DateTime(2012, 3, 25), Progress = 0d, Cost = 23d, BaselineCost = 34 })); + taskDetails[0].ChildCollection[0].ChildCollection[2].ChildCollection.Add((new Task() { ID = 15, Name = "Plumbing Permit", StartDate = new DateTime(2012, 3, 25), EndDate = new DateTime(2012, 3, 26), BaselineStart = new DateTime(2012, 3, 25), BaselineEnd = new DateTime(2012, 3, 26), Progress = 0d, Cost = 63d, BaselineCost = 53 })); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 16, Name = "Site Work", StartDate = new DateTime(2012, 3, 26), EndDate = new DateTime(2012, 3, 27), BaselineStart = new DateTime(2012, 3, 26), BaselineEnd = new DateTime(2012, 3, 27), Progress = 0d, Cost = 2000d, BaselineCost = 1000 }); + taskDetails[0].ChildCollection[1].ChildCollection.Add(new Task() { ID = 17, Name = "Clear Lot", StartDate = new DateTime(2012, 3, 26), EndDate = new DateTime(2012, 3, 27), BaselineStart = new DateTime(2012, 3, 27), BaselineEnd = new DateTime(2012, 3, 28), Progress = 0d, Cost = 2000d, BaselineCost = 1000 }); + taskDetails[0].ChildCollection[1].ChildCollection.Add(new Task() { ID = 18, Name = "Strip Topsoil", StartDate = new DateTime(2012, 3, 27), EndDate = new DateTime(2012, 3, 28), BaselineStart = new DateTime(2012, 3, 27), BaselineEnd = new DateTime(2012, 3, 28), Progress = 0d, Cost = 1200d, BaselineCost = 800 }); + taskDetails[0].ChildCollection[1].ChildCollection.Add(new Task() { ID = 19, Name = "Installing Temporary requirements", StartDate = new DateTime(2012, 3, 28), EndDate = new DateTime(2012, 3, 29), BaselineStart = new DateTime(2012, 3, 30), BaselineEnd = new DateTime(2012, 4, 2), Progress = 0d, Cost = 354d, BaselineCost = 230 }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 20, Name = "Foundation", StartDate = new DateTime(2012, 3, 29), EndDate = new DateTime(2012, 4, 2), BaselineStart = new DateTime(2012, 3, 29), BaselineEnd = new DateTime(2012, 4, 2), Progress = 0d, Cost = 899, BaselineCost = 833d, }); + taskDetails[0].ChildCollection[2].ChildCollection.Add(new Task() { ID = 21, Name = "Excavate for foundation", StartDate = new DateTime(2012, 3, 29), EndDate = new DateTime(2012, 4, 2), BaselineStart = new DateTime(2012, 3, 29), BaselineEnd = new DateTime(2012, 4, 2), Progress = 0d, Cost = 899, BaselineCost = 833d, }); + taskDetails[0].ChildCollection[2].ChildCollection.Add(new Task() { ID = 22, Name = "Building Basement Walls", StartDate = new DateTime(2012, 4, 3), EndDate = new DateTime(2012, 4, 8), BaselineStart = new DateTime(2012, 4, 3), BaselineEnd = new DateTime(2012, 4, 8), Progress = 0d, Cost = 889, BaselineCost = 803d, }); + taskDetails[0].ChildCollection[2].ChildCollection.Add(new Task() { ID = 23, Name = "Foundation inspection", StartDate = new DateTime(2012, 4, 8), EndDate = new DateTime(2012, 4, 10), BaselineStart = new DateTime(2012, 4, 7), BaselineEnd = new DateTime(2012, 4, 9), Progress = 0d, Cost = 8, BaselineCost = 8d, }); + taskDetails[0].ChildCollection[2].ChildCollection.Add(new Task() { ID = 24, Name = "Finishing Foundation", StartDate = new DateTime(2012, 4, 10), EndDate = new DateTime(2012, 4, 17), BaselineStart = new DateTime(2012, 4, 10), BaselineEnd = new DateTime(2012, 4, 17), Progress = 0d, Cost = 0, BaselineCost = 8d, }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 25, Name = "Framing", StartDate = new DateTime(2012, 4, 18), EndDate = new DateTime(2012, 4, 24), BaselineStart = new DateTime(2012, 4, 18), BaselineEnd = new DateTime(2012, 4, 24), Progress = 0d, Cost = 890, BaselineCost = 803d, }); + taskDetails[0].ChildCollection[3].ChildCollection.Add(new Task() { ID = 26, Name = "First Floor Framing", StartDate = new DateTime(2012, 4, 18), EndDate = new DateTime(2012, 4, 24), BaselineStart = new DateTime(2012, 4, 17), BaselineEnd = new DateTime(2012, 4, 23), Progress = 0d, Cost = 890, BaselineCost = 803d, }); + taskDetails[0].ChildCollection[3].ChildCollection.Add(new Task() { ID = 27, Name = "Second Floor Framing", StartDate = new DateTime(2012, 4, 24), EndDate = new DateTime(2012, 5, 3), BaselineStart = new DateTime(2012, 4, 24), BaselineEnd = new DateTime(2012, 5, 3), Progress = 0d, Cost = 789, BaselineCost = 898d, }); + taskDetails[0].ChildCollection[3].ChildCollection.Add(new Task() { ID = 28, Name = "Framing Roof", StartDate = new DateTime(2012, 5, 3), EndDate = new DateTime(2012, 5, 7), BaselineStart = new DateTime(2012, 5, 4), BaselineEnd = new DateTime(2012, 5, 8), Progress = 0d, Cost = 780, BaselineCost = 833d, }); + taskDetails[0].ChildCollection[3].ChildCollection.Add(new Task() { ID = 29, Name = "Framing Inspection", StartDate = new DateTime(2012, 5, 7), EndDate = new DateTime(2012, 5, 8), BaselineStart = new DateTime(2012, 5, 7), BaselineEnd = new DateTime(2012, 5, 8), Progress = 0d, Cost = 5, BaselineCost = 8d, }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 30, Name = "Dry In", StartDate = new DateTime(2012, 5, 8), EndDate = new DateTime(2012, 5, 14), BaselineStart = new DateTime(2012, 5, 8), BaselineEnd = new DateTime(2012, 5, 15), Progress = 0d, Cost = 232, BaselineCost = 323d, }); + taskDetails[0].ChildCollection[4].ChildCollection.Add(new Task() { ID = 31, Name = "Installing Sheathing for floors", StartDate = new DateTime(2012, 5, 8), EndDate = new DateTime(2012, 5, 14), BaselineStart = new DateTime(2012, 5, 9), BaselineEnd = new DateTime(2012, 5, 15), Progress = 0d, Cost = 232, BaselineCost = 323d, }); + taskDetails[0].ChildCollection[4].ChildCollection.Add(new Task() { ID = 32, Name = "Installing Windows", StartDate = new DateTime(2012, 5, 14), EndDate = new DateTime(2012, 5, 25), BaselineStart = new DateTime(2012, 5, 14), BaselineEnd = new DateTime(2012, 5, 25), Progress = 0d, Cost = 325, BaselineCost = 452d, }); + taskDetails[0].ChildCollection[4].ChildCollection.Add(new Task() { ID = 33, Name = "Installing Sheathing for Roof", StartDate = new DateTime(2012, 5, 25), EndDate = new DateTime(2012, 5, 30), BaselineStart = new DateTime(2012, 5, 23), BaselineEnd = new DateTime(2012, 5, 30), Progress = 0d, Cost = 82, BaselineCost = 83d, }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 34, Name = "Exterior Finishing", StartDate = new DateTime(2012, 5, 31), EndDate = new DateTime(2012, 6, 12), BaselineStart = new DateTime(2012, 5, 31), BaselineEnd = new DateTime(2012, 6, 12), Progress = 0d, Cost = 463, BaselineCost = 633d, }); + taskDetails[0].ChildCollection[5].ChildCollection.Add(new Task() { ID = 35, Name = "Exterior Trimming", StartDate = new DateTime(2012, 5, 31), EndDate = new DateTime(2012, 6, 12), BaselineStart = new DateTime(2012, 5, 31), BaselineEnd = new DateTime(2012, 6, 12), Progress = 0d, Cost = 463, BaselineCost = 633d, }); + taskDetails[0].ChildCollection[5].ChildCollection.Add(new Task() { ID = 36, Name = "Completing Exterior Bricks", StartDate = new DateTime(2012, 6, 12), EndDate = new DateTime(2012, 6, 17), BaselineStart = new DateTime(2012, 6, 12), BaselineEnd = new DateTime(2012, 6, 17), Progress = 0d, Cost = 234, BaselineCost = 333d, }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 37, Name = "Interior Finishing", StartDate = new DateTime(2012, 6, 17), EndDate = new DateTime(2012, 6, 19), BaselineStart = new DateTime(2012, 6, 17), BaselineEnd = new DateTime(2012, 6, 19), Progress = 0d, Cost = 43, BaselineCost = 33d, }); + + taskDetails[0].ChildCollection[6].ChildCollection.Add(new Task() { ID = 38, Name = "Installing Insulation", StartDate = new DateTime(2012, 6, 17), EndDate = new DateTime(2012, 6, 19), BaselineStart = new DateTime(2012, 6, 17), BaselineEnd = new DateTime(2012, 6, 19), Progress = 0d, Cost = 43, BaselineCost = 33d, }); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection.Add(new Task() { ID = 39, Name = "Install Floor Insulation", StartDate = new DateTime(2012, 6, 17), EndDate = new DateTime(2012, 6, 19), BaselineStart = new DateTime(2012, 6, 17), BaselineEnd = new DateTime(2012, 6, 19), Progress = 0d, Cost = 43, BaselineCost = 33d, }); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection.Add(new Task() { ID = 40, Name = "Install Wall Insulation", StartDate = new DateTime(2012, 6, 19), EndDate = new DateTime(2012, 6, 21), BaselineStart = new DateTime(2012, 6, 19), BaselineEnd = new DateTime(2012, 6, 21), Progress = 0d, Cost = 53, BaselineCost = 83d, }); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection.Add(new Task() { ID = 41, Name = "Install Ceiling Insulation", StartDate = new DateTime(2012, 6, 21), EndDate = new DateTime(2012, 6, 22), BaselineStart = new DateTime(2012, 6, 21), BaselineEnd = new DateTime(2012, 6, 22), Progress = 0d, Cost = 89, BaselineCost = 83d, }); + + + taskDetails[0].ChildCollection[6].ChildCollection.Add(new Task() { ID = 42, Name = "Painting and Wallpaper", StartDate = new DateTime(2012, 6, 22), EndDate = new DateTime(2012, 6, 23), BaselineStart = new DateTime(2012, 6, 22), BaselineEnd = new DateTime(2012, 6, 23), Progress = 0d, Cost = 453, BaselineCost = 563, }); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection.Add(new Task() { ID = 43, Name = "Painting all Interior", StartDate = new DateTime(2012, 6, 22), EndDate = new DateTime(2012, 6, 23), BaselineStart = new DateTime(2012, 6, 22), BaselineEnd = new DateTime(2012, 6, 23), Progress = 0d, Cost = 453, BaselineCost = 563, }); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection.Add(new Task() { ID = 44, Name = "Painting all Exterior", StartDate = new DateTime(2012, 6, 23), EndDate = new DateTime(2012, 6, 25), BaselineStart = new DateTime(2012, 6, 23), BaselineEnd = new DateTime(2012, 6, 25), Progress = 0d, Cost = 352, BaselineCost = 342, }); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection.Add(new Task() { ID = 45, Name = "Additional Trimming Work", StartDate = new DateTime(2012, 6, 25), EndDate = new DateTime(2012, 6, 27), BaselineStart = new DateTime(2012, 6, 25), BaselineEnd = new DateTime(2012, 6, 27), Progress = 0d, Cost = 32, BaselineCost = 50, }); + + taskDetails[0].ChildCollection[6].ChildCollection.Add(new Task() { ID = 46, Name = "Finishing Plumbing", StartDate = new DateTime(2012, 6, 27), EndDate = new DateTime(2012, 6, 29), BaselineStart = new DateTime(2012, 6, 27), BaselineEnd = new DateTime(2012, 6, 29), Progress = 0d, Cost = 424, BaselineCost = 423, }); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection.Add(new Task() { ID = 47, Name = "First floor Plumbing", StartDate = new DateTime(2012, 6, 27), EndDate = new DateTime(2012, 6, 29), BaselineStart = new DateTime(2012, 6, 27), BaselineEnd = new DateTime(2012, 6, 29), Progress = 0d, Cost = 424, BaselineCost = 423, }); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection.Add(new Task() { ID = 48, Name = "Second floor plumbing", StartDate = new DateTime(2012, 6, 29), EndDate = new DateTime(2012, 7, 1), BaselineStart = new DateTime(2012, 6, 29), BaselineEnd = new DateTime(2012, 7, 1), Progress = 0d, Cost = 234, BaselineCost = 324, }); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection.Add(new Task() { ID = 49, Name = "Inspecting Plumbing", StartDate = new DateTime(2012, 7, 1), EndDate = new DateTime(2012, 7, 3), BaselineStart = new DateTime(2012, 7, 1), BaselineEnd = new DateTime(2012, 7, 3), Progress = 0d, Cost = 23, BaselineCost = 33d, }); + + taskDetails[0].ChildCollection[6].ChildCollection.Add(new Task() { ID = 50, Name = "Finishing Electrical", StartDate = new DateTime(2012, 7, 3), EndDate = new DateTime(2012, 7, 5), BaselineStart = new DateTime(2012, 7, 3), BaselineEnd = new DateTime(2012, 7, 5), Progress = 0d, Cost = 432, BaselineCost = 536, }); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection.Add(new Task() { ID = 51, Name = "Progress first floor connections", StartDate = new DateTime(2012, 7, 3), EndDate = new DateTime(2012, 7, 5), BaselineStart = new DateTime(2012, 7, 3), BaselineEnd = new DateTime(2012, 7, 5), Progress = 0d, Cost = 432, BaselineCost = 536, }); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection.Add(new Task() { ID = 52, Name = "Progress second floor connections", StartDate = new DateTime(2012, 7, 5), EndDate = new DateTime(2012, 7, 7), BaselineStart = new DateTime(2012, 7, 4), BaselineEnd = new DateTime(2012, 7, 6), Progress = 0d, Cost = 563, BaselineCost = 463, }); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection.Add(new Task() { ID = 53, Name = "Progress non-Electrical Wiring", StartDate = new DateTime(2012, 7, 7), EndDate = new DateTime(2012, 7, 8), BaselineStart = new DateTime(2012, 7, 7), BaselineEnd = new DateTime(2012, 7, 8), Progress = 0d, Cost = 234, BaselineCost = 563, }); + + taskDetails[0].ChildCollection[6].ChildCollection.Add(new Task() { ID = 54, Name = "Carpet,Tiles and Furnishing", StartDate = new DateTime(2012, 7, 8), EndDate = new DateTime(2012, 7, 10), BaselineStart = new DateTime(2012, 7, 9), BaselineEnd = new DateTime(2012, 7, 11), Progress = 0d, Cost = 253, BaselineCost = 210, }); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection.Add(new Task() { ID = 55, Name = "Progress first floor carpet", StartDate = new DateTime(2012, 7, 8), EndDate = new DateTime(2012, 7, 10), BaselineStart = new DateTime(2012, 7, 8), BaselineEnd = new DateTime(2012, 7, 10), Progress = 0d, Cost = 253, BaselineCost = 210, }); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection.Add(new Task() { ID = 56, Name = "Progress second floor carpet", StartDate = new DateTime(2012, 7, 10), EndDate = new DateTime(2012, 7, 13), BaselineStart = new DateTime(2012, 7, 10), BaselineEnd = new DateTime(2012, 7, 13), Progress = 0d, Cost = 341, BaselineCost = 300, }); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection.Add(new Task() { ID = 57, Name = "Progress Furnishing Kitchen, bath, hall", StartDate = new DateTime(2012, 7, 13), EndDate = new DateTime(2012, 7, 14), BaselineStart = new DateTime(2012, 7, 13), BaselineEnd = new DateTime(2012, 7, 14), Progress = 0, Cost = 4252, BaselineCost = 6033d, }); + + taskDetails[0].ChildCollection.Add(new Task() { ID = 58, Name = "Final Acceptance", StartDate = new DateTime(2012, 7, 14), EndDate = new DateTime(2012, 7, 16), BaselineStart = new DateTime(2012, 7, 14), BaselineEnd = new DateTime(2012, 7, 16), Progress = 0d, Cost = 430, BaselineCost = 433d, }); + taskDetails[0].ChildCollection[7].ChildCollection.Add(new Task() { ID = 59, Name = "Cleaning", StartDate = new DateTime(2012, 7, 14), EndDate = new DateTime(2012, 7, 16), BaselineStart = new DateTime(2012, 7, 14), BaselineEnd = new DateTime(2012, 7, 16), Progress = 0d, Cost = 430, BaselineCost = 433d, }); + taskDetails[0].ChildCollection[7].ChildCollection.Add(new Task() { ID = 60, Name = "Final Inspection", StartDate = new DateTime(2012, 7, 16), EndDate = new DateTime(2012, 7, 17), BaselineStart = new DateTime(2012, 7, 16), BaselineEnd = new DateTime(2012, 7, 17), Progress = 0d, Cost = 0, BaselineCost = 5, }); + taskDetails[0].ChildCollection[7].ChildCollection.Add(new Task() { ID = 61, Name = "Move In", StartDate = new DateTime(2012, 7, 17), EndDate = new DateTime(2012, 7, 17), BaselineStart = new DateTime(2012, 7, 18), BaselineEnd = new DateTime(2012, 7, 18), Progress = 0d, Cost = 0, BaselineCost = 0, }); + + + //Adding Resources + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[0].Resource.Add(ResidentialConstructionResources[1]); + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[0].Resource.Add(ResidentialConstructionResources[0]); + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[0].Resource.Add(ResidentialConstructionResources[2]); + + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[1].Resource.Add(ResidentialConstructionResources[0]); + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[1].Resource.Add(ResidentialConstructionResources[1]); + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[1].Resource.Add(ResidentialConstructionResources[2]); + + taskDetails[0].ChildCollection[1].ChildCollection[0].Resource.Add(ResidentialConstructionResources[3]); + taskDetails[0].ChildCollection[1].ChildCollection[1].Resource.Add(ResidentialConstructionResources[3]); + taskDetails[0].ChildCollection[1].ChildCollection[2].Resource.Add(ResidentialConstructionResources[5]); + taskDetails[0].ChildCollection[1].ChildCollection[2].Resource.Add(ResidentialConstructionResources[6]); + taskDetails[0].ChildCollection[1].ChildCollection[2].Resource.Add(ResidentialConstructionResources[4]); + + taskDetails[0].ChildCollection[2].ChildCollection[0].Resource.Add(ResidentialConstructionResources[3]); + taskDetails[0].ChildCollection[2].ChildCollection[1].Resource.Add(ResidentialConstructionResources[6]); + taskDetails[0].ChildCollection[2].ChildCollection[2].Resource.Add(ResidentialConstructionResources[7]); + taskDetails[0].ChildCollection[2].ChildCollection[3].Resource.Add(ResidentialConstructionResources[3]); + + taskDetails[0].ChildCollection[3].ChildCollection[0].Resource.Add(ResidentialConstructionResources[8]); + taskDetails[0].ChildCollection[3].ChildCollection[1].Resource.Add(ResidentialConstructionResources[8]); + taskDetails[0].ChildCollection[3].ChildCollection[2].Resource.Add(ResidentialConstructionResources[9]); + taskDetails[0].ChildCollection[3].ChildCollection[3].Resource.Add(ResidentialConstructionResources[7]); + + taskDetails[0].ChildCollection[4].ChildCollection[0].Resource.Add(ResidentialConstructionResources[8]); + taskDetails[0].ChildCollection[4].ChildCollection[1].Resource.Add(ResidentialConstructionResources[9]); + taskDetails[0].ChildCollection[4].ChildCollection[2].Resource.Add(ResidentialConstructionResources[8]); + + taskDetails[0].ChildCollection[5].ChildCollection[0].Resource.Add(ResidentialConstructionResources[14]); + taskDetails[0].ChildCollection[5].ChildCollection[1].Resource.Add(ResidentialConstructionResources[8]); + + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection[0].Resource.Add(ResidentialConstructionResources[10]); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection[1].Resource.Add(ResidentialConstructionResources[10]); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection[2].Resource.Add(ResidentialConstructionResources[10]); + + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[0].Resource.Add(ResidentialConstructionResources[12]); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[1].Resource.Add(ResidentialConstructionResources[12]); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[2].Resource.Add(ResidentialConstructionResources[12]); + + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection[0].Resource.Add(ResidentialConstructionResources[5]); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection[1].Resource.Add(ResidentialConstructionResources[5]); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection[2].Resource.Add(ResidentialConstructionResources[7]); + + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[0].Resource.Add(ResidentialConstructionResources[4]); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[1].Resource.Add(ResidentialConstructionResources[4]); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[2].Resource.Add(ResidentialConstructionResources[4]); + + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection[0].Resource.Add(ResidentialConstructionResources[13]); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection[1].Resource.Add(ResidentialConstructionResources[13]); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection[2].Resource.Add(ResidentialConstructionResources[14]); + + taskDetails[0].ChildCollection[7].ChildCollection[0].Resource.Add(ResidentialConstructionResources[16]); + taskDetails[0].ChildCollection[7].ChildCollection[1].Resource.Add(ResidentialConstructionResources[7]); + taskDetails[0].ChildCollection[7].ChildCollection[2].Resource.Add(ResidentialConstructionResources[1]); + + //Adding Predecessors + taskDetails[0].ChildCollection[0].ChildCollection[0].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 4, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[0].ChildCollection[0].ChildCollection[1].ChildCollection[4].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + + taskDetails[0].ChildCollection[0].ChildCollection[2].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[0].ChildCollection[0].ChildCollection[2].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[0].ChildCollection[0].ChildCollection[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + + taskDetails[0].ChildCollection[1].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 13, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[1].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 14, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[1].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 15, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[1].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 17, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[2].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 19, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[2].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 21, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 19, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[2].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 23, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[3].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 24, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[3].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 26, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[3].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 27, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[3].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 28, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[4].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 29, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[4].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 31, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[4].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 32, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[5].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 33, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[5].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 35, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 36, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 39, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[0].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 40, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 41, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 43, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 44, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 43, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 45, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 47, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 48, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 49, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 48, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 51, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[3].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 52, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 53, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 55, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[6].ChildCollection[4].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 56, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[0].ChildCollection[7].ChildCollection[0].Predecessor.Add(new Predecessor() { GanttTaskIndex = 57, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[7].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 59, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + taskDetails[0].ChildCollection[7].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 60, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + return taskDetails; + } + + /// + /// Gets the resources. + /// + /// + private static ObservableCollection GetResources() + { + ObservableCollection Resources = new ObservableCollection(); + Resources.Add(new Resource() { ID = 1, Name = "General Contractor" }); + Resources.Add(new Resource() { ID = 2, Name = "Owner" }); + Resources.Add(new Resource() { ID = 3, Name = "Architect" }); + Resources.Add(new Resource() { ID = 4, Name = "Site Excavation Contractor" }); + Resources.Add(new Resource() { ID = 5, Name = "Electrical Contractor" }); + Resources.Add(new Resource() { ID = 6, Name = "Plumbing Contractor" }); + Resources.Add(new Resource() { ID = 7, Name = "Concrete Contractor" }); + Resources.Add(new Resource() { ID = 8, Name = "Inspector" }); + Resources.Add(new Resource() { ID = 9, Name = "Framing Contractor" }); + Resources.Add(new Resource() { ID = 10, Name = "Roofing Contractor" }); + Resources.Add(new Resource() { ID = 11, Name = "Insulation Contractor" }); + Resources.Add(new Resource() { ID = 12, Name = "Drywall contractor" }); + Resources.Add(new Resource() { ID = 13, Name = "Painting Contractor" }); + Resources.Add(new Resource() { ID = 14, Name = "Flooring Contractor" }); + Resources.Add(new Resource() { ID = 15, Name = "Appliance Contractor" }); + Resources.Add(new Resource() { ID = 16, Name = "Masonry Contractor" }); + Resources.Add(new Resource() { ID = 17, Name = "MaID Service" }); + + return Resources; + } +} + +{% endhighlight %} +{% highlight c# %} + // To load the Variance Table View -this.Gantt.LoadVarianceTableView(); +this.ganttControl.LoadVarianceTableView(); // To load the Default [Editing] View -this.Gantt.LoadDefaultTableView(); +this.ganttControl.LoadDefaultTableView(); {% endhighlight %} {% endtabs %} The following image shows the BaseLine Table View: -![Baseline-Support_img1](Baseline-Support_images/Baseline-Support_img1.png) +![gantt-control-baseline-grid](Baseline-Support_images/gantt-control-baseline-grid.png) BaseLine Table View {:.caption} @@ -164,7 +739,7 @@ NA The following image shows the BaseLine Chart View: -![Baseline-Chart_img4](Baseline-Support_images/Baseline-Chart_img4.png) +![gantt-control-baseline-chart](Baseline-Support_images/gantt-control-baseline-chart.png) #### Samples @@ -186,7 +761,7 @@ Initially, Gantt will get loaded with a default set of columns. Then, you can ad This helps the Project Lead to store the estimation and will help to schedule the project in an efficient way by comparing the progress on planning itself. Organizations can have the default set of columns on Gantt Grid on loading, and when they need to compare a field with the estimate data, they can pick that column from the drop down. -![Baseline-Support_img2](Baseline-Support_images/Baseline-Support_img2.png) +![gantt-control-add-new-column](Baseline-Support_images/gantt-control-add-new-column.png) On-Demand Baseline Column Inclusion {:caption} @@ -222,33 +797,38 @@ The following codes illustrate Adding On-Demand Baseline Column Inclusion to an {% tabs %} {% highlight xaml %} - - - - - - + + + + + + + + + {% endhighlight %} {% highlight c# %} -// Displaying the Add New column drop down -this.Gantt.ShowAddNewColumn = true; +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +// Displaying the Add new column drop down +ganttControl.ShowAddNewColumn = true; +this.Content = ganttControl; {% endhighlight %} {% endtabs %} @@ -309,44 +889,49 @@ The following codes illustrate adding Project Statistics to an application: {% tabs %} {% highlight xaml %} - - - - - - + + + + + + + {% endhighlight %} {% highlight c# %} +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; // To get the Project Statistics -ProjectInfo projInfo = this.Gantt.GetProjectStatistics(); +ProjectInfo projInfo = this.ganttControl.GetProjectStatistics(); (or) ProjectInfo projInfo = new ProjectInfo(); -projInfo = this.Gantt.GetProjectStatistics(); +projInfo = this.ganttControl.GetProjectStatistics(); {% endhighlight %} {% endtabs %} Sample Project Statistic Visual: -![Baseline-Support_images3](Baseline-Support_images/Baseline-Support_img3.png) +![gantt-control-project-statistics](Baseline-Support_images/gantt-control-project-statistics.png) Project Statistics {:.caption} diff --git a/wpf/Gantt/calendar-customization.md b/wpf/Gantt/calendar-customization.md index bb045dd688..7c50657f0e 100644 --- a/wpf/Gantt/calendar-customization.md +++ b/wpf/Gantt/calendar-customization.md @@ -102,96 +102,409 @@ Define the value to weekdays, months, FY Numbering, default start time and defau The following code illustrates adding Calendar Customization to an Application: {% tabs %} -{% highlight xaml %} - - - - - - - - - - - - - - - +{% highlight xaml %} + + + + + + + + + {% endhighlight %} {% highlight c# %} +GanttControl ganttControl = new GanttControl(); +CalendarCustomizationViewModel viewModel = new CalendarCustomizationViewModel(); +ganttControl.DataContext = viewModel; +ganttControl.ItemsSource = viewModel.TaskCollection; //To set WeekBeginsOn -Gantt.WeekBeginsOn = DayOfWeek.Friday; +ganttControl.WeekBeginsOn = DayOfWeek.Friday; //To set FY Numbering -Gantt.IsFYNumberingEndbled = true; +ganttControl.IsFiscalYearNumberingEnabled = true; //To set FiscalYearBeginsOn -Gantt.FiscalYearBeginsOn = Month.June; +ganttControl.FiscalYearBeginsOn = Month.June; //To set DefaultStartTime -Gantt.DefaultStartTime = new TimeSpan(10,0,0); +ganttControl.DefaultStartTime = new TimeSpan(10, 0, 0); //To set DefaultEndTime -Gantt.DefaultEndTime = new TimeSpan(16, 0, 0); +ganttControl.DefaultEndTime = new TimeSpan(16, 0, 0); //To set Weekends -Gantt.Weekends = Days.Wednesday | Days.Thursday; +ganttControl.Weekends = Days.Wednesday | Days.Thursday; //To set ShowWeekends -Gantt.ShowWeekends = true; +ganttControl.ShowWeekends = true; //To set ExcludeWeekends -Gantt.ExcludeWeekends = true; +ganttControl.ExcludeWeekends = true; //To set ShowNonWorkingHoursBackground -Gantt.ShowNonWorkingHoursBackground = true; - -// To Set FY Numbering -Gantt.IsFYNumberingEndbled = true; +ganttControl.ShowNonWorkingHoursBackground = true; + +// Task attribute mapping +TaskAttributeMapping attributes = new TaskAttributeMapping(); +attributes.TaskNameMapping = "TaskName"; +attributes.TaskIdMapping = "TaskId"; +attributes.StartDateMapping = "StartDate"; +attributes.ChildMapping = "Child"; +attributes.FinishDateMapping = "FinishDate"; +attributes.DurationMapping = "Duration"; +attributes.ProgressMapping = "Progress"; +attributes.MileStoneMapping = "IsMileStone"; +attributes.PredecessorMapping = "Predecessor"; +ganttControl.TaskAttributeMapping = attributes; +this.Content = ganttControl; +{% endhighlight %} +{% highlight c# tabtitle="CalendarCustomizationViewModel.cs" %} + +public class CalendarCustomizationViewModel +{ + /// + /// Holds the collection value. + /// + private ObservableCollection _taskCollection; + + /// + /// Holds the default start value. + /// + private string[] defaultstart; + + /// + /// Holds the default end value. + /// + private string[] defaultend; + + /// + /// Holds the fynumbering value. + /// + private string[] fynumbering; + + + /// + /// Gets or sets the default start. + /// + /// The default start. + public string[] DefaultStart + { + get + { + return defaultstart; + } + set + { + defaultstart = value; + } + } + + /// + /// Gets or sets the default end. + /// + /// The default end. + public string[] DefaultEnd + { + get + { + return defaultend; + } + set + { + defaultend = value; + } + } + + /// + /// Gets or sets the FY numbering. + /// + /// The FY numbering. + public string[] FYNumbering + { + get + { + return fynumbering; + } + set + { + fynumbering = value; + } + } + + public string[] ShowHolidaysCollection { get; set; } + public string[] ExcludeHolidaysCollection { get; set; } + + public string[] ShowWeekendsCollection { get; set; } + + public string[] ExcludeWeekendsCollection { get; set; } + + /// + /// Gets or sets the Holidays collection. + /// + /// The Holiday collection. + public GanttHolidayCollection GanttHolidayCollection { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public CalendarCustomizationViewModel() + { + _taskCollection = GetData(); + ExcludeWeekendsCollection = ShowWeekendsCollection = ExcludeHolidaysCollection = ShowHolidaysCollection = FYNumbering = new string[] { "True", "False" }; + DefaultStart = new string[]{"12:00 AM","01:00 AM","02:00 AM","03:00 AM","04:00 AM","05:00 AM","06:00 AM","07:00 AM","08:00 AM","09:00 AM", + "10:00 AM","11:00 AM","12:00 PM","01:00 PM","02:00 PM","03:00 PM","04:00 PM","05:00 PM","06:00 PM","07:00 PM","08:00 PM","09:00 PM", + "10:00 PM","11:00 PM"}; + DefaultEnd = new string[]{"12:00 AM","01:00 AM","02:00 AM","03:00 AM","04:00 AM","05:00 AM","06:00 AM","07:00 AM","08:00 AM","09:00 AM", + "10:00 AM","11:00 AM","12:00 PM","01:00 PM","02:00 PM","03:00 PM","04:00 PM","05:00 PM","06:00 PM","07:00 PM","08:00 PM","09:00 PM", + "10:00 PM","11:00 PM"}; + this.GanttHolidayCollection = this.GetHolidayCollection(); + } + + /// + /// Gets the Holiday collection. + /// + /// The Holiday collection. + private GanttHolidayCollection GetHolidayCollection() + { + GanttHolidayCollection collection = new GanttHolidayCollection(); + collection.Add(new GanttHoliday { Day = new DateTime(2010, 6, 10), Background = Brushes.CadetBlue }); + collection.Add(new GanttHoliday { Day = new DateTime(2010, 7, 8), Background = Brushes.CadetBlue }); + collection.Add(new GanttHoliday { Day = new DateTime(2010, 8, 3), Background = Brushes.CadetBlue }); + collection.Add(new GanttHoliday { Day = new DateTime(2010, 9, 20), Background = Brushes.CadetBlue }); + return collection; + } + + + /// + /// Gets or sets the appointment item source. + /// + /// The appointment item source. + public ObservableCollection TaskCollection + { + get + { + return _taskCollection; + } + set + { + _taskCollection = value; + } + } + + /// + /// Gets the data. + /// + /// + public ObservableCollection GetData() + { + ObservableCollection taskDetails = new ObservableCollection(); + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 2), FinishDate = new DateTime(2010, 6, 18), TaskName = "Analysing Market Scope of the Product", TaskId = 1 }); + + ObservableCollection MarketAnalysis = new ObservableCollection(); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 2), FinishDate = new DateTime(2010, 6, 6), TaskName = "Current Market Review", TaskId = 2 }); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 6), FinishDate = new DateTime(2010, 6, 9), TaskName = "Establish milestone for future development", TaskId = 3 }); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 9), FinishDate = new DateTime(2010, 6, 10), TaskName = "Establish goals", TaskId = 4 }); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 10), FinishDate = new DateTime(2010, 6, 13), TaskName = "Sales, marketing and pricing plan", TaskId = 5 }); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 11), FinishDate = new DateTime(2010, 6, 14), TaskName = "Define product goals and milestones", TaskId = 6 }); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 12), FinishDate = new DateTime(2010, 6, 17), TaskName = "Organization status review", TaskId = 7 }); + MarketAnalysis.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 18), FinishDate = new DateTime(2010, 6, 18), TaskName = "Market Scope of Product clarified", TaskId = 8 }); + ObservableCollection predecessors = new ObservableCollection(); + predecessors.Add(new Predecessor { GanttTaskIndex = 2, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + predecessors.Add(new Predecessor { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + predecessors.Add(new Predecessor { GanttTaskIndex = 4, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + predecessors.Add(new Predecessor { GanttTaskIndex = 5, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + predecessors.Add(new Predecessor { GanttTaskIndex = 6, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + predecessors.Add(new Predecessor { GanttTaskIndex = 7, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + MarketAnalysis[6].Predecessor = predecessors; + + taskDetails[0].Child = MarketAnalysis; + + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 18), FinishDate = new DateTime(2010, 7, 14), TaskName = "Infrastructure for Product Planning", TaskId = 9 }); + ObservableCollection InfrastructureReq = new ObservableCollection(); + InfrastructureReq.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 18), FinishDate = new DateTime(2010, 6, 24), TaskName = "Define procedure for qualifying ideas", TaskId = 10 }); + InfrastructureReq.Add(new TaskDetails { StartDate = new DateTime(2010, 6, 24), FinishDate = new DateTime(2010, 7, 7), TaskName = "Define process for idea sharing", TaskId = 11 }); + InfrastructureReq.Add(new TaskDetails { StartDate = new DateTime(2010, 7, 7), FinishDate = new DateTime(2010, 7, 14), TaskName = "Infrastructure for Product planning Complete", TaskId = 12 }); + InfrastructureReq[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 10, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + InfrastructureReq[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 11, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[1].Child = InfrastructureReq; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 7, 14), FinishDate = new DateTime(2010, 8, 29), TaskName = "Product Definition Phase", TaskId = 13 }); + ObservableCollection Product = new ObservableCollection(); + Product.Add(new TaskDetails { StartDate = new DateTime(2010, 7, 14), FinishDate = new DateTime(2010, 7, 25), TaskName = "Identify product", TaskId = 14 }); + Product.Add(new TaskDetails { StartDate = new DateTime(2010, 7, 28), FinishDate = new DateTime(2010, 8, 1), TaskName = "Identify need for the product", TaskId = 15 }); + Product.Add(new TaskDetails { StartDate = new DateTime(2010, 8, 4), FinishDate = new DateTime(2010, 8, 8), TaskName = "Identify current trend for targets", TaskId = 16 }); + Product.Add(new TaskDetails { StartDate = new DateTime(2010, 8, 4), FinishDate = new DateTime(2010, 8, 29), TaskName = "Define product use and features", TaskId = 17 }); + Product.Add(new TaskDetails { StartDate = new DateTime(2010, 8, 4), FinishDate = new DateTime(2010, 8, 8), TaskName = "Identify competitor product", TaskId = 18 }); + Product.Add(new TaskDetails { StartDate = new DateTime(2010, 8, 29), FinishDate = new DateTime(2010, 8, 29), TaskName = "Product Definition Complete", TaskId = 19 }); + + Product[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 14, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Product[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 15, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Product[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 16, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Product[5].Predecessor.Add(new Predecessor { GanttTaskIndex = 16, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Product[5].Predecessor.Add(new Predecessor { GanttTaskIndex = 17, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Product[5].Predecessor.Add(new Predecessor { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + + taskDetails[2].Child = Product; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 10), TaskName = "Analysing Customer Requirement", TaskId = 20 }); + ObservableCollection Customer = new ObservableCollection(); + Customer.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 4), TaskName = "Identify Consumer of Products", TaskId = 21 }); + Customer.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 3), FinishDate = new DateTime(2010, 9, 6), TaskName = "Identify Customer Requirement", TaskId = 22 }); + Customer.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 5), FinishDate = new DateTime(2010, 9, 8), TaskName = "Analysing Customer Requiremet with current plan", TaskId = 23 }); + Customer.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 7), FinishDate = new DateTime(2010, 9, 10), TaskName = "Design based on Customer Requirement", TaskId = 24 }); + Customer.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 10), FinishDate = new DateTime(2010, 9, 10), TaskName = "Customer Requirement Analysis Complete", TaskId = 25 }); + Customer[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 21, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Customer[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 22, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Customer[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 23, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Customer[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 24, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[3].Child = Customer; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 10, 10), TaskName = "Competitor Analysis", TaskId = 26 }); + ObservableCollection Competitor = new ObservableCollection(); + Competitor.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 13), TaskName = "Define competitor with similar Product", TaskId = 27 }); + Competitor.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 13), FinishDate = new DateTime(2010, 9, 20), TaskName = "Define competitive advantage", TaskId = 28 }); + Competitor.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 22), FinishDate = new DateTime(2010, 9, 27), TaskName = "Identify competitive features", TaskId = 29 }); + Competitor.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 29), FinishDate = new DateTime(2010, 10, 10), TaskName = "Define how to build competitive features", TaskId = 30 }); + Competitor[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 27, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Competitor[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 28, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Competitor[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 29, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[4].Child = Competitor; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 9), FinishDate = new DateTime(2010, 9, 20), TaskName = "Defining Sucess Measure", TaskId = 31 }); + ObservableCollection Measure = new ObservableCollection(); + Measure.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 6), TaskName = "Identify Risks", TaskId = 32 }); + Measure.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 6), TaskName = "Define Key success measures", TaskId = 33 }); + Measure.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 7), FinishDate = new DateTime(2010, 9, 13), TaskName = "Define strategy to address risks", TaskId = 34 }); + Measure.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 13), FinishDate = new DateTime(2010, 9, 20), TaskName = "Define strategy to meet market position", TaskId = 35 }); + Measure.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 20), FinishDate = new DateTime(2010, 9, 20), TaskName = "Success Measure Defined", TaskId = 36 }); + + Measure[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 32, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Measure[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 33, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Measure[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 34, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Measure[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 35, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[5].Child = Measure; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 23), FinishDate = new DateTime(2010, 10, 17), TaskName = "Defining Team to Develop", TaskId = 37 }); + ObservableCollection Team = new ObservableCollection(); + Team.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 23), FinishDate = new DateTime(2010, 9, 27), TaskName = "Define successful team components for success", TaskId = 38 }); + Team.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 30), FinishDate = new DateTime(2010, 10, 3), TaskName = "Identify Key qualities needed to develop, produce and grow", TaskId = 39 }); + Team.Add(new TaskDetails { StartDate = new DateTime(2010, 10, 6), FinishDate = new DateTime(2010, 10, 10), TaskName = "Define current team members", TaskId = 40 }); + Team.Add(new TaskDetails { StartDate = new DateTime(2010, 10, 13), FinishDate = new DateTime(2010, 10, 17), TaskName = "Identify and address gaps", TaskId = 41 }); + Team.Add(new TaskDetails { StartDate = new DateTime(2010, 10, 17), FinishDate = new DateTime(2010, 10, 17), TaskName = "Team Defined", TaskId = 42 }); + + Team[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 38, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Team[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 39, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Team[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 40, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Team[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 41, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[6].Child = Team; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 24), TaskName = "Budgeting in the Product", TaskId = 43 }); + ObservableCollection Budget = new ObservableCollection(); + Budget.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 2), FinishDate = new DateTime(2010, 9, 3), TaskName = "Define financial metrics of product", TaskId = 44 }); + Budget.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 3), FinishDate = new DateTime(2010, 9, 13), TaskName = "Estimate cost need to develop", TaskId = 45 }); + Budget.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 13), FinishDate = new DateTime(2010, 9, 15), TaskName = "Estimate time to develop", TaskId = 46 }); + Budget.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 15), FinishDate = new DateTime(2010, 9, 20), TaskName = "Analyse resource cost", TaskId = 47 }); + Budget.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 20), FinishDate = new DateTime(2010, 9, 24), TaskName = "Define financial plan of Product", TaskId = 48 }); + Budget.Add(new TaskDetails { StartDate = new DateTime(2010, 9, 24), FinishDate = new DateTime(2010, 9, 24), TaskName = "Product Budget defined", TaskId = 49 }); + + Budget[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 44, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Budget[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 45, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Budget[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 46, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Budget[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 47, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Budget[5].Predecessor.Add(new Predecessor { GanttTaskIndex = 48, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[7].Child = Budget; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 10, 20), FinishDate = new DateTime(2010, 11, 10), TaskName = "Product Development", TaskId = 50 }); + ObservableCollection Development = new ObservableCollection(); + Development.Add(new TaskDetails { StartDate = new DateTime(2010, 10, 20), FinishDate = new DateTime(2010, 10, 30), TaskName = "Implementation Phase 1", TaskId = 51 }); + Development.Add(new TaskDetails { StartDate = new DateTime(2010, 10, 30), FinishDate = new DateTime(2010, 11, 10), TaskName = "Implementation Phase 2", TaskId = 52 }); + Development.Add(new TaskDetails { StartDate = new DateTime(2010, 11, 10), FinishDate = new DateTime(2010, 11, 10), TaskName = "Product Developed", TaskId = 53 }); + + Development[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 51, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Development[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 52, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[8].Child = Development; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 11, 8), FinishDate = new DateTime(2010, 11, 13), TaskName = "Product Review", TaskId = 54 }); + taskDetails[9].Child.Add(new TaskDetails { StartDate = new DateTime(2010, 11, 8), FinishDate = new DateTime(2010, 11, 10), TaskName = "Product Techincal Review", TaskId = 55 }); + taskDetails[9].Child.Add(new TaskDetails { StartDate = new DateTime(2010, 11, 9), FinishDate = new DateTime(2010, 11, 13), TaskName = "Product Cost Review", TaskId = 56 }); + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 11, 15), FinishDate = new DateTime(2010, 11, 30), TaskName = "Beta Testing", TaskId = 57 }); + ObservableCollection Testing = new ObservableCollection(); + Testing.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 15), FinishDate = new DateTime(2010, 11, 17), TaskName = "Disseminate completed product", TaskId = 58 })); + Testing.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 18), FinishDate = new DateTime(2010, 11, 20), TaskName = "Obtain feedback", TaskId = 59 })); + Testing.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 20), FinishDate = new DateTime(2010, 11, 25), TaskName = "Modification", TaskId = 60 })); + Testing.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 24), FinishDate = new DateTime(2010, 11, 30), TaskName = "Test", TaskId = 61 })); + Testing.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 30), FinishDate = new DateTime(2010, 11, 30), TaskName = "Testing Completed", TaskId = 62 })); + + Testing[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 58, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Testing[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 59, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Testing[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 60, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + Testing[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 61, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[10].Child = Testing; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 11, 25), FinishDate = new DateTime(2010, 12, 06), TaskName = "Post Product Review", TaskId = 63 }); + ObservableCollection PostReview = new ObservableCollection(); + PostReview.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 25), FinishDate = new DateTime(2010, 11, 27), TaskName = "Finalize cost analysis", TaskId = 64 })); + PostReview.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 27), FinishDate = new DateTime(2010, 11, 28), TaskName = "Analyze performance", TaskId = 65 })); + PostReview.Add((new TaskDetails { StartDate = new DateTime(2010, 11, 29), FinishDate = new DateTime(2010, 12, 2), TaskName = "Archive files", TaskId = 66 })); + PostReview.Add((new TaskDetails { StartDate = new DateTime(2010, 12, 2), FinishDate = new DateTime(2010, 12, 4), TaskName = "Document lessons learned", TaskId = 67 })); + PostReview.Add((new TaskDetails { StartDate = new DateTime(2010, 12, 4), FinishDate = new DateTime(2010, 12, 6), TaskName = "Distribute to team members", TaskId = 68 })); + PostReview.Add((new TaskDetails { StartDate = new DateTime(2010, 12, 6), FinishDate = new DateTime(2010, 12, 6), TaskName = "Post-project review complete", TaskId = 69 })); + + PostReview[1].Predecessor.Add(new Predecessor { GanttTaskIndex = 64, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + PostReview[2].Predecessor.Add(new Predecessor { GanttTaskIndex = 65, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + PostReview[3].Predecessor.Add(new Predecessor { GanttTaskIndex = 66, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + PostReview[4].Predecessor.Add(new Predecessor { GanttTaskIndex = 67, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + PostReview[5].Predecessor.Add(new Predecessor { GanttTaskIndex = 68, GanttTaskRelationship = GanttTaskRelationship.FinishToStart }); + + taskDetails[11].Child = PostReview; + + taskDetails.Add(new TaskDetails { StartDate = new DateTime(2010, 12, 10), FinishDate = new DateTime(2010, 12, 10), TaskName = "Product Released Successfully", TaskId = 70 }); + + return taskDetails; + } +} -{% endhighlight %} +{% endhighlight %} {% endtabs %} The following image shows Customized Calender and Weekends: - - -![Calendar-Customization_img1](Calendar-Customization_images/Calendar-Customization_img1.png) - - +![gantt-control-calendar-customization](Calendar-Customization_images/gantt-control-calendar-customization.png) Customized Calender {:.caption} diff --git a/wpf/Gantt/custom-tooltip.md b/wpf/Gantt/custom-tooltip.md index 1af5da4d41..3428d9027a 100644 --- a/wpf/Gantt/custom-tooltip.md +++ b/wpf/Gantt/custom-tooltip.md @@ -34,98 +34,382 @@ DataTemplate The following code illustrates how to add a custom tooltip to the Gantt control. +{% tabs %} {% highlight xaml %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + {% endhighlight %} +{% highlight c# tabtitle="Task.cs" %} +public class Task : INotifyPropertyChanged +{ + /// + /// Holds the start date and end date value. + /// + private DateTime startDate, endDate; -The following image shows Custom ToolTip: + /// + /// Holds the duration value. + /// + private TimeSpan duration; + + /// + /// Holds the progress value. + /// + private double progress; + + /// + /// Holds the id value. + /// + private int id; + + /// + /// Holds the name value. + /// + private string name; + + /// + /// Holds the collection value. + /// + private ObservableCollection childCollection; + + /// + /// Holds the resource value. + /// + private ObservableCollection resource; + + /// + /// Holds the predecessor value. + /// + private ObservableCollection predecessor; + + public Task() + { + this.ChildCollection = new ObservableCollection(); + this.Predecessor = new ObservableCollection(); + this.Resource = new ObservableCollection(); + } + + /// + /// Property for Start Date. + /// + public DateTime StartDate + { + get + { + return this.startDate; + } + set + { + this.startDate = value; + OnPropertyChanged("StartDate"); + } + } + + /// + /// Property for Finish Date. + /// + public DateTime EndDate + { + get + { + return this.endDate; + } + set + { + this.endDate = value; + OnPropertyChanged("EndDate"); + } + } + + /// + /// Property for duration value. + /// + public TimeSpan Duration + { + get + { + return this.duration; + } + set + { + this.duration = value; + OnPropertyChanged("Duration"); + } + } + + /// + /// Property for ID value. + /// + public int ID + { + get + { + return this.id; + } + set + { + this.id = value; + OnPropertyChanged("ID"); + } + } + + /// + /// Property for Name. + /// + public string Name + { + get + { + return this.name; + } + set + { + this.name = value; + OnPropertyChanged("Name"); + } + } + + /// + /// Property to define progress value. + /// + public double Progress + { + get + { + return this.progress; + } + set + { + this.progress = value; + OnPropertyChanged("Progress"); + } + } + + /// + /// Property to add child collection. + /// + public ObservableCollection ChildCollection + { + get + { + return this.childCollection; + } + set + { + this.childCollection = value; + OnPropertyChanged("ChildCollection"); + } + } + + /// + /// Property to define resource value. + /// + public ObservableCollection Resource + { + get + { + return this.resource; + } + set + { + this.resource = value; + OnPropertyChanged("Resource"); + } + } + + /// + /// Property to define predecessor value. + /// + public ObservableCollection Predecessor + { + get + { + return this.predecessor; + } + set + { + this.predecessor = value; + OnPropertyChanged("Predecessor"); + } + } + private void OnPropertyChanged(string propName) + { + if (this.PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propName)); + } + } + public event PropertyChangedEventHandler PropertyChanged; +} -![CustomToolTip_img1](CustomToolTip_images/CustomToolTip_img1.png) +{% endhighlight %} +{% highlight c# tabtitle="ViewModel.cs" %} + +public class ViewModel +{ + /// + /// Property to add task collection. + /// + public ObservableCollection TaskCollection { get; set; } + + public ViewModel() + { + this.TaskCollection = this.GetDataSource(); + } + + /// + /// Method to get taskDetails source. + /// + private ObservableCollection GetDataSource() + { + var taskDetails = new ObservableCollection(); + taskDetails.Add(new Task() { ID = 1, Name = "Scope", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 14), Progress = 40d, Resource = new ObservableCollection() { new Resource() { Name = "John" } } }); + taskDetails[0].ChildCollection.Add((new Task() { ID = 2, Name = "Determine project office scope", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 5), Progress = 20d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 3, Name = "Justify Project Offfice via business model", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 7), Progress = 20d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 4, Name = "Secure executive sponsorship", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 5, Name = "Secure Progress", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + + taskDetails.Add(new Task() { ID = 6, Name = "Risk Assessment", StartDate = new DateTime(2011, 7, 15), EndDate = new DateTime(2011, 7, 24), Resource = new ObservableCollection() { new Resource() { Name = "DavID" } } }); + taskDetails[1].ChildCollection.Add((new Task() { ID = 7, Name = "Perform risk assessment", StartDate = new DateTime(2011, 7, 15), EndDate = new DateTime(2011, 7, 21), Progress = 20d })); + taskDetails[1].ChildCollection.Add((new Task() { ID = 8, Name = "Evaluate risk assessment", StartDate = new DateTime(2011, 7, 21), EndDate = new DateTime(2011, 7, 23), Progress = 20d })); + taskDetails[1].ChildCollection.Add((new Task() { ID = 9, Name = "Prepare contingency plans", StartDate = new DateTime(2011, 7, 21), EndDate = new DateTime(2011, 7, 24), Progress = 20d })); + taskDetails[1].ChildCollection.Add((new Task() { ID = 10, Name = "Risk Assessment Progress", StartDate = new DateTime(2011, 7, 24), EndDate = new DateTime(2011, 7, 24), Progress = 30d })); + + taskDetails.Add(new Task() { ID = 11, Name = "Monitoring", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 8, 6), Duration = new TimeSpan(1, 0, 0, 0) }); + taskDetails[2].ChildCollection.Add((new Task() { ID = 12, Name = "Prepare Meeting agenda", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 7, 26), Progress = 20d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 13, Name = "Conduct review meeting", StartDate = new DateTime(2011, 7, 27), EndDate = new DateTime(2011, 7, 30), Progress = 20d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 14, Name = "Migrate critical issues", StartDate = new DateTime(2011, 7, 31), EndDate = new DateTime(2011, 8, 2), Progress = 20d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 15, Name = "Estabilish change mgmt Control", StartDate = new DateTime(2011, 8, 3), EndDate = new DateTime(2011, 8, 6), Progress = 30d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 16, Name = "Monitoring Progress", StartDate = new DateTime(2011, 8, 6), EndDate = new DateTime(2011, 8, 6), Progress = 30d })); + + taskDetails.Add(new Task() { ID = 17, Name = "Post Implementation", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 8, 12) }); + taskDetails[3].ChildCollection.Add((new Task() { ID = 18, Name = "Obtain User feedback", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 7, 29), Progress = 20d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 19, Name = "Evaluate lessons learned", StartDate = new DateTime(2011, 7, 29), EndDate = new DateTime(2011, 8, 5), Progress = 20d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 20, Name = "Modify items as necessary", StartDate = new DateTime(2011, 8, 2), EndDate = new DateTime(2011, 8, 8), Progress = 20d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 21, Name = "Post Implementation Progress", StartDate = new DateTime(2011, 8, 8), EndDate = new DateTime(2011, 8, 12), Progress = 30d })); + + + taskDetails[0].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 2, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[0].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[0].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + taskDetails[1].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 9, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 10, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[1].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 7, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + taskDetails[2].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[2].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + + taskDetails[3].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[3].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[3].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 19, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + return taskDetails; + } +} + +{% endhighlight %} +{% endtabs %} + +The following image shows Custom ToolTip: +![gantt-control-custom-tooltip](CustomToolTip_images/gantt-control-custom-tooltip.png) Custom ToolTip Demo diff --git a/wpf/Gantt/data-binding.md b/wpf/Gantt/data-binding.md index 510b08c215..cea50ceebd 100644 --- a/wpf/Gantt/data-binding.md +++ b/wpf/Gantt/data-binding.md @@ -15,102 +15,118 @@ Essential Gantt for WPF includes an built-in class called TaskDetails, which is #### Use Case Scenarios -You can easily create the task details collection using the TaskDetails class or by creating a new class by inheriting the IGantt interface. +You can easily create the taskDetails details collection using the TaskDetails class or by creating a new class by inheriting the IGantt interface. Binding TaskDetails collection to Gantt Control The following code illustrates how to bind the Task Details to the Gantt Control: {% tabs %} + {% highlight xaml %} - - - - - + + + + + + + + + +{% endhighlight %} -{% endhighlight %} {% highlight c# %} -GanttControl Gantt = new GanttControl(); -ViewModel model = new ViewModel(); -this.Gantt.DataContext = model; -Gantt.ItemsSource = model.GanttItemSource; +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; + +{% endhighlight %} + +{% highlight c# tabtitle="ViewModel.cs" %} public class ViewModel { - public ObservableCollection TaskCollection { get; set; } + /// + /// Holds the collection value. + /// + private ObservableCollection taskDetails; + public ViewModel() { - TaskCollection = this.GetDataSource(); + this.taskDetails = this.GetTaskDetails(); + } + + /// + /// Gets or sets the task collection. + /// + /// The task collection. + public ObservableCollection TaskDetails + { + get + { + return taskDetails; + } + set + { + this.taskDetails = value; + } } - private ObservableCollection GetDataSource() + /// + /// Gets the task details. + /// + /// + ObservableCollection GetTaskDetails() { - ObservableCollection task = new ObservableCollection(); - task.Add( - new TaskDetails - { - TaskId = 1, - TaskName = "Scope", - StartDate = new DateTime(2011, 1, 3), - FinishDate = new DateTime(2011, 1, 14), - Progress = 40d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 2, - TaskName = "Determine project office scope", - StartDate = new DateTime(2011, 1, 3), - FinishDate = new DateTime(2011, 1, 5), - Progress = 20d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 3, - TaskName = "Justify project office via business model", - StartDate = new DateTime(2011, 1, 6), - FinishDate = new DateTime(2011, 1, 7), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 4, - TaskName = "Secure executive sponsorship", - StartDate = new DateTime(2011, 1, 10), - FinishDate = new DateTime(2011, 1, 14), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 5, - TaskName = "Secure complete", - StartDate = new DateTime(2011, 1, 14), - FinishDate = new DateTime(2011, 1, 14), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - return task; + ObservableCollection taskDetails = new ObservableCollection(); + taskDetails.Add(new TaskDetails { TaskId = 1, TaskName = "Scope", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 14), Progress = 40d }); + taskDetails[0].Child.Add(new TaskDetails { TaskId = 2, TaskName = "Determine project office scope", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 5), Progress = 20d }); + taskDetails[0].Child.Add(new TaskDetails { TaskId = 3, TaskName = "Justify Project Offfice via business model", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 7), Progress = 20d }); + taskDetails[0].Child.Add(new TaskDetails { TaskId = 4, TaskName = "Secure executive sponsorship", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 14), Progress = 20d }); + taskDetails[0].Child.Add(new TaskDetails { TaskId = 5, TaskName = "Secure complete", StartDate = new DateTime(2011, 7, 14), FinishDate = new DateTime(2011, 7, 14), Progress = 20d }); + + taskDetails.Add(new TaskDetails { TaskId = 6, TaskName = "Risk Assessment", StartDate = new DateTime(2011, 7, 8), FinishDate = new DateTime(2011, 7, 24), Progress = 30d }); + + taskDetails[1].Child.Add(new TaskDetails { TaskId = 7, TaskName = "Perform risk assessment", StartDate = new DateTime(2011, 7, 8), FinishDate = new DateTime(2011, 7, 21), Progress = 20d }); + taskDetails[1].Child.Add(new TaskDetails { TaskId = 8, TaskName = "Evaluate risk assessment", StartDate = new DateTime(2011, 7, 8), FinishDate = new DateTime(2011, 7, 23), Progress = 30d }); + taskDetails[1].Child.Add(new TaskDetails { TaskId = 9, TaskName = "Prepare contingency plans", StartDate = new DateTime(2011, 7, 12), FinishDate = new DateTime(2011, 7, 24), Progress = 30d }); + taskDetails[1].Child.Add(new TaskDetails { TaskId = 10, TaskName = "Risk Assessment complete", StartDate = new DateTime(2011, 7, 15), FinishDate = new DateTime(2011, 7, 24), Progress = 30d }); + + taskDetails.Add(new TaskDetails { TaskId = 11, TaskName = "Monitoring", StartDate = new DateTime(2011, 7, 13), FinishDate = new DateTime(2011, 8, 6), Progress = 40d }); + taskDetails[2].Child.Add(new TaskDetails { TaskId = 12, TaskName = "Prepare Meeting agenda", StartDate = new DateTime(2011, 7, 13), FinishDate = new DateTime(2011, 7, 26), Progress = 30d }); + taskDetails[2].Child.Add(new TaskDetails { TaskId = 13, TaskName = "Conduct review meeting", StartDate = new DateTime(2011, 7, 13), FinishDate = new DateTime(2011, 7, 30), Progress = 30d }); + taskDetails[2].Child.Add(new TaskDetails { TaskId = 14, TaskName = "Migrate critical issues", StartDate = new DateTime(2011, 7, 18), FinishDate = new DateTime(2011, 8, 2), Progress = 30d }); + taskDetails[2].Child.Add(new TaskDetails { TaskId = 15, TaskName = "Estabilish change mgmt Control", StartDate = new DateTime(2011, 8, 3), FinishDate = new DateTime(2011, 8, 6), Progress = 30d }); + taskDetails[2].Child.Add(new TaskDetails { TaskId = 16, TaskName = "Monitoring Complete", StartDate = new DateTime(2011, 8, 6), FinishDate = new DateTime(2011, 8, 6), Progress = 30d }); + + taskDetails.Add(new TaskDetails { TaskId = 17, TaskName = "Post Implementation", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 19), Progress = 40d }); + taskDetails[3].Child.Add(new TaskDetails { TaskId = 18, TaskName = "Obtain User feedback", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 10), Progress = 30d }); + taskDetails[3].Child.Add(new TaskDetails { TaskId = 19, TaskName = "Evaluate lessons learned", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 17), Progress = 30d }); + taskDetails[3].Child.Add(new TaskDetails { TaskId = 20, TaskName = "Modify items as necessary", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 19), Progress = 30d }); + taskDetails[3].Child.Add(new TaskDetails { TaskId = 21, TaskName = "Post Implementation complete", StartDate = new DateTime(2011, 8, 19), FinishDate = new DateTime(2011, 8, 19), Progress = 30d }); + + taskDetails[0].Resources = new ObservableCollection() { new Resource { ID = 1, Name = "John" }, new Resource { ID = 2, Name = "Neil" } }; + taskDetails[0].Child[3].Resources = new ObservableCollection() { new Resource() { ID = 3, Name = "Peter" } }; + taskDetails[1].Resources = new ObservableCollection() { new Resource() { ID = 4, Name = "David" } }; + return taskDetails; } } + {% endhighlight %} {% endtabs %} -The following image shows the BindingTask Details: +The following image shows the binding TaskDetails: -![Data-Binding_img1](Data-Binding_images/Data-Binding_img1.png) +![gantt-control-taskdetails-binding](Data-Binding_images/gantt-control-taskdetails-binding.png) #### Samples Link @@ -132,31 +148,41 @@ The following code illustrate how to map the properties using the TaskAttributeM {% tabs %} {% highlight xaml %} - - + + + + + + + + {% endhighlight %} {% highlight c# %} -TaskAttributeMapping attributes = new TaskAttributeMapping(); -attributes.TaskIdMapping = "Id"; -attributes.TaskNameMapping = "Name"; -attributes.StartDateMapping = "StartDate"; -attributes.FinishDateMapping = "EndDate"; -attributes.DurationMapping = "Duration"; -attributes.ChildMapping = "ChildTask"; -attributes.ResourceInfoMapping = "Resource"; -attributes.ProgressMapping = "Predecessor"; -this.Gantt.TaskAttributeMapping = attributes; +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +TaskAttributeMapping taskAttributeMapping = new TaskAttributeMapping(); +taskAttributeMapping.ChildMapping = "ChildCollection"; +taskAttributeMapping.DurationMapping = "Duration"; +taskAttributeMapping.FinishDateMapping = "EndDate"; +taskAttributeMapping.PredecessorMapping = "Predecessor"; +taskAttributeMapping.ProgressMapping = "Progress"; +taskAttributeMapping.ResourceInfoMapping = "Resource"; +taskAttributeMapping.StartDateMapping = "StartDate"; +taskAttributeMapping.TaskIdMapping = "ID"; +taskAttributeMapping.TaskNameMapping = "Name"; +this.ganttControl.TaskAttributeMapping = taskAttributeMapping; +this.Content = ganttControl; {% endhighlight %} {% endtabs %} @@ -166,54 +192,96 @@ The following code illustrates how to bind the external source to Gantt control: {% tabs %} {% highlight xaml %} - - - - - - - - - + + + + + + + + {% endhighlight %} {% highlight c# %} - //Initializing Gantt - GanttControl Gantt = new GanttControl(); - ViewModel model=  new ViewModel(); - TaskAttributeMapping attributes = new TaskAttributeMapping(); - attributes.TaskIdMapping = "ID"; - attributes.TaskNameMapping = "Name"; - attributes.StartDateMapping = "StartDate"; - attributes.FinishDateMapping = "EndDate"; - attributes.DurationMapping = "Duration"; - attributes.ChildMapping = "ChildCollection";  - this.Gantt.DataContext = model; - Gantt.TaskAttributeMapping = attributes; - Gantt.ItemsSource = model.GanttItemSource; +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskCollection; + +// Task attribute mapping +TaskAttributeMapping taskAttributeMapping = new TaskAttributeMapping(); +taskAttributeMapping.ChildMapping = "ChildCollection"; +taskAttributeMapping.DurationMapping = "Duration"; +taskAttributeMapping.FinishDateMapping = "EndDate"; +taskAttributeMapping.PredecessorMapping = "Predecessor"; +taskAttributeMapping.ProgressMapping = "Progress"; +taskAttributeMapping.ResourceInfoMapping = "Resource"; +taskAttributeMapping.StartDateMapping = "StartDate"; +taskAttributeMapping.TaskIdMapping = "ID"; +taskAttributeMapping.TaskNameMapping = "Name"; +this.ganttControl.TaskAttributeMapping = taskAttributeMapping; +this.Content = ganttControl; + +{% endhighlight %} +{% highlight c# tabtitle="Task.cs" %} public class Task : INotifyPropertyChanged -{ - private DateTime startDate,endDate; - +{ + /// + /// Holds the start date and end date value. + /// + private DateTime startDate, endDate; + + /// + /// Holds the duration value. + /// private TimeSpan duration; - + + /// + /// Holds the progress value. + /// private double progress; - + + /// + /// Holds the id value. + /// private int id; + /// + /// Holds the name value. + /// private string name; + /// + /// Holds the collection value. + /// private ObservableCollection childCollection; + /// + /// Holds the resource value. + /// + private ObservableCollection resource; + + /// + /// Holds the predecessor value. + /// + private ObservableCollection predecessor; + + public Task() + { + this.ChildCollection = new ObservableCollection(); + this.Predecessor = new ObservableCollection(); + this.Resource = new ObservableCollection(); + } + /// /// Property for Start Date. /// @@ -261,11 +329,11 @@ public class Task : INotifyPropertyChanged OnPropertyChanged("Duration"); } } - + /// /// Property for ID value. /// - public int ID + public int ID { get { @@ -277,11 +345,11 @@ public class Task : INotifyPropertyChanged OnPropertyChanged("ID"); } } - + /// /// Property for Name. /// - public string Name + public string Name { get { @@ -293,11 +361,11 @@ public class Task : INotifyPropertyChanged OnPropertyChanged("Name"); } } - + /// /// Property to define progress value. /// - public double Progress + public double Progress { get { @@ -310,6 +378,9 @@ public class Task : INotifyPropertyChanged } } + /// + /// Property to add child collection. + /// public ObservableCollection ChildCollection { get @@ -322,96 +393,133 @@ public class Task : INotifyPropertyChanged OnPropertyChanged("ChildCollection"); } } - + + /// + /// Property to define resource value. + /// + public ObservableCollection Resource + { + get + { + return this.resource; + } + set + { + this.resource = value; + OnPropertyChanged("Resource"); + } + } + + /// + /// Property to define predecessor value. + /// + public ObservableCollection Predecessor + { + get + { + return this.predecessor; + } + set + { + this.predecessor = value; + OnPropertyChanged("Predecessor"); + } + } + private void OnPropertyChanged(string propName) { if (this.PropertyChanged != null) { - PropertyChanged(this,new PropertyChangedEventArgs(propName)); + PropertyChanged(this, new PropertyChangedEventArgs(propName)); } } - + public event PropertyChangedEventHandler PropertyChanged; } + +{% endhighlight %} +{% highlight c# tabtitle="ViewModel.cs" %} public class ViewModel { + /// + /// Property to add task collection. + /// public ObservableCollection TaskCollection { get; set; } - + public ViewModel() { - TaskCollection = this.GetDataSource(); + this.TaskCollection = this.GetDataSource(); } private ObservableCollection GetDataSource() { - ObservableCollection task = new ObservableCollection(); - task.Add( - new Task - { - ID = 1, - Name = "Scope", - StartDate = new DateTime(2011, 1, 3), - EndDate = new DateTime(2011, 1, 14), - Progress = 40d - }); - - task[0].ChildCollection = new ObservableCollection(); - task[0].ChildCollection.Add( - new Task - { - ID = 2, - Name = "Determine project office scope", - StartDate = new DateTime(2011, 1, 3), - EndDate = new DateTime(2011, 1, 5), - Progress = 20d - }); - - task[0].ChildCollection.Add( - new Task - { - ID = 3, - Name = "Justify project office via business model", - StartDate = new DateTime(2011, 1, 6), - EndDate = new DateTime(2011, 1, 7), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - task[0].ChildCollection.Add( - new Task - { - ID = 4, - Name = "Secure executive sponsorship", - StartDate = new DateTime(2011, 1, 10), - EndDate = new DateTime(2011, 1, 14), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - task[0].ChildCollection.Add( - new Task - { - ID = 5, - Name = "Secure complete", - StartDate = new DateTime(2011, 1, 14), - EndDate = new DateTime(2011, 1, 14), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - return task; - } + + var data = new ObservableCollection(); + data.Add(new Task() { ID = 1, Name = "Scope", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 14), Progress = 40d }); + data[0].ChildCollection.Add((new Task() { ID = 2, Name = "Determine project office scope", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 5), Progress = 20d, })); + data[0].ChildCollection.Add((new Task() { ID = 3, Name = "Justify Project Offfice via business model", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 7), Progress = 20d })); + data[0].ChildCollection.Add((new Task() { ID = 4, Name = "Secure executive sponsorship", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d, })); + data[0].ChildCollection.Add((new Task() { ID = 5, Name = "Secure Progress", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + + data.Add(new Task() { ID = 6, Name = "Risk Assessment", StartDate = new DateTime(2011, 7, 15), EndDate = new DateTime(2011, 7, 24) }); + data[1].ChildCollection.Add((new Task() { ID = 7, Name = "Perform risk assessment", StartDate = new DateTime(2011, 7, 15), EndDate = new DateTime(2011, 7, 21), Progress = 20d, })); + data[1].ChildCollection.Add((new Task() { ID = 8, Name = "Evaluate risk assessment", StartDate = new DateTime(2011, 7, 21), EndDate = new DateTime(2011, 7, 23), Progress = 20d, })); + data[1].ChildCollection.Add((new Task() { ID = 9, Name = "Prepare contingency plans", StartDate = new DateTime(2011, 7, 21), EndDate = new DateTime(2011, 7, 24), Progress = 20d, })); + data[1].ChildCollection.Add((new Task() { ID = 10, Name = "Risk Assessment Progress", StartDate = new DateTime(2011, 7, 24), EndDate = new DateTime(2011, 7, 24), Progress = 30d })); + + data.Add(new Task() { ID = 11, Name = "Monitoring", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 8, 6), Duration = new TimeSpan(1, 0, 0, 0) }); + data[2].ChildCollection.Add((new Task() { ID = 12, Name = "Prepare Meeting agenda", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 7, 26), Progress = 20d, })); + data[2].ChildCollection.Add((new Task() { ID = 13, Name = "Conduct review meeting", StartDate = new DateTime(2011, 7, 27), EndDate = new DateTime(2011, 7, 30), Progress = 20d, })); + data[2].ChildCollection.Add((new Task() { ID = 14, Name = "Migrate critical issues", StartDate = new DateTime(2011, 7, 31), EndDate = new DateTime(2011, 8, 2), Progress = 20d, })); + data[2].ChildCollection.Add((new Task() { ID = 15, Name = "Estabilish change mgmt Control", StartDate = new DateTime(2011, 8, 3), EndDate = new DateTime(2011, 8, 6), Progress = 30d, })); + data[2].ChildCollection.Add((new Task() { ID = 16, Name = "Monitoring Progress", StartDate = new DateTime(2011, 8, 6), EndDate = new DateTime(2011, 8, 6), Progress = 30d })); + + data.Add(new Task() { ID = 17, Name = "Post Implementation", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 8, 12) }); + data[3].ChildCollection.Add((new Task() { ID = 18, Name = "Obtain User feedback", StartDate = new DateTime(2011, 7, 25), EndDate = new DateTime(2011, 7, 29), Progress = 20d, })); + data[3].ChildCollection.Add((new Task() { ID = 19, Name = "Evaluate lessons learned", StartDate = new DateTime(2011, 7, 29), EndDate = new DateTime(2011, 8, 5), Progress = 20d, })); + data[3].ChildCollection.Add((new Task() { ID = 20, Name = "Modify items as necessary", StartDate = new DateTime(2011, 8, 2), EndDate = new DateTime(2011, 8, 8), Progress = 20d, })); + data[3].ChildCollection.Add((new Task() { ID = 21, Name = "Post Implementation Progress", StartDate = new DateTime(2011, 8, 8), EndDate = new DateTime(2011, 8, 12), Progress = 30d })); + + data[0].ChildCollection[0].Resource.Add(new Resource() { ID = 1, Name = "Leslie" }); + data[0].ChildCollection[1].Resource.Add(new Resource() { ID = 2, Name = "John" }); + data[0].ChildCollection[2].Resource.Add(new Resource() { ID = 3, Name = "DavID" }); + data[0].ChildCollection[3].Resource.Add(new Resource() { ID = 4, Name = "Peter" }); + + data[1].ChildCollection[0].Resource.Add(new Resource() { ID = 5, Name = "Neil" }); + data[1].ChildCollection[1].Resource.Add(new Resource() { ID = 7, Name = "Johnson" }); + data[1].ChildCollection[1].Resource.Add(new Resource() { ID = 8, Name = "Julie" }); + data[1].ChildCollection[2].Resource.Add(new Resource() { ID = 9, Name = "Peterson" }); + data[1].ChildCollection[3].Resource.Add(new Resource() { ID = 10, Name = "Thomas" }); + + data[3].ChildCollection[1].Resource.Add(new Resource() { ID = 5, Name = "DavID" }); + data[3].ChildCollection[2].Resource.Add(new Resource() { ID = 7, Name = "Peter" }); + data[3].ChildCollection[3].Resource.Add(new Resource() { ID = 8, Name = "Thomas" }); + + data[0].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 2, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + data[0].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + data[0].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + data[1].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 9, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + data[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 10, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + data[1].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 7, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + data[2].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + data[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + data[2].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + + data[3].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + data[3].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + data[3].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 19, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + return data; + } } {% endhighlight %} {% endtabs %} The following image shows the External Property Binding: - - - -![Data-Binding_img2](Data-Binding_images/Data-Binding_img2.png) +![gantt-control-external-property-binding](Data-Binding_images/gantt-control-external-property-binding.png) #### Samples Link diff --git a/wpf/Gantt/dependency-relationship.md b/wpf/Gantt/dependency-relationship.md index e9461c9a98..800c8f9327 100644 --- a/wpf/Gantt/dependency-relationship.md +++ b/wpf/Gantt/dependency-relationship.md @@ -71,36 +71,344 @@ Specifying the Relationship between Tasks The following code illustrates how to add the Dependency Relationship between tasks: +{% tabs %} +{% highlight xaml %} + + + + + + + + + + +{% endhighlight %} {% highlight c# %} +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskCollection; +this.Content = ganttControl; + +// Task attribute mapping +TaskAttributeMapping taskAttributeMapping = new TaskAttributeMapping(); +taskAttributeMapping.ChildMapping = "ChildCollection"; +taskAttributeMapping.DurationMapping = "Duration"; +taskAttributeMapping.FinishDateMapping = "EndDate"; +taskAttributeMapping.PredecessorMapping = "Predecessor"; +taskAttributeMapping.ProgressMapping = "Progress"; +taskAttributeMapping.ResourceInfoMapping = "Resource"; +taskAttributeMapping.StartDateMapping = "StartDate"; +taskAttributeMapping.TaskIdMapping = "ID"; +taskAttributeMapping.TaskNameMapping = "Name"; +this.ganttControl.TaskAttributeMapping = taskAttributeMapping; +this.Content = ganttControl; - // Adding dependency relationship. -task[0].ChildCollection[1].Predecessors = new ObservableCollection( -task[0].ChildCollection[1].Predecessors.Add(new Predecessor() - { - GanttTaskIndex = - GanttTaskRelationship = GanttTaskRelationship.StartToStart - }); - -task[0].ChildCollection[2].Predecessors = new ObservableCollection(); -task[0].ChildCollection[2].Predecessors.Add(new Predecessor() - { - GanttTaskIndex = - GanttTaskRelationship = GanttTaskRelationship.StartToFinish - }); - -task[0].ChildCollection[3].Predecessors = new ObservableCollection(); -task[0].ChildCollection[3].Predecessors.Add(new Predecessor() - { - GanttTaskIndex = - GanttTaskRelationship = GanttTaskRelationship.FinishToFinish - }); +{% endhighlight %} +{% highlight c# tabtitle="Task.cs" %} + +public class Task : INotifyPropertyChanged +{ + /// + /// Holds the start date and end date value. + /// + private DateTime startDate, endDate; + + /// + /// Holds the duration value. + /// + private TimeSpan duration; + + /// + /// Holds the progress value. + /// + private double progress; + + /// + /// Holds the id value. + /// + private int id; + + /// + /// Holds the name value. + /// + private string name; + + /// + /// Holds the collection value. + /// + private ObservableCollection childCollection; + + /// + /// Holds the resource value. + /// + private ObservableCollection resource; + + /// + /// Holds the predecessor value. + /// + private ObservableCollection predecessor; + + public Task() + { + this.ChildCollection = new ObservableCollection(); + this.Predecessor = new ObservableCollection(); + this.Resource = new ObservableCollection(); + } + + /// + /// Property for Start Date. + /// + public DateTime StartDate + { + get + { + return this.startDate; + } + set + { + this.startDate = value; + OnPropertyChanged("StartDate"); + } + } + + /// + /// Property for Finish Date. + /// + public DateTime EndDate + { + get + { + return this.endDate; + } + set + { + this.endDate = value; + OnPropertyChanged("EndDate"); + } + } + + /// + /// Property for duration value. + /// + public TimeSpan Duration + { + get + { + return this.duration; + } + set + { + this.duration = value; + OnPropertyChanged("Duration"); + } + } + + /// + /// Property for ID value. + /// + public int ID + { + get + { + return this.id; + } + set + { + this.id = value; + OnPropertyChanged("ID"); + } + } + + /// + /// Property for Name. + /// + public string Name + { + get + { + return this.name; + } + set + { + this.name = value; + OnPropertyChanged("Name"); + } + } + + /// + /// Property to define progress value. + /// + public double Progress + { + get + { + return this.progress; + } + set + { + this.progress = value; + OnPropertyChanged("Progress"); + } + } + + /// + /// Property to add child collection. + /// + public ObservableCollection ChildCollection + { + get + { + return this.childCollection; + } + set + { + this.childCollection = value; + OnPropertyChanged("ChildCollection"); + } + } + + /// + /// Property to define resource value. + /// + public ObservableCollection Resource + { + get + { + return this.resource; + } + set + { + this.resource = value; + OnPropertyChanged("Resource"); + } + } + + /// + /// Property to define predecessor value. + /// + public ObservableCollection Predecessor + { + get + { + return this.predecessor; + } + set + { + this.predecessor = value; + OnPropertyChanged("Predecessor"); + } + } + + private void OnPropertyChanged(string propName) + { + if (this.PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propName)); + } + } + + public event PropertyChangedEventHandler PropertyChanged; +} + +{% endhighlight %} +{% highlight c# tabtitle="ViewModel.cs" %} + +public class ViewModel +{ + /// + /// Property to add task collection. + /// + public ObservableCollection TaskCollection { get; set; } + + public ViewModel() + { + this.TaskCollection = this.GetDataSource(); + } + + private ObservableCollection GetDataSource() + { + + var taskDetails = new ObservableCollection(); + taskDetails.Add(new Task() { ID = 1, Name = "Analysis/Planning", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 8, 14), Progress = 40d }); + taskDetails[0].ChildCollection.Add((new Task() { ID = 2, Name = "IDentify Components to be Localized", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 5), Progress = 20d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 3, Name = "Ensure file localizability", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 7), Progress = 20d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 4, Name = "IDentify tools", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 5, Name = "Test tools", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 8, 1), Progress = 10d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 6, Name = "Develop delivery timeline", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 8, 1), Progress = 10d })); + taskDetails[0].ChildCollection.Add((new Task() { ID = 7, Name = "Analysis Progress", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 8, 10), Progress = 10d })); + + taskDetails.Add(new Task() { ID = 8, Name = "Production", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 14), Progress = 40d }); + taskDetails[1].ChildCollection.Add((new Task() { ID = 9, Name = "Software Components", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 5), Progress = 20d, })); + taskDetails[1].ChildCollection.Add((new Task() { ID = 10, Name = "Localization Component - User Interface", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 7), Progress = 20d })); + taskDetails[1].ChildCollection.Add((new Task() { ID = 11, Name = "User Assistance Components", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + taskDetails[1].ChildCollection.Add((new Task() { ID = 12, Name = "Software components Progress", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 7, 18), Progress = 10d })); + + + taskDetails.Add(new Task() { ID = 13, Name = "Quality Assurance", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 12), Progress = 40d, }); + taskDetails[2].ChildCollection.Add((new Task() { ID = 14, Name = "Review project information", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 15), Progress = 20d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 15, Name = "Localization Component", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 8), Progress = 20d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 16, Name = "Localization Component", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + taskDetails[2].ChildCollection.Add((new Task() { ID = 17, Name = "Localization Component", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 7, 18), Progress = 10d })); + + taskDetails.Add(new Task() { ID = 18, Name = "Beta Testing", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 14), Progress = 40d }); + taskDetails[3].ChildCollection.Add((new Task() { ID = 19, Name = "Disseminate Progressd product", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 5), Progress = 20d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 20, Name = "Obtain feedback", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 7), Progress = 20d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 21, Name = "Modify", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 19), Progress = 10d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 22, Name = "Test", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 7, 19), Progress = 10d })); + taskDetails[3].ChildCollection.Add((new Task() { ID = 23, Name = "Progress", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 19), Progress = 10d })); + + taskDetails.Add(new Task() { ID = 24, Name = "Post-Project Review", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 14), Progress = 40d, }); + taskDetails[4].ChildCollection.Add((new Task() { ID = 25, Name = "Finalize cost analysis", StartDate = new DateTime(2011, 7, 3), EndDate = new DateTime(2011, 7, 5), Progress = 20d })); + taskDetails[4].ChildCollection.Add((new Task() { ID = 26, Name = "Analyze performance", StartDate = new DateTime(2011, 7, 6), EndDate = new DateTime(2011, 7, 7), Progress = 20d })); + taskDetails[4].ChildCollection.Add((new Task() { ID = 27, Name = "Archive files", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + taskDetails[4].ChildCollection.Add((new Task() { ID = 28, Name = "Document lessons learned", StartDate = new DateTime(2011, 7, 14), EndDate = new DateTime(2011, 7, 18), Progress = 10d })); + taskDetails[4].ChildCollection.Add((new Task() { ID = 29, Name = "Distribute to team members", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + taskDetails[4].ChildCollection.Add((new Task() { ID = 30, Name = "Post-project review Progress", StartDate = new DateTime(2011, 7, 10), EndDate = new DateTime(2011, 7, 14), Progress = 10d })); + + taskDetails[1].Resource.Add(new Resource() { ID = 1, Name = "Localizer" }); + taskDetails[2].Resource.Add(new Resource() { ID = 2, Name = "Technical Reviewer" }); + taskDetails[3].Resource.Add(new Resource() { ID = 3, Name = "Project Manager" }); + + taskDetails[0].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 2, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[0].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[0].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 3, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + taskDetails[1].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 9, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[1].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 10, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[1].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 7, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + taskDetails[2].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[2].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + taskDetails[2].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 12, GanttTaskRelationship = GanttTaskRelationship.FinishToFinish }); + + taskDetails[3].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[3].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 18, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[3].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 19, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + + taskDetails[4].ChildCollection[1].Predecessor.Add(new Predecessor() { GanttTaskIndex = 25, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[4].ChildCollection[2].Predecessor.Add(new Predecessor() { GanttTaskIndex = 28, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[4].ChildCollection[3].Predecessor.Add(new Predecessor() { GanttTaskIndex = 30, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + taskDetails[4].ChildCollection[4].Predecessor.Add(new Predecessor() { GanttTaskIndex = 27, GanttTaskRelationship = GanttTaskRelationship.StartToStart }); + return taskDetails; + } +} {% endhighlight %} +{% endtabs %} The following image shows the Dependency Relationship: -![Dependency-Relationship_img5](Dependency-Relationship_images/Dependency-Relationship_img5.png) +![gantt-control-dependency-relationship](Dependency-Relationship_images/gantt-control-dependency-relationship.png) #### Samples Link @@ -153,11 +461,11 @@ NA The following image shows the Predecessor in Manual Mode: -![Predecessors ManualMode](Dependency-Relationship_images/Predecessors ManualMode.png) +![gantt-control-predecessors-in-manual-mode](Dependency-Relationship_images/gantt-control-predecessors-in-manual-mode.png) The following image shows the Predecessor in Auto Mode: -![Predecessors AutoMode](Dependency-Relationship_images/Predecessors AutoMode.png) +![gantt-control-predecessors-in-auto-mode](Dependency-Relationship_images/gantt-control-predecessors-in-auto-mode.png) #### Editing Predecessors @@ -193,42 +501,50 @@ As of now, resources cannot be edited in Grid. You can update the resource colle This helps to change the dependency relationships and resources of the tasks dynamically. -![Dependency-Relationship_img6](Dependency-Relationship_images/Dependency-Relationship_img6.png) +![gantt-control-predecessor-editing](Dependency-Relationship_images/gantt-control-predecessor-editing.png) Adding Dynamic Predecessors and Resources to an Application The dynamic editing of predecessor will be automatically included in the Gantt by default. There is no need to provide any additional data for that. The following codes illustrate this: +{% tabs %} {% highlight xaml %} - - - - - - + + + + + + + +   {% endhighlight %} {% highlight c# %} +GanttControl ganttControl = new GanttControl(); +ViewModel viewModel = new ViewModel(); +ganttControl.ItemsSource = viewModel.TaskCollection; +this.Content = ganttControl; //// The following code will illustrate how to dynamically add resource and predecessor in the underlying collection: // To Add the Dynamic Predecessors - -this.viewModel.GanttItemSource[0].ChildCollection[2].Predecessors.Add(new Predecessor() - { - GanttTaskIndex = 3, - GanttTaskRelationship = GanttTaskRelationship.StartToFinish - }); +viewModel.TaskCollection[2].Predecessor.Add(new Predecessor() +{ + GanttTaskIndex = 3, + GanttTaskRelationship = GanttTaskRelationship.StartToFinish +}); //To Add the Dynamic Resources -this.viewModel.GanttItemSource[0].ChildTask[2].Resource.Add(new Resource { ID = 3, Name = "Resource3" }); +viewModel.TaskCollection[2].Resource.Add(new Resource { ID = 3, Name = "Resource3" }); -{% endhighlight %} \ No newline at end of file +{% endhighlight %} +{% endtabs %} \ No newline at end of file diff --git a/wpf/Gantt/getting-started.md b/wpf/Gantt/getting-started.md index 47d91a0bc5..a992f44a4a 100644 --- a/wpf/Gantt/getting-started.md +++ b/wpf/Gantt/getting-started.md @@ -17,13 +17,13 @@ Gantt control is composed of three controls. They are: * ScheduleHeader * GanttChartVisualControl -![WPF Gantt appearance and structure](Getting-Started_images/Getting-Started_img1.png) +![gantt-control-appearance-and-structure](Getting-Started_images/gantt-control-appearance-and-structure.png) #### Gantt grid Gantt Grid is a table view control which displays the scheduled tasks/activities of the project with its hierarchy. You can edit the fields of the bounded tasks using this grid. -![WPF Gantt grid allotment](Getting-Started_images/Getting-Started_img2.png) +![gantt-control-gantt-grid](Getting-Started_images/gantt-control-gantt-grid.png) * Header— Header represents the table header which contains the field name of the task. * Parent Task—Parent task represents the summary of the child tasks. This is an activity which will be further split into various child tasks. @@ -34,7 +34,7 @@ Gantt Grid is a table view control which displays the scheduled tasks/activities Gantt Chart is an items control which provides a graphically representation of the task/activity that are currently scheduled. Gantt Chart have different components to represent the type of Task, Progress of the Task and Relationship between Tasks. -![WPF Gantt chart allotment](Getting-Started_images/Getting-Started_img3.png) +![gantt-control-gantt-chart](Getting-Started_images/gantt-control-gantt-chart.png) * Node— Node represents an individual or child task. * Header Node—HeaderNode represents the parent or summary task of the projects. @@ -88,16 +88,10 @@ You can add Gantt control to the application using the following code: {% tabs %} {% highlight xaml %} - - - + {% endhighlight %} - {% highlight c# %} - - //Initializing Gantt - GanttControl Gantt = new GanttControl(); - +GanttControl ganttControl = new GanttControl(); {% endhighlight %} {% endtabs %} @@ -113,99 +107,92 @@ Create a collection of tasks and bind it to the newly created GanttControl as gi {% highlight xaml %} - - + + - - + + {% endhighlight %} {% highlight c# %} - //Initializing Gantt -GanttControl Gantt = new GanttControl(); -ViewModel model=  new ViewModel(); -this.Gantt.DataContext = model; -Gantt.ItemsSource = model.GanttItemSource; +GanttControl ganttControl = new GanttControl(); +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; {% endhighlight %} -{% endtabs %} - -{% highlight c# %} - -[C#] +{% highlight c# tabtitle="ViewModel.cs" %} public class ViewModel { - public ObservableCollection TaskCollection { get; set; } public ViewModel() { - TaskCollection = this.GetDataSource(); + taskDetails = this.GetTaskDetails(); } - - private ObservableCollection GetDataSource() + + private ObservableCollection taskDetails; + + /// + /// Gets or sets the task collection. + /// + /// The task collection. + public ObservableCollection TaskDetails { - ObservableCollection task = new ObservableCollection(); - task.Add( - new TaskDetails - { - TaskId = 1, - TaskName = "Scope", - StartDate = new DateTime(2011, 1, 3), - FinishDate = new DateTime(2011, 1, 14), - Progress = 40d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 2, - TaskName = "Determine project office scope", - StartDate = new DateTime(2011, 1, 3), - FinishDate = new DateTime(2011, 1, 5), - Progress = 20d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 3, - TaskName = "Justify project office via business model", - StartDate = new DateTime(2011, 1, 6), - FinishDate = new DateTime(2011, 1, 7), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 4, - TaskName = "Secure executive sponsorship", - StartDate = new DateTime(2011, 1, 10), - FinishDate = new DateTime(2011, 1, 14), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); - - task[0].Child.Add( - new TaskDetails - { - TaskId = 5, - TaskName = "Secure complete", - StartDate = new DateTime(2011, 1, 14), - FinishDate = new DateTime(2011, 1, 14), - Duration = new TimeSpan(1, 0, 0, 0), - Progress = 20d - }); + get + { + return taskDetails; + } + set + { + taskDetails = value; + } + } + /// + /// Gets the task details. + /// + /// + ObservableCollection GetTaskDetails() + { + ObservableCollection task = new ObservableCollection(); + task.Add(new TaskDetails { TaskId = 1, TaskName = "Scope", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 14), Progress = 40d }); + task[0].Child.Add(new TaskDetails { TaskId = 2, TaskName = "Determine project office scope", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 5), Progress = 20d }); + task[0].Child.Add(new TaskDetails { TaskId = 3, TaskName = "Justify Project Offfice via business model", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 7), Progress = 20d }); + task[0].Child.Add(new TaskDetails { TaskId = 4, TaskName = "Secure executive sponsorship", StartDate = new DateTime(2011, 7, 3), FinishDate = new DateTime(2011, 7, 14), Progress = 20d }); + task[0].Child.Add(new TaskDetails { TaskId = 5, TaskName = "Secure complete", StartDate = new DateTime(2011, 7, 14), FinishDate = new DateTime(2011, 7, 14), Progress = 20d }); + + task.Add(new TaskDetails { TaskId = 6, TaskName = "Risk Assessment", StartDate = new DateTime(2011, 7, 8), FinishDate = new DateTime(2011, 7, 24), Progress = 30d }); + + task[1].Child.Add(new TaskDetails { TaskId = 7, TaskName = "Perform risk assessment", StartDate = new DateTime(2011, 7, 8), FinishDate = new DateTime(2011, 7, 21), Progress = 20d }); + task[1].Child.Add(new TaskDetails { TaskId = 8, TaskName = "Evaluate risk assessment", StartDate = new DateTime(2011, 7, 8), FinishDate = new DateTime(2011, 7, 23), Progress = 30d }); + task[1].Child.Add(new TaskDetails { TaskId = 9, TaskName = "Prepare contingency plans", StartDate = new DateTime(2011, 7, 12), FinishDate = new DateTime(2011, 7, 24), Progress = 30d }); + task[1].Child.Add(new TaskDetails { TaskId = 10, TaskName = "Risk Assessment complete", StartDate = new DateTime(2011, 7, 15), FinishDate = new DateTime(2011, 7, 24), Progress = 30d }); + + task.Add(new TaskDetails { TaskId = 11, TaskName = "Monitoring", StartDate = new DateTime(2011, 7, 13), FinishDate = new DateTime(2011, 8, 6), Progress = 40d }); + task[2].Child.Add(new TaskDetails { TaskId = 12, TaskName = "Prepare Meeting agenda", StartDate = new DateTime(2011, 7, 13), FinishDate = new DateTime(2011, 7, 26), Progress = 30d }); + task[2].Child.Add(new TaskDetails { TaskId = 13, TaskName = "Conduct review meeting", StartDate = new DateTime(2011, 7, 13), FinishDate = new DateTime(2011, 7, 30), Progress = 30d }); + task[2].Child.Add(new TaskDetails { TaskId = 14, TaskName = "Migrate critical issues", StartDate = new DateTime(2011, 7, 18), FinishDate = new DateTime(2011, 8, 2), Progress = 30d }); + task[2].Child.Add(new TaskDetails { TaskId = 15, TaskName = "Estabilish change mgmt Control", StartDate = new DateTime(2011, 8, 3), FinishDate = new DateTime(2011, 8, 6), Progress = 30d }); + task[2].Child.Add(new TaskDetails { TaskId = 16, TaskName = "Monitoring Complete", StartDate = new DateTime(2011, 8, 6), FinishDate = new DateTime(2011, 8, 6), Progress = 30d }); + + task.Add(new TaskDetails { TaskId = 17, TaskName = "Post Implementation", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 19), Progress = 40d }); + task[3].Child.Add(new TaskDetails { TaskId = 18, TaskName = "Obtain User feedback", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 10), Progress = 30d }); + task[3].Child.Add(new TaskDetails { TaskId = 19, TaskName = "Evaluate lessons learned", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 17), Progress = 30d }); + task[3].Child.Add(new TaskDetails { TaskId = 20, TaskName = "Modify items as necessary", StartDate = new DateTime(2011, 8, 7), FinishDate = new DateTime(2011, 8, 19), Progress = 30d }); + task[3].Child.Add(new TaskDetails { TaskId = 21, TaskName = "Post Implementation complete", StartDate = new DateTime(2011, 8, 19), FinishDate = new DateTime(2011, 8, 19), Progress = 30d }); + + task[0].Resources = new ObservableCollection() { new Resource { ID = 1, Name = "John" }, new Resource { ID = 2, Name = "Neil" } }; + task[0].Child[3].Resources = new ObservableCollection() { new Resource() { ID = 3, Name = "Peter" } }; + task[1].Resources = new ObservableCollection() { new Resource() { ID = 4, Name = "David" } }; return task; } } - - {% endhighlight %} + +{% endhighlight %} +{% endtabs %} ### Adding GanttControl through designer @@ -234,48 +221,39 @@ The following are the steps to create Gantt control through designer. The GanttControl allows users to set the width for GanttChart and GanttGrid using the [`ChartWidth`](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Gantt.GanttControl.html#Syncfusion_Windows_Controls_Gantt_GanttControl_ChartWidth) and [`GridWidth`](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Gantt.GanttControl.html#Syncfusion_Windows_Controls_Gantt_GanttControl_GridWidth) properties. The following code sample demonstrates how to set width for chart and grid. {% tabs %} - {% highlight xaml %} - - - + + {% endhighlight %} - {% highlight c# %} - //Initializing Gantt -GanttControl control = new GanttControl(); -control.GridWidth = new GridLength(200); -control.ChartWidth = new GridLength(800); +this.ganttControl.GridWidth = new GridLength(200); +this.ganttControl.ChartWidth = new GridLength(800); {% endhighlight %} - -{% endtabs %} - +{% endtabs %} ## Schedule padding Gantt schedule view can be extended by using the [`ScheduleRangePadding`](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Gantt.GanttControl.html#Syncfusion_Windows_Controls_Gantt_GanttControl_ScheduleRangePadding) property in GanttControl. This property extends the schedule with number of lower schedule units in starting position to improve the user experience. {% tabs %} - {% highlight xaml %} - - + + {% endhighlight %} - {% highlight c# %} - //Initializing Gantt -GanttControl control = new GanttControl(); -control.ScheduleRangePadding = 5; +this.ganttControl.ScheduleRangePadding = 5; {% endhighlight %} - {% endtabs %} ## ScheduleType @@ -297,24 +275,18 @@ By using the [`ScheduleType`](https://help.syncfusion.com/cr/wpf/Syncfusion.Wind The following code sample demonstrates how to set **ScheduleType** for GanttControl. {% tabs %} - {% highlight xaml %} - - + + {% endhighlight %} - {% highlight c# %} -//Initializing Gantt -GanttControl control = new GanttControl(); -control.DataContext = new ViewModel(); -control.SetBinding(GanttControl.ItemsSourceProperty,"TaskCollection"); -control.ScheduleType = ScheduleType.YearWithMonths; +this.ganttControl.ScheduleType = ScheduleType.YearWithMonths; {% endhighlight %} - {% endtabs %} ## Showing date with time in GanttGrid @@ -322,27 +294,25 @@ control.ScheduleType = ScheduleType.YearWithMonths; To show the date with time in the GanttGrid, enable the ShowDateWithTime property as shown in the following code sample. {% tabs %} - {% highlight xaml %} - - - - - + + + + + {% endhighlight %} - {% highlight c# %} - //Initializing Gantt - GanttControl control = new GanttControl(); - control.DataContext = new ViewModel(); - control.SetBinding(GanttControl.ItemsSourceProperty,"TaskCollection"); - control.ShowDateWithTime = true; +GanttControl ganttControl = new GanttControl(); +ganttControl.ShowDateWithTime = true; +this.ganttControl.ItemsSource = new ViewModel().TaskDetails; +this.Content = ganttControl; {% endhighlight %} - {% endtabs %} N> By default, GanttGrid will show the date alone. diff --git a/wpf/Gantt/holidays-customization.md b/wpf/Gantt/holidays-customization.md index a937ed880e..c43e1ec06f 100644 --- a/wpf/Gantt/holidays-customization.md +++ b/wpf/Gantt/holidays-customization.md @@ -96,7 +96,7 @@ public partial class MainWindow : Window The following screenshot illustrates the customized holidays sample. -![Holiday customization sample](Holiday-Customization_images/Holiday-Customization_images_img1.png) +![gantt-control-holiday-customization](Holiday-Customization_images/gantt-control-holiday-customization.png) You can download the holiday customization sample from the following link: diff --git a/wpf/Gantt/overview.md b/wpf/Gantt/overview.md index abc29b4bb2..782e37dff4 100644 --- a/wpf/Gantt/overview.md +++ b/wpf/Gantt/overview.md @@ -15,9 +15,4 @@ Essential Gantt for WPF is a MS Project-like Project Viewer with built-in grid, Research scholars, IT companies or any organization that following work breakdown structure can use Gantt control to schedule and track their tasks/ activities. This helps tracking the progress of an assignment. By tracking the progress one can change or reschedule the plan to achieve the goal. - - -![Gantt - Overview](Overview_images/Overview_img1.png) - - - +![gantt-control-overview](Overview_images/gantt-control-overview.png) \ No newline at end of file