StyleSet Class
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).
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.Modeling.Diagrams.StyleSet
Namespace: Microsoft.VisualStudio.Modeling.Diagrams
Assembly: Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.10.0.dll)
Syntax
'宣言
Public Class StyleSet
public class StyleSet
public ref class StyleSet
type StyleSet = class end
public class StyleSet
The StyleSet type exposes the following members.
Constructors
Name | Description | |
---|---|---|
StyleSet | Creates an instance of the StyleSet linking the current one to its parent. |
Top
Properties
Name | Description | |
---|---|---|
Parent | ||
UseHighContrastColors | Gets a value indicating whether this StyleSet resolves to high contrast colors. |
Top
Methods
Name | Description | |
---|---|---|
AddBrush | Add a new Brush to this StyleSet. | |
AddFont | Add a new Font to this StyleSet. | |
AddPen | Add a new Pen to this StyleSet. | |
ClearBrushOverride | Clears an overriden Brush in the StyleSet. | |
ClearFontOverride | Clears an overriden Font in the StyleSet. | |
ClearPenOverride | Clears an overriden Pen in the StyleSet. | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetBrush | 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 | 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 | 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 | 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 | 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. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetOverriddenBrushSettings | 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 | 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 | 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 | 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 | 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. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OverrideBrush | Overrides the specified Brush in the StyleSet. | |
OverrideBrushWorker | Overrides the specified Brush in the StyleSet. | |
OverrideFont | Overrides the specified Font in the StyleSet. | |
OverrideFontWorker | Overrides the specified Font in the StyleSet. | |
OverridePen | Overrides the specified Pen in the StyleSet. | |
OverridePenWorker | Overrides the specified Pen in the StyleSet. | |
RefreshResources | Forces a re-resolution of the resources if necessary. The resources are resolved later when used. | |
RemoveBrush | Removes a Brush from this StyleSet. | |
RemoveFont | Removes a Font from this StyleSet. | |
RemovePen | Removes a Pen from this StyleSet. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.