Exemplo n.º 1
0
        public GraphicsPath GetFramePath(GaugeGraphics g, float shrinkBy)
        {
            RectangleF frameRectangle    = this.GetFrameRectangle(g);
            float      absoluteDimension = g.GetAbsoluteDimension(shrinkBy);

            frameRectangle.Inflate((float)(0.0 - absoluteDimension), (float)(0.0 - absoluteDimension));
            if (shrinkBy > 0.0)
            {
                frameRectangle.Inflate(1f, 1f);
            }
            if (this.FrameShape == BackFrameShape.Circular)
            {
                GraphicsPath graphicsPath = new GraphicsPath();
                graphicsPath.AddEllipse(frameRectangle);
                return(graphicsPath);
            }
            if (this.FrameShape == BackFrameShape.AutoShape)
            {
                GraphicsPath graphicsPath2 = new GraphicsPath();
                if (this.Parent is CircularGauge)
                {
                    CircularGauge circularGauge = (CircularGauge)this.Parent;
                    if (circularGauge.Scales.Count == 0)
                    {
                        graphicsPath2.AddEllipse(frameRectangle);
                    }
                    else
                    {
                        this.BuildCircularGaugeAutoFrame(g, graphicsPath2, circularGauge, shrinkBy);
                    }
                }
                else
                {
                    graphicsPath2.AddRectangle(frameRectangle);
                }
                return(graphicsPath2);
            }
            if (this.FrameShape == BackFrameShape.RoundedRectangular)
            {
                float   num   = (!(frameRectangle.Width > frameRectangle.Height)) ? frameRectangle.Width : frameRectangle.Height;
                float   num2  = (float)(num / 8.0);
                float[] array = new float[10];
                for (int i = 0; i < 10; i++)
                {
                    array[i] = num2;
                }
                return(g.CreateRoundedRectPath(frameRectangle, array));
            }
            if (this.FrameShape == BackFrameShape.Rectangular)
            {
                GraphicsPath graphicsPath3 = new GraphicsPath();
                graphicsPath3.AddRectangle(frameRectangle);
                return(graphicsPath3);
            }
            GraphicsPath graphicsPath4 = new GraphicsPath();

            graphicsPath4.FillMode = FillMode.Winding;
            XamlRenderer cachedXamlRenderer = this.GetCachedXamlRenderer(g);

            graphicsPath4.AddPath(cachedXamlRenderer.Layers[0].Paths[0], false);
            return(graphicsPath4);
        }
