internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !Visible || GetScale() == null)
            {
                return;
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name));
            g.StartHotRegion(this);
            if (Image != "")
            {
                DrawImage(g, drawShadow: false);
                SetAllHotRegions(g);
                g.EndHotRegion();
                Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                return;
            }
            Pen pen = new Pen(base.BorderColor, base.BorderWidth);

            pen.DashStyle = g.GetPenStyle(base.BorderStyle);
            if (pen.DashStyle != 0)
            {
                pen.Alignment = PenAlignment.Center;
            }
            if (Type == LinearPointerType.Bar)
            {
                BarStyleAttrib barStyleAttrib = GetBarStyleAttrib(g);
                try
                {
                    if (barStyleAttrib.primaryPath != null)
                    {
                        g.FillPath(barStyleAttrib.primaryBrush, barStyleAttrib.primaryPath);
                    }
                    if (barStyleAttrib.secondaryPaths != null)
                    {
                        int            num            = 0;
                        GraphicsPath[] secondaryPaths = barStyleAttrib.secondaryPaths;
                        foreach (GraphicsPath graphicsPath in secondaryPaths)
                        {
                            if (graphicsPath != null && barStyleAttrib.secondaryBrushes[num] != null)
                            {
                                g.FillPath(barStyleAttrib.secondaryBrushes[num], graphicsPath);
                            }
                            num++;
                        }
                    }
                    if (base.BorderWidth > 0 && barStyleAttrib.primaryBrush != null && base.BorderStyle != 0)
                    {
                        g.DrawPath(pen, barStyleAttrib.primaryPath);
                    }
                }
                catch (Exception)
                {
                    barStyleAttrib.Dispose();
                }
                if (barStyleAttrib.primaryPath != null)
                {
                    AddHotRegion(barStyleAttrib.primaryPath, primary: true);
                }
            }
            else if (Type == LinearPointerType.Thermometer)
            {
                BarStyleAttrib thermometerStyleAttrib = GetThermometerStyleAttrib(g);
                try
                {
                    if (thermometerStyleAttrib.totalPath != null)
                    {
                        g.FillPath(thermometerStyleAttrib.totalBrush, thermometerStyleAttrib.totalPath);
                    }
                    if (thermometerStyleAttrib.primaryPath != null)
                    {
                        g.FillPath(thermometerStyleAttrib.primaryBrush, thermometerStyleAttrib.primaryPath);
                    }
                    if (thermometerStyleAttrib.secondaryPaths != null)
                    {
                        int            num2           = 0;
                        GraphicsPath[] secondaryPaths = thermometerStyleAttrib.secondaryPaths;
                        foreach (GraphicsPath graphicsPath2 in secondaryPaths)
                        {
                            if (graphicsPath2 != null && thermometerStyleAttrib.secondaryBrushes[num2] != null)
                            {
                                g.FillPath(thermometerStyleAttrib.secondaryBrushes[num2], graphicsPath2);
                            }
                            num2++;
                        }
                    }
                    if (base.BorderWidth > 0 && thermometerStyleAttrib.primaryBrush != null && base.BorderStyle != 0)
                    {
                        g.DrawPath(pen, thermometerStyleAttrib.totalPath);
                    }
                }
                catch (Exception)
                {
                    thermometerStyleAttrib.Dispose();
                }
                if (thermometerStyleAttrib.primaryPath != null)
                {
                    AddHotRegion(thermometerStyleAttrib.primaryPath, primary: true);
                }
            }
            else
            {
                MarkerStyleAttrib markerStyleAttrib = GetMarkerStyleAttrib(g);
                try
                {
                    if (markerStyleAttrib.path != null)
                    {
                        bool circularFill = (MarkerStyle == MarkerStyle.Circle) ? true : false;
                        g.FillPath(markerStyleAttrib.brush, markerStyleAttrib.path, 0f, useBrushOffset: true, circularFill);
                    }
                    if (base.BorderWidth > 0 && markerStyleAttrib.path != null && base.BorderStyle != 0)
                    {
                        g.DrawPath(pen, markerStyleAttrib.path);
                    }
                }
                catch (Exception)
                {
                    markerStyleAttrib.Dispose();
                }
                if (markerStyleAttrib.path != null)
                {
                    AddHotRegion(markerStyleAttrib.path, primary: true);
                }
            }
            SetAllHotRegions(g);
            g.EndHotRegion();
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
        }
 public override void Render(GaugeGraphics g)
 {
     if (this.Common != null && base.Visible && this.GetScale() != null)
     {
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(this.Name));
         g.StartHotRegion(this);
         this.GetScale().SetDrawRegion(g);
         RectangleF    rectangleF         = this.CalculateRangeRectangle();
         CircularScale scale              = this.GetScale();
         double        valueLimit         = scale.GetValueLimit(this.StartValue);
         double        valueLimit2        = scale.GetValueLimit(this.EndValue);
         float         positionFromValue  = scale.GetPositionFromValue(valueLimit);
         float         positionFromValue2 = scale.GetPositionFromValue(valueLimit2);
         float         num = positionFromValue2 - positionFromValue;
         if (Math.Round((double)num, 4) == 0.0)
         {
             g.RestoreDrawRegion();
             g.EndHotRegion();
             this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
         }
         else
         {
             Pen          pen          = null;
             Brush        brush        = null;
             GraphicsPath graphicsPath = null;
             try
             {
                 graphicsPath = g.GetCircularRangePath(rectangleF, (float)(positionFromValue + 90.0), num, this.StartWidth, this.EndWidth, this.Placement);
                 if (graphicsPath == null)
                 {
                     g.RestoreDrawRegion();
                     g.EndHotRegion();
                     this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
                     return;
                 }
                 RectangleF rect = rectangleF;
                 if (this.Placement != 0)
                 {
                     float num2 = this.StartWidth;
                     if (num2 < this.EndWidth)
                     {
                         num2 = this.EndWidth;
                     }
                     if (this.Placement == Placement.Outside)
                     {
                         rect.Inflate(num2, num2);
                     }
                     else
                     {
                         rect.Inflate((float)(num2 / 2.0), (float)(num2 / 2.0));
                     }
                 }
                 RangeGradientType fillGradientType = base.FillGradientType;
                 brush         = g.GetCircularRangeBrush(rect, (float)(positionFromValue + 90.0), num, base.FillColor, base.FillHatchStyle, "", GaugeImageWrapMode.Unscaled, Color.Empty, GaugeImageAlign.TopLeft, fillGradientType, base.FillGradientEndColor);
                 pen           = new Pen(base.BorderColor, (float)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)
             {
                 if (graphicsPath != null)
                 {
                     graphicsPath.Dispose();
                 }
                 if (pen != null)
                 {
                     pen.Dispose();
                 }
                 if (brush != null)
                 {
                     brush.Dispose();
                 }
                 g.RestoreDrawRegion();
                 throw;
             }
             this.Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(this.GetScale().GetPivotPoint()), graphicsPath);
             g.RestoreDrawRegion();
             g.EndHotRegion();
             this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
         }
     }
 }
 void IRenderable.RenderDynamicElements(GaugeGraphics g)
 {
     if (this.Visible)
     {
         g.StartHotRegion(this);
         GraphicsPath graphicsPath  = null;
         GraphicsPath graphicsPath2 = null;
         Brush        brush         = null;
         Brush        brush2        = null;
         Brush        brush3        = null;
         Pen          pen           = null;
         try
         {
             graphicsPath  = this.GetBackPath(g);
             graphicsPath2 = this.GetTextPath(g);
             if (graphicsPath != null)
             {
                 if (this.BackShadowOffset != 0)
                 {
                     using (Matrix matrix = new Matrix())
                     {
                         brush3 = g.GetShadowBrush();
                         matrix.Translate((float)this.BackShadowOffset, (float)this.BackShadowOffset, MatrixOrder.Append);
                         graphicsPath.Transform(matrix);
                         g.FillPath(brush3, graphicsPath);
                         matrix.Reset();
                         matrix.Translate((float)(-this.BackShadowOffset), (float)(-this.BackShadowOffset), MatrixOrder.Append);
                         graphicsPath.Transform(matrix);
                     }
                 }
                 brush2 = this.GetBackBrush(g);
                 g.FillPath(brush2, graphicsPath);
                 pen = this.GetPen(g);
                 if (pen != null)
                 {
                     g.DrawPath(pen, graphicsPath);
                 }
                 this.Common.GaugeCore.HotRegionList.SetHotRegion(this, Point.Empty, (GraphicsPath)graphicsPath.Clone());
             }
             if (graphicsPath2 != null)
             {
                 if (this.TextShadowOffset != 0)
                 {
                     using (Matrix matrix2 = new Matrix())
                     {
                         brush3 = g.GetShadowBrush();
                         matrix2.Translate((float)this.TextShadowOffset, (float)this.TextShadowOffset, MatrixOrder.Append);
                         graphicsPath2.Transform(matrix2);
                         g.FillPath(brush3, graphicsPath2);
                         matrix2.Reset();
                         matrix2.Translate((float)(-this.TextShadowOffset), (float)(-this.TextShadowOffset), MatrixOrder.Append);
                         graphicsPath2.Transform(matrix2);
                     }
                 }
                 brush = new SolidBrush(this.TextColor);
                 AntiAliasing antiAliasing  = this.Common.GaugeContainer.AntiAliasing;
                 AntiAliasing antiAliasing2 = g.AntiAliasing;
                 if (this.Common.GaugeContainer.AntiAliasing == AntiAliasing.Text)
                 {
                     antiAliasing = AntiAliasing.Graphics;
                 }
                 else if (this.Common.GaugeContainer.AntiAliasing == AntiAliasing.Graphics)
                 {
                     antiAliasing = AntiAliasing.None;
                 }
                 g.AntiAliasing = antiAliasing;
                 g.FillPath(brush, graphicsPath2);
                 g.AntiAliasing = antiAliasing2;
             }
         }
         finally
         {
             if (graphicsPath != null)
             {
                 graphicsPath.Dispose();
             }
             if (graphicsPath2 != null)
             {
                 graphicsPath2.Dispose();
             }
             if (brush3 != null)
             {
                 brush3.Dispose();
             }
             if (brush2 != null)
             {
                 brush2.Dispose();
             }
             if (brush != null)
             {
                 brush.Dispose();
             }
             if (pen != null)
             {
                 pen.Dispose();
             }
             g.EndHotRegion();
         }
     }
 }
