예제 #1
0
        internal GraphicsPath GetPath(GaugeGraphics g, bool getShadowPath)
        {
            if (getShadowPath && (!base.Visible || base.ShadowOffset == 0f))
            {
                return(null);
            }
            GetScale().SetDrawRegion(g);
            CircularScale scale              = GetScale();
            RectangleF    rect               = CalculateRangeRectangle();
            double        valueLimit         = scale.GetValueLimit(StartValue);
            double        valueLimit2        = scale.GetValueLimit(EndValue);
            float         positionFromValue  = scale.GetPositionFromValue(valueLimit);
            float         positionFromValue2 = scale.GetPositionFromValue(valueLimit2);

            if (Math.Round(positionFromValue2 - positionFromValue, 4) == 0.0)
            {
                g.RestoreDrawRegion();
                return(null);
            }
            GraphicsPath circularRangePath = g.GetCircularRangePath(rect, positionFromValue + 90f, positionFromValue2 - positionFromValue, StartWidth, EndWidth, Placement);

            if (circularRangePath != null && getShadowPath)
            {
                using (Matrix matrix = new Matrix())
                {
                    matrix.Translate(base.ShadowOffset, base.ShadowOffset);
                    circularRangePath.Transform(matrix);
                }
            }
            PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);

            g.RestoreDrawRegion();
            PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY);

            if (circularRangePath != null)
            {
                using (Matrix matrix2 = new Matrix())
                {
                    matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y);
                    circularRangePath.Transform(matrix2);
                    return(circularRangePath);
                }
            }
            return(circularRangePath);
        }
예제 #2
0
        internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !base.Visible || GetScale() == null)
            {
                return;
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name));
            g.StartHotRegion(this);
            GetScale().SetDrawRegion(g);
            RectangleF    rectangleF        = CalculateRangeRectangle();
            CircularScale scale             = GetScale();
            double        valueLimit        = scale.GetValueLimit(StartValue);
            double        valueLimit2       = scale.GetValueLimit(EndValue);
            float         positionFromValue = scale.GetPositionFromValue(valueLimit);
            float         num = scale.GetPositionFromValue(valueLimit2) - positionFromValue;

            if (Math.Round(num, 4) == 0.0)
            {
                g.RestoreDrawRegion();
                g.EndHotRegion();
                Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                return;
            }
            Pen          pen          = null;
            Brush        brush        = null;
            GraphicsPath graphicsPath = null;

            try
            {
                graphicsPath = g.GetCircularRangePath(rectangleF, positionFromValue + 90f, num, StartWidth, EndWidth, Placement);
                if (graphicsPath == null)
                {
                    g.RestoreDrawRegion();
                    g.EndHotRegion();
                    Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                    return;
                }
                RectangleF rect = rectangleF;
                if (Placement != 0)
                {
                    float num2 = StartWidth;
                    if (num2 < EndWidth)
                    {
                        num2 = EndWidth;
                    }
                    if (Placement == Placement.Outside)
                    {
                        rect.Inflate(num2, num2);
                    }
                    else
                    {
                        rect.Inflate(num2 / 2f, num2 / 2f);
                    }
                }
                RangeGradientType fillGradientType = base.FillGradientType;
                brush         = g.GetCircularRangeBrush(rect, positionFromValue + 90f, num, base.FillColor, base.FillHatchStyle, "", GaugeImageWrapMode.Unscaled, Color.Empty, GaugeImageAlign.TopLeft, fillGradientType, base.FillGradientEndColor);
                pen           = new Pen(base.BorderColor, base.BorderWidth);
                pen.DashStyle = g.GetPenStyle(base.BorderStyle);
                g.FillPath(brush, graphicsPath);
                if (base.BorderStyle != 0 && base.BorderWidth > 0)
                {
                    g.DrawPath(pen, graphicsPath);
                }
            }
            catch (Exception)
            {
                graphicsPath?.Dispose();
                pen?.Dispose();
                brush?.Dispose();
                g.RestoreDrawRegion();
                throw;
            }
            Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(GetScale().GetPivotPoint()), graphicsPath);
            g.RestoreDrawRegion();
            g.EndHotRegion();
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
        }