public void AddManagedActivity(IDependentActivity <int> dependentActivity)
        {
            if (dependentActivity == null)
            {
                throw new ArgumentNullException(nameof(dependentActivity));
            }

            lock (m_Lock)
            {
                var dateTimeCalculator = new DateTimeCalculator();
                dateTimeCalculator.UseBusinessDays(UseBusinessDays);

                var activity = new ManagedActivityViewModel(
                    dependentActivity,
                    ProjectStart,
                    ResourceSettingsDto.Resources,
                    dateTimeCalculator,
                    m_EventService);

                if (m_VertexGraphCompiler.AddActivity(activity))
                {
                    Activities.Add(activity);
                }
            }
        }
        public ManagedActivityViewModel(
            IDependentActivity <int, int> dependentActivity,
            DateTime projectStart,
            DateTime?minimumEarliestStartDateTime,
            IEnumerable <ResourceModel> targetResources,
            IDateTimeCalculator dateTimeCalculator,
            IEventAggregator eventService)
            : this(dateTimeCalculator, eventService)
        {
            DependentActivity = dependentActivity ?? throw new ArgumentNullException(nameof(dependentActivity));
            m_ProjectStart    = projectStart;
            m_MinimumEarliestStartDateTime = minimumEarliestStartDateTime;
            var selectedResources = new HashSet <int>(DependentActivity.TargetResources.ToList());

            ResourceSelector.SetTargetResources(targetResources, selectedResources);
            UpdateAllocatedToResources();

            if (MinimumEarliestStartDateTime.HasValue)
            {
                CalculateMinimumEarliestStartTime();
            }
            else if (MinimumEarliestStartTime.HasValue)
            {
                CalculateMinimumEarliestStartDateTime();
            }
        }
Example #3
0
 public static DependentActivityDto ToDto(IDependentActivity <int> dependentActivity)
 {
     if (dependentActivity == null)
     {
         throw new ArgumentNullException(nameof(dependentActivity));
     }
     return(new DependentActivityDto
     {
         Activity = ToDto(dependentActivity as IActivity <int>),
         Dependencies = dependentActivity.Dependencies.ToList(),
         ResourceDependencies = dependentActivity.ResourceDependencies.ToList()
     });
 }
        private GanttTask CreateGanttTask(
            DateTime projectStart,
            IDependentActivity <int> activity,
            SlackColorFormatLookup colorFormatLookup)
        {
            Color background = colorFormatLookup?.FindSlackColor(activity.TotalSlack) ?? Colors.DodgerBlue;

            return(new GanttTask
            {
                Start = m_DateTimeCalculator.AddDays(projectStart, activity.EarliestStartTime.Value),
                End = m_DateTimeCalculator.AddDays(projectStart, activity.EarliestFinishTime.Value),
                Name = activity.Name,
                BackgroundColor = new SolidColorBrush(background),
                ForegroundColor = new SolidColorBrush(ContrastConvert(background)),
                Radius = activity.Duration < 3 ? 0 : 5,
                TaskProgressVisibility = Visibility.Collapsed,
            });
        }