Ejemplo n.º 1
0
        public MainPage()
        {
            // Create and set the assignable resource collection as page resource before the InitializeComponent call in order to be able to refer it from XAML using the StaticResource markup extension.
            var assignableResources = new ObservableCollection <string>();

            Resources.Add("AssignableResources", assignableResources);

            InitializeComponent();

            GanttChartItem item0 = GanttChartDataGrid.Items[0];

            GanttChartItem item1 = GanttChartDataGrid.Items[1];

            item1.Start              = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item1.Finish             = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));
            item1.CompletedFinish    = DateTime.Today.Add(TimeSpan.Parse("12:00:00"));
            item1.AssignmentsContent = "Resource 1";

            GanttChartItem item2 = GanttChartDataGrid.Items[2];

            item2.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            item2.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));
            // Important note: CompletedFinish value defaults to DateTime.Today, therefore you should always set it to a Start (or a value between Start and Finish) when you initialize a past task item! In this example we don't set it as the task is in the future.
            item2.AssignmentsContent = "Resource 1, Resource 2";
            item2.Predecessors.Add(new PredecessorItem {
                Item = item1
            });

            GanttChartItem item3 = GanttChartDataGrid.Items[3];

            item3.Predecessors.Add(new PredecessorItem {
                Item = item0, DependencyType = DependencyType.StartStart
            });

            GanttChartItem item4 = GanttChartDataGrid.Items[4];

            item4.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item4.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item6 = GanttChartDataGrid.Items[6];

            item6.Start          = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item6.Finish         = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));
            item6.BaselineStart  = item6.Start;
            item6.BaselineFinish = item6.Finish;

            GanttChartItem item7 = GanttChartDataGrid.Items[7];

            item7.Start       = DateTime.Today.AddDays(4);
            item7.IsMilestone = true;
            item7.Predecessors.Add(new PredecessorItem {
                Item = item4
            });
            item7.Predecessors.Add(new PredecessorItem {
                Item = item6
            });
            item7.BaselineStart = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item8 = GanttChartDataGrid.Items[8];

            item8.Start              = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));
            item8.Finish             = DateTime.Today.AddDays(6).Add(TimeSpan.Parse("14:00:00"));
            item8.AssignmentsContent = "Resource 1 [50%], Resource 2 [75%]";
            item8.BaselineStart      = DateTime.Today.Add(TimeSpan.Parse("12:00:00"));
            item8.BaselineFinish     = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("14:00:00"));

            GanttChartItem item9 = GanttChartDataGrid.Items[9];

            item9.Start              = DateTime.Today.AddDays(6).Add(TimeSpan.Parse("08:00:00"));
            item9.Finish             = DateTime.Today.AddDays(6).Add(TimeSpan.Parse("16:00:00"));
            item9.AssignmentsContent = "Resource 1";
            item9.BaselineStart      = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("12:00:00"));
            item9.BaselineFinish     = DateTime.Today.AddDays(6).Add(TimeSpan.Parse("16:00:00"));

            // You may uncomment the next lines of code to set default schedule and timeline visibility settings for the Gantt Chart.
            // // Working week: between Tuesday and Saturday.
            // GanttChartDataGrid.WorkingWeekStart = DayOfWeek.Tuesday;
            // GanttChartDataGrid.WorkingWeekFinish = DayOfWeek.Saturday;
            // // Working day: between 9 AM and 5 PM.
            // GanttChartDataGrid.VisibleDayStart = GanttChartDataGrid.WorkingDayStart = TimeOfDay.Parse("09:00:00");
            // GanttChartDataGrid.VisibleDayFinish = GanttChartDataGrid.WorkingDayFinish = TimeOfDay.Parse("17:00:00");
            // // Optionally, generic nonworking intervals.
            // GanttChartDataGrid.NonworkingIntervals = new ObservableCollection<TimeInterval>(
            //    new TimeInterval[] {
            //        new TimeInterval(DateTime.Today.AddDays(1), DateTime.Today.AddDays(1).Add(TimeOfDay.MaxValue)), // Holiday: full day.
            //        new TimeInterval(DateTime.Today.AddDays(3), DateTime.Today.AddDays(5).Add(TimeSpan.Parse("12:00:00"))) // Custom time interval off: full and partial day accepted.
            //    });
            // // Optionally, specific nonworking intervals based on date parameter: recurrent breaks and holidays accepted.
            // GanttChartDataGrid.NonworkingDayIntervalProvider = (date) => {
            //    if (date.Day % 3 == 0) // First recurrence expression: on the end of every set of three days in the month.
            //        return new DayTimeInterval[] {
            //            new DayTimeInterval(TimeOfDay.MinValue, TimeOfDay.Parse("12:00:00")), // Large interval off: first part of day.
            //            new DayTimeInterval(TimeOfDay.Parse("12:30:00"), TimeOfDay.Parse("13:00:00")) // Short break: fast lunch time.
            //        };
            //    else if (date.DayOfWeek != DayOfWeek.Wednesday) // Second recurrence expression: every day except Wednesdays.
            //        return new DayTimeInterval[] {
            //            new DayTimeInterval(TimeOfDay.Parse("12:00:00"), TimeOfDay.Parse("13:00:00")) // Break: regular lunch time.
            //        };
            //    return null; // Otherwise use regular timing only.
            // };
            // // Alternatively, add working day time breaks using AddWorkingDayTimeBreak or AddWorkingDayTimeBreaks methods.
            // GanttChartDataGrid.AddWorkingDayTimeBreak(TimeOfDay.Parse("11:30"), TimeOfDay.Parse("12:30"));

            // You may uncomment the next lines of code to set specific schedule settings for Task 3.
            // item8.Schedule = new Schedule(
            //    DayOfWeek.Sunday, DayOfWeek.Thursday, // Working week: between Sunday and Thursday.
            //    TimeSpan.Parse("10:00:00"), TimeSpan.Parse("14:00:00"), // Working day: between 10 AM and 2 PM.
            //    new TimeInterval[] { // Optionally, generic nonworking intervals.
            //        new TimeInterval(DateTime.Today.AddDays(4), DateTime.Today.AddDays(4).Add(TimeOfDay.MaxValue)), // Holiday: full day.
            //        new TimeInterval(DateTime.Today.AddDays(8), DateTime.Today.AddDays(10).Add(TimeSpan.Parse("12:00:00"))) // Custom time interval off: full and partial day accepted.
            //    },
            //    (date) => { // Optionally, specific nonworking intervals based on date parameter: recurrent breaks and holidays accepted.
            //        if (date.Day % 10 == 0) // First recurrence expression: every ten days.
            //            return new DayTimeInterval[] {
            //                new DayTimeInterval(TimeOfDay.MinValue, TimeOfDay.Parse("12:00:00")), // Large interval off: first part of day.
            //                new DayTimeInterval(TimeOfDay.Parse("12:30:00"), TimeOfDay.Parse("13:00:00")) // Short break: fast lunch time.
            //            };
            //        else if (date.DayOfWeek != DayOfWeek.Monday) // Second recurrence expression: every day except Mondays.
            //            return new DayTimeInterval[] {
            //                new DayTimeInterval(TimeOfDay.Parse("12:00:00"), TimeOfDay.Parse("13:00:00")) // Break: regular lunch time.
            //            };
            //        return null; // Otherwise use regular timing only.
            //    });
            // GanttChartDataGrid.IsIndividualItemNonworkingTimeHighlighted = true;

            // You may uncomment the next lines of code to test the component performance:
            // for (int i = 5; i <= 4096; i++)
            // {
            //     GanttChartDataGrid.Items.Add(
            //         new GanttChartItem
            //         {
            //             Content = "Task " + i,
            //             Start = DateTime.Today.AddDays(5 + i / 20),
            //             Finish = DateTime.Today.AddDays(5 + i / 10 + 1)
            //         });
            // }

            // Optionally, define assignable resources.
            foreach (string resource in new string[] { "Resource 1", "Resource 2", "Resource 3", "Material 1", "Material 2" })
            {
                assignableResources.Add(resource);
            }
            GanttChartDataGrid.AssignableResources = assignableResources;

            // Optionally, define the quantity values to consider when leveling resources, indicating maximum material amounts available for use at the same time.
            GanttChartDataGrid.ResourceQuantities = new Dictionary <string, double> {
                { "Material 1", 4 }, { "Material 2", double.PositiveInfinity }
            };
            item4.AssignmentsContent = "Material 1 [300%]";
            item6.AssignmentsContent = "Material 1 [250%], Material 2";

            // Optionally, define task and resource costs.
            // GanttChartDataGrid.TaskInitiationCost = 5;
            item4.ExecutionCost = 50;
            // GanttChartDataGrid.DefaultResourceUsageCost = 1;
            // GanttChartDataGrid.SpecificResourceUsageCosts = new Dictionary<string, double> { { "Resource 1", 2 }, { "Material 1", 7 } };
            GanttChartDataGrid.DefaultResourceHourCost   = 10;
            GanttChartDataGrid.SpecificResourceHourCosts = new Dictionary <string, double> {
                { "Resource 1", 20 }, { "Material 2", 0.5 }
            };

            // Optionally, set AreHierarchyConstraintsEnabled to false to increase performance when you perform hierarchy validation in your application logic.
            GanttChartDataGrid.AreHierarchyConstraintsEnabled = false;

            // Initialize the control area.
            ScalesComboBox.SelectedIndex   = 0;
            ShowWeekendsCheckBox.IsChecked = true;
            BaselineCheckBox.IsChecked     = true;
            EnableDependencyConstraintsCheckBox.IsChecked = true;
        }
