public MainWindow()
        {
            InitializeComponent();

            LoadChartDataGrid.TimelinePageStart  = DateTime.Today;
            LoadChartDataGrid.TimelinePageFinish = DateTime.Today.AddMonths(2);
            LoadChartDataGrid.VisibleDayStart    = TimeOfDay.Parse("09:00:00");
            LoadChartDataGrid.VisibleDayFinish   = TimeOfDay.Parse("15:00:00");

            AllocationItem allocation11 = LoadChartDataGrid.Items[0].GanttChartItems[0];

            allocation11.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            allocation11.Finish = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));

            AllocationItem allocation112 = LoadChartDataGrid.Items[0].GanttChartItems[1];

            allocation112.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            allocation112.Finish = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00"));
            allocation112.Units  = 1.5;

            AllocationItem allocation12 = LoadChartDataGrid.Items[0].GanttChartItems[2];

            allocation12.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00"));
            allocation12.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));
            allocation12.Units  = 0.5;

            AllocationItem allocation13 = LoadChartDataGrid.Items[0].GanttChartItems[3];

            allocation13.Start  = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("08:00:00"));
            allocation13.Finish = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("16:00:00"));

            AllocationItem allocation22 = LoadChartDataGrid.Items[1].GanttChartItems[0];

            allocation22.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            allocation22.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));

            for (int i = 3; i <= 16; i++)
            {
                LoadChartItem item = new LoadChartItem {
                    Content = "Resource " + i
                };
                for (int j = 1; j <= (i - 1) % 4 + 1; j++)
                {
                    item.GanttChartItems.Add(
                        new AllocationItem
                    {
                        Content = "Task " + i + "." + j + (((i + j) % 2 == 1 ? " [200%]" : string.Empty)),
                        Start   = DateTime.Today.AddDays(i + (i - 1) * (j - 1)),
                        Finish  = DateTime.Today.AddDays(i * 1.2 + (i - 1) * (j - 1) + 1),
                        Units   = 1 + (i + j) % 2
                    });
                }
                LoadChartDataGrid.Items.Add(item);
            }
        }
示例#2
0
        // Control area commands.
        private void AddNewButton_Click(object sender, RoutedEventArgs e)
        {
            LoadChartItem item = new LoadChartItem {
                Content = "New Resource"
            };

            item.GanttChartItems.Add(new AllocationItem {
                Content = "New Task", Start = DateTime.Today, Finish = DateTime.Today.AddDays(1)
            });
            LoadChartDataGrid.Items.Add(item);
            LoadChartDataGrid.SelectedItem = item;
            LoadChartDataGrid.ScrollTo(item.GanttChartItems[0]);
        }
示例#3
0
        private void InsertNewButton_Click(object sender, RoutedEventArgs e)
        {
            LoadChartItem selectedItem = LoadChartDataGrid.SelectedItem as LoadChartItem;

            if (selectedItem == null)
            {
                MessageBox.Show("Cannot insert a new item before selection as the selection is empty; you can either add a new item to the end of the list instead, or select an item first.", "Information", MessageBoxButton.OK);
                return;
            }
            LoadChartItem item = new LoadChartItem {
                Content = "New Resource"
            };

            item.GanttChartItems.Add(new AllocationItem {
                Content = "New Task", Start = DateTime.Today, Finish = DateTime.Today.AddDays(1)
            });
            LoadChartDataGrid.Items.Insert(LoadChartDataGrid.SelectedIndex, item);
            LoadChartDataGrid.SelectedItem = item;
        }
