private void ScheduleChartButton_Click(object sender, RoutedEventArgs e)
        {
            double originalOpacity = Opacity;

            Opacity = 0.5;
            GanttChartDataGrid.UnassignedScheduleChartItemContent = "(Unassigned)"; // Optional
            ObservableCollection <ScheduleChartItem> scheduleChartItems = GanttChartDataGrid.GetScheduleChartItems();
            Window scheduleChartWindow =
                new Window
            {
                Owner   = Application.Current.MainWindow, Title = "Schedule Chart", WindowStartupLocation = WindowStartupLocation.CenterOwner, Width = 640, Height = 480, ResizeMode = ResizeMode.CanResize,
                Content = new ScheduleChartDataGrid
                {
                    Items = scheduleChartItems, DataGridWidth = new GridLength(0.2, GridUnitType.Star),
                    UseMultipleLinesPerRow = true, AreIndividualItemAppearanceSettingsApplied = true, IsAlternatingItemBackgroundInverted = true, UnassignedScheduleChartItemContent = GanttChartDataGrid.UnassignedScheduleChartItemContent     // Optional
                }
            };

            if (themeResourceDictionary != null)
            {
                (scheduleChartWindow.Content as FrameworkElement).Resources.MergedDictionaries.Add(themeResourceDictionary);
            }
            scheduleChartWindow.ShowDialog();
            GanttChartDataGrid.UpdateChangesFromScheduleChartItems(scheduleChartItems);
            GanttChartDataGrid.DisposeScheduleChartItems(scheduleChartItems);
            Opacity = originalOpacity;
        }