Ejemplo n.º 2
0
        private void bindToChart(List<DataLibrary.ExtSchedulerDTO> list)
        {
            DateTime dtMin = new DateTime();
            DateTime dtMax = new DateTime();
            
            ObservableCollection<GanttChartItem> items = new ObservableCollection<GanttChartItem>();

            gccSchedule.UseSimpleDateFormatting = true;
            gccSchedule.AreTaskDependenciesVisible = false;
            gccSchedule.IsTaskCompletedEffortVisible = false;
            
            ////test for altering holidays.
            //gccSchedule.WorkingWeekStart = 0;
            //gccSchedule.WorkingWeekFinish = 6;
            //gccSchedule.SpecialNonworkingDays.Clear();
            //gccSchedule.SpecialNonworkingDays.Add(new DateTimeOffset(Convert.ToDateTime("2013-06-03")));
            //gccSchedule.SpecialNonworkingDays.Add(new DateTimeOffset(Convert.ToDateTime("2013-06-04")));
            //gccSchedule.SpecialNonworkingDays.Add(new DateTimeOffset(Convert.ToDateTime("2013-06-05")));
            //gccSchedule.SpecialNonworkingDays.Add(new DateTimeOffset(Convert.ToDateTime("2013-06-06")));
            //gccSchedule.SpecialNonworkingDays.Add(new DateTimeOffset(Convert.ToDateTime("2013-06-07")));

            string barColor = "Orange";
            foreach (DataLibrary.ExtSchedulerDTO dto in list)
            {
                if (barColor == "Red")
                    barColor = "Orange";
                else
                    barColor = "Red";

                GanttChartItem item = new GanttChartItem();

                item.Content = "<div style='text-align: left; width: 170px; font-size: 15px; word-wrap:break-word; margin: 5px;'>" + dto.Name + "</div>";
                item.Start = new DateTimeOffset(dto.StartDate == null ? new DateTime() : Convert.ToDateTime(dto.StartDate.ToString("MM/dd/yyyy")));
                item.Finish = new DateTimeOffset(dto.EndDate == null ? new DateTime() : Convert.ToDateTime(dto.EndDate.ToString("MM/dd/yyyy") + " 11:59:59 PM"));
                item.Tag = dto;

                item.IsMilestone = false;
                item.TaskTemplateClientCode = @"
                var control = item.ganttChartView, settings = control.settings, document = control.ownerDocument, svgns = 'http://www.w3.org/2000/svg', xlinkns = 'http://www.w3.org/1999/xlink';

                // Create, if needed, and store a SVG group element that will represent the task bar area.
                if (typeof item.taskBarAreaContainerGroup === 'undefined')
                    item.taskBarAreaContainerGroup = document.createElementNS(svgns, 'g');

                var containerGroup = item.taskBarAreaContainerGroup;

                for (var i = containerGroup.childNodes.length; i-- > 0; )
                    containerGroup.removeChild(containerGroup.childNodes[i]);

                // Determine item positioning values.
                var itemLeft = control.getChartPosition(item.start, settings), itemRight = control.getChartPosition(item.finish, settings), itemCompletedRight = control.getChartPosition(item.completedFinish, settings);

                // SVG rectangle element that will represent the main bar of the task (blue).
                var rect = document.createElementNS(svgns, 'rect'); 
                rect.setAttribute('x', itemLeft); 
                rect.setAttribute('width', Math.max(" + gccSchedule.HourWidth * 8 + @", itemRight - itemLeft));
                rect.setAttribute('y', settings.barMargin - 0.5); 
                rect.setAttribute('height', settings.barHeight + 0.5);
                rect.setAttribute('style', 'stroke: Blue; fill: LightBlue; stroke-width: 0.65px; fill-opacity: 0.5;');
                containerGroup.appendChild(rect);

                if (settings.isTaskCompletedEffortVisible) {
                    // SVG rectangle element that will represent the completion bar of the task (gray).
                    var completionRect = document.createElementNS(svgns, 'rect');
                    completionRect.setAttribute('x', itemLeft);
                    completionRect.setAttribute('y', settings.barMargin + settings.completedBarMargin - 0.5);
                    completionRect.setAttribute('width', Math.max(0, itemCompletedRight - itemLeft));
                    completionRect.setAttribute('height', settings.completedBarHeight + 0.5);
                    completionRect.setAttribute('style', 'stroke: Gray; fill: Gray; stroke-width: 0.65px; fill-opacity: 0.5;');
                    containerGroup.appendChild(completionRect);
                }

                // SVG rectangle element that will behave as a task bar thumb, providing horizontal drag and drop operations for the main task bar.
                var thumb = document.createElementNS(svgns, 'rect');
                thumb.setAttribute('x', itemLeft); 
                thumb.setAttribute('width', Math.max(" + gccSchedule.HourWidth * 8 + @", itemRight - itemLeft));
                thumb.setAttribute('y', settings.barMargin); 
                thumb.setAttribute('height', settings.barHeight + 0.5);
                thumb.setAttribute('style', 'stroke: " + barColor + @"; stroke-width: 1px; fill: " + barColor + @"; fill-opacity: 0.9; cursor: move');
                containerGroup.appendChild(thumb);
                    
                // SVG rectangle element that will behave as a task start time editing thumb, providing horizontal drag and drop operations for the left end of the main task bar.
                var startThumb = document.createElementNS(svgns, 'rect');
                startThumb.setAttribute('x', Math.max(itemLeft, Math.min(itemRight - " + gccSchedule.HourWidth * 8 + @", itemLeft)) - 25);
                startThumb.setAttribute('y', settings.barMargin);
                startThumb.setAttribute('width', 25);
                startThumb.setAttribute('height', settings.barHeight + 0.5);
                startThumb.setAttribute('style', 'fill: " + barColor + @"; fill-opacity: 0.1; cursor: e-resize'); //'fill: Transparent; cursor: e-resize');
                containerGroup.appendChild(startThumb);

                // SVG rectangle element that will behave as a task finish time editing thumb, providing horizontal drag and drop operations for the right end of the main task bar.
                var finishThumb = document.createElementNS(svgns, 'rect');
                finishThumb.setAttribute('x', Math.max(itemLeft + " + gccSchedule.HourWidth * 8 + @", itemRight));                
                finishThumb.setAttribute('y', settings.barMargin);
                finishThumb.setAttribute('width', 25);
                finishThumb.setAttribute('height', settings.barHeight + 0.5);
                finishThumb.setAttribute('style', 'fill: " + barColor + @"; fill-opacity: 0.1; cursor: e-resize'); //'fill: Transparent; cursor: e-resize');
                containerGroup.appendChild(finishThumb);

                control.initializeTaskDraggingThumbs(thumb, startThumb, finishThumb, null, item, itemLeft, itemRight, null);                    

                if (settings.areTaskDependenciesVisible) {
                    // SVG circle element that will behave as a task dependency creation thumb, providing vertical drag and drop operations for the right end of the main task bar.
                    var dependencyThumb = document.createElementNS(svgns, 'circle');
                    dependencyThumb.setAttribute('cx', itemRight);
                    dependencyThumb.setAttribute('cy', settings.barMargin + settings.barHeight / 2);
                    dependencyThumb.setAttribute('r', settings.barHeight / 4);
                    dependencyThumb.setAttribute('style', 'fill: Transparent; cursor: pointer');
                    containerGroup.appendChild(dependencyThumb); 
                    control.initializeDependencyDraggingThumb(dependencyThumb, containerGroup, item, settings.barMargin + settings.barHeight / 2, itemRight);
                }
                return containerGroup;";

                items.Add(item);

                if (dtMin == new DateTime() || dtMin > dto.StartDate)
                    dtMin = dto.StartDate;
                if (dtMax == new DateTime() || dtMax < dto.EndDate)
                    dtMax = dto.EndDate;
            }
            
            gccSchedule.Items = items;
            
            // Set the scrollable timeline to present, and the displayed and current time values to automatically scroll to a specific chart coordinate, and display a vertical bar highlighter at the specified point.
            gccSchedule.DisplayedTime = new DateTimeOffset(dtMin.AddDays(-3));
            gccSchedule.CurrentTime = new DateTimeOffset(dtMin);
            gccSchedule.TimelineStart = new DateTimeOffset(dtMin == new DateTime() ? WinAppLibrary.Utilities.Helper.DateTimeMinValue : dtMin.AddYears(-1));
            gccSchedule.TimelineFinish = new DateTimeOffset(dtMax == new DateTime() ? DateTime.Now.AddYears(1) : dtMax.AddYears(1));
            
            gccSchedule.IsGridReadOnly = true;
            gccSchedule.IsChartReadOnly = false;
            gccSchedule.IsCurrentTimeLineVisible = false;
            gccSchedule.IsTaskToolTipVisible = false;
            gccSchedule.IsHoldingEnabled = false;

            gccSchedule.ItemHeight = 70;
            gccSchedule.BarHeight = 50;
            gccSchedule.BarMargin = 10;

            gccSchedule.SelectedItemBackgroundColor = (new WinAppLibrary.Utilities.Helper()).GetColorFromHexa("#7da7d9").Color;
            gccSchedule.SelectedItemForegroundColor = (new WinAppLibrary.Utilities.Helper()).GetColorFromHexa("#004a80").Color; 
            gccSchedule.HeaderBackgroundColor = (new WinAppLibrary.Utilities.Helper()).GetColorFromHexa("#004a80").Color; 
           
            gccSchedule.Columns[1].Header = "<div style='text-align: center;'>IWP</div>";
            gccSchedule.Columns[1].Width = 200;
            gccSchedule.Columns[2].IsVisible = false;
            gccSchedule.Columns[3].IsVisible = false;
            gccSchedule.Columns[4].IsVisible = false;
            gccSchedule.Columns[5].IsVisible = false;
            gccSchedule.Columns[6].IsVisible = false;
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            GanttChartItem item0 = GanttChartDataGrid.Items[0];

            GanttChartItem item1 = GanttChartDataGrid.Items[1];

            item1.Start              = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item1.Finish             = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));
            item1.CompletedFinish    = DateTime.Today.Add(TimeSpan.Parse("12:00:00"));
            item1.AssignmentsContent = "Resource 1";

            GanttChartItem item2 = GanttChartDataGrid.Items[2];

            item2.Start              = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            item2.Finish             = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));
            item2.AssignmentsContent = "Resource 1, Resource 2";
            item2.Predecessors.Add(new PredecessorItem {
                Item = item1
            });

            GanttChartItem item3 = GanttChartDataGrid.Items[3];

            item3.Predecessors.Add(new PredecessorItem {
                Item = item0, DependencyType = DependencyType.StartStart
            });

            GanttChartItem item4 = GanttChartDataGrid.Items[4];

            item4.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item4.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item6 = GanttChartDataGrid.Items[6];

            item6.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item6.Finish = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item7 = GanttChartDataGrid.Items[7];

            item7.Start       = DateTime.Today.AddDays(4);
            item7.IsMilestone = true;
            item7.Predecessors.Add(new PredecessorItem {
                Item = item4
            });
            item7.Predecessors.Add(new PredecessorItem {
                Item = item6
            });

            for (int i = 3; i <= 25; i++)
            {
                GanttChartDataGrid.Items.Add(
                    new GanttChartItem
                {
                    Content         = "Task " + i,
                    Indentation     = i % 3 == 0 ? 0 : 1,
                    Start           = DateTime.Today.AddDays(i <= 8 ? (i - 4) * 2 : i - 8),
                    Finish          = DateTime.Today.AddDays((i <= 8 ? (i - 4) * 2 + (i > 8 ? 6 : 1) : i - 2) + 2),
                    CompletedFinish = DateTime.Today.AddDays(i <= 8 ? (i - 4) * 2 : i - 8).AddDays(i % 6 == 4 ? 3 : 0)
                });
            }
        }
