예제 #1
0
        internal GraphicsPath GetPointerPath(GaugeGraphics g)
        {
            if (!Visible)
            {
                return(null);
            }
            GraphicsPath graphicsPath = new GraphicsPath();
            LinearScale  scale        = GetScale();

            scale.GetPositionFromValue(scale.GetValueLimit(base.Position));
            if (Type == LinearPointerType.Marker || Image != string.Empty)
            {
                MarkerStyleAttrib markerStyleAttrib = GetMarkerStyleAttrib(g);
                if (markerStyleAttrib.path != null)
                {
                    graphicsPath.AddPath(markerStyleAttrib.path, connect: false);
                }
            }
            else if (Type == LinearPointerType.Bar)
            {
                BarStyleAttrib barStyleAttrib = GetBarStyleAttrib(g);
                if (barStyleAttrib.primaryPath == null)
                {
                    graphicsPath.Dispose();
                    return(null);
                }
                if (barStyleAttrib.primaryPath != null)
                {
                    graphicsPath.AddPath(barStyleAttrib.primaryPath, connect: false);
                }
            }
            else if (Type == LinearPointerType.Thermometer)
            {
                BarStyleAttrib thermometerStyleAttrib = GetThermometerStyleAttrib(g);
                if (thermometerStyleAttrib.primaryPath == null)
                {
                    graphicsPath.Dispose();
                    return(null);
                }
                if (thermometerStyleAttrib.totalPath != null)
                {
                    graphicsPath.AddPath(thermometerStyleAttrib.primaryPath, connect: false);
                }
            }
            return(graphicsPath);
        }
예제 #2
0
        internal MarkerStyleAttrib GetMarkerStyleAttrib(GaugeGraphics g)
        {
            MarkerStyleAttrib markerStyleAttrib  = new MarkerStyleAttrib();
            float             absoluteDimension  = g.GetAbsoluteDimension(MarkerLength);
            float             absoluteDimension2 = g.GetAbsoluteDimension(Width);

            markerStyleAttrib.path = g.CreateMarker(new PointF(0f, 0f), absoluteDimension2, absoluteDimension, MarkerStyle);
            float num = 0f;

            if (Placement == Placement.Cross || Placement == Placement.Inside)
            {
                num += 180f;
            }
            if (GetGauge().GetOrientation() == GaugeOrientation.Vertical)
            {
                num += 270f;
            }
            if (num > 0f)
            {
                using (Matrix matrix = new Matrix())
                {
                    matrix.Rotate(num);
                    markerStyleAttrib.path.Transform(matrix);
                }
            }
            float       num2              = CalculateMarkerDistance();
            LinearScale scale             = GetScale();
            float       positionFromValue = scale.GetPositionFromValue(scale.GetValueLimit(base.Position));
            PointF      pointF            = Point.Empty;

            pointF = ((GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num2, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num2)));
            markerStyleAttrib.brush = g.GetMarkerBrush(markerStyleAttrib.path, MarkerStyle, pointF, 0f, FillColor, FillGradientType, FillGradientEndColor, FillHatchStyle);
            using (Matrix matrix2 = new Matrix())
            {
                matrix2.Translate(pointF.X, pointF.Y, MatrixOrder.Append);
                markerStyleAttrib.path.Transform(matrix2);
                return(markerStyleAttrib);
            }
        }
예제 #3
0
        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));
        }