예제 #1
0
        public ViewRendering GetViewRendering(Control control)
        {
            string str2;
            DesignerRegionCollection regions;
            CatalogPart part = control as CatalogPart;

            if (part == null)
            {
                return(new ViewRendering(ControlDesigner.CreateErrorDesignTimeHtml(System.Design.SR.GetString("CatalogZoneDesigner_OnlyCatalogParts"), null, control), new DesignerRegionCollection()));
            }
            try
            {
                IDictionary data = new HybridDictionary(1);
                data["Zone"] = base.Zone;
                ((IControlDesignerAccessor)part).SetDesignModeState(data);
                this._partViewRendering = ControlDesigner.GetViewRendering(part);
                regions = this._partViewRendering.Regions;
                StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
                this.RenderCatalogPart(new DesignTimeHtmlTextWriter(writer), (CatalogPart)PartDesigner.GetViewControl(part));
                str2 = writer.ToString();
            }
            catch (Exception exception)
            {
                str2    = ControlDesigner.CreateErrorDesignTimeHtml(System.Design.SR.GetString("ControlDesigner_UnhandledException"), exception, control);
                regions = new DesignerRegionCollection();
            }
            return(new ViewRendering(str2, regions));
        }
        public ViewRendering GetViewRendering(Control control)
        {
            string str;
            DesignerRegionCollection regions;

            try
            {
                this._partViewRendering = ControlDesigner.GetViewRendering(control);
                regions = this._partViewRendering.Regions;
                WebPart part = control as WebPart;
                if (part == null)
                {
                    part = new DesignerGenericWebPart(PartDesigner.GetViewControl(control));
                }
                StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
                this.RenderWebPart(new DesignTimeHtmlTextWriter(writer), (WebPart)PartDesigner.GetViewControl(part));
                str = writer.ToString();
            }
            catch (Exception exception)
            {
                str     = ControlDesigner.CreateErrorDesignTimeHtml(System.Design.SR.GetString("ControlDesigner_UnhandledException"), exception, control);
                regions = new DesignerRegionCollection();
            }
            StringWriter             writer2 = new StringWriter(CultureInfo.InvariantCulture);
            DesignTimeHtmlTextWriter writer3 = new DesignTimeHtmlTextWriter(writer2);
            bool flag = base.Zone.LayoutOrientation == Orientation.Horizontal;

            if (flag)
            {
                writer3.AddStyleAttribute("display", "inline-block");
                writer3.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");
                writer3.RenderBeginTag(HtmlTextWriterTag.Span);
            }
            writer3.Write(str);
            if (flag)
            {
                writer3.RenderEndTag();
            }
            return(new ViewRendering(writer2.ToString(), regions));
        }