RadiantQ WPF Gantt
Dependencies
Previous Topic  Next Topic 

Activity Dependencies


Activities within a project could have dependencies on other activities. The dependent activity's start time is then constrained by the predecessor activity's times. The GanttControl supports these 4 different types of dependency constraints:


Dependency Type

Constraint behavior

FinishToStart (Default)

The ToActivity's start time cannot be earlier than the FromActivity's end time.

StartToStart

The ToActivity's start time cannot be earlier than the FromActivity's start time.

FinishToFinish

The ToActivity's end time cannot be earlier than the FromActivity's end time.

StartToFinish

The ToActivity's end time cannot be earlier than the FromActivity's start time.


There can also be a "lag" specified between the 2 times above.


A FinishToStart dependency between these 2 activities with a lag of 4 hours



is represented as follows:


{TaskName="Task 1", TaskID="5" ....}

{TaskName="Task 2", TaskID="6", PredecessorIndices="5+4"}


The PredecessorIndices property indicates a dependency with activity ID "5" and a lag of "4 hours". "5-4" would correspond to a negative lag of "-4 hours".  The lag number by default is considered a hours. If you want this to be something else then set the LagStringUnitsInHours property appropriately (24, if you want it to indicate the number of days).


The dependency type is indicated with a corresponding suffix ("FS", "SF", "SS" or "FF") as follows:

{TaskName="Task 2", TaskID="6", PredecessorIndices="5SF"}


The above example indicates a StartToFinish dependency. Specifying the "FS" (Finish To Start) suffix is optional since that's the default.


Multiple predecessors


If an activity is constrained by more than 1 predecessor activity, then the dependency is represented as follows:


PredecessorIndices="4, 2, 9+3"


Simply separate the different predecessor activity IDs by commas.


Editing the Dependencies


End-users can simply drag and drop a connection line from one activity to another in the gantt chart to setup a dependency connection between the two. This results in the default FinishToStart type of dependency. If you need to change the dependency type to something else and/or specify a lag between the from and to activity times, edit the field's value in the corresponding gantt table field.


When the end-user connects 2 tasks to create a new dependency, the DependencyLineAdded event will be raised, where you can get hold of the from and to activity as follows:


        void ganttControl_DependencyLineAdded(object sender, DependencyLineEventArgs e)

        {

            e.DependencyLine.Loaded += delegate(object s, RoutedEventArgs args)

            {

                GanttDependencyView depLineView = ((GanttDependencyLine)s).DataContext as GanttDependencyView;

                IActivity fromActivity = depLineView.Dependency.FromActivity;

                IActivity toActivity = depLineView.Dependency.ToActivity;

            };

        }


Deleting a Dependency

Easily delete the dependency programmatically as follows:


            this.ganttControl.Model.Dependencies.Remove(dependency);


Validating the predecessor-dependency setting


During runtime the gantt control validates all predecessor settings before applying it. For example, a parent cannot be a predecessor to it's child. The gantt prevents applying such dependecy settings. If you want to programatically validate a dependency setting before applying it, use this API:


// The arguments are IActivity instances

this.ganttControl.Model.CanAddNewDependency(fromActivity, toActivity);



Preventing Dependency Constraints Conditionally


You can choose to prevent getting the dependency constraints applied on some activities, conditionally as follows, by listening to the ShouldEnforceDependencyConstraintsOnActivity event.



        public MainPage()

        {

           ...

            this.ganttControl.ShouldEnforceDependencyConstraintsOnActivity += Gantt_ShouldEnforceDependencyConstraints;

        }



        void Gantt_ShouldEnforceDependencyConstraints(object sender, EnforceDependencyConstraintsEventArgs args)

        {

            // Prevent dependency constraints once there is progress on the dependency activity.

            if (args.Activity.ProgressPercent >= 0)

                args.Enforce = false;

            else

                args.Enforce = true;

        }




� RadiantQ 2009 - 2019. All Rights Reserved.