Ejemplo n.º 2
0
        private void IncreaseIndentationButton_Click(object sender, RoutedEventArgs e)
        {
            List <GanttChartItem> items = new List <GanttChartItem>();

            foreach (GanttChartItem item in GanttChartDataGrid.GetSelectedItems())
            {
                items.Add(item);
            }
            if (items.Count <= 0)
            {
                MessageBox.Show("Cannot increase indentation for the selected item(s) as the selection is empty; select an item first.", "Information", MessageBoxButton.OK);
                return;
            }
            foreach (GanttChartItem item in items)
            {
                int index = GanttChartDataGrid.IndexOf(item);
                if (index > 0)
                {
                    GanttChartItem previousItem = GanttChartDataGrid[index - 1];
                    if (item.Indentation <= previousItem.Indentation)
                    {
                        item.Indentation++;
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Cannot increase indentation for {0} because the previous item is its parent item; increase the indentation of its parent item first.", item), "Information", MessageBoxButton.OK);
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Cannot increase indentation for {0} because it is the first item; insert an item before this one first.", item), "Information", MessageBoxButton.OK);
                }
            }
        }
        private void MoveDownButton_Click(object sender, RoutedEventArgs e)
        {
            if (GanttChartDataGrid.GetSelectedItemCount() <= 0)
            {
                MessageBox.Show("Cannot move selected item(s) as the selection is empty; select an item first.", "Information", MessageBoxButton.OK);
                return;
            }
            var selectedItems = GanttChartDataGrid.GetSelectedItems().Reverse().ToArray();

            if (selectedItems.Select(i => i.Parent).Distinct().Count() > 1)
            {
                MessageBox.Show("Cannot move selected item(s) as the selection includes items that have different parents; select only root items or only items having the same parent.", "Information", MessageBoxButton.OK);
                return;
            }
            // GanttChartDataGrid.BeginInit();
            foreach (GanttChartItem item in selectedItems)
            {
                GanttChartDataGrid.MoveDown(item, true, true);
            }
            // GanttChartDataGrid.EndInit();
            GanttChartDataGrid.SelectedItems.Clear();
            foreach (GanttChartItem item in selectedItems)
            {
                GanttChartDataGrid.SelectedItems.Add(item);
            }
        }
Ejemplo n.º 4
0
        private void NetworkDiagramButton_Click(object sender, RoutedEventArgs e)
        {
            // Optionally, specify a maximum indentation level to consider when generating network items as a parameter to the GetNetworkDiagramItems method call.
            networkDiagramItems = GanttChartDataGrid.GetNetworkDiagramItems();
            var networkDiagramView = new DlhSoft.Windows.Controls.Pert.NetworkDiagramView {
                Items = networkDiagramItems
            };
            ChildWindow networkDiagramWindow =
                new ChildWindow
            {
                Title   = "Network Diagram", Width = 960, Height = 600,
                Content = networkDiagramView
            };

            networkDiagramView.AsyncPresentationCompleted += delegate(object senderCompleted, EventArgs eCompleted)
            {
                // Optionally, reposition start and finish milestones between the first and second rows of the view.
                networkDiagramView.RepositionEnds();
                // Optionally, highlight the critical path.
                Brush redBrush = new SolidColorBrush(Colors.Red);
                foreach (var item in networkDiagramView.GetCriticalItems())
                {
                    DlhSoft.Windows.Controls.Pert.NetworkDiagramView.SetShapeStroke(item, redBrush);
                }
                foreach (var predecessorItem in networkDiagramView.GetCriticalDependencies())
                {
                    DlhSoft.Windows.Controls.Pert.NetworkDiagramView.SetDependencyLineStroke(predecessorItem, redBrush);
                }
            };
            networkDiagramWindow.Closed += NetworkDiagramWindow_Closed;
            networkDiagramWindow.Show();
        }
Ejemplo n.º 5
0
        private void DecreaseIndentationButton_Click(object sender, RoutedEventArgs e)
        {
            List <GanttChartItem> items = new List <GanttChartItem>();

            foreach (GanttChartItem item in GanttChartDataGrid.GetSelectedItems())
            {
                items.Add(item);
            }
            if (items.Count <= 0)
            {
                MessageBox.Show("Cannot decrease indentation for the selected item(s) as the selection is empty; select an item first.", "Information", MessageBoxButton.OK);
                return;
            }
            items.Reverse();
            foreach (GanttChartItem item in items)
            {
                if (item.Indentation > 0)
                {
                    int            index    = GanttChartDataGrid.IndexOf(item);
                    GanttChartItem nextItem = index < GanttChartDataGrid.Items.Count - 1 ? GanttChartDataGrid[index + 1] : null;
                    if (nextItem == null || item.Indentation >= nextItem.Indentation)
                    {
                        item.Indentation--;
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Cannot increase indentation for {0} because the next item is one of its child items; decrease the indentation of its child items first.", item), "Information", MessageBoxButton.OK);
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Cannot decrease indentation for {0} because it is on the first indentation level, being a root item.", item), "Information", MessageBoxButton.OK);
                }
            }
        }
Ejemplo n.º 6
0
        private void PertChartButton_Click(object sender, RoutedEventArgs e)
        {
            // Optionally, specify a maximum indentation level to consider when generating PERT items as a parameter to the GetPertChartItems method call.
            pertChartItems = GanttChartDataGrid.GetPertChartItems();
            var pertChartView = new DlhSoft.Windows.Controls.Pert.PertChartView {
                Items = pertChartItems, PredecessorToolTipTemplate = Resources["PertChartPredecessorToolTipTemplate"] as DataTemplate
            };
            ChildWindow pertChartWindow =
                new ChildWindow
            {
                Title   = "PERT Chart", Width = 640, Height = 480,
                Content = pertChartView
            };

            pertChartView.AsyncPresentationCompleted += delegate(object senderCompleted, EventArgs eCompleted)
            {
                // Optionally, highlight the critical path.
                Brush redBrush = new SolidColorBrush(Colors.Red);
                foreach (var item in pertChartView.GetCriticalItems())
                {
                    DlhSoft.Windows.Controls.Pert.PertChartView.SetShapeStroke(item, redBrush);
                    DlhSoft.Windows.Controls.Pert.PertChartView.SetTextForeground(item, redBrush);
                }
                foreach (var predecessorItem in pertChartView.GetCriticalDependencies())
                {
                    DlhSoft.Windows.Controls.Pert.PertChartView.SetDependencyLineStroke(predecessorItem, redBrush);
                    DlhSoft.Windows.Controls.Pert.PertChartView.SetDependencyTextForeground(predecessorItem, redBrush);
                }
            };
            pertChartWindow.Closed += PertChartWindow_Closed;
            pertChartWindow.Show();
        }
Ejemplo n.º 7
0
        private void CriticalPathCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            EditButton.IsEnabled                          = false;
            AddNewButton.IsEnabled                        = false;
            InsertNewButton.IsEnabled                     = false;
            IncreaseIndentationButton.IsEnabled           = false;
            DecreaseIndentationButton.IsEnabled           = false;
            DeleteButton.IsEnabled                        = false;
            PasteButton.IsEnabled                         = false;
            UndoButton.IsEnabled                          = false;
            RedoButton.IsEnabled                          = false;
            SetColorButton.IsEnabled                      = false;
            SplitRemainingWorkButton.IsEnabled            = false;
            LevelResourcesButton.IsEnabled                = false;
            EnableDependencyConstraintsCheckBox.IsEnabled = false;
            ScheduleChartButton.IsEnabled                 = false;
            LoadProjectXmlButton.IsEnabled                = false;
            GanttChartDataGrid.IsReadOnly                 = true;
            TimeSpan criticalDelay = TimeSpan.FromHours(8);

            foreach (GanttChartItem item in GanttChartDataGrid.Items)
            {
                if (item.HasChildren)
                {
                    continue;
                }
                SetCriticalPathHighlighting(item, GanttChartDataGrid.IsCritical(item, criticalDelay));
            }
            if (CriticalPathCheckBox.IsChecked == true)
            {
                MessageBox.Show("Gantt Chart items are temporarily read only while critical path is highlighted.", "Information", MessageBoxButton.OK);
            }
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            List <GanttChartItem> items = new List <GanttChartItem>();

            foreach (GanttChartItem item in GanttChartDataGrid.GetSelectedItems())
            {
                items.Add(item);
            }
            if (items.Count <= 0)
            {
                MessageBox.Show("Cannot delete the selected item(s) as the selection is empty; select an item first.", "Information", MessageBoxButton.OK);
                return;
            }
            items.Reverse();
            // If you have many items, you may use BeginInit and EndInit to avoid intermediate user interface updates.
            // GanttChartDataGrid.BeginInit();
            foreach (GanttChartItem item in items)
            {
                if (item.HasChildren)
                {
                    MessageBox.Show(string.Format("Cannot delete {0} because it has child items; remove its child items first.", item), "Information", MessageBoxButton.OK);
                    continue;
                }
                GanttChartDataGrid.Items.Remove(item);
            }
            // GanttChartDataGrid.EndInit();
        }
Ejemplo n.º 9
0
        private void GanttChartDataGrid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point controlPosition = e.GetPosition(GanttChartDataGrid);
            Point contentPosition = e.GetPosition(GanttChartDataGrid.ChartContentElement);

            DateTime       dateTime = GanttChartDataGrid.GetDateTime(contentPosition.X);
            GanttChartItem itemRow  = GanttChartDataGrid.GetItemAt(contentPosition.Y);

            GanttChartItem   item             = null;
            PredecessorItem  predecessorItem  = null;
            FrameworkElement frameworkElement = e.OriginalSource as FrameworkElement;

            if (frameworkElement != null)
            {
                item = frameworkElement.DataContext as GanttChartItem;
                DependencyArrowLine.LineSegment dependencyLine = frameworkElement.DataContext as DependencyArrowLine.LineSegment;
                if (dependencyLine != null)
                {
                    predecessorItem = dependencyLine.Parent.DataContext as PredecessorItem;
                }
            }

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

            if (controlPosition.Y < GanttChartDataGrid.HeaderHeight)
            {
                message = string.Format("You have clicked the chart scale header at date and time {0:g}.", dateTime);
            }
            else if (item != null && item.HasChildren)
            {
                message = string.Format("You have clicked the summary task item '{0}' at date and time {1:g}.", item, dateTime < item.Start ? item.Start : (dateTime > item.Finish ? item.Finish : dateTime));
            }
            else if (item != null && item.IsMilestone)
            {
                message = string.Format("You have clicked the milestone task item '{0}' at date and time {1:g}.", item, item.Start);
            }
            else if (item != null)
            {
                message = string.Format("You have clicked the standard task item '{0}' at date and time {1:g}.", item, dateTime > item.Finish ? item.Finish : dateTime);
            }
            else if (predecessorItem != null)
            {
                message = string.Format("You have clicked the task dependency line between '{0}' and '{1}'.", predecessorItem.DependentItem, predecessorItem.Item);
            }
            else if (itemRow != null)
            {
                message = string.Format("You have clicked at date and time {0:g} within the row of item '{1}'.", dateTime, itemRow);
            }
            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();
        }
