Пример #1
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();
        }
        private void GanttChartDataGrid_ItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.StartsWith("Actual") || e.PropertyName.StartsWith("Computed") || e.PropertyName.Contains("Index"))
            {
                return;
            }
            var    item    = sender as GanttChartItem;
            string message = string.Format("Property '{0}' of item '{1}' has changed.", e.PropertyName, item);

            NotificationsTextBox.AppendText(string.Format("{0}{1}", NotificationsTextBox.Text.Length > 0 ? "\n" : string.Empty, message));
            NotificationsTextBox.ScrollToEnd();
        }
        private void ScheduleChartDataGrid_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point controlPosition = e.GetPosition(ScheduleChartDataGrid);
            Point contentPosition = e.GetPosition(ScheduleChartDataGrid.ChartContentElement);

            DateTime          dateTime = ScheduleChartDataGrid.GetDateTime(contentPosition.X);
            ScheduleChartItem itemRow  = ScheduleChartDataGrid.GetItemAt(contentPosition.Y);

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

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

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

            if (controlPosition.Y < ScheduleChartDataGrid.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 task item '{0}' assigned to resource item '{1}' at date and time {2:g}.", item, itemRow, 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);
            }
            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();
        }