Пример #1
0
        internal GraphicsPath GetPointerPath(GaugeGraphics g)
        {
            if (!Visible)
            {
                return(null);
            }
            GraphicsPath    graphicsPath      = new GraphicsPath();
            float           positionFromValue = GetScale().GetPositionFromValue(base.Position);
            PointF          absolutePoint     = g.GetAbsolutePoint(GetScale().GetPivotPoint());
            KnobStyleAttrib knobStyleAttrib   = GetKnobStyleAttrib(g, absolutePoint, positionFromValue);

            if (knobStyleAttrib.paths != null && knobStyleAttrib.paths[0] != null)
            {
                graphicsPath.AddPath(knobStyleAttrib.paths[0], connect: false);
            }
            return(graphicsPath);
        }
Пример #2
0
        internal KnobStyleAttrib GetKnobStyleAttrib(GaugeGraphics g, PointF pointOrigin, float angle)
        {
            KnobStyleAttrib knobStyleAttrib = new KnobStyleAttrib();

            if (Image != "" && CapImage != "")
            {
                return(knobStyleAttrib);
            }
            float absoluteDimension = g.GetAbsoluteDimension(Width);
            float num = CapWidth / 100f * absoluteDimension;

            knobStyleAttrib.paths   = new GraphicsPath[6];
            knobStyleAttrib.brushes = new Brush[6];
            if (Image == "")
            {
                knobStyleAttrib.paths[0] = GetKnobPath(g, absoluteDimension, absoluteDimension * 0.5f);
            }
            else
            {
                knobStyleAttrib.paths[0] = null;
            }
            if (CapVisible && CapImage == "")
            {
                if (CapShadowOffset != 0f)
                {
                    knobStyleAttrib.paths[1] = new GraphicsPath();
                    knobStyleAttrib.paths[1].AddEllipse(0f - num + CapShadowOffset, 0f - num + CapShadowOffset, num * 2f, num * 2f);
                    using (Matrix matrix = new Matrix())
                    {
                        matrix.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append);
                        knobStyleAttrib.paths[1].Transform(matrix);
                    }
                }
                knobStyleAttrib.paths[2] = new GraphicsPath();
                knobStyleAttrib.paths[2].AddEllipse(0f - num, 0f - num, num * 2f, num * 2f);
            }
            else
            {
                if (CapShadowOffset == 0f)
                {
                    knobStyleAttrib.paths[1] = null;
                }
                knobStyleAttrib.paths[2] = null;
            }
            float  y            = MarkerPosition / 100f * absoluteDimension * 2f;
            float  num2         = MarkerWidth / 100f * absoluteDimension * 2f;
            float  markerHeight = MarkerLength / 100f * absoluteDimension * 2f;
            PointF point        = new PointF(0f, y);

            knobStyleAttrib.paths[3] = g.CreateMarker(point, num2, markerHeight, MarkerStyle);
            using (Matrix matrix2 = new Matrix())
            {
                matrix2.RotateAt(180f, point, MatrixOrder.Append);
                if (!MarkerRotateGradient)
                {
                    matrix2.Rotate(angle, MatrixOrder.Append);
                    matrix2.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append);
                }
                knobStyleAttrib.paths[3].Transform(matrix2);
            }
            if (Image == "" && knobStyleAttrib.paths[0] != null)
            {
                float angle2 = RotateGradient ? angle : 0f;
                knobStyleAttrib.brushes[0] = GetFillBrush(g, knobStyleAttrib.paths[0], pointOrigin, angle2, FillColor, FillGradientType, FillGradientEndColor, FillHatchStyle);
            }
            else
            {
                knobStyleAttrib.brushes[0] = null;
            }
            if (CapVisible && CapImage == "")
            {
                if (CapShadowOffset != 0f)
                {
                    knobStyleAttrib.brushes[1] = g.GetShadowBrush();
                }
                float angle3 = CapRotateGradient ? angle : 0f;
                knobStyleAttrib.brushes[2] = GetFillBrush(g, knobStyleAttrib.paths[2], pointOrigin, angle3, CapFillColor, CapFillGradientType, CapFillGradientEndColor, CapFillHatchStyle);
            }
            else
            {
                if (CapShadowOffset == 0f)
                {
                    knobStyleAttrib.brushes[1] = null;
                }
                knobStyleAttrib.brushes[2] = null;
            }
            float  angle4       = MarkerRotateGradient ? angle : 0f;
            PointF pointOrigin2 = pointOrigin;

            if (!MarkerRotateGradient)
            {
                pointOrigin2 = new PointF(0f, 0f);
            }
            knobStyleAttrib.brushes[3] = g.GetMarkerBrush(knobStyleAttrib.paths[3], MarkerStyle, pointOrigin2, angle4, MarkerFillColor, MarkerFillGradientType, MarkerFillGradientEndColor, MarkerFillHatchStyle);
            if (CapVisible && CapReflection && CapImage == "")
            {
                g.GetCircularEdgeReflection(knobStyleAttrib.paths[2].GetBounds(), 135f, 200, pointOrigin, out knobStyleAttrib.paths[4], out knobStyleAttrib.brushes[4]);
                g.GetCircularEdgeReflection(knobStyleAttrib.paths[2].GetBounds(), 315f, 128, pointOrigin, out knobStyleAttrib.paths[5], out knobStyleAttrib.brushes[5]);
            }
            else
            {
                knobStyleAttrib.paths[4]   = null;
                knobStyleAttrib.paths[5]   = null;
                knobStyleAttrib.brushes[4] = null;
                knobStyleAttrib.brushes[5] = null;
            }
            using (Matrix matrix3 = new Matrix())
            {
                matrix3.Rotate(angle, MatrixOrder.Append);
                matrix3.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append);
                if (knobStyleAttrib.paths[0] != null)
                {
                    knobStyleAttrib.paths[0].Transform(matrix3);
                }
                if (knobStyleAttrib.paths[2] != null)
                {
                    knobStyleAttrib.paths[2].Transform(matrix3);
                }
                if (knobStyleAttrib.paths[3] != null)
                {
                    if (MarkerRotateGradient)
                    {
                        knobStyleAttrib.paths[3].Transform(matrix3);
                        return(knobStyleAttrib);
                    }
                    return(knobStyleAttrib);
                }
                return(knobStyleAttrib);
            }
        }