Ejemplo n.º 4
0
 // Compare two items and return -1 if the items are specified in ascending order, 0 if the items are similar, or +1 if the items are in specified descending order.
 private static int Compare(GanttChartItem item1, GanttChartItem item2, string columnHeader)
 {
     // The current implementation compares the content (returned by ToString method) of the two items.
     // Optionally, you may modify the code below to apply a custom sort implementation based on column header and specific requirements.
     return(string.Compare(item1.ToString(), item2.ToString()));
 }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            GanttChartItem item0 = GanttChartDataGrid.Items[0];

            GanttChartItem item1 = GanttChartDataGrid.Items[1];

            item1.Start              = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item1.Finish             = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));
            item1.CompletedFinish    = DateTime.Today.Add(TimeSpan.Parse("12:00:00"));
            item1.AssignmentsContent = "Resource 1";

            GanttChartItem item2 = GanttChartDataGrid.Items[2];

            item2.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            item2.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));
            // Important note: CompletedFinish value defaults to DateTime.Today, therefore you should always set it to a Start (or a value between Start and Finish) when you initialize a past task item! In this example we don't set it as the task is in the future.
            item2.AssignmentsContent = "Resource 1, Resource 2";
            item2.Predecessors.Add(new PredecessorItem {
                Item = item1
            });

            GanttChartItem item3 = GanttChartDataGrid.Items[3];

            item3.Predecessors.Add(new PredecessorItem {
                Item = item0, DependencyType = DependencyType.StartStart
            });

            GanttChartItem item4 = GanttChartDataGrid.Items[4];

            item4.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item4.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item6 = GanttChartDataGrid.Items[6];

            item6.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item6.Finish = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item7 = GanttChartDataGrid.Items[7];

            item7.Start       = DateTime.Today.AddDays(4);
            item7.IsMilestone = true;
            item7.Predecessors.Add(new PredecessorItem {
                Item = item4
            });
            item7.Predecessors.Add(new PredecessorItem {
                Item = item6
            });

            for (int i = 3; i <= 25; i++)
            {
                GanttChartDataGrid.Items.Add(
                    new GanttChartItem
                {
                    Content         = "Task " + i,
                    Indentation     = i % 3 == 0 ? 0 : 1,
                    Start           = DateTime.Today.AddDays(i <= 8 ? (i - 4) * 3 : i - 8),
                    Finish          = DateTime.Today.AddDays((i <= 8 ? (i - 4) * 3 + (i > 8 ? 6 : 1) : i - 2) + 1),
                    CompletedFinish = DateTime.Today.AddDays(i <= 8 ? (i - 4) * 3 : i - 8).AddDays(i % 6 == 1 ? 3 : 0)
                });
            }
        }