示例#4
0
        private void LoadChartDataGrid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point controlPosition = e.GetPosition(LoadChartDataGrid);
            Point contentPosition = e.GetPosition(LoadChartDataGrid.ChartContentElement);

            DateTime      dateTime = LoadChartDataGrid.GetDateTime(contentPosition.X);
            LoadChartItem itemRow  = LoadChartDataGrid.GetItemAt(contentPosition.Y) as LoadChartItem;

            AllocationItem   item             = null;
            FrameworkElement frameworkElement = e.OriginalSource as FrameworkElement;

            if (frameworkElement != null)
            {
                item = frameworkElement.DataContext as AllocationItem;
            }

            if (controlPosition.X < LoadChartDataGrid.ActualWidth - LoadChartDataGrid.GanttChartView.ActualWidth)
            {
                return;
            }
            string message = String.Empty;

            if (controlPosition.Y < LoadChartDataGrid.HeaderHeight)
            {
                message = string.Format("You have clicked the chart scale header at date and time {0:g}.", dateTime);
            }
            else if (item != null)
            {
                message = string.Format("You have clicked the allocation item '{0}' of resource item '#{1}' at date and time {2:g}.", item, itemRow.ActualDisplayRowIndex + 1, dateTime > item.Finish ? item.Finish : dateTime);
            }
            else if (itemRow != null)
            {
                message = string.Format("You have clicked at date and time {0:g} within the row of item '#{1}'.", dateTime, itemRow.ActualDisplayRowIndex + 1);
            }
            else
            {
                message = string.Format("You have clicked at date and time {0:g} within an empty area of the chart.", dateTime);
            }

            NotificationsTextBox.AppendText(string.Format("{0}{1}", NotificationsTextBox.Text.Length > 0 ? "\n" : string.Empty, message));
            NotificationsTextBox.ScrollToEnd();
        }
        public MainWindow()
        {
            InitializeComponent();

            AllocationItem allocation11 = LoadChartView.Items[0].GanttChartItems[0];

            allocation11.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            allocation11.Finish = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));

            AllocationItem allocation112 = LoadChartView.Items[0].GanttChartItems[1];

            allocation112.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            allocation112.Finish = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00"));
            allocation112.Units  = 1.5;

            AllocationItem allocation12 = LoadChartView.Items[0].GanttChartItems[2];

            allocation12.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("12:00:00"));
            allocation12.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));
            allocation12.Units  = 0.5;

            AllocationItem allocation13 = LoadChartView.Items[0].GanttChartItems[3];

            allocation13.Start  = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("08:00:00"));
            allocation13.Finish = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("16:00:00"));

            AllocationItem allocation22 = LoadChartView.Items[1].GanttChartItems[0];

            allocation22.Start  = DateTime.Today.AddDays(1).Add(TimeSpan.Parse("08:00:00"));
            allocation22.Finish = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("16:00:00"));

            for (int i = 3; i <= 16; i++)
            {
                LoadChartItem item = new LoadChartItem();
                for (int j = 1; j <= (i - 1) % 4 + 1; j++)
                {
                    item.GanttChartItems.Add(
                        new AllocationItem
                    {
                        Content = "Task " + i + "." + j + (((i + j) % 2 == 1 ? " [200%]" : string.Empty) + " (Resource " + i + ")"),
                        Start   = DateTime.Today.AddDays(i + (i - 1) * (j - 1)),
                        Finish  = DateTime.Today.AddDays(i * 1.2 + (i - 1) * (j - 1) + 1),
                        Units   = 1 + (i + j) % 2
                    });
                }
                LoadChartView.Items.Add(item);
            }

            // You may uncomment the next lines of code to test the component performance:
            // for (int i = 17; i <= 1024; i++)
            // {
            //    LoadChartItem item = new LoadChartItem();
            //    for (int j = 1; j <= (i - 1) % 4 + 1; j++)
            //    {
            //        item.GanttChartItems.Add(
            //            new AllocationItem
            //            {
            //                Content = "Task " + i + "." + j + (((i + j) % 2 == 1 ? " [200%]" : string.Empty) + " (Resource " + i + ")"),
            //                Start = DateTime.Today.AddDays(i + (i - 1) * (j - 1)),
            //                Finish = DateTime.Today.AddDays(i * 1.2 + (i - 1) * (j - 1) + 1),
            //                Units = 1 + (i + j) % 2
            //            });
            //    }
            //    LoadChartView.Items.Add(item);
            // }

            // Initialize the control area.
            ScalesComboBox.SelectedIndex   = 0;
            ShowWeekendsCheckBox.IsChecked = true;
        }