コード例 #1
0
        public GraphicsPath GetPointerPath(GaugeGraphics g)
        {
            if (!this.Visible)
            {
                return(null);
            }
            GraphicsPath    graphicsPath      = new GraphicsPath();
            float           positionFromValue = this.GetScale().GetPositionFromValue(base.Position);
            PointF          absolutePoint     = g.GetAbsolutePoint(this.GetScale().GetPivotPoint());
            KnobStyleAttrib knobStyleAttrib   = this.GetKnobStyleAttrib(g, absolutePoint, positionFromValue);

            if (knobStyleAttrib.paths != null && knobStyleAttrib.paths[0] != null)
            {
                graphicsPath.AddPath(knobStyleAttrib.paths[0], false);
            }
            return(graphicsPath);
        }
コード例 #2
0
        public KnobStyleAttrib GetKnobStyleAttrib(GaugeGraphics g, PointF pointOrigin, float angle)
        {
            KnobStyleAttrib knobStyleAttrib = new KnobStyleAttrib();

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

            knobStyleAttrib.paths   = new GraphicsPath[6];
            knobStyleAttrib.brushes = new Brush[6];
            if (this.Image == "")
            {
                knobStyleAttrib.paths[0] = this.GetKnobPath(g, absoluteDimension, (float)(absoluteDimension * 0.5));
            }
            else
            {
                knobStyleAttrib.paths[0] = null;
            }
            if (this.CapVisible && this.CapImage == "")
            {
                if (this.CapShadowOffset != 0.0)
                {
                    knobStyleAttrib.paths[1] = new GraphicsPath();
                    knobStyleAttrib.paths[1].AddEllipse((float)(0.0 - num + this.CapShadowOffset), (float)(0.0 - num + this.CapShadowOffset), (float)(num * 2.0), (float)(num * 2.0));
                    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((float)(0.0 - num), (float)(0.0 - num), (float)(num * 2.0), (float)(num * 2.0));
            }
            else
            {
                if (this.CapShadowOffset == 0.0)
                {
                    knobStyleAttrib.paths[1] = null;
                }
                knobStyleAttrib.paths[2] = null;
            }
            float  y            = (float)(this.MarkerPosition / 100.0 * absoluteDimension * 2.0);
            float  num2         = (float)(this.MarkerWidth / 100.0 * absoluteDimension * 2.0);
            float  markerHeight = (float)(this.MarkerLength / 100.0 * absoluteDimension * 2.0);
            PointF point        = new PointF(0f, y);

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

            if (!this.MarkerRotateGradient)
            {
                pointOrigin2 = new PointF(0f, 0f);
            }
            knobStyleAttrib.brushes[3] = g.GetMarkerBrush(knobStyleAttrib.paths[3], this.MarkerStyle, pointOrigin2, angle4, this.MarkerFillColor, this.MarkerFillGradientType, this.MarkerFillGradientEndColor, this.MarkerFillHatchStyle);
            if (this.CapVisible && this.CapReflection && this.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 (this.MarkerRotateGradient)
                    {
                        knobStyleAttrib.paths[3].Transform(matrix3);
                        return(knobStyleAttrib);
                    }
                    return(knobStyleAttrib);
                }
                return(knobStyleAttrib);
            }
        }
コード例 #3
0
 public override void Render(GaugeGraphics g)
 {
     if (this.Common != null && this.Visible && this.GetScale() != null)
     {
         g.StartHotRegion(this);
         this.GetScale().SetDrawRegion(g);
         if (this.Image != "" && this.CapImage != "")
         {
             this.DrawImage(g, true, false);
             this.DrawImage(g, false, false);
             this.SetAllHotRegions(g);
             g.RestoreDrawRegion();
             g.EndHotRegion();
         }
         else
         {
             if (this.Image != "")
             {
                 this.DrawImage(g, true, false);
             }
             float  positionFromValue = this.GetScale().GetPositionFromValue(base.Position);
             PointF absolutePoint     = g.GetAbsolutePoint(this.GetScale().GetPivotPoint());
             Pen    pen = new Pen(base.BorderColor, (float)base.BorderWidth);
             pen.DashStyle = g.GetPenStyle(base.BorderStyle);
             if (pen.DashStyle != 0)
             {
                 pen.Alignment = PenAlignment.Center;
             }
             KnobStyleAttrib knobStyleAttrib = this.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)
                     {
                         this.AddHotRegion((GraphicsPath)knobStyleAttrib.paths[0].Clone(), true);
                     }
                 }
             }
             finally
             {
                 knobStyleAttrib.Dispose();
             }
             if (this.CapImage != "")
             {
                 this.DrawImage(g, false, false);
             }
             this.SetAllHotRegions(g);
             g.RestoreDrawRegion();
             g.EndHotRegion();
         }
     }
 }