Ejemplo n.º 1
0
 public void UnlinkFromDescendant(PertTask descendant)
 {
     if (this._descendants.Contains(descendant))
     {
         this._descendants.Remove(descendant);
         descendant._ancestors.Remove(this);
     }
     else
     {
         throw new ArgumentException($"Task '{this.Name}' does not have task '{descendant.Name}' as a descendant.");
     }
 }
Ejemplo n.º 2
0
 public void UnlinkFromAncestor(PertTask ancestor)
 {
     if (this._ancestors.Contains(ancestor))
     {
         ancestor._descendants.Remove(this);
         this._ancestors.Remove(ancestor);
     }
     else
     {
         throw new ArgumentException($"Task '{this.Name}' does not have task '{ancestor.Name}' as an ancestor.");
     }
 }
Ejemplo n.º 3
0
 public TaskViewModel(PertTask taskModel)
 {
     this._task     = taskModel;
     this.Resources = new ObservableCollection <IResource>();
     foreach (var modelResource in this.Model.Resources)
     {
         this.Resources.Add(modelResource);
     }
     this.Resources.CollectionChanged += Resources_CollectionChanged;
     this.TimeEstimate = new EstimateViewModel(this._task.TimeEstimate);
     this.TimeEstimate.PropertyChanged += TimeEstimate_PropertyChanged;
 }
Ejemplo n.º 4
0
 public void LinkToDescendant(PertTask descendant)
 {
     if (descendant == this)
     {
         throw new ArgumentException("Cannot link a task to itself");
     }
     if (descendant.AllDescendants.Contains(this))
     {
         throw new ArgumentException($"Making task '{descendant.Name}' a descendant of task '{this.Name}' would create a cyclic project network.");
     }
     if (this._descendants.Contains(descendant))
     {
         throw new ArgumentException($"Task '{descendant.Name}' is already an ancestor of task '{this.Name}'.");
     }
     this._descendants.Add(descendant);
     descendant._ancestors.Add(this);
 }
Ejemplo n.º 5
0
 public void LinkToAncestor(PertTask ancestor)
 {
     // Check to make sure we're not creating a cyclic graph
     if (ancestor == this)
     {
         throw new ArgumentException("Cannot link a task to itself");
     }
     if (ancestor.AllAncestors.Contains(this))
     {
         throw new ArgumentException($"Making task '{ancestor.Name}' an ancestor of task '{this.Name}' would create a cyclic project network.");
     }
     if (this._ancestors.Contains(ancestor))
     {
         throw new ArgumentException($"Task '{ancestor.Name}' is already an ancestor of task '{this.Name}'.");
     }
     this._ancestors.Add(ancestor);
     ancestor._descendants.Add(this);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Return as HashSet with all descendants of a task located by recursively walking the graph
        /// </summary>
        /// <param name="task">The task to find all descendants of</param>
        /// <returns></returns>
        public static HashSet <PertTask> AllDescendantsOf(PertTask task)
        {
            var tasks      = new HashSet <PertTask>();
            var checkTasks = new Queue <PertTask>();

            checkTasks.Enqueue(task);
            while (checkTasks.Count != 0)
            {
                var working = checkTasks.Dequeue();
                foreach (var item in working.Descendants)
                {
                    checkTasks.Enqueue(item);
                }
                tasks.Add(working);
            }
            tasks.Remove(task);
            return(tasks);
        }
Ejemplo n.º 7
0
 public void RemoveTask(PertTask task)
 {
     this._tasks.Remove(task);
     task.UnlinkAll();
 }
Ejemplo n.º 8
0
 public void AddTask(PertTask task)
 {
     this._tasks.Add(task);
 }