Ejemplo n.º 6
0
        public MainWindow()
        {
            InitializeComponent();

            // Record the current date and time at minute level.
            DateTime now = DateTime.Now; now = now.Date.AddHours(now.Hour).AddMinutes(now.Minute);

            GanttChartItem item0 = GanttChartDataGrid.Items[0];

            GanttChartItem item1 = GanttChartDataGrid.Items[1];

            item1.Start              = now.Add(TimeSpan.Parse("00:08:00"));
            item1.Finish             = now.Add(TimeSpan.Parse("00:16:00"));
            item1.CompletedFinish    = now.Add(TimeSpan.Parse("00:12:00"));
            item1.AssignmentsContent = "Resource 1";

            GanttChartItem item2 = GanttChartDataGrid.Items[2];

            item2.Start              = now.Add(TimeSpan.Parse("00:16:00"));
            item2.Finish             = now.Add(TimeSpan.Parse("00:32:00"));
            item2.AssignmentsContent = "Resource 1, Resource 2";
            item2.Predecessors.Add(new PredecessorItem {
                Item = item1
            });

            GanttChartItem item3 = GanttChartDataGrid.Items[3];

            item3.Predecessors.Add(new PredecessorItem {
                Item = item0, DependencyType = DependencyType.StartStart
            });

            GanttChartItem item4 = GanttChartDataGrid.Items[4];

            item4.Start  = now.Add(TimeSpan.Parse("00:08:00"));
            item4.Finish = now.Add(TimeSpan.Parse("00:28:00"));

            GanttChartItem item6 = GanttChartDataGrid.Items[6];

            item6.Start  = now.Add(TimeSpan.Parse("00:08:00"));
            item6.Finish = now.Add(TimeSpan.Parse("00:36:00"));

            GanttChartItem item7 = GanttChartDataGrid.Items[7];

            item7.Start       = now.Add(TimeSpan.Parse("00:36:00"));
            item7.IsMilestone = true;
            item7.Predecessors.Add(new PredecessorItem {
                Item = item4
            });
            item7.Predecessors.Add(new PredecessorItem {
                Item = item6
            });

            for (int i = 3; i <= 25; i++)
            {
                GanttChartDataGrid.Items.Add(
                    new GanttChartItem
                {
                    Content         = "Task " + i,
                    Indentation     = i % 3 == 0 ? 0 : 1,
                    Start           = now.AddMinutes(i <= 8 ? (i - 4) * 3 : i - 8),
                    Finish          = now.AddMinutes((i <= 8 ? (i - 4) * 3 + (i > 8 ? 6 : 1) : i - 2) + 1),
                    CompletedFinish = now.AddMinutes(i <= 8 ? (i - 4) * 3 : i - 8).AddMinutes(i % 6 == 1 ? 3 : 0)
                });
            }

            // Set working and visible time to 24 hours/day and 7 day/week, and nonworking time as not highlighted (as there is only working time).
            GanttChartDataGrid.WorkingDayStart             = GanttChartDataGrid.VisibleDayStart = TimeOfDay.MinValue;
            GanttChartDataGrid.WorkingDayFinish            = GanttChartDataGrid.VisibleDayFinish = TimeOfDay.MaxValue;
            GanttChartDataGrid.WorkingWeekStart            = GanttChartDataGrid.VisibleWeekStart = DayOfWeek.Sunday;
            GanttChartDataGrid.WorkingWeekFinish           = GanttChartDataGrid.VisibleWeekFinish = DayOfWeek.Saturday;
            GanttChartDataGrid.IsNonworkingTimeHighlighted = false;

            // Set timeline page start and displayed time to the numeric day origin.
            GanttChartDataGrid.SetTimelinePage(now.AddMinutes(-10), now.AddMinutes(60));
            GanttChartDataGrid.DisplayedTime = now.AddMinutes(-1);
        }