Example #4
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();
         }
     }
 }
 public override void Render(GaugeGraphics g)
 {
     if (this.Common != null && this.Visible && this.GetScale() != null)
     {
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(this.Name));
         g.StartHotRegion(this);
         if (this.Image != "")
         {
             this.DrawImage(g, false);
             this.SetAllHotRegions(g);
             g.EndHotRegion();
             this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
         }
         else
         {
             Pen pen = new Pen(base.BorderColor, (float)base.BorderWidth);
             pen.DashStyle = g.GetPenStyle(base.BorderStyle);
             if (pen.DashStyle != 0)
             {
                 pen.Alignment = PenAlignment.Center;
             }
             if (this.Type == LinearPointerType.Bar)
             {
                 BarStyleAttrib barStyleAttrib = this.GetBarStyleAttrib(g);
                 try
                 {
                     if (barStyleAttrib.primaryPath != null)
                     {
                         g.FillPath(barStyleAttrib.primaryBrush, barStyleAttrib.primaryPath);
                     }
                     if (barStyleAttrib.secondaryPaths != null)
                     {
                         int            num            = 0;
                         GraphicsPath[] secondaryPaths = barStyleAttrib.secondaryPaths;
                         foreach (GraphicsPath graphicsPath in secondaryPaths)
                         {
                             if (graphicsPath != null && barStyleAttrib.secondaryBrushes[num] != null)
                             {
                                 g.FillPath(barStyleAttrib.secondaryBrushes[num], graphicsPath);
                             }
                             num++;
                         }
                     }
                     if (base.BorderWidth > 0 && barStyleAttrib.primaryBrush != null && base.BorderStyle != 0)
                     {
                         g.DrawPath(pen, barStyleAttrib.primaryPath);
                     }
                 }
                 catch (Exception)
                 {
                     barStyleAttrib.Dispose();
                 }
                 if (barStyleAttrib.primaryPath != null)
                 {
                     this.AddHotRegion(barStyleAttrib.primaryPath, true);
                 }
             }
             else if (this.Type == LinearPointerType.Thermometer)
             {
                 BarStyleAttrib thermometerStyleAttrib = this.GetThermometerStyleAttrib(g);
                 try
                 {
                     if (thermometerStyleAttrib.totalPath != null)
                     {
                         g.FillPath(thermometerStyleAttrib.totalBrush, thermometerStyleAttrib.totalPath);
                     }
                     if (thermometerStyleAttrib.primaryPath != null)
                     {
                         g.FillPath(thermometerStyleAttrib.primaryBrush, thermometerStyleAttrib.primaryPath);
                     }
                     if (thermometerStyleAttrib.secondaryPaths != null)
                     {
                         int            num2            = 0;
                         GraphicsPath[] secondaryPaths2 = thermometerStyleAttrib.secondaryPaths;
                         foreach (GraphicsPath graphicsPath2 in secondaryPaths2)
                         {
                             if (graphicsPath2 != null && thermometerStyleAttrib.secondaryBrushes[num2] != null)
                             {
                                 g.FillPath(thermometerStyleAttrib.secondaryBrushes[num2], graphicsPath2);
                             }
                             num2++;
                         }
                     }
                     if (base.BorderWidth > 0 && thermometerStyleAttrib.primaryBrush != null && base.BorderStyle != 0)
                     {
                         g.DrawPath(pen, thermometerStyleAttrib.totalPath);
                     }
                 }
                 catch (Exception)
                 {
                     thermometerStyleAttrib.Dispose();
                 }
                 if (thermometerStyleAttrib.primaryPath != null)
                 {
                     this.AddHotRegion(thermometerStyleAttrib.primaryPath, true);
                 }
             }
             else
             {
                 MarkerStyleAttrib markerStyleAttrib = this.GetMarkerStyleAttrib(g);
                 try
                 {
                     if (markerStyleAttrib.path != null)
                     {
                         bool circularFill = (byte)((this.MarkerStyle == MarkerStyle.Circle) ? 1 : 0) != 0;
                         g.FillPath(markerStyleAttrib.brush, markerStyleAttrib.path, 0f, true, circularFill);
                     }
                     if (base.BorderWidth > 0 && markerStyleAttrib.path != null && base.BorderStyle != 0)
                     {
                         g.DrawPath(pen, markerStyleAttrib.path);
                     }
                 }
                 catch (Exception)
                 {
                     markerStyleAttrib.Dispose();
                 }
                 if (markerStyleAttrib.path != null)
                 {
                     this.AddHotRegion(markerStyleAttrib.path, true);
                 }
             }
             this.SetAllHotRegions(g);
             g.EndHotRegion();
             this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name));
         }
     }
 }
        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));
        }
 internal void RenderFrame(GaugeGraphics g)
 {
     if (Image.Length != 0)
     {
         Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingImageFrame);
         DrawFrameImage(g);
         Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceImageFrameRenderingComplete);
     }
     else
     {
         if (FrameStyle == BackFrameStyle.None)
         {
             return;
         }
         Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingFrame);
         ResetCachedXamlRenderer();
         if (IsCustomXamlFrame())
         {
             RenderShadow(g);
             XamlRenderer cachedXamlRenderer = GetCachedXamlRenderer(g);
             cachedXamlRenderer.Layers[0].Render(g);
             cachedXamlRenderer.Layers[1].Render(g);
         }
         else
         {
             RenderShadow(g);
             Brush        brush         = null;
             GraphicsPath graphicsPath  = null;
             GraphicsPath graphicsPath2 = null;
             GraphicsPath graphicsPath3 = null;
             Brush        brush2        = null;
             Brush        brush3        = null;
             Pen          pen           = null;
             Pen          pen2          = null;
             try
             {
                 graphicsPath  = GetFramePath(g, 0f);
                 graphicsPath3 = GetFramePath(g, FrameWidth);
                 brush         = GetBrush(g, graphicsPath3.GetBounds(), backHatchStyle, BackGradientType, BackColor, BackGradientEndColor, frame: false, 0f);
                 g.FillPath(brush, graphicsPath3, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular);
                 if (FrameStyle == BackFrameStyle.Simple)
                 {
                     using (GraphicsPath graphicsPath4 = new GraphicsPath())
                     {
                         graphicsPath4.AddPath(graphicsPath, connect: false);
                         graphicsPath4.AddPath(graphicsPath3, connect: false);
                         graphicsPath4.CloseFigure();
                         brush2 = GetBrush(g, graphicsPath4.GetBounds(), FrameHatchStyle, FrameGradientType, FrameColor, FrameGradientEndColor, frame: true, frameWidth);
                         pen    = new Pen(brush, 2f);
                         g.DrawPath(pen, graphicsPath3);
                         g.FillPath(brush2, graphicsPath4, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular);
                     }
                 }
                 else if (FrameStyle == BackFrameStyle.Edged)
                 {
                     float num = FrameWidth * 0.7f;
                     using (GraphicsPath addingPath = GetFramePath(g, num))
                     {
                         using (GraphicsPath graphicsPath5 = new GraphicsPath())
                         {
                             using (GraphicsPath graphicsPath6 = new GraphicsPath())
                             {
                                 graphicsPath5.AddPath(graphicsPath, connect: false);
                                 graphicsPath5.AddPath(addingPath, connect: false);
                                 graphicsPath6.AddPath(addingPath, connect: false);
                                 graphicsPath6.AddPath(graphicsPath3, connect: false);
                                 brush2 = GetBrush(g, graphicsPath5.GetBounds(), FrameHatchStyle, FrameGradientType, FrameColor, FrameGradientEndColor, frame: true, num);
                                 g.FillPath(brush2, graphicsPath5, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular);
                                 brush3 = ((FrameGradientType != 0 || FrameHatchStyle != 0) ? GetBrush(g, graphicsPath6.GetBounds(), FrameHatchStyle, FrameGradientType, FrameGradientEndColor, FrameColor, frame: true, frameWidth - num) : GetBrush(g, graphicsPath6.GetBounds(), FrameHatchStyle, FrameGradientType, FrameColor, FrameColor, frame: true, frameWidth - num));
                                 if (FrameWidth > 0f)
                                 {
                                     pen = new Pen(brush3, 2f);
                                     g.DrawPath(pen, graphicsPath6);
                                 }
                                 g.FillPath(brush3, graphicsPath6, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular);
                             }
                         }
                     }
                 }
                 if (BorderWidth > 0 && BorderStyle != 0)
                 {
                     pen2           = new Pen(BorderColor, BorderWidth);
                     pen2.DashStyle = g.GetPenStyle(BorderStyle);
                     pen2.Alignment = PenAlignment.Center;
                     g.DrawPath(pen2, graphicsPath);
                 }
             }
             finally
             {
                 brush?.Dispose();
                 graphicsPath?.Dispose();
                 graphicsPath2?.Dispose();
                 brush2?.Dispose();
                 brush3?.Dispose();
                 pen?.Dispose();
                 pen2?.Dispose();
             }
         }
         Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceFrameRenderingComplete);
     }
 }
        internal void RenderGlassEffect(GaugeGraphics g)
        {
            if (GlassEffect == GlassEffect.None || FrameStyle == BackFrameStyle.None)
            {
                return;
            }
            if (IsCustomXamlFrame())
            {
                GetCachedXamlRenderer(g).Layers[2].Render(g);
                return;
            }
            RectangleF bounds;

            using (GraphicsPath graphicsPath = GetFramePath(g, FrameWidth - 1f))
            {
                bounds = graphicsPath.GetBounds();
                using (Brush brush = new LinearGradientBrush(bounds, Color.FromArgb(15, Color.Black), Color.FromArgb(128, Color.Black), LinearGradientMode.ForwardDiagonal))
                {
                    if (bounds.Height > 0f && bounds.Width > 0f)
                    {
                        g.FillPath(brush, graphicsPath);
                    }
                }
            }
            if (FrameShape == BackFrameShape.Rectangular || FrameShape == BackFrameShape.RoundedRectangular)
            {
                _ = g.GetAbsoluteSize(new SizeF(8f, 0f)).Width;
                GraphicsPath graphicsPath2      = new GraphicsPath();
                float        absoluteDimension  = g.GetAbsoluteDimension(30f);
                float        absoluteDimension2 = g.GetAbsoluteDimension(10f);
                float        absoluteDimension3 = g.GetAbsoluteDimension(50f);
                float        absoluteDimension4 = g.GetAbsoluteDimension(5f);
                g.GetAbsoluteDimension(30f);
                g.GetAbsoluteDimension(5f);
                PointF[] points = new PointF[4]
                {
                    new PointF(bounds.X, bounds.Y + absoluteDimension),
                    new PointF(bounds.X + absoluteDimension, bounds.Y),
                    new PointF(bounds.X + absoluteDimension + absoluteDimension2, bounds.Y),
                    new PointF(bounds.X, bounds.Y + absoluteDimension + absoluteDimension2)
                };
                PointF[] points2 = new PointF[4]
                {
                    new PointF(bounds.X, bounds.Y + absoluteDimension3),
                    new PointF(bounds.X + absoluteDimension3, bounds.Y),
                    new PointF(bounds.X + absoluteDimension3 + absoluteDimension4, bounds.Y),
                    new PointF(bounds.X, bounds.Y + absoluteDimension3 + absoluteDimension4)
                };
                graphicsPath2.AddPolygon(points);
                graphicsPath2.AddPolygon(points2);
                Brush brush2 = new SolidBrush(Color.FromArgb(148, Color.White));
                g.FillPath(brush2, graphicsPath2);
            }
            else if ((FrameShape == BackFrameShape.Circular || FrameShape == BackFrameShape.AutoShape) && GlassEffect == GlassEffect.Simple)
            {
                float absoluteDimension5 = g.GetAbsoluteDimension(15f);
                bounds.X      += absoluteDimension5;
                bounds.Y      += absoluteDimension5;
                bounds.Width  -= absoluteDimension5 * 2f;
                bounds.Height -= absoluteDimension5 * 2f;
                GraphicsPath circularRangePath  = g.GetCircularRangePath(g.GetRelativeRectangle(bounds), 226f, 30f, 6f, 6f, Placement.Inside);
                GraphicsPath circularRangePath2 = g.GetCircularRangePath(g.GetRelativeRectangle(bounds), 224f, -30f, 6f, 6f, Placement.Inside);
                Brush        brush3             = new SolidBrush(Color.FromArgb(200, Color.White));
                g.FillPath(brush3, circularRangePath);
                g.FillPath(brush3, circularRangePath2);
            }
        }
