// ExStart:ImplementCustomBarStyleWriting static void ImplementCustomBarSytle() { try { // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); Project project = new Project(dataDir + "Blank2010.mpp"); project.RootTask.Children.Add("Task"); GanttChartView view = project.DefaultView as GanttChartView; GanttBarStyle custom = GetCustomBarStyle(); // Add the custom bar style to the custom bar collection of the project view view.CustomBarStyles.Add(custom); string file = "ImplementCustomBarStyleWriting_out.mpp"; MPPSaveOptions options = new MPPSaveOptions(); options.WriteViewData = true; project.Save(dataDir + file, options); } catch (NotSupportedException ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx."); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); //ExStart:ReadCustomBarStyle //ExFor: GanttChartView.CustomBarStyles //ExSummary: Shows how to read custom bar styles of Gantt Chart project view. Project project = new Project(dataDir + "CustomBarStyle.mpp"); GanttChartView view = (GanttChartView)project.DefaultView; Console.WriteLine("Custom bar styles count: {0}", view.CustomBarStyles.Count); GanttBarStyle style1 = view.CustomBarStyles[0]; Console.WriteLine("Style1.LeftField is TaskDurationText : {0}", style1.LeftField.Equals(Field.TaskDurationText)); Console.WriteLine("Style1.RightField is TaskResourceNames : {0}", style1.RightField.Equals(Field.TaskResourceNames)); Console.WriteLine("Style1.TopField is TaskACWP: {0}", style1.TopField.Equals(Field.TaskACWP)); Console.WriteLine("Style1.BottomField is Undefined : {0}", style1.BottomField.Equals(Field.Undefined)); Console.WriteLine("Style1.InsideField is Undefined : {0}", style1.InsideField.Equals(Field.Undefined)); GanttBarStyle style2 = view.CustomBarStyles[1]; Console.WriteLine("Style2.LeftField is TaskActualWork : {0}", style2.LeftField.Equals(Field.TaskActualWork)); Console.WriteLine("Style2.RightField is TaskActualCost : {0}", style2.RightField.Equals(Field.TaskActualCost)); Console.WriteLine("Style2.TopField is Undefined : {0}", style2.TopField.Equals(Field.Undefined)); Console.WriteLine("Style2.BottomField is Undefined : {0}", style2.BottomField.Equals(Field.Undefined)); Console.WriteLine("Style2.InsideField is Undefined : {0}", style2.InsideField.Equals(Field.Undefined)); GanttBarStyle style3 = view.CustomBarStyles[2]; Console.WriteLine("Style3.LeftField is TaskPercentComplete : {0}", style3.LeftField.Equals(Field.TaskPercentComplete)); Console.WriteLine("Style3.RightField is TaskPercentWorkComplete : {0}", style3.RightField.Equals(Field.TaskPercentWorkComplete)); Console.WriteLine("Style3.TopField is Field.TaskActive : {0}", style3.TopField.Equals(Field.TaskActive)); Console.WriteLine("Style3.BottomField is TaskActualCost : {0}", style3.BottomField.Equals(Field.TaskActualCost)); Console.WriteLine("Style3.InsideField is Field.TaskActualDuration : {0}", style3.InsideField.Equals(Field.TaskActualDuration)); Console.WriteLine("Style3.StartShape is HouseDown : {0}", style3.StartShape.Equals(GanttBarEndShape.HouseDown)); Console.WriteLine("Style3.StartShapeType is Framed : {0}", style3.StartShapeType.Equals(GanttBarType.Framed)); Console.WriteLine("Style3.StartShapeColor is Red : {0}", style3.StartShapeColor.Equals(Color.FromArgb(Color.Red.ToArgb()))); Console.WriteLine("Style3.EndShape is CircleDiamond : {0}", style3.EndShape.Equals(GanttBarEndShape.CircleDiamond)); Console.WriteLine("Style3.EndShapeType is Solid : {0}", style3.EndShapeType.Equals(GanttBarType.Solid)); Console.WriteLine("Style3.EndShapeColor is Yellow : {0}", style3.EndShapeColor.Equals(Color.FromArgb(Color.Yellow.ToArgb()))); Console.WriteLine("Style3.MiddleShape is RectangleTop : {0}", style3.MiddleShape.Equals(GanttBarMiddleShape.RectangleTop)); Console.WriteLine("Style3.MiddleFillPattern is SolidFill : {0}", style3.MiddleFillPattern.Equals(GanttBarFillPattern.SolidFill)); Console.WriteLine("Style3.EndShapeColor is Red : {0}", style3.MiddleShapeColor.Equals(Color.FromArgb(Color.Red.ToArgb()))); //ExEnd:ReadCustomBarStyle }
private static GanttBarStyle GetCustomBarStyle() { GanttBarStyle style = new GanttBarStyle(); style.ShowFor = "1"; 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 GetCustomBarStyle() { GanttBarStyle style = new GanttBarStyle(); style.ShowFor = "1"; 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); }
//ExStart:ImplementCustomBarStyleWriting //ExFor: GanttChartView.CustomBarStyles //ExSummary: Shows how to set custom bar styles of Gantt Chart project view. private static void ImplementCustomBarStyle(string dataDir) { try { Project project = new Project(dataDir + "Blank2010.mpp"); project.RootTask.Children.Add("Task"); GanttChartView view = (GanttChartView)project.DefaultView; GanttBarStyle custom = GetCustomBarStyle(); // Add the custom bar style to the custom bar collection of the project view view.CustomBarStyles.Add(custom); MPPSaveOptions options = new MPPSaveOptions(); options.WriteViewData = true; project.Save(dataDir + "ImplementCustomBarStyleWriting_out.mpp", options); } catch (NotSupportedException ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx."); } }
public static GanttBarStyle GetCustomBarStyle() { var style = new GanttBarStyle { ShowForTaskUid = 1, MiddleShape = GanttBarMiddleShape.RectangleBottom, MiddleFillPattern = GanttBarFillPattern.MediumFill, MiddleShapeColor = Color.Blue, StartShape = GanttBarEndShape.ArrowDown, StartShapeColor = Color.Red, EndShape = GanttBarEndShape.ArrowUp, EndShapeColor = Color.Yellow, LeftField = Field.TaskResourceNames, RightField = Field.TaskName, TopField = Field.TaskStart, BottomField = Field.TaskFinish, InsideField = Field.TaskDuration }; return(style); }