Hi,
Hi,
What about first part of my question - formatting of tasks themselves?
Hi,
TableTextStyle can be used to set the color of the task text. Constructor of TableTextStyle takes Uid of the task for which these properties are defined. Please give a try to the following sample code and share the feedback.
Project project = new Project(@“blank2010.mpp”);
project.Set(Prj.NewTasksAreManual,false);
project.RootTask.Children.Add("Task 1");
project.RootTask.Children.Add("Task 2");
GanttChartView view = project.Views.ToList()[1] as GanttChartView;
// Set first task name text style
TableTextStyle tableTextStyle = new TableTextStyle(1);//Text style for task Uid = 1
tableTextStyle.BackgroundColor = Color.Blue;
tableTextStyle.Color = Color.Yellow;
tableTextStyle.Field = Field.TaskName;
tableTextStyle.FontStyle = FontStyle.Bold | FontStyle.Italic;
view.TableTextStyles.Add(tableTextStyle);
// Set second task duration text style
tableTextStyle = new TableTextStyle(2); //Text style for task Uid = 2
tableTextStyle.Color = Color.Yellow;
tableTextStyle.BackgroundColor = Color.Red;
tableTextStyle.Field = Field.TaskDurationText;
tableTextStyle.FontStyle = FontStyle.Underline;
view.TableTextStyles.Add(tableTextStyle);
MPPSaveOptions saveOptions = new MPPSaveOptions();
saveOptions.WriteViewData = true;
project.Save("temp updated.mpp", saveOptions);