Ejemplo n.º 7
0
        public MainWindow()
        {
            InitializeComponent();

            GanttChartItem item0 = GanttChartDataGrid.Items[0];

            GanttChartItem item1 = GanttChartDataGrid.Items[1];

            item1.Start              = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item1.Finish             = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));
            item1.CompletedFinish    = DateTime.Today.Add(TimeSpan.Parse("12:00:00"));
            item1.AssignmentsContent = "Resource 1";

            GanttChartItem item2 = GanttChartDataGrid.Items[2];

            item2.Start              = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            item2.Finish             = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));
            item2.AssignmentsContent = "Resource 1 [200%], Resource 2";
            item2.Predecessors.Add(new PredecessorItem {
                Item = item1
            });

            GanttChartItem item3 = GanttChartDataGrid.Items[3];

            item3.Predecessors.Add(new PredecessorItem {
                Item = item0, DependencyType = DependencyType.StartStart
            });

            GanttChartItem item4 = GanttChartDataGrid.Items[4];

            item4.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item4.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item6 = GanttChartDataGrid.Items[6];

            item6.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item6.Finish = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));

            GanttChartItem item7 = GanttChartDataGrid.Items[7];

            item7.Start       = DateTime.Today.AddDays(4);
            item7.IsMilestone = true;
            item7.Predecessors.Add(new PredecessorItem {
                Item = item4
            });
            item7.Predecessors.Add(new PredecessorItem {
                Item = item6
            });

            for (int i = 3; i <= 25; i++)
            {
                GanttChartDataGrid.Items.Add(
                    new GanttChartItem
                {
                    Content         = "Task " + i,
                    Indentation     = i % 3 == 0 ? 0 : 1,
                    Start           = DateTime.Today.AddDays(i <= 8 ? (i - 4) * 2 : i - 8),
                    Finish          = DateTime.Today.AddDays((i <= 8 ? (i - 4) * 2 + (i > 8 ? 6 : 1) : i - 2) + 2),
                    CompletedFinish = DateTime.Today.AddDays(i <= 8 ? (i - 4) * 2 : i - 8).AddDays(i % 6 == 4 ? 3 : 0)
                });
            }

            // Define assignable resources.
            GanttChartDataGrid.AssignableResources = new ObservableCollection <string> {
                "Resource 1", "Resource 2", "Resource 3",
                "Material 1", "Material 2"
            };

            // Define the quantity values to consider when leveling resources, indicating maximum material amounts available for use at the same time.
            GanttChartDataGrid.ResourceQuantities = new Dictionary <string, double> {
                { "Material 1", 4 }, { "Material 2", double.PositiveInfinity }
            };
            item4.AssignmentsContent = "Material 1 [300%]";
            item6.AssignmentsContent = "Resource 2, Material 2";

            // Define task and resource costs.
            GanttChartDataGrid.TaskInitiationCost = 5;
            item4.ExecutionCost = 50;
            GanttChartDataGrid.DefaultResourceUsageCost   = 10;
            GanttChartDataGrid.SpecificResourceUsageCosts = new Dictionary <string, double> {
                { "Resource 1", 2 }, { "Material 1", 7 }
            };
            GanttChartDataGrid.SpecificResourceHourCosts = new Dictionary <string, double> {
                { "Resource 2", 20 }, { "Material 2", 0.5 }
            };
        }