Class GripPrimitive
Represents a primitive element that renders a visual grip or handle, commonly used for resizing, moving, or indicating interactive areas within Telerik WinControls components.
Inheritance
Inherited Members
Namespace: Telerik.WinControls.Primitives
Assembly: Telerik.WinControls.dll
Syntax
public class GripPrimitive : BasePrimitive, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode, IPrimitive
Remarks
The GripPrimitive class provides specialized rendering capabilities for displaying grip handles consisting of a series of dots or small rectangular elements. These grips are typically used in splitters, resizable panels, toolbars, and other interactive elements where users need visual indication of draggable or resizable areas.
The primitive renders a vertical series of rectangular dots with shadow effects to create a three-dimensional appearance. The number of dots, colors, and spacing can be customized through various properties. Each dot consists of a main colored rectangle with a slightly offset shadow rectangle to enhance the visual depth.
Key features include customizable dot count through NumberOfDots, configurable colors for main dots and shadows, automatic spacing calculation, and integration with the RadProperty system for consistent theming across the framework.
Constructors
GripPrimitive()
Declaration
public GripPrimitive()
Fields
BackColor2Property
Identifies the BackColor2 dependency property.
Declaration
public static RadProperty BackColor2Property
Field Value
RadProperty
|
Remarks
This property defines the shadow color used to create a three-dimensional effect for the grip dots, enhancing the visual depth and making the grip more prominent.
NumberOfDotsProperty
Identifies the NumberOfDots dependency property.
Declaration
public static RadProperty NumberOfDotsProperty
Field Value
RadProperty
|
Remarks
This property controls how many individual dot elements are rendered in the grip handle, affecting the overall visual density and length of the grip indicator.
Properties
BackColor2
Gets or sets the shadow color used for creating depth effect in the grip dots.
Declaration
[RadPropertyDefaultValue("BackColor2", typeof(GripPrimitive))]
public virtual Color BackColor2 { get; set; }
Property Value
System.Drawing.Color
A System.Drawing.Color value representing the shadow color. The default value is System.Drawing.KnownColor.Control. |
Remarks
This color is used to render shadow rectangles slightly offset from the main grip dots, creating a three-dimensional appearance that makes the grip more visually prominent. The shadow is typically rendered in a lighter color than the main dots.
For best visual results, this color should contrast appropriately with both the main BackColor and the containing element's background.
NumberOfDots
Gets or sets the number of dots to display in the grip handle.
Declaration
public virtual int NumberOfDots { get; set; }
Property Value
System.Int32
An integer value representing the number of dot elements to render. The default value is 4. |
Remarks
This property determines how many individual dot elements are rendered vertically within the grip handle. More dots create a longer grip that may be easier to grab, while fewer dots create a more compact appearance.
The dots are evenly spaced based on the primitive's height and the number of dots specified. Each dot is rendered as a small rectangle with an associated shadow for depth effect.
StretchHorizontally
Gets or sets a value indicating whether the primitive should stretch horizontally to fill available space.
Declaration
public override bool StretchHorizontally { get; set; }
Property Value
System.Boolean
|
Overrides
Remarks
Grip handles are generally designed to have a fixed width to ensure consistent visual appearance
and proper user interaction. Setting this to true
may cause the grip to appear distorted.
StretchVertically
Gets or sets a value indicating whether the primitive should stretch vertically to fill available space.
Declaration
public override bool StretchVertically { get; set; }
Property Value
System.Boolean
|
Overrides
Remarks
While grip handles may vary in height based on their container, they typically maintain
consistent spacing and dot size. Setting this to true
should be done carefully
to maintain proper visual proportions.
Methods
InitializeFields()
Initializes the default field values for the grip primitive.
Declaration
protected override void InitializeFields()
Overrides
Remarks
This method configures the primitive to have fixed sizing by default, as grip handles typically have predetermined dimensions and should not stretch to fill available space. The primitive maintains its intrinsic size for consistent visual appearance.
PaintPrimitive(IGraphics, Single, SizeF)
Renders the grip handle using the specified graphics context, applying rotation and scaling transformations.
Declaration
public override void PaintPrimitive(IGraphics g, float angle, SizeF scale)
Parameters
IGraphics
g
The IGraphics interface used for drawing the grip dots. |
System.Single
angle
The rotation angle in degrees to apply to the rendered content. |
System.Drawing.SizeF
scale
The scaling factor to apply to the rendered content. |
Overrides
Remarks
This method renders a series of small rectangular dots arranged vertically to create a grip handle appearance. Each dot consists of two rectangles: a shadow rectangle (rendered with BackColor2) and a main rectangle (rendered with BackColor).
The rendering process:
- Calculates the spacing between dots based on the primitive's height and NumberOfDots
- Renders each dot as a 2x2 pixel rectangle starting from the top
- For each dot, first renders a shadow rectangle offset by 0.1 pixels
- Then renders the main dot rectangle on top
- Continues until reaching the bottom of the primitive or running out of space
The dots are positioned with a 4-pixel vertical offset from the top and spaced 4 pixels apart vertically. Each dot is 2x2 pixels in size with a subtle shadow effect for depth.