Ejemplo n.º 10
0
 private void CopyButton_Click(object sender, RoutedEventArgs e)
 {
     if (GanttChartDataGrid.GetSelectedItemCount() <= 0)
     {
         MessageBox.Show("Cannot copy selected item(s) as the selection is empty; select an item first.", "Information", MessageBoxButton.OK);
         return;
     }
     GanttChartDataGrid.Copy();
 }
Ejemplo n.º 11
0
        private void ProjectStatisticsButton_Click(object sender, RoutedEventArgs e)
        {
            var statistics = string.Format("Start:\t{0:d}\nFinish:\t{1:d}\nEffort:\t{2:0.##}h\nCompl.:\t{3:0.##%}\nCost:\t${4:0.##}",
                                           GanttChartDataGrid.GetProjectStart(), GanttChartDataGrid.GetProjectFinish(),
                                           GanttChartDataGrid.GetProjectEffort().TotalHours, GanttChartDataGrid.GetProjectCompletion(),
                                           GanttChartDataGrid.GetProjectCost());

            MessageBox.Show(statistics, "Project statistics", MessageBoxButton.OK);
        }
 private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (TabControl.SelectedItem == PertChartTabItem)
     {
         // Get PERT Chart items from Gantt Chart. The collection may contain generic links, i.e. virtual effort tasks.
         var taskEvents = GanttChartDataGrid.GetPertChartItems();
         OptimizeTasks(taskEvents); // Comment this line to see default behavior of DlhSoft Gantt Chart Light Library components.
         PertChartView.Items = taskEvents;
     }
 }
