다음을 통해 공유


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.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.Diagrams.12.0.dll)

Syntax

'Declaration
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
Public method StyleSet Creates an instance of the StyleSet linking the current one to its parent.

Top

Properties

  Name Description
Protected property Parent
Public property UseHighContrastColors Gets a value indicating whether this StyleSet resolves to high contrast colors.

Top

Methods

  Name Description
Public method AddBrush Add a new Brush to this StyleSet.
Public method AddFont Add a new Font to this StyleSet.
Public method AddPen Add a new Pen to this StyleSet.
Public method ClearBrushOverride Clears an overriden Brush in the StyleSet.
Public method ClearFontOverride Clears an overriden Font in the StyleSet.
Public method ClearPenOverride Clears an overriden Pen in the StyleSet.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method 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!
Public method 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.
Public method 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.
Public method 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.
Public method 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.
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method 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.
Public method 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.
Public method 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.
Public method 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!
Public method 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.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method OverrideBrush Overrides the specified Brush in the StyleSet.
Protected method OverrideBrushWorker Overrides the specified Brush in the StyleSet.
Public method OverrideFont Overrides the specified Font in the StyleSet.
Protected method OverrideFontWorker Overrides the specified Font in the StyleSet.
Public method OverridePen Overrides the specified Pen in the StyleSet.
Protected method OverridePenWorker Overrides the specified Pen in the StyleSet.
Public method RefreshResources Forces a re-resolution of the resources if necessary. The resources are resolved later when used.
Public method RemoveBrush Removes a Brush from this StyleSet.
Public method RemoveFont Removes a Font from this StyleSet.
Public method RemovePen Removes a Pen from this StyleSet.
Public method 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.

See Also

Reference

Microsoft.VisualStudio.Modeling.Diagrams Namespace