protected void RegisterDynamicImage(ref Stream dynamicImageStream, ref string streamName, string extension, string mimeType, PageContext pageContext, out System.Drawing.Rectangle offsets)
 {
     offsets = System.Drawing.Rectangle.Empty;
     if (dynamicImageStream != null && dynamicImageStream.Length != 0)
     {
         if (pageContext.ImageConsolidation != null)
         {
             ImageConsolidation imageConsolidation = pageContext.ImageConsolidation;
             offsets = imageConsolidation.AppendImage(dynamicImageStream);
             if (offsets != System.Drawing.Rectangle.Empty)
             {
                 dynamicImageStream = null;
                 streamName         = imageConsolidation.GetStreamName();
             }
         }
         else if (!pageContext.RegisteredStreamNames.Contains(streamName))
         {
             pageContext.RegisteredStreamNames.Add(streamName, null);
             Stream stream = pageContext.CreateAndRegisterStream(streamName, extension, null, mimeType, false, StreamOper.CreateAndRegister);
             if (stream != null)
             {
                 dynamicImageStream.Position = 0L;
                 int    num   = (int)dynamicImageStream.Length;
                 byte[] array = new byte[4096];
                 while (num > 0)
                 {
                     int num2 = dynamicImageStream.Read(array, 0, Math.Min(array.Length, num));
                     stream.Write(array, 0, num2);
                     num -= num2;
                 }
                 dynamicImageStream = null;
             }
         }
     }
 }
        public bool RegisterItem(PageItem pageItem, PageContext pageContext)
        {
            if (!this.m_itemFound && pageItem != null)
            {
                switch (this.m_eventType)
                {
                case EventType.Collect:
                {
                    ReportItemInstance instance2 = pageItem.Source.Instance;
                    if (pageContext.Labels != null)
                    {
                        pageContext.Labels.WriteDocMapLabel(instance2);
                    }
                    if (pageContext.Bookmarks != null)
                    {
                        pageContext.Bookmarks.WriteBookmark(instance2);
                    }
                    if (pageContext.PageBookmarks != null)
                    {
                        pageContext.RegisterPageBookmark(instance2);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.BookmarkNavigationEvent:
                {
                    ReportItemInstance instance = pageItem.Source.Instance;
                    if (instance.Bookmark != null && SPBProcessing.CompareWithOrdinalComparison(this.m_bookmarkId, instance.Bookmark, false) == 0)
                    {
                        this.m_itemFound = true;
                        this.m_itemInfo  = instance.UniqueName;
                        return(false);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.DrillthroughEvent:
                {
                    ReportItemInstance instance5       = pageItem.Source.Instance;
                    TextBoxInstance    textBoxInstance = instance5 as TextBoxInstance;
                    if (textBoxInstance != null)
                    {
                        AspNetCore.ReportingServices.OnDemandReportRendering.TextBox textBox = (AspNetCore.ReportingServices.OnDemandReportRendering.TextBox)pageItem.Source;
                        if (!this.HasMatchingDrillthrough(textBox.ActionInfo))
                        {
                            foreach (ParagraphInstance paragraphInstance in textBoxInstance.ParagraphInstances)
                            {
                                foreach (TextRunInstance textRunInstance in paragraphInstance.TextRunInstances)
                                {
                                    AspNetCore.ReportingServices.OnDemandReportRendering.TextRun definition = textRunInstance.Definition;
                                    if (this.HasMatchingDrillthrough(definition.ActionInfo))
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ImageInstance imageInstance2 = instance5 as ImageInstance;
                        if (imageInstance2 != null)
                        {
                            if (!this.HasMatchingDrillthrough(imageInstance2.ActionInfoWithDynamicImageMapAreas))
                            {
                                AspNetCore.ReportingServices.OnDemandReportRendering.Image image = (AspNetCore.ReportingServices.OnDemandReportRendering.Image)pageItem.Source;
                                this.HasMatchingDrillthrough(image.ActionInfo);
                            }
                        }
                        else
                        {
                            IDynamicImageInstance dynamicImageInstance = instance5 as IDynamicImageInstance;
                            if (dynamicImageInstance != null)
                            {
                                ActionInfoWithDynamicImageMapCollection imageMaps = default(ActionInfoWithDynamicImageMapCollection);
                                using (dynamicImageInstance.GetImage(DynamicImageInstance.ImageType.PNG, out imageMaps))
                                {
                                }
                                this.HasMatchingDrillthrough(imageMaps);
                            }
                        }
                    }
                    if (this.m_itemFound)
                    {
                        return(false);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.DocumentMapNavigationEvent:
                {
                    ReportItemInstance instance3 = pageItem.Source.Instance;
                    if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, instance3.UniqueName, true) == 0)
                    {
                        this.m_itemFound = true;
                        return(false);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.GetDocumentMap:
                {
                    ReportItemInstance instance4 = pageItem.Source.Instance;
                    if (pageContext.Labels != null)
                    {
                        pageContext.Labels.WriteDocMapLabel(instance4);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.FindChart:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source2 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source2.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            ChartInstance chartInstance2 = source2.Instance as ChartInstance;
                            if (chartInstance2 != null)
                            {
                                this.WriteDynamicImageStream(chartInstance2.GetImage());
                            }
                        }
                    }
                    break;

                case EventType.FindGaugePanel:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source3 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source3.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            GaugePanelInstance gaugePanelInstance2 = source3.Instance as GaugePanelInstance;
                            if (gaugePanelInstance2 != null)
                            {
                                this.WriteDynamicImageStream(gaugePanelInstance2.GetImage());
                            }
                        }
                    }
                    break;

                case EventType.FindMap:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source5 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source5.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            MapInstance mapInstance2 = source5.Instance as MapInstance;
                            if (mapInstance2 != null)
                            {
                                this.WriteDynamicImageStream(mapInstance2.GetImage());
                            }
                        }
                    }
                    break;

                case EventType.FindImage:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source4 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source4.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            ImageInstance imageInstance = source4.Instance as ImageInstance;
                            if (imageInstance != null)
                            {
                                Stream stream2   = this.m_createAndRegisterStream(this.m_streamName, string.Empty, null, imageInstance.MIMEType, false, StreamOper.CreateAndRegister);
                                byte[] imageData = imageInstance.ImageData;
                                if (stream2 != null && imageData != null && imageData.Length != 0)
                                {
                                    stream2.Write(imageData, 0, imageData.Length);
                                }
                            }
                        }
                    }
                    break;

                case EventType.ImageConsolidation:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem         source             = pageItem.Source;
                        GaugePanelInstance gaugePanelInstance = source.Instance as GaugePanelInstance;
                        Stream             stream             = null;
                        if (gaugePanelInstance != null)
                        {
                            stream = gaugePanelInstance.GetImage();
                        }
                        else
                        {
                            ChartInstance chartInstance = source.Instance as ChartInstance;
                            if (chartInstance != null)
                            {
                                stream = chartInstance.GetImage();
                            }
                            else
                            {
                                MapInstance mapInstance = source.Instance as MapInstance;
                                if (mapInstance != null)
                                {
                                    stream = mapInstance.GetImage();
                                }
                            }
                        }
                        if (stream != null)
                        {
                            ImageConsolidation imageConsolidation = pageContext.ImageConsolidation;
                            imageConsolidation.AppendImage(stream);
                            if (imageConsolidation.CurrentOffset >= imageConsolidation.IgnoreOffsetTill + 1 && imageConsolidation.ImageInfos.Count > 0)
                            {
                                this.m_itemFound = true;
                            }
                        }
                    }
                    break;

                default:
                    this.FindTextBox(pageItem as TextBox, pageContext);
                    break;
                }
                return(true);
            }
            return(false);
        }