Ejemplo n.º 13
0
        private void MinorScaleHeaderFormatComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (GanttChartDataGrid == null)
            {
                return;
            }
            TimeScaleTextFormat headerFormat = (TimeScaleTextFormat)MinorScaleHeaderFormatComboBox.SelectedItem;

            GanttChartDataGrid.GetScale(1).HeaderContentFormat = headerFormat;
        }
Ejemplo n.º 14
0
        private void AddNewButton_Click(object sender, RoutedEventArgs e)
        {
            GanttChartItem item = new GanttChartItem {
                Content = "New Task", Start = DateTime.Today, Finish = DateTime.Today.AddDays(1)
            };

            GanttChartDataGrid.Items.Add(item);
            GanttChartDataGrid.SelectedItem = item;
            GanttChartDataGrid.ScrollTo(item);
        }
Ejemplo n.º 15
0
        private void SetMajorScale()
        {
            if (GanttChartDataGrid == null)
            {
                return;
            }
            ScaleType scaleType = (ScaleType)MajorScaleTypeComboBox.SelectedItem;

            GanttChartDataGrid.GetScale(0).ScaleType = GetActualScaleType(scaleType);
            UpdateFromSelectedMajorScaleType(scaleType);
        }
Ejemplo n.º 16
0
        private void SplitRemainingWorkButton_Click(object sender, RoutedEventArgs e)
        {
            GanttChartItem selectedItem = GanttChartDataGrid.SelectedItem as GanttChartItem;

            if (selectedItem == null || selectedItem.HasChildren || selectedItem.IsMilestone || !selectedItem.HasStarted || selectedItem.IsCompleted)
            {
                MessageBox.Show("Cannot split work as the selection is empty or the selected item does not represent a standard task in progress; you should select an appropriate item first.", "Information", MessageBoxButton.OK);
                return;
            }
            GanttChartDataGrid.SplitRemainingWork(selectedItem, " (rem. work)", " (compl. work)");
        }
Ejemplo n.º 17
0
 private void RedoButton_Click(object sender, RoutedEventArgs e)
 {
     if (GanttChartDataGrid.CanRedo())
     {
         GanttChartDataGrid.Redo();
     }
     else
     {
         MessageBox.Show("Currently there is no recorded action in the redo queue; perform an action and undo it first.", "Information", MessageBoxButton.OK);
     }
 }