Exemplo n.º 2
0
 public void RenderGlassEffect(GaugeGraphics g)
 {
     if (this.GlassEffect != 0 && this.FrameStyle != 0)
     {
         if (this.IsCustomXamlFrame())
         {
             XamlRenderer cachedXamlRenderer = this.GetCachedXamlRenderer(g);
             cachedXamlRenderer.Layers[2].Render(g);
         }
         else
         {
             RectangleF bounds;
             using (GraphicsPath graphicsPath = this.GetFramePath(g, (float)(this.FrameWidth - 1.0)))
             {
                 bounds = graphicsPath.GetBounds();
                 using (Brush brush = new LinearGradientBrush(bounds, Color.FromArgb(15, Color.Black), Color.FromArgb(128, Color.Black), LinearGradientMode.ForwardDiagonal))
                 {
                     if (bounds.Height > 0.0 && bounds.Width > 0.0)
                     {
                         g.FillPath(brush, graphicsPath);
                     }
                 }
             }
             if (this.FrameShape == BackFrameShape.Rectangular || this.FrameShape == BackFrameShape.RoundedRectangular)
             {
                 float        width              = 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 (this.FrameShape != 0 && this.FrameShape != BackFrameShape.AutoShape)
                 {
                     return;
                 }
                 if (this.GlassEffect == GlassEffect.Simple)
                 {
                     float absoluteDimension5 = g.GetAbsoluteDimension(15f);
                     bounds.X      += absoluteDimension5;
                     bounds.Y      += absoluteDimension5;
                     bounds.Width  -= (float)(absoluteDimension5 * 2.0);
                     bounds.Height -= (float)(absoluteDimension5 * 2.0);
                     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);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Called to preform a render of the current Markdown.
        /// </summary>
        private void RenderMarkdown()
        {
            // Make sure we have something to parse.
            if (Text == null)
            {
                return;
            }

            // Leave if we don't have our root yet.
            if (_rootElement == null)
            {
                return;
            }

            // Disconnect from OnClick handlers.
            UnhookListeners();

            MarkdownRenderedEventArgs markdownRenderedArgs = new MarkdownRenderedEventArgs(null);

            try
            {
                // Try to parse the markdown.
                MarkdownDocument markdown = new MarkdownDocument();
                markdown.Parse(Text);

                // Now try to display it
                var renderer = new XamlRenderer(markdown, this)
                {
                    Background             = Background,
                    BorderBrush            = BorderBrush,
                    BorderThickness        = BorderThickness,
                    CharacterSpacing       = CharacterSpacing,
                    FontFamily             = FontFamily,
                    FontSize               = FontSize,
                    FontStretch            = FontStretch,
                    FontStyle              = FontStyle,
                    FontWeight             = FontWeight,
                    Foreground             = Foreground,
                    IsTextSelectionEnabled = IsTextSelectionEnabled,
                    Padding                 = Padding,
                    CodeBackground          = CodeBackground,
                    CodeBorderBrush         = CodeBorderBrush,
                    CodeBorderThickness     = CodeBorderThickness,
                    CodeForeground          = CodeForeground,
                    CodeFontFamily          = CodeFontFamily,
                    CodePadding             = CodePadding,
                    CodeMargin              = CodeMargin,
                    Header1FontSize         = Header1FontSize,
                    Header1FontWeight       = Header1FontWeight,
                    Header1Margin           = Header1Margin,
                    Header1Foreground       = Header1Foreground,
                    Header2FontSize         = Header2FontSize,
                    Header2FontWeight       = Header2FontWeight,
                    Header2Margin           = Header2Margin,
                    Header2Foreground       = Header2Foreground,
                    Header3FontSize         = Header3FontSize,
                    Header3FontWeight       = Header3FontWeight,
                    Header3Margin           = Header3Margin,
                    Header3Foreground       = Header3Foreground,
                    Header4FontSize         = Header4FontSize,
                    Header4FontWeight       = Header4FontWeight,
                    Header4Margin           = Header4Margin,
                    Header4Foreground       = Header4Foreground,
                    Header5FontSize         = Header5FontSize,
                    Header5FontWeight       = Header5FontWeight,
                    Header5Margin           = Header5Margin,
                    Header5Foreground       = Header5Foreground,
                    Header6FontSize         = Header6FontSize,
                    Header6FontWeight       = Header6FontWeight,
                    Header6Margin           = Header6Margin,
                    Header6Foreground       = Header6Foreground,
                    HorizontalRuleBrush     = HorizontalRuleBrush,
                    HorizontalRuleMargin    = HorizontalRuleMargin,
                    HorizontalRuleThickness = HorizontalRuleThickness,
                    ListMargin              = ListMargin,
                    ListGutterWidth         = ListGutterWidth,
                    ListBulletSpacing       = ListBulletSpacing,
                    ParagraphMargin         = ParagraphMargin,
                    QuoteBackground         = QuoteBackground,
                    QuoteBorderBrush        = QuoteBorderBrush,
                    QuoteBorderThickness    = QuoteBorderThickness,
                    QuoteForeground         = QuoteForeground,
                    QuoteMargin             = QuoteMargin,
                    QuotePadding            = QuotePadding,
                    TableBorderBrush        = TableBorderBrush,
                    TableBorderThickness    = TableBorderThickness,
                    TableCellPadding        = TableCellPadding,
                    TableMargin             = TableMargin,
                    TextWrapping            = TextWrapping,
                    LinkForeground          = LinkForeground,
                    ImageStretch            = ImageStretch
                };
                _rootElement.Child = renderer.Render();
            }
            catch (Exception ex)
            {
                DebuggingReporter.ReportCriticalError("Error while parsing and rendering: " + ex.Message);
                markdownRenderedArgs = new MarkdownRenderedEventArgs(ex);
            }

            // Indicate that the parse is done.
            MarkdownRendered?.Invoke(this, markdownRenderedArgs);
        }
Exemplo n.º 4
0
        private void PaintCellSeriesSymbol(MapGraphics g, int fontSizeReducedBy, Font legendAutoFont, SizeF singleWCharacterSize)
        {
            Rectangle r = cellPosition;

            if (SymbolSize.Width >= 0)
            {
                int num = (int)((float)SymbolSize.Width * singleWCharacterSize.Width / 100f);
                if (num > cellPosition.Width)
                {
                    num = cellPosition.Width;
                }
                r.Width = num;
            }
            if (SymbolSize.Height >= 0)
            {
                int num2 = (int)((float)SymbolSize.Height * singleWCharacterSize.Height / 100f);
                if (num2 > cellPosition.Height)
                {
                    num2 = cellPosition.Height;
                }
                r.Height = num2;
            }
            if (r.Height <= 0 || r.Width <= 0)
            {
                return;
            }
            r.X = (int)((float)cellPosition.X + (float)cellPosition.Width / 2f - (float)r.Width / 2f);
            r.Y = (int)((float)cellPosition.Y + (float)cellPosition.Height / 2f - (float)r.Height / 2f);
            if (Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.TopLeft)
            {
                r.X = cellPosition.X;
            }
            else if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight)
            {
                r.X = cellPosition.Right - r.Width;
            }
            if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight)
            {
                r.Y = cellPosition.Bottom - r.Height;
            }
            else if (Alignment == ContentAlignment.TopCenter || Alignment == ContentAlignment.TopLeft || Alignment == ContentAlignment.TopRight)
            {
                r.Y = cellPosition.Y;
            }
            g.StartHotRegion(this);
            if (!string.IsNullOrEmpty(legendItem.Image))
            {
                Rectangle empty = Rectangle.Empty;
                Image     image = GetLegend().Common.ImageLoader.LoadImage(legendItem.Image);
                empty.Width  = image.Size.Width;
                empty.Height = image.Size.Height;
                float num3 = 1f;
                if (empty.Height > r.Height)
                {
                    num3 = (float)empty.Height / (float)r.Height;
                }
                if (empty.Width > r.Width)
                {
                    num3 = Math.Max(num3, (float)empty.Width / (float)r.Width);
                }
                empty.Height = (int)((float)empty.Height / num3);
                empty.Width  = (int)((float)empty.Width / num3);
                empty.X      = (int)((float)r.X + (float)r.Width / 2f - (float)empty.Width / 2f);
                empty.Y      = (int)((float)r.Y + (float)r.Height / 2f - (float)empty.Height / 2f);
                ImageAttributes imageAttributes = new ImageAttributes();
                if (legendItem.ImageTranspColor != Color.Empty)
                {
                    imageAttributes.SetColorKey(legendItem.ImageTranspColor, legendItem.ImageTranspColor, ColorAdjustType.Default);
                }
                g.DrawImage(image, empty, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
            }
            else if (legendItem.ItemStyle == LegendItemStyle.Shape)
            {
                g.FillRectangleRel(g.GetRelativeRectangle(r), legendItem.Color, legendItem.HatchStyle, legendItem.Image, legendItem.ImageWrapMode, legendItem.ImageTranspColor, legendItem.ImageAlign, legendItem.GradientType, legendItem.SecondaryColor, legendItem.borderColor, (legendItem.BorderWidth > 2) ? 2 : legendItem.BorderWidth, legendItem.BorderStyle, legendItem.ShadowColor, (legendItem.ShadowOffset > 3) ? 3 : legendItem.ShadowOffset, PenAlignment.Center);
            }
            else if (legendItem.ItemStyle == LegendItemStyle.Path)
            {
                Point location = r.Location;
                location.Y = (int)Math.Round((float)r.Y + (float)r.Height / 2f);
                Point pt   = new Point(r.Right, location.Y);
                int   num4 = (int)Math.Round((float)legendItem.PathWidth / 2f);
                location.X += num4;
                pt.X       -= num4;
                SmoothingMode smoothingMode = g.SmoothingMode;
                if (legendItem.PathWidth < 2 && legendItem.BorderWidth < 2)
                {
                    g.SmoothingMode = SmoothingMode.None;
                }
                using (GraphicsPath graphicsPath = new GraphicsPath())
                {
                    graphicsPath.AddLine(location, pt);
                    int num5 = (legendItem.shadowOffset > 3) ? 3 : legendItem.shadowOffset;
                    if (num5 > 0)
                    {
                        using (Pen pen = Path.GetColorPen(g.GetShadowColor(), legendItem.PathWidth, legendItem.BorderWidth))
                        {
                            if (pen != null)
                            {
                                Matrix matrix = new Matrix();
                                matrix.Translate(num5, num5, MatrixOrder.Append);
                                graphicsPath.Transform(matrix);
                                g.DrawPath(pen, graphicsPath);
                                matrix.Reset();
                                matrix.Translate(-num5, -num5, MatrixOrder.Append);
                                graphicsPath.Transform(matrix);
                            }
                        }
                    }
                    if (legendItem.BorderWidth > 0)
                    {
                        using (Pen pen2 = Path.GetColorPen(legendItem.BorderColor, legendItem.PathWidth, legendItem.BorderWidth))
                        {
                            if (pen2 != null)
                            {
                                g.DrawPath(pen2, graphicsPath);
                            }
                        }
                    }
                    RectangleF bounds = graphicsPath.GetBounds();
                    bounds.Inflate((float)legendItem.PathWidth / 2f, (float)legendItem.PathWidth / 2f);
                    using (Pen pen3 = Path.GetFillPen(g, graphicsPath, bounds, legendItem.PathWidth, legendItem.PathLineStyle, legendItem.Color, legendItem.SecondaryColor, legendItem.GradientType, legendItem.HatchStyle))
                    {
                        if (pen3 != null)
                        {
                            g.DrawPath(pen3, graphicsPath);
                            if (pen3.Brush != null)
                            {
                                pen3.Brush.Dispose();
                            }
                        }
                    }
                }
                g.SmoothingMode = smoothingMode;
            }
            else if (legendItem.ItemStyle == LegendItemStyle.Symbol)
            {
                MarkerStyle markerStyle = legendItem.markerStyle;
                if (markerStyle != 0 || !string.IsNullOrEmpty(legendItem.markerImage))
                {
                    int num6 = Math.Min(r.Width, r.Height);
                    int num7 = (legendItem.MarkerBorderWidth > 3) ? 3 : legendItem.MarkerBorderWidth;
                    if (num7 > 0)
                    {
                        num6 -= num7;
                        if (num6 < 1)
                        {
                            num6 = 1;
                        }
                    }
                    Point point = default(Point);
                    point.X = (int)((float)r.X + (float)r.Width / 2f);
                    point.Y = (int)((float)r.Y + (float)r.Height / 2f);
                    Rectangle empty2 = Rectangle.Empty;
                    if (!string.IsNullOrEmpty(legendItem.markerImage))
                    {
                        Image image2 = GetLegend().Common.ImageLoader.LoadImage(legendItem.markerImage);
                        empty2.Width  = image2.Size.Width;
                        empty2.Height = image2.Size.Height;
                        float num8 = 1f;
                        if (empty2.Height > r.Height)
                        {
                            num8 = (float)empty2.Height / (float)r.Height;
                        }
                        if (empty2.Width > r.Width)
                        {
                            num8 = Math.Max(num8, (float)empty2.Width / (float)r.Width);
                        }
                        empty2.Height = (int)((float)empty2.Height / num8);
                        empty2.Width  = (int)((float)empty2.Width / num8);
                    }
                    Color color = (legendItem.markerColor == Color.Empty) ? legendItem.Color : legendItem.markerColor;
                    if (Symbol.IsXamlMarker(markerStyle))
                    {
                        RectangleF rect = r;
                        if (rect.Width > rect.Height)
                        {
                            rect.X    += (rect.Width - rect.Height) / 2f;
                            rect.Width = rect.Height;
                        }
                        else if (rect.Height > rect.Width)
                        {
                            rect.Y     += (rect.Height - rect.Width) / 2f;
                            rect.Height = rect.Width;
                        }
                        using (XamlRenderer xamlRenderer = Symbol.CreateXamlRenderer(markerStyle, color, rect))
                        {
                            XamlLayer[] layers = xamlRenderer.Layers;
                            for (int i = 0; i < layers.Length; i++)
                            {
                                layers[i].Render(g);
                            }
                        }
                    }
                    else
                    {
                        PointF absolute = new PointF(point.X, point.Y);
                        if ((double)(num6 % 2) != 0.0)
                        {
                            absolute.X -= 0.5f;
                            absolute.Y -= 0.5f;
                        }
                        g.DrawMarkerRel(g.GetRelativePoint(absolute), markerStyle, num6, color, legendItem.MarkerGradientType, legendItem.MarkerHatchStyle, legendItem.MarkerSecondaryColor, legendItem.MarkerBorderStyle, (legendItem.markerBorderColor == Color.Empty) ? legendItem.borderColor : legendItem.markerBorderColor, num7, legendItem.markerImage, legendItem.markerImageTranspColor, (legendItem.shadowOffset > 3) ? 3 : legendItem.shadowOffset, legendItem.shadowColor, empty2);
                    }
                }
            }
            g.EndHotRegion();
        }
Exemplo n.º 5
0
 protected override void Write([NotNull] XamlRenderer renderer, [NotNull] HtmlEntityInline obj)
 {
     renderer.WriteEscape(obj.Transcoded);
 }