BarStyle Class

Change the visual style of the bar for the item in the project view.
Inheritance Hierarchy
SystemObject
  Aspose.Tasks.VisualizationBarStyle

Namespace:  Aspose.Tasks.Visualization
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.10
Syntax
public class BarStyle

The BarStyle type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleBarStyle
Initializes a new instance of the BarStyle class.
Properties
  NameDescription
Public propertyCode exampleBarColor
Gets or sets Color of the bar style.
Public propertyCode exampleBarShape
Gets or sets BarShape of the bar style.
Public propertyCode exampleBarTextConverter Obsolete.
Gets or sets converter to get text for the bar to render.
Public propertyBottomBarTextConverter
Gets or sets user-defined converter to get text to render on the bottom of the task's bar. Overrides the value of BottomField property.
Public propertyBottomField
Gets or sets a field to be displayed on the bottom of the bar.
Public propertyCode exampleEndShape
Gets or sets Shape at the end of the bar.
Public propertyCode exampleEndShapeColor
Gets or sets Color of the shape at the end of the bar.
Public propertyInsideBarTextConverter
Gets or sets user-defined converter to get text to render inside of the task's bar. Overrides the value of InsideField property.
Public propertyInsideField
Gets or sets a field to be displayed inside of the bar.
Public propertyCode exampleItemType
Gets or sets BarItemType of the bar style.
Public propertyLeftBarTextConverter
Gets or sets user-defined converter to get text to render on the left of the task's bar. Overrides the value of LeftField property.
Public propertyLeftField
Gets or sets a field to be displayed on the left of the bar.
Public propertyRightBarTextConverter
Gets or sets user-defined converter to get text to render on the right of the task's bar. Overrides the value of RightField property.
Public propertyRightField
Gets or sets a field to be displayed on the right of the bar.
Public propertyCode exampleStartShape
Gets or sets Shape at the beginning of the bar.
Public propertyCode exampleStartShapeColor
Gets or sets Color of the shape at the beginning of the bar.
Public propertyCode exampleTextStyle
Gets or sets of the text to render on the right of the bar.
Public propertyTopBarTextConverter
Gets or sets user-defined converter to get text to render on the top of the task's bar. Overrides the value of TopField property.
Public propertyTopField
Gets or sets a field to be displayed on the top of the bar.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to use custom bar styles.
var project = new Project(DataDir + "Project2.mpp");
SaveOptions options = new PdfSaveOptions
{
    BarStyles = new List<BarStyle>()
};

// add a bar style for milestone tasks
var style = new BarStyle();
// set <see cref="T:Aspose.Tasks.Visualization.BarItemType" /> of the bar style
style.ItemType = BarItemType.Milestone;
// set <see cref="T:System.Drawing.Color" /> of the bar style.
style.BarColor = Color.Green;
// set <see cref="P:Aspose.Tasks.Visualization.BarStyle.BarShape" /> of the bar style
style.BarShape = BarShape.HalfHeight;
// set <see cref="T:Aspose.Tasks.Visualization.Shape" /> at the beginning of the bar
style.StartShape = Shape.LeftBracket;
// set <see cref="T:System.Drawing.Color" /> of the shape at the beginning of the bar
style.StartShapeColor = Color.Aqua;
// set <see cref="T:Aspose.Tasks.Visualization.Shape" /> at the end of the bar
style.EndShape = Shape.RightBracket;
// set <see cref="T:System.Drawing.Color" /> of the shape at the end of the bar
style.EndShapeColor = Color.Aquamarine;
// set of the text to render on the right of the bar.
style.TextStyle = new TextStyle();
style.TextStyle.BackgroundColor = Color.Black;

// there is exists a feature that allow to convert a text of the bar
// lets set converter to get text for the bar to render.
style.LeftBarTextConverter = task =>
{
    if (!task.Get(Tsk.Name).StartsWith("T"))
    {
        task.Set(Tsk.Name, "T" + task.Get(Tsk.Name));
    }

    return task.Get(Tsk.Name);
};

options.BarStyles.Add(style);

// save the project
project.Save(OutDir + "WorkWithBarStyle_out.mpp", options);
See Also