private void CalculateResourceChartPlotModel() { lock (m_Lock) { IList <ResourceSeriesDto> resourceSeriesSet = ResourceSeriesSet; PlotModel plotModel = null; if (resourceSeriesSet != null && resourceSeriesSet.Any()) { plotModel = new PlotModel(); plotModel.Axes.Add(BuildResourceChartXAxis()); plotModel.Axes.Add(BuildResourceChartYAxis()); plotModel.LegendPlacement = LegendPlacement.Outside; plotModel.LegendPosition = LegendPosition.RightMiddle; var total = new List <int>(); m_DateTimeCalculator.UseBusinessDays(UseBusinessDays); foreach (ResourceSeriesDto series in resourceSeriesSet) { if (series != null) { var areaSeries = new AreaSeries { Smooth = false, StrokeThickness = 0.0, Title = series.Title, Color = OxyColor.FromArgb( series.ColorFormatDto.A, series.ColorFormatDto.R, series.ColorFormatDto.G, series.ColorFormatDto.B) }; for (int i = 0; i < series.Values.Count; i++) { int j = series.Values[i]; if (i >= total.Count) { total.Add(0); } areaSeries.Points.Add( new DataPoint(ChartHelper.CalculateChartTimeXValue(i, ShowDates, ProjectStart, m_DateTimeCalculator), total[i])); total[i] += j; areaSeries.Points2.Add( new DataPoint(ChartHelper.CalculateChartTimeXValue(i, ShowDates, ProjectStart, m_DateTimeCalculator), total[i])); } plotModel.Series.Add(areaSeries); } } } ResourceChartPlotModel = plotModel; } RaiseCanExecuteChangedAllCommands(); }
public void UseBusinessDays(bool useBusinessDays) { m_DateTimeCalculator.UseBusinessDays(useBusinessDays); RaisePropertyChanged(nameof(EarliestStartDateTime)); RaisePropertyChanged(nameof(LatestStartDateTime)); RaisePropertyChanged(nameof(EarliestFinishDateTime)); RaisePropertyChanged(nameof(LatestFinishDateTime)); CalculateMinimumEarliestStartTime(); RaisePropertyChanged(nameof(MinimumEarliestStartTime)); CalculateMaximumLatestFinishTime(); RaisePropertyChanged(nameof(MaximumLatestFinishTime)); }
private double?CalculateDurationManMonths() { lock (m_Lock) { int?durationManDays = m_CoreViewModel.Duration; if (!durationManDays.HasValue) { return(null); } m_DateTimeCalculator.UseBusinessDays(UseBusinessDays); int daysPerWeek = m_DateTimeCalculator.DaysPerWeek; return(durationManDays.GetValueOrDefault() / (daysPerWeek * 52.0 / 12.0)); } }
private void GenerateGanttChart() { GanttChartAreaCtrl.ClearGantt(); GanttChartDto ganttChartDto = ViewModel.GanttChartDto; if (ganttChartDto != null) { IList <IDependentActivity <int> > dependentActivities = ganttChartDto.DependentActivities; IList <ResourceSeriesDto> resourceSeriesSet = ganttChartDto.ResourceSeriesSet; IList <IResourceSchedule <int> > resourceSchedules = ganttChartDto.ResourceSchedules; m_DateTimeCalculator.UseBusinessDays(ViewModel.UseBusinessDays); DateTime projectStart = ViewModel.ProjectStart; DateTime minDate = DatePicker.SelectedDate ?? projectStart; DateTime maxDate = minDate.AddDays(DaysSelect.Value.GetValueOrDefault()); GanttChartAreaCtrl.Initialize(minDate, maxDate); // Create timelines and define how they should be presented. GanttChartAreaCtrl.CreateTimeLine(new PeriodYearSplitter(minDate, maxDate), FormatYear); GanttChartAreaCtrl.CreateTimeLine(new PeriodMonthSplitter(minDate, maxDate), FormatMonth); TimeLine gridLineTimeLine = GanttChartAreaCtrl.CreateTimeLine(new PeriodDaySplitter(minDate, maxDate), FormatDay); //GanttChartAreaCtrl.CreateTimeLine(new PeriodDaySplitter(minDate, maxDate), FormatDayName); // Attach gridlines. GanttChartAreaCtrl.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground); // Prep formatting helpers. SlackColorFormatLookup colorFormatLookup = null; ArrowGraphSettingsDto arrowGraphSettingsDto = ViewModel.ArrowGraphSettingsDto; if (arrowGraphSettingsDto?.ActivitySeverities != null) { colorFormatLookup = new SlackColorFormatLookup(arrowGraphSettingsDto.ActivitySeverities); } if (GroupByResource.IsChecked.GetValueOrDefault()) { BuildGanttChart(dependentActivities, resourceSeriesSet, resourceSchedules, projectStart, colorFormatLookup); } else { BuildGanttChart(dependentActivities, projectStart, colorFormatLookup); } } }
private void CalculateResourceChartPlotModel() { lock (m_Lock) { ResourceSeriesSetModel resourceSeriesSet = ResourceSeriesSet; PlotModel plotModel = null; if (resourceSeriesSet != null) { IEnumerable <ResourceSeriesModel> combinedResourceSeries = resourceSeriesSet.Combined.OrderBy(x => x.DisplayOrder); if (combinedResourceSeries.Any()) { plotModel = new PlotModel(); plotModel.Axes.Add(BuildResourceChartXAxis()); plotModel.Axes.Add(BuildResourceChartYAxis()); plotModel.LegendPlacement = LegendPlacement.Outside; plotModel.LegendPosition = LegendPosition.RightMiddle; var total = new List <int>(); m_DateTimeCalculator.UseBusinessDays(UseBusinessDays); foreach (ResourceSeriesModel series in combinedResourceSeries) { if (series != null) { var areaSeries = new AreaSeries { //Smooth = false, StrokeThickness = 0.0, Title = series.Title, Color = OxyColor.FromArgb( series.ColorFormat.A, series.ColorFormat.R, series.ColorFormat.G, series.ColorFormat.B) }; if (series.Values.Any()) { // Mark the start of the plot. areaSeries.Points.Add(new DataPoint(0.0, 0.0)); areaSeries.Points2.Add(new DataPoint(0.0, 0.0)); for (int i = 0; i < series.Values.Count; i++) { int j = series.Values[i]; if (i >= total.Count) { total.Add(0); } int dayNumber = i + 1; areaSeries.Points.Add( new DataPoint(ChartHelper.CalculateChartTimeXValue(dayNumber, ShowDates, ProjectStart, m_DateTimeCalculator), total[i])); total[i] += j; areaSeries.Points2.Add( new DataPoint(ChartHelper.CalculateChartTimeXValue(dayNumber, ShowDates, ProjectStart, m_DateTimeCalculator), total[i])); } } plotModel.Series.Add(areaSeries); } } } } ResourceChartPlotModel = plotModel; } RaiseCanExecuteChangedAllCommands(); }