Example #9
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();
        }
 public void RenderFrame(GaugeGraphics g)
 {
     if (this.Image.Length != 0)
     {
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingImageFrame);
         this.DrawFrameImage(g);
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceImageFrameRenderingComplete);
     }
     else if (this.FrameStyle != 0)
     {
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingFrame);
         this.ResetCachedXamlRenderer();
         if (this.IsCustomXamlFrame())
         {
             this.RenderShadow(g);
             XamlRenderer cachedXamlRenderer = this.GetCachedXamlRenderer(g);
             cachedXamlRenderer.Layers[0].Render(g);
             cachedXamlRenderer.Layers[1].Render(g);
         }
         else
         {
             this.RenderShadow(g);
             Brush        brush         = null;
             GraphicsPath graphicsPath  = null;
             GraphicsPath graphicsPath2 = null;
             GraphicsPath graphicsPath3 = null;
             Brush        brush2        = null;
             Brush        brush3        = null;
             Pen          pen           = null;
             Pen          pen2          = null;
             try
             {
                 graphicsPath  = this.GetFramePath(g, 0f);
                 graphicsPath3 = this.GetFramePath(g, this.FrameWidth);
                 brush         = this.GetBrush(g, graphicsPath3.GetBounds(), this.backHatchStyle, this.BackGradientType, this.BackColor, this.BackGradientEndColor, false, 0f);
                 g.FillPath(brush, graphicsPath3, 0f, false, this.FrameShape == BackFrameShape.Circular);
                 if (this.FrameStyle == BackFrameStyle.Simple)
                 {
                     using (GraphicsPath graphicsPath4 = new GraphicsPath())
                     {
                         graphicsPath4.AddPath(graphicsPath, false);
                         graphicsPath4.AddPath(graphicsPath3, false);
                         graphicsPath4.CloseFigure();
                         brush2 = this.GetBrush(g, graphicsPath4.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameColor, this.FrameGradientEndColor, true, this.frameWidth);
                         pen    = new Pen(brush, 2f);
                         g.DrawPath(pen, graphicsPath3);
                         g.FillPath(brush2, graphicsPath4, 0f, false, this.FrameShape == BackFrameShape.Circular);
                     }
                 }
                 else if (this.FrameStyle == BackFrameStyle.Edged)
                 {
                     float num = (float)(this.FrameWidth * 0.699999988079071);
                     using (GraphicsPath addingPath = this.GetFramePath(g, num))
                     {
                         using (GraphicsPath graphicsPath5 = new GraphicsPath())
                         {
                             using (GraphicsPath graphicsPath6 = new GraphicsPath())
                             {
                                 graphicsPath5.AddPath(graphicsPath, false);
                                 graphicsPath5.AddPath(addingPath, false);
                                 graphicsPath6.AddPath(addingPath, false);
                                 graphicsPath6.AddPath(graphicsPath3, false);
                                 brush2 = this.GetBrush(g, graphicsPath5.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameColor, this.FrameGradientEndColor, true, num);
                                 g.FillPath(brush2, graphicsPath5, 0f, false, this.FrameShape == BackFrameShape.Circular);
                                 brush3 = ((this.FrameGradientType != 0 || this.FrameHatchStyle != 0) ? this.GetBrush(g, graphicsPath6.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameGradientEndColor, this.FrameColor, true, this.frameWidth - num) : this.GetBrush(g, graphicsPath6.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameColor, this.FrameColor, true, this.frameWidth - num));
                                 if (this.FrameWidth > 0.0)
                                 {
                                     pen = new Pen(brush3, 2f);
                                     g.DrawPath(pen, graphicsPath6);
                                 }
                                 g.FillPath(brush3, graphicsPath6, 0f, false, this.FrameShape == BackFrameShape.Circular);
                             }
                         }
                     }
                 }
                 if (this.BorderWidth > 0 && this.BorderStyle != 0)
                 {
                     pen2           = new Pen(this.BorderColor, (float)this.BorderWidth);
                     pen2.DashStyle = g.GetPenStyle(this.BorderStyle);
                     pen2.Alignment = PenAlignment.Center;
                     g.DrawPath(pen2, graphicsPath);
                 }
             }
             finally
             {
                 if (brush != null)
                 {
                     brush.Dispose();
                 }
                 if (graphicsPath != null)
                 {
                     graphicsPath.Dispose();
                 }
                 if (graphicsPath2 != null)
                 {
                     graphicsPath2.Dispose();
                 }
                 if (brush2 != null)
                 {
                     brush2.Dispose();
                 }
                 if (brush3 != null)
                 {
                     brush3.Dispose();
                 }
                 if (pen != null)
                 {
                     pen.Dispose();
                 }
                 if (pen2 != null)
                 {
                     pen2.Dispose();
                 }
             }
         }
         this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceFrameRenderingComplete);
     }
 }