Gauge Positioning and Arrangement
In This Topic
The origin of the coordinate system is at the top-left corner of the C1Gauge control. It is possible to align multiple gauges in the same container control. Gauges can be overlapped or placed side-by-side. The fine-turning settings give an ability to maintain the aspect ratio and relative position of individual gauges when resizing the container control.
The C1GaugeViewport class lies in the core of these abilities.
The following elements have the Viewport property: C1Gauge, C1GaugeBase, and C1GaugeBaseShape. They are related as parent-child-grandchild. So the client area of the container control becomes the basis for C1Gauge viewport. Viewport for an individual gauge is based on the owner C1Gauge viewport. Viewport for gauge shapes is count from the owner gauge's viewport.
Now let's consider how we can get the working area for a given element having its viewport settings and the owner element's working area.
The following is list of the C1GaugeViewport object properties in the same order as they are applied:
- C1GaugeViewport.TranslateX and C1GaugeViewport.TranslateY – at the first stage we move the viewport by the specified relative amount along the X and Y axes. The amount of 1.0 corresponds to the whole width or height of the owner area.
- C1GaugeViewport.ScaleX and C1GaugeViewport.ScaleY – scale the width and height of the viewport by the specified relative amount.
- C1GaugeViewport.MarginX and C1GaugeViewport.MarginY – specify the horizontal and vertical margins, in pixels. If these margins are negative the working area becomes wider than the original bounds.
- C1GaugeViewport.X and C1GaugeViewport.Y – set the offset of the viewport, in pixels. Negative offset is count from the right or bottom edge of the owner area.
- C1GaugeViewport.Width and C1GaugeViewport.Height – specify the width and height of the viewport, in pixels. These properties equal to 0 by default. That extends the viewport till the opposite edge of the owner area. For example, if the X property value is negative the viewport will be extended till the left edge. Negative width/height extends the viewport backwards. For example, to move the working area to the right top corner you may set X=-100, Width=-100, Y=0, Height=0.
- C1GaugeViewport.AspectRatio – sets the fixed ratio of width to height of the viewport. Maintaining the aspect ratio may cause moving the working area.
- C1GaugeViewport.AspectPinX and C1GaugeViewport.AspectPinY – at the last stage we set the relative position that remains fixed when the working area moves in order to maintain the aspect ratio. For a radial gauge these properties are equal to C1RadialGauge.PointerOriginX and C1RadialGauge.PointerOriginY by default.
The next image shows a viewport that has all pixel-based properties set to positive values, except the Width which is equal to 0 (other properties have their default values):
Next sample shows a viewport where the MarginX, X, and Y properties are negative and Height is equal to 0.
See Also