Exemplo n.º 1
0
        public void RenderReportItem(RPLElement reportItem, RPLItemMeasurement measurement, StyleContext styleContext, ref int borderContext, bool renderId, bool treatAsTopLevel)
        {
            RPLImageProps    rPLImageProps    = (RPLImageProps)reportItem.ElementProps;
            RPLImagePropsDef rPLImagePropsDef = (RPLImagePropsDef)rPLImageProps.Definition;

            RPLFormat.Sizings sizing = rPLImagePropsDef.Sizing;
            RPLImageData      image  = rPLImageProps.Image;

            this.html5Renderer.GetInnerContainerHeightSubtractBorders(measurement, rPLImageProps.Style);
            float  innerContainerWidthSubtractBorders = this.html5Renderer.GetInnerContainerWidthSubtractBorders(measurement, rPLImageProps.Style);
            string text      = this.html5Renderer.GetImageUrl(true, image);
            string ariaLabel = null;
            string role      = null;
            string tooltip   = this.html5Renderer.GetTooltip(rPLImageProps);

            if (treatAsTopLevel)
            {
                ariaLabel = (string.IsNullOrEmpty(tooltip) ? RenderRes.AccessibleImageLabel : RenderRes.AccessibleImageNavigationGroupLabel(tooltip));
                role      = HTMLElements.m_navigationRole;
            }
            string altText = string.IsNullOrEmpty(tooltip) ? RenderRes.AccessibleImageLabel : tooltip;
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            if (this.html5Renderer.m_elementExtender.ShouldApplyToElement(treatAsTopLevel))
            {
                dictionary.Add(HTMLElements.m_reportItemDataName, this.html5Renderer.m_elementExtender.ApplyToElement());
                dictionary.Add(HTMLElements.m_reportItemCustomAttrStr, this.html5Renderer.GetReportItemPath(rPLImagePropsDef.Name));
            }
            bool flag = rPLImageProps.ActionImageMapAreas != null && rPLImageProps.ActionImageMapAreas.Length > 0;

            if (flag)
            {
                string s = HTMLElements.m_hashTag + this.html5Renderer.m_deviceInfo.HtmlPrefixId + HTMLElements.m_mapPrefixString + rPLImageProps.UniqueName;
                dictionary.Add(HTMLElements.m_useMapName, HttpUtility.HtmlAttributeEncode(s));
            }
            if (this.html5Renderer.HasAction(rPLImageProps.ActionInfo))
            {
                this.RenderElementHyperlink(rPLImageProps.Style, rPLImageProps.ActionInfo.Actions[0]);
            }
            if (!styleContext.InTablix)
            {
                if (sizing == RPLFormat.Sizings.AutoSize)
                {
                    styleContext.RenderMeasurements = false;
                }
                this.html5Renderer.WriteStream(HTMLElements.m_openDiv);
                this.html5Renderer.RenderReportItemStyle(reportItem, (RPLElementProps)rPLImageProps, (RPLElementPropsDef)rPLImagePropsDef, measurement, styleContext, ref borderContext, rPLImagePropsDef.ID);
                this.html5Renderer.WriteStream(HTMLElements.m_closeBracket);
            }
            if (string.IsNullOrEmpty(text))
            {
                text = "data:image/gif;base64," + Convert.ToBase64String(HTMLRendererResources.GetBytes("Blank.gif"));
            }
            HtmlElement htmlElement;

            switch (sizing)
            {
            case RPLFormat.Sizings.FitProportional:
                htmlElement = new FitProportionalImageElement(text, innerContainerWidthSubtractBorders, role, altText, ariaLabel, dictionary);
                break;

            case RPLFormat.Sizings.Fit:
                htmlElement = new FitImageElement(text, role, altText, ariaLabel, dictionary);
                break;

            case RPLFormat.Sizings.Clip:
                htmlElement = new ClipImageElement(text, role, altText, ariaLabel, dictionary);
                break;

            default:
                htmlElement = new OriginalSizeImageElement(text, role, altText, ariaLabel, dictionary);
                break;
            }
            htmlElement.Render(new Html5OutputStream(this.html5Renderer));
            if (!styleContext.InTablix)
            {
                this.html5Renderer.WriteStream(HTMLElements.m_closeDiv);
            }
            if (this.html5Renderer.HasAction(rPLImageProps.ActionInfo))
            {
                this.html5Renderer.WriteStream(HTMLElements.m_closeA);
            }
            if (flag)
            {
                this.html5Renderer.RenderImageMapAreas(rPLImageProps.ActionImageMapAreas, (double)measurement.Width, (double)measurement.Height, rPLImageProps.UniqueName, 0, 0);
            }
        }
        public void RenderReportItem(RPLElement dynamicImage, RPLItemMeasurement measurement, StyleContext styleContext, ref int borderContext, bool renderId, bool treatAsTopLevel)
        {
            RPLElementProps      elementProps         = dynamicImage.ElementProps;
            RPLElementPropsDef   definition           = elementProps.Definition;
            RPLDynamicImageProps rPLDynamicImageProps = (RPLDynamicImageProps)elementProps;
            string tooltip = this.html5Renderer.GetTooltip(rPLDynamicImageProps);

            if (dynamicImage != null)
            {
                bool      flag      = rPLDynamicImageProps.ActionImageMapAreas != null && rPLDynamicImageProps.ActionImageMapAreas.Length > 0;
                Rectangle rectangle = this.RenderDynamicImage(measurement, rPLDynamicImageProps);
                int       xOffset   = 0;
                int       yOffset   = 0;
                bool      flag2     = !rectangle.IsEmpty;
                bool      flag3     = !this.html5Renderer.m_deviceInfo.IsBrowserSafari || this.html5Renderer.m_deviceInfo.AllowScript || !styleContext.InTablix;
                if (flag3)
                {
                    this.html5Renderer.WriteStream(HTMLElements.m_openDiv);
                    if (flag2 && this.html5Renderer.m_elementExtender.ShouldApplyToElement(treatAsTopLevel))
                    {
                        this.WriteReportItemDataName();
                    }
                    this.html5Renderer.WriteAccesibilityTags(RenderRes.AccessibleChartLabel, rPLDynamicImageProps, treatAsTopLevel);
                    if (treatAsTopLevel)
                    {
                        string accessibleAriaName = string.IsNullOrEmpty(tooltip) ? RenderRes.AccessibleChartLabel : RenderRes.AccessibleChartNavigationGroupLabel(tooltip);
                        this.html5Renderer.WriteAriaAccessibleTags(accessibleAriaName);
                    }
                }
                bool flag4 = this.html5Renderer.m_deviceInfo.DataVisualizationFitSizing == DataVisualizationFitSizing.Exact && styleContext.InTablix;
                if (flag2)
                {
                    RPLFormat.Sizings sizing = (RPLFormat.Sizings)(flag4 ? 1 : 0);
                    this.html5Renderer.WriteOuterConsolidation(rectangle, sizing, rPLDynamicImageProps.UniqueName);
                    this.html5Renderer.RenderReportItemStyle(dynamicImage, (RPLItemMeasurement)null, ref borderContext);
                    xOffset = rectangle.Left;
                    yOffset = rectangle.Top;
                }
                else if (flag4 && this.html5Renderer.m_deviceInfo.AllowScript)
                {
                    if (this.html5Renderer.m_imgFitDivIdsStream == null)
                    {
                        this.html5Renderer.CreateImgFitDivImageIdsStream();
                    }
                    this.html5Renderer.WriteIdToSecondaryStream(this.html5Renderer.m_imgFitDivIdsStream, rPLDynamicImageProps.UniqueName + "_ifd");
                    this.html5Renderer.RenderReportItemId(rPLDynamicImageProps.UniqueName + "_ifd");
                }
                if (flag3)
                {
                    this.html5Renderer.WriteStream(HTMLElements.m_closeBracket);
                }
                this.html5Renderer.WriteStream(HTMLElements.m_img);
                if (this.html5Renderer.m_elementExtender.ShouldApplyToElement(treatAsTopLevel))
                {
                    if (!flag2)
                    {
                        this.WriteReportItemDataName();
                    }
                    RPLItemPropsDef rPLItemPropsDef = (RPLItemPropsDef)definition;
                    this.html5Renderer.WriteAttrEncoded(HTMLElements.m_reportItemCustomAttr, this.html5Renderer.GetReportItemPath(rPLItemPropsDef.Name));
                }
                if (this.html5Renderer.m_browserIE)
                {
                    this.html5Renderer.WriteStream(HTMLElements.m_imgOnError);
                }
                if (renderId)
                {
                    this.html5Renderer.RenderReportItemId(rPLDynamicImageProps.UniqueName);
                }
                this.html5Renderer.WriteStream(HTMLElements.m_zeroBorder);
                bool flag5 = dynamicImage is RPLChart;
                if (flag)
                {
                    this.html5Renderer.WriteAttrEncoded(HTMLElements.m_useMap, "#" + this.html5Renderer.m_deviceInfo.HtmlPrefixId + HTMLElements.m_mapPrefixString + rPLDynamicImageProps.UniqueName);
                    if (flag4)
                    {
                        this.html5Renderer.OpenStyle();
                        if (this.html5Renderer.m_useInlineStyle && !flag2)
                        {
                            this.html5Renderer.WriteStream(HTMLElements.m_styleHeight);
                            this.html5Renderer.WriteStream(HTMLElements.m_percent);
                            this.html5Renderer.WriteStream(HTMLElements.m_semiColon);
                            this.html5Renderer.WriteStream(HTMLElements.m_styleWidth);
                            this.html5Renderer.WriteStream(HTMLElements.m_percent);
                            this.html5Renderer.WriteStream(HTMLElements.m_semiColon);
                            flag5 = false;
                        }
                        this.html5Renderer.WriteStream("border-style:none;");
                    }
                }
                else if (flag4 && this.html5Renderer.m_useInlineStyle && !flag2)
                {
                    this.html5Renderer.PercentSizes();
                    flag5 = false;
                }
                StyleContext styleContext2 = new StyleContext();
                if (!flag4 && (this.html5Renderer.m_deviceInfo.IsBrowserIE7 || this.html5Renderer.m_deviceInfo.IsBrowserIE6))
                {
                    styleContext2.RenderMeasurements    = false;
                    styleContext2.RenderMinMeasurements = false;
                }
                if (!flag2)
                {
                    if (flag4)
                    {
                        this.html5Renderer.RenderReportItemStyle(dynamicImage, (RPLItemMeasurement)null, ref borderContext, styleContext2);
                    }
                    else if (flag5)
                    {
                        RPLElementProps elementProps2 = dynamicImage.ElementProps;
                        StyleContext    styleContext3 = new StyleContext();
                        styleContext3.RenderMeasurements = false;
                        this.html5Renderer.OpenStyle();
                        this.html5Renderer.RenderMeasurementStyle(measurement.Height, measurement.Width);
                        this.html5Renderer.RenderReportItemStyle(dynamicImage, elementProps2, definition, measurement, styleContext3, ref borderContext, definition.ID);
                    }
                    else
                    {
                        this.html5Renderer.RenderReportItemStyle(dynamicImage, measurement, ref borderContext, styleContext2);
                    }
                }
                else
                {
                    this.html5Renderer.WriteClippedDiv(rectangle);
                }
                tooltip = (string.IsNullOrEmpty(tooltip) ? RenderRes.AccessibleChartLabel : tooltip);
                this.html5Renderer.WriteToolTipAttribute(tooltip);
                this.html5Renderer.WriteStream(HTMLElements.m_src);
                this.html5Renderer.RenderDynamicImageSrc(rPLDynamicImageProps);
                this.html5Renderer.WriteStreamCR(HTMLElements.m_closeTag);
                if (flag)
                {
                    this.html5Renderer.RenderImageMapAreas(rPLDynamicImageProps.ActionImageMapAreas, (double)measurement.Width, (double)measurement.Height, rPLDynamicImageProps.UniqueName, xOffset, yOffset);
                }
                if (flag3)
                {
                    this.html5Renderer.WriteStream(HTMLElements.m_closeDiv);
                }
            }
        }