Aspose::Words::Shading class

Shading class

Contains shading attributes for an object. To learn more, visit the Programming with Documents documentation article.

class Shading : public Aspose::Words::InternableComplexAttr,
                public Aspose::Words::IComplexAttr

Methods

MethodDescription
ClearFormatting()Removes shading from the object.
Equals(const System::SharedPtr<Aspose::Words::Shading>&)Determines whether the specified Shading is equal in value to the current Shading.
Equals(System::SharedPtr<System::Object>) overrideDetermines whether the specified object is equal in value to the current object.
get_BackgroundPatternColor()Gets or sets the color that’s applied to the background of the Shading object.
get_BackgroundPatternThemeColor()Gets the background pattern theme color in the applied color scheme that is associated with this Shading object.
get_BackgroundTintAndShade()Gets or sets a double value that lightens or darkens a background theme color.
get_ForegroundPatternColor()Gets or sets the color that’s applied to the foreground of the Shading object.
get_ForegroundPatternThemeColor()Gets the foreground pattern theme color in the applied color scheme that is associated with this Shading object.
get_ForegroundTintAndShade()Gets or sets a double value that lightens or darkens a foreground theme color.
get_Texture()Gets or sets the shading texture.
GetHashCode() const overrideServes as a hash function for this type.
GetType() const override
Is(const System::TypeInfo&) const override
set_BackgroundPatternColor(System::Drawing::Color)Setter for Aspose::Words::Shading::get_BackgroundPatternColor.
set_BackgroundPatternThemeColor(Aspose::Words::Themes::ThemeColor)Sets the background pattern theme color in the applied color scheme that is associated with this Shading object.
set_BackgroundTintAndShade(double)Setter for Aspose::Words::Shading::get_BackgroundTintAndShade.
set_ForegroundPatternColor(System::Drawing::Color)Setter for Aspose::Words::Shading::get_ForegroundPatternColor.
set_ForegroundPatternThemeColor(Aspose::Words::Themes::ThemeColor)Sets the foreground pattern theme color in the applied color scheme that is associated with this Shading object.
set_ForegroundTintAndShade(double)Setter for Aspose::Words::Shading::get_ForegroundTintAndShade.
set_Texture(Aspose::Words::TextureIndex)Setter for Aspose::Words::Shading::get_Texture.
static Type()

Examples

Shows how to apply border and shading color while building a table.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

// Start a table and set a default color/thickness for its borders.
SharedPtr<Table> table = builder->StartTable();
table->SetBorders(LineStyle::Single, 2.0, System::Drawing::Color::get_Black());

// Create a row with two cells with different background colors.
builder->InsertCell();
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_LightSkyBlue());
builder->Writeln(u"Row 1, Cell 1.");
builder->InsertCell();
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_Orange());
builder->Writeln(u"Row 1, Cell 2.");
builder->EndRow();

// Reset cell formatting to disable the background colors
// set a custom border thickness for all new cells created by the builder,
// then build a second row.
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->get_Borders()->get_Left()->set_LineWidth(4.0);
builder->get_CellFormat()->get_Borders()->get_Right()->set_LineWidth(4.0);
builder->get_CellFormat()->get_Borders()->get_Top()->set_LineWidth(4.0);
builder->get_CellFormat()->get_Borders()->get_Bottom()->set_LineWidth(4.0);

builder->InsertCell();
builder->Writeln(u"Row 2, Cell 1.");
builder->InsertCell();
builder->Writeln(u"Row 2, Cell 2.");

doc->Save(ArtifactsDir + u"DocumentBuilder.TableBordersAndShading.docx");

Shows how to decorate text with borders and shading.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

SharedPtr<BorderCollection> borders = builder->get_ParagraphFormat()->get_Borders();
borders->set_DistanceFromText(20);
borders->idx_get(BorderType::Left)->set_LineStyle(LineStyle::Double);
borders->idx_get(BorderType::Right)->set_LineStyle(LineStyle::Double);
borders->idx_get(BorderType::Top)->set_LineStyle(LineStyle::Double);
borders->idx_get(BorderType::Bottom)->set_LineStyle(LineStyle::Double);

SharedPtr<Shading> shading = builder->get_ParagraphFormat()->get_Shading();
shading->set_Texture(TextureIndex::TextureDiagonalCross);
shading->set_BackgroundPatternColor(System::Drawing::Color::get_LightCoral());
shading->set_ForegroundPatternColor(System::Drawing::Color::get_LightSalmon());

builder->Write(u"This paragraph is formatted with a double border and shading.");
doc->Save(ArtifactsDir + u"DocumentBuilder.ApplyBordersAndShading.docx");

See Also