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,
You are welcome.
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.