Ejemplo n.º 18
0
        private void SetMinorScale()
        {
            if (GanttChartDataGrid == null || MinorScaleTypeComboBox.SelectedItem == null)
            {
                return;
            }
            var scaleType = (ScaleType)MinorScaleTypeComboBox.SelectedItem;

            GanttChartDataGrid.GetScale(1).ScaleType = GetActualScaleType(scaleType);
            UpdateFromSelectedMinorScaleType(scaleType);
        }
        private void AddNewButton_Click(object sender, RoutedEventArgs e)
        {
            GanttChartItem item = new GanttChartItem {
                Content = "New Task", Start = DateTime.Today, Finish = DateTime.Today.AddDays(1)
            };

            GanttChartDataGrid.Items.Add(item);
            Dispatcher.BeginInvoke((Action) delegate
            {
                GanttChartDataGrid.SelectedItem = item;
                GanttChartDataGrid.ScrollTo(item);
                GanttChartDataGrid.ScrollTo(item.Start);
            });
        }
Ejemplo n.º 20
0
 private void MajorScaleSeparatorCheckBox_Checked(object sender, RoutedEventArgs e)
 {
     if (GanttChartDataGrid == null)
     {
         return;
     }
     if (MajorScaleSeparatorCheckBox.IsChecked == true)
     {
         GanttChartDataGrid.GetScale(0).BorderThickness = new Thickness(0, 0, 1, 0);
     }
     else
     {
         GanttChartDataGrid.GetScale(0).BorderThickness = new Thickness(0);
     }
 }
Ejemplo n.º 21
0
        private void InsertNewButton_Click(object sender, RoutedEventArgs e)
        {
            GanttChartItem selectedItem = GanttChartDataGrid.SelectedItem as GanttChartItem;

            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;
            }
            GanttChartItem item = new GanttChartItem {
                Content = "New Task", Indentation = selectedItem.Indentation, Start = DateTime.Today, Finish = DateTime.Today.AddDays(1)
            };

            GanttChartDataGrid.Items.Insert(GanttChartDataGrid.SelectedIndex, item);
            GanttChartDataGrid.SelectedItem = item;
            GanttChartDataGrid.ScrollTo(item);
        }
        public MainWindow()
        {
            InitializeComponent();
            RecurrentGanttChartItem item1 = GanttChartDataGrid.Items[1] as RecurrentGanttChartItem;

            item1.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item1.Finish = DateTime.Today.Add(TimeSpan.Parse("16:00:00"));
            // Set OccurrenceCount to indicate the number of occurrences that should be generated for the task.
            item1.OccurrenceCount = 4;
            RecurrentGanttChartItem item2 = GanttChartDataGrid.Items[2] as RecurrentGanttChartItem;

            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.OccurrenceCount = 3;
            RecurrentGanttChartItem item4 = GanttChartDataGrid.Items[4] as RecurrentGanttChartItem;

            item4.Start           = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item4.Finish          = DateTime.Today.AddDays(2).Add(TimeSpan.Parse("12:00:00"));
            item4.OccurrenceCount = int.MaxValue;
            RecurrentGanttChartItem item6 = GanttChartDataGrid.Items[6] as RecurrentGanttChartItem;

            item6.Start  = DateTime.Today.Add(TimeSpan.Parse("08:00:00"));
            item6.Finish = DateTime.Today.AddDays(3).Add(TimeSpan.Parse("12:00:00"));
            // You may set OccurrenceCount to MaxValue to indicate that virtually unlimited occurrences should be generated.
            item6.OccurrenceCount = int.MaxValue;
            RecurrentGanttChartItem item7 = GanttChartDataGrid.Items[7] as RecurrentGanttChartItem;

            item7.Start  = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("08:00:00"));
            item7.Finish = DateTime.Today.AddDays(4).Add(TimeSpan.Parse("16:00:00"));
            // Set RecurrenceType to indicate the type of recurrence to use when generating occurrences for the task.
            item7.RecurrenceType  = RecurrenceType.Daily;
            item7.OccurrenceCount = 2;

            // Component ApplyTemplate is called in order to complete loading of the user interface, after the main ApplyTemplate that initializes the custom theme, and using an asynchronous action to allow further constructor initializations if they exist (such as setting up the theme name to load).
            Dispatcher.BeginInvoke((Action) delegate
            {
                ApplyTemplate();

                // Apply template to be able to access the internal GanttChartView control.
                GanttChartDataGrid.ApplyTemplate();

                // Set up the internally managed occurrence item collection to be displayed in the chart area (instead of GanttChartDataGrid.Items).
                GanttChartDataGrid.GanttChartView.Items = ganttChartItemOccurrences;
                UpdateOccurrences();
            });
        }
        private void LoadChartButton_Click(object sender, RoutedEventArgs e)
        {
            double originalOpacity = Opacity;

            Opacity = 0.5;
            ObservableCollection <LoadChartItem> loadChartItems = GanttChartDataGrid.GetLoadChartItems();
            ObservableCollection <LoadChartItem> selectedLoadChartItemContainer = new ObservableCollection <LoadChartItem>();
            ComboBox resourceComboBox = new ComboBox {
                ItemsSource = loadChartItems, DisplayMemberPath = "Content", Margin = new Thickness(4)
            };

            resourceComboBox.SelectionChanged += delegate
            {
                selectedLoadChartItemContainer.Clear();
                selectedLoadChartItemContainer.Add(resourceComboBox.SelectedItem as LoadChartItem);
            };
            if (resourceComboBox.Items.Count > 0)
            {
                resourceComboBox.SelectedIndex = 0;
            }
            DockPanel dockPanel = new DockPanel();

            dockPanel.Children.Add(resourceComboBox);
            DockPanel.SetDock(resourceComboBox, Dock.Top);
            dockPanel.Children.Add(new LoadChartView {
                Items = selectedLoadChartItemContainer, ItemHeight = 170, BarHeight = 166, Height = 230, Margin = new Thickness(4, 0, 4, 4), VerticalAlignment = VerticalAlignment.Top
            });
            Window loadChartWindow =
                new Window
            {
                Owner   = Application.Current.MainWindow, Title = "Load Chart", WindowStartupLocation = WindowStartupLocation.CenterOwner, Width = 640, Height = 300, ResizeMode = ResizeMode.CanMinimize,
                Content = dockPanel
            };

            if (themeResourceDictionary != null)
            {
                var loadChartView = dockPanel.Children[dockPanel.Children.Count - 1] as LoadChartView;
                loadChartView.Resources.MergedDictionaries.Add(themeResourceDictionary);
                loadChartView.BarHeight  -= 15;
                loadChartView.ItemHeight -= 15;
            }
            loadChartWindow.ShowDialog();
            GanttChartDataGrid.DisposeLoadChartItems(loadChartItems);
            Opacity = originalOpacity;
        }
