Struct NineRects
Represents a structure that divides a container rectangle into nine distinct rectangular regions based on a specified patch rectangle. This structure is commonly used to facilitate scalable rendering of user interface elements by enabling separate manipulation of each region.
public struct NineRects
Remarks
The NineRects structure provides properties and methods to access individual rectangles within the nine-part grid, including both the patch area and the surrounding regions. It supports conversion between device-independent pixels (DIPs) and pixels using a scale factor, and offers utility methods for retrieving rectangles by alignment or containment. This structure is particularly useful for scenarios such as nine-slice scaling, where different regions of a UI element require separate rendering or layout logic.
Constructors
- NineRects(RectD, RectD, float)
Initializes a new instance of the NineRects class with the specified container and patch rectangles.
- NineRects(RectI, RectI)
Initializes a new instance of the NineRects class with the specified container and patch rectangles.
Properties
- BottomCenter
Bottom-center corner of the Container.
- BottomCenterScaled
Gets the bottom-center rectangle in device-independent pixels (DIPs). Returns BottomCenter converted from pixels to DIPs using the specified scale factor.
- BottomLeft
Bottom-left corner of the Container.
- BottomLeftScaled
Gets the bottom-left corner rectangle in device-independent pixels (DIPs). Returns BottomLeft converted from pixels to DIPs using the specified scale factor.
- BottomRect
Gets the bottom rectangular region defined by the container's position and the patch's dimensions. This rectangle returns the area which is below the patch.
- BottomRectScaled
Gets the bottom rectangular region in device-independent pixels (DIPs). Returns BottomRect converted from pixels to DIPs using the specified scale factor.
- BottomRight
Bottom-right corner of the Container.
- BottomRightScaled
Gets the bottom-right corner rectangle in device-independent pixels (DIPs). Returns BottomRight converted from pixels to DIPs using the specified scale factor.
- CenterLeft
Center-left corner of the Container.
- CenterLeftScaled
Gets the center-left rectangle in device-independent pixels (DIPs). Returns CenterLeft converted from pixels to DIPs using the specified scale factor.
- CenterRight
Center-right corner of the Container.
- CenterRightScaled
Gets the center-right rectangle in device-independent pixels (DIPs). Returns CenterRight converted from pixels to DIPs using the specified scale factor.
- CenterScaled
Gets the center rectangle (patch area) in device-independent pixels (DIPs). Returns Center converted from pixels to DIPs using the specified scale factor.
- Container
Rectangle which is sliced.
- IsTopRectLarger
Gets a value indicating whether the height of the top rectangle is greater than the height of the bottom rectangle.
- LeftRect
Gets the rectangle that starts at the top-left corner of the container and spans its full height. Width is determined by the horizontal position of the patch, creating a vertical strip along the left edge of the container.
- LeftRectScaled
Gets the LeftRect scaled from pixels to device-independent units using the current scale factor.
- OuterRects
Gets all rectangles except the center rectangle.
- OuterRectsScaled
Gets the outer rectangles (all rectangles except the center rectangle) after scaling from pixels to device-independent pixels (DIPs) using the specified scale factor.
- Patch
Rectangle which defines sliced parts.
- Rects
Gets all nine rectangles.
- RectsScaled
Gets an array of all nine rectangles. This property returns the rectangles converted from pixels to device-independent pixels (DIPs) using the specified scale factor.
- RightRect
Gets the rectangle that represents the right area of the container, adjusted to match the container's current height. Width is determined by the horizontal position of the patch, creating a vertical strip along the right edge of the container.
- RightRectScaled
Gets the RightRect scaled from pixels to device-independent units using the current scale factor.
- ScaleFactor
Gets or sets the scale factor used for converting pixels to DIPs.
- TopCenterScaled
Gets the top-center rectangle in device-independent pixels (DIPs). Returns TopCenter converted from pixels to DIPs using the specified scale factor.
- TopLeftScaled
Gets the top-left corner rectangle in device-independent pixels (DIPs). Returns TopLeft converted from pixels to DIPs using the specified scale factor.
- TopRect
Gets the top rectangular region defined by the container's position and the patch's dimensions. This rectangle returns the area which is above the patch.
- TopRectScaled
Gets the top rectangular region in device-independent pixels (DIPs). Returns TopRect converted from pixels to DIPs using the specified scale factor.
- TopRightScaled
Gets the top-right corner rectangle in device-independent pixels (DIPs). Returns TopRight converted from pixels to DIPs using the specified scale factor.
Methods
- GetPart(NineRectsParts)
Retrieves the rectangle corresponding to the specified part of the nine-part grid.
- GetPartScaled(NineRectsParts)
Gets the scaled rectangle that corresponds to the specified part of the NineRects layout.
- GetParts(NineRectsParts)
Returns an array of rectangular regions corresponding to the specified parts of the nine-part grid.
- GetPartsScaled(NineRectsParts)
Returns an array of rectangular regions corresponding to the specified parts of the nine-part grid. This method allows you to retrieve specific rectangles based on the provided flags, which can represent any combination of the defined parts. This method returns scaled rectangles, converting them from pixels to device-independent pixels (DIPs) using the specified scale factor. The returned rectangles reflect the current scaling transformation, ensuring that they are appropriately sized for rendering on different display densities.
- GetRect(HorizontalAlignment, VerticalAlignment)
Gets rectangle specified by
horzandvertparams. Only left, center, right, top, bottom values are supported.
- OuterRectInsideContainer(RectI, NineRectsParts)
Returns the first outer rectangle that is fully contained within the specified container rectangle.
- OuterRectsInsideContainer(RectI, NineRectsParts)
Returns an array of outer rectangles that are fully contained within the specified container rectangle.
- SuggestVertAlignmentForToolTip(RectD, RectD)
Suggests the vertical alignment for a tooltip based on the relative sizes and positions of a container rectangle and an item rectangle.