Color a Task's text & Gantt bar

I’m very new to your product. Can you please show me a simple code example where:

1. Two tasks are created.
2. The text color for task1 is set to Blue and the Gantt bar is set to Red.
3. The text color for task2 is set to Red and the Gantt bar is set to Blue.

Thanks in advance…

Is the following the correct approach? It is based on code from here.

static void ImplementCustomBarSytle()
{
    Project project = new Project("C:\\temp\\AsposeTest.mpp"); // empty mpp project
    project.RootTask.Children.Add("Task1"); // add task with id = 1
    project.RootTask.Children.Add("Task2"); // add task with id = 2
    project.RootTask.Children.Add("Task3"); // add task with id = 3
    GanttChartView view = project.DefaultView as GanttChartView;
    GanttBarStyle customBlue = GetCustomBarStyleBlue(); // see the code below
    view.CustomBarStyles.Add(customBlue); // add the custom bar style to the custom bar collection of the project view
    GanttBarStyle customRed = GetCustomBarStyleRed(); // see the code below
    view.CustomBarStyles.Add(customRed); // add the custom bar style to the custom bar collection of the project view
    string file = "C:\\temp\\CustomStyle.mpp";
    MPPSaveOptions options = new MPPSaveOptions();
    options.WriteViewData = true;
    project.Save(file, options);
}

private static GanttBarStyle GetCustomBarStyleBlue()
{
    GanttBarStyle style = new GanttBarStyle();
    style.ShowFor = "2";
    style.MiddleShape = GanttBarMiddleShape.RectangleBottom;
    style.MiddleFillPattern = GanttBarFillPattern.MediumFill;
    style.MiddleShapeColor = Color.Blue;
    style.StartShape = GanttBarEndShape.ArrowDown;
    style.StartShapeColor = Color.Red;
    style.EndShape = GanttBarEndShape.ArrowUp;
    style.EndShapeColor = Color.Yellow;
    style.LeftField = Field.TaskResourceNames;
    style.RightField = Field.TaskName;
    style.TopField = Field.TaskStart;
    style.BottomField = Field.TaskFinish;
    style.InsideField = Field.TaskDuration;
    return style;
}
private static GanttBarStyle GetCustomBarStyleRed()
{
    GanttBarStyle style = new GanttBarStyle();
    style.ShowFor = "1;3";
    style.MiddleShape = GanttBarMiddleShape.RectangleBottom;
    style.MiddleFillPattern = GanttBarFillPattern.MediumFill;
    style.MiddleShapeColor = Color.Red;
    style.StartShape = GanttBarEndShape.ArrowDown;
    style.StartShapeColor = Color.Red;
    style.EndShape = GanttBarEndShape.ArrowUp;
    style.EndShapeColor = Color.Yellow;
    style.LeftField = Field.TaskResourceNames;
    style.RightField = Field.TaskName;
    style.TopField = Field.TaskStart;
    style.BottomField = Field.TaskFinish;
    style.InsideField = Field.TaskDuration;
    return style;
}

You are welcome.

Hi,

Are you able to give me the approximate resolution date to fix this bug? We are trying to determine if it’s worth implementing a temporary 3rd party fix for this issue until the Aspose problem is resolved.

Thanks

Ian

Hi,


The issue is still pending for resolution at our end and there is no ETA available in this regard. We’ve requested our Product team to share the ETA for this issue and will update you here as soon as some information is available in this regard.

You are welcome.

@casablanca,

We have just released Aspose.Tasks for .NET 17.7 version where this issue has been fixed. Please download this latest version for testing at your end and let us know if we can be of any additional help to you.