Ejemplo n.º 24
0
        private void SortingToggleButton_CheckedChanged(object sender, RoutedEventArgs e)
        {
            ToggleButton toggleButton = e.OriginalSource as ToggleButton;

            if (toggleButton == null)
            {
                return;
            }
            string columnHeader = toggleButton.DataContext as string;

            if (columnHeader == null)
            {
                return;
            }
            GanttChartDataGrid.Sort(
                delegate(GanttChartItem item1, GanttChartItem item2) { return(Compare(item1, item2, columnHeader)); },
                toggleButton.IsChecked == true);
        }
Ejemplo n.º 25
0
        private void ScheduleChartButton_Click(object sender, RoutedEventArgs e)
        {
            GanttChartDataGrid.UnassignedScheduleChartItemContent = "(Unassigned)"; // Optional
            scheduleChartItems = GanttChartDataGrid.GetScheduleChartItems();
            ChildWindow scheduleChartWindow =
                new ChildWindow
            {
                Title   = "Schedule Chart", Width = 640, Height = 480,
                Content = new ScheduleChartDataGrid
                {
                    Items = scheduleChartItems, DataGridWidth = new GridLength(0.2, GridUnitType.Star),
                    UseMultipleLinesPerRow = true, AreIndividualItemAppearanceSettingsApplied = true, IsAlternatingItemBackgroundInverted = true, UnassignedScheduleChartItemContent = GanttChartDataGrid.UnassignedScheduleChartItemContent     // Optional
                }
            };

            scheduleChartWindow.Closed += ScheduleChartWindow_Closed;
            scheduleChartWindow.Show();
        }