Пример #3
0
        internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !Visible || GetScale() == null)
            {
                return;
            }
            g.StartHotRegion(this);
            GetScale().SetDrawRegion(g);
            if (Image != "" && CapImage != "")
            {
                DrawImage(g, primary: true, drawShadow: false);
                DrawImage(g, primary: false, drawShadow: false);
                SetAllHotRegions(g);
                g.RestoreDrawRegion();
                g.EndHotRegion();
                return;
            }
            if (Image != "")
            {
                DrawImage(g, primary: true, drawShadow: false);
            }
            float  positionFromValue = GetScale().GetPositionFromValue(base.Position);
            PointF absolutePoint     = g.GetAbsolutePoint(GetScale().GetPivotPoint());
            Pen    pen = new Pen(base.BorderColor, base.BorderWidth);

            pen.DashStyle = g.GetPenStyle(base.BorderStyle);
            if (pen.DashStyle != 0)
            {
                pen.Alignment = PenAlignment.Center;
            }
            KnobStyleAttrib knobStyleAttrib = GetKnobStyleAttrib(g, absolutePoint, positionFromValue);

            try
            {
                if (knobStyleAttrib.paths != null)
                {
                    for (int i = 0; i < knobStyleAttrib.paths.Length; i++)
                    {
                        if (knobStyleAttrib.brushes[i] != null && knobStyleAttrib.paths[i] != null)
                        {
                            g.FillPath(knobStyleAttrib.brushes[i], knobStyleAttrib.paths[i]);
                        }
                    }
                    if (base.BorderWidth > 0 && knobStyleAttrib.paths[0] != null)
                    {
                        g.DrawPath(pen, knobStyleAttrib.paths[0]);
                    }
                    if (knobStyleAttrib.paths[0] != null)
                    {
                        AddHotRegion((GraphicsPath)knobStyleAttrib.paths[0].Clone(), primary: true);
                    }
                }
            }
            finally
            {
                knobStyleAttrib.Dispose();
            }
            if (CapImage != "")
            {
                DrawImage(g, primary: false, drawShadow: false);
            }
            SetAllHotRegions(g);
            g.RestoreDrawRegion();
            g.EndHotRegion();
        }