共用方式為


StyleSet Class

Definition

A StyleSet is a collection of graphics objects that can be used by an application to specify a set of pens, brushes, and fonts to be used for all of the drawing operations. Within the painting code, you can call StyleSet.GetPen to retrieve a specific pen defined by the system. That pen will be set to the correct color and style defined with the application. Use that pen immediately as it is unique. If you need to hold onto a pen use GetPenCopy.

StyleSets can live at multiple levels in the system. There's an ApplicationStyleSet which are the app defined defaults style scheme. There are also ClassStyleSets which exist at the class type level to specify styles for all instances of that class of shape. There can also exist instance StyleSets which contains resource information for each instance of a shape. This should be used when different instances of the same class of shapes can have different appearance.

When actually trying to retrieve an object, like a Pen, the StyleSet code goes up the inheritance chain from instance to class to application StyleSets until if finds that first one that contains that resource that you're looking for (as defined by the ResourceId that you're asking for).

public ref class StyleSet
public class StyleSet
type StyleSet = class
Public Class StyleSet
Inheritance
StyleSet

Constructors

StyleSet(StyleSet)

Creates an instance of the StyleSet linking the current one to its parent.

Properties

Parent

Gets the parent of this StyleSet in the inheritance chain. Will be null if this is the ApplicationStyleSet.

UseHighContrastColors

Gets a value indicating whether this StyleSet resolves to high contrast colors.

Methods

AddBrush(StyleSetResourceId, StyleSetResourceId, BrushSettings)

Add a new Brush to this StyleSet.

AddFont(StyleSetResourceId, StyleSetResourceId, FontSettings)

Add a new Font to this StyleSet.

AddPen(StyleSetResourceId, StyleSetResourceId, PenSettings)

Add a new Pen to this StyleSet.

ClearBrushOverride(StyleSetResourceId)

Clears an overriden Brush in the StyleSet.

ClearFontOverride(StyleSetResourceId)

Clears an overriden Font in the StyleSet.

ClearPenOverride(StyleSetResourceId)

Clears an overriden Pen in the StyleSet.

GetBrush(StyleSetResourceId)

Retrieves a specific Brush from the StyleSet. If it's not in the current one, it looks up the parent chain to see if it can find it there. This is a singleton. Do not dispose - this will crash! Use immediately. Use GetBrushCopy if another brush is needed!

GetBrushCopy(StyleSetResourceId)

Retrieves a specific Brush from the StyleSet. If it's not in the current one, it looks up the parent chain to see if it can find it there. This is a copy. Caller is responsible for dispose.

GetFont(StyleSetResourceId)

Retrieves a specific Font from the StyleSet. If it's not in the current one, it looks up the parent chain to see if it can find it there.

GetFontHeight(StyleSetResourceId)

Returns the line spacing of the specified font (i.e., the height of a line of text) in world units. Line spacing is the ascent + the descent + some recommended extra. The ascent is the height of the character above the baseline, and the descent is the height of the character below the baseline. The extra is below the descent.

GetFontSize(StyleSetResourceId)

Returns the em height of the font with the specified id. This is the value specified when the font was created. Use GetFontHeight instead to get the height of a line of text when using this font.

GetOverriddenBrushSettings(StyleSetResourceId)

Gets a BrushSettings object containing settings which have been overriden in this style set. If no settings have been overriden, this method returns null.

GetOverriddenFontSettings(StyleSetResourceId)

Gets a FontSettings object containing settings which have been overriden in this style set. If no settings have been overriden, this method returns null.

GetOverriddenPenSettings(StyleSetResourceId)

Gets a PenSettings object containing settings which have been overriden in this style set. If no settings have been overriden, this method returns null.

GetPen(StyleSetResourceId)

Retrieves a specific Pen from the StyleSet. If it's not in the current one, it looks up the parent chain to see if it can find it there. This is a singleton. Do not dispose - this will crash! Use immediately. Use GetPenCopy if another pen is needed!

GetPenCopy(StyleSetResourceId)

Retrieves a specific Pen from the StyleSet. If it's not in the current one, it looks up the parent chain to see if it can find it there. This is a copy. Caller is responsible for dispose.

OverrideBrush(StyleSetResourceId, BrushSettings)

Overrides the specified Brush in the StyleSet.

OverrideBrushWorker(StyleSetResourceId, StyleSetResourceId, BrushSettings)

Overrides the specified Brush in the StyleSet.

OverrideFont(StyleSetResourceId, FontSettings)

Overrides the specified Font in the StyleSet.

OverrideFontWorker(StyleSetResourceId, StyleSetResourceId, FontSettings)

Overrides the specified Font in the StyleSet.

OverridePen(StyleSetResourceId, PenSettings)

Overrides the specified Pen in the StyleSet.

OverridePenWorker(StyleSetResourceId, StyleSetResourceId, PenSettings)

Overrides the specified Pen in the StyleSet.

RefreshResources(Boolean)

Forces a re-resolution of the resources if necessary. The resources are resolved later when used.

RemoveBrush(StyleSetResourceId)

Removes a Brush from this StyleSet.

RemoveFont(StyleSetResourceId)

Removes a Font from this StyleSet.

RemovePen(StyleSetResourceId)

Removes a Pen from this StyleSet.

Applies to