Ejemplo n.º 26
0
        private void LoadProjectXmlButton_Click(object sender, RoutedEventArgs e)
        {
            // Select a Project XML file to load data from.
            OpenFileDialog openFileDialog = new OpenFileDialog {
                Filter = "Project XML files|*.xml", Multiselect = false
            };

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }
            var assignableResources = GanttChartDataGrid.AssignableResources;

            using (Stream stream = openFileDialog.File.OpenRead())
            {
                GanttChartDataGrid.LoadProjectXml(stream, assignableResources);
            }
        }
Ejemplo n.º 27
0
        private void SaveProjectXmlButton_Click(object sender, RoutedEventArgs e)
        {
            // Select a Project XML file to save data to.
            SaveFileDialog saveFileDialog = new SaveFileDialog {
                Filter = "Project XML files|*.xml", DefaultExt = ".xml"
            };

            if (saveFileDialog.ShowDialog() != true)
            {
                return;
            }
            var assignableResources = GanttChartDataGrid.AssignableResources;

            using (Stream stream = saveFileDialog.OpenFile())
            {
                GanttChartDataGrid.SaveProjectXml(stream, assignableResources);
            }
        }
Ejemplo n.º 28
0
        private void LoadChartButton_Click(object sender, RoutedEventArgs e)
        {
            loadChartItems = GanttChartDataGrid.GetLoadChartItems();
            ObservableCollection <LoadChartItem> selectedLoadChartItemContainer = new ObservableCollection <LoadChartItem>();
            ComboBox resourceComboBox = new ComboBox {
                ItemsSource = loadChartItems, DisplayMemberPath = "Content", Margin = new Thickness(0, 0, 0, 4)
            };

            resourceComboBox.SelectionChanged += delegate
            {
                selectedLoadChartItemContainer.Clear();
                selectedLoadChartItemContainer.Add(resourceComboBox.SelectedItem as LoadChartItem);
            };
            if (resourceComboBox.Items.Count > 0)
            {
                resourceComboBox.SelectedIndex = 0;
            }
            Grid grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(0, GridUnitType.Auto)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.Children.Add(resourceComboBox);
            Grid.SetRow(resourceComboBox, 0);
            LoadChartView loadChartView = new LoadChartView {
                Items = selectedLoadChartItemContainer, ItemHeight = 176, BarHeight = 172, Height = 240, VerticalAlignment = VerticalAlignment.Top
            };

            grid.Children.Add(loadChartView);
            Grid.SetRow(loadChartView, 1);
            ChildWindow loadChartWindow =
                new ChildWindow
            {
                Title   = "Load Chart", Width = 640, Height = 300,
                Content = grid
            };

            loadChartWindow.Closed += LoadChartWindow_Closed;
            loadChartWindow.Show();
        }
 private void ExportImageButton_Click(object sender, RoutedEventArgs e)
 {
     GanttChartDataGrid.Export((Action) delegate
     {
         SaveFileDialog saveFileDialog = new SaveFileDialog {
             Title = "Export Image To", Filter = "PNG image files|*.png"
         };
         if (saveFileDialog.ShowDialog() != true)
         {
             return;
         }
         BitmapSource bitmapSource = GanttChartDataGrid.GetExportBitmapSource(96 * 2);
         using (Stream stream = saveFileDialog.OpenFile())
         {
             PngBitmapEncoder pngBitmapEncoder = new PngBitmapEncoder();
             pngBitmapEncoder.Frames.Add(BitmapFrame.Create(bitmapSource));
             pngBitmapEncoder.Save(stream);
         }
     });
 }
Ejemplo n.º 30
0
        private void MoveDownButton_Click(object sender, RoutedEventArgs e)
        {
            if (GanttChartDataGrid.GetSelectedItemCount() <= 0)
            {
                MessageBox.Show("Cannot move as the selection is empty; select an item first.", "Information", MessageBoxButton.OK);
                return;
            }
            if (GanttChartDataGrid.GetSelectedItemCount() > 1)
            {
                MessageBox.Show("Cannot move as the selection is multiple; select a single item to move.", "Information", MessageBoxButton.OK);
                return;
            }
            var item = GanttChartDataGrid.SelectedItem;

            GanttChartDataGrid.MoveDown(item, true, true);
            Dispatcher.BeginInvoke((Action) delegate
            {
                GanttChartDataGrid.SelectedItem = item;
            });
        }