private void Gantt_Loaded(object sender, RoutedEventArgs e)
        {
            Border       border       = VisualTreeHelper.GetChild(Gantt, 0) as Border;
            Grid         grid         = VisualTreeHelper.GetChild(border, 0) as Grid;
            ScrollViewer scrollViewer = VisualTreeHelper.GetChild(grid, 2) as ScrollViewer;
            Grid         scrollGrid   = scrollViewer.Content as Grid;

            ganttChart    = VisualTreeHelper.GetChild(scrollGrid, 1) as GanttChart;
            ganttSchedule = VisualTreeHelper.GetChild(scrollGrid, 0) as GanttSchedule;

            List <StripLineInfo> stripCollection = new List <StripLineInfo>();
            var differenceTime = (this.ganttSchedule.EndTime - this.ganttSchedule.StartTime).Days;

            for (int i = 0; i < differenceTime; i++)
            {
                stripCollection.Add(new StripLineInfo()
                {
                    Type     = StriplineType.Absolute,
                    Width    = 2,
                    Height   = this.ganttChart.ActualHeight,
                    Position = new Point(PositionCalculation(this.ganttSchedule.StartTime.AddDays(i)), 0),
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    Background = new SolidColorBrush(Colors.Orange),
                });
            }
            model.StripCollection = stripCollection;
        }
コード例 #2
0
        private void RefreshSchedule()
        {
            FieldInfo propertyInfo = typeof(GanttControl).GetField(
                "GanttSchedule",
                BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            GanttSchedule ganttSchedule = (GanttSchedule)propertyInfo.GetValue(this.Gantt);

            if (ganttSchedule != null)
            {
                MethodInfo RedrawSchedule = ganttSchedule.GetType().GetMethod("RedrawSchedule", BindingFlags.Instance | BindingFlags.NonPublic);
                RedrawSchedule.Invoke(ganttSchedule, new object[] { });
            }
        }