protected virtual Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) { throw new ArgumentOutOfRangeException("chromeType"); } if ((chromeType == PartChromeType.BorderOnly) || (chromeType == PartChromeType.TitleAndBorder)) { return this.Zone.PartChromeStyle; } if (this._chromeStyleNoBorder == null) { Style style = new Style(); style.CopyFrom(this.Zone.PartChromeStyle); if (style.BorderStyle != BorderStyle.None) { style.BorderStyle = BorderStyle.None; } if (style.BorderWidth != Unit.Empty) { style.BorderWidth = Unit.Empty; } if (style.BorderColor != Color.Empty) { style.BorderColor = Color.Empty; } this._chromeStyleNoBorder = style; } return this._chromeStyleNoBorder; }
// Events ///////////////////////////////////////////////////////////////// public override void RenderEditorPart(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) throw new ArgumentNullException("editorPart"); RenderEditorPartInternal(writer, editorPart); }
public virtual void RenderEditorPart(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } PartChromeType effectiveChromeType = this.Zone.GetEffectiveChromeType(editorPart); Style style = this.CreateEditorPartChromeStyle(editorPart, effectiveChromeType); if (!style.IsEmpty) { style.AddAttributesToRender(writer, this.Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); switch (effectiveChromeType) { case PartChromeType.TitleAndBorder: case PartChromeType.TitleOnly: this.RenderTitle(writer, editorPart); break; } if (editorPart.ChromeState != PartChromeState.Minimized) { Style partStyle = this.Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, this.Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Div); this.RenderPartContents(writer, editorPart); writer.RenderEndTag(); } writer.RenderEndTag(); }
private void RenderTitle(HtmlTextWriter writer, EditorPart editorPart) { string displayTitle = editorPart.DisplayTitle; if (!string.IsNullOrEmpty(displayTitle)) { TableItemStyle partTitleStyle = this.Zone.PartTitleStyle; if (this._titleTextStyle == null) { Style style2 = new Style(); style2.CopyFrom(partTitleStyle); this._titleTextStyle = style2; } if (!this._titleTextStyle.IsEmpty) { this._titleTextStyle.AddAttributesToRender(writer, this.Zone); } string description = editorPart.Description; if (!string.IsNullOrEmpty(description)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, description); } string accessKey = editorPart.AccessKey; if (!string.IsNullOrEmpty(accessKey)) { writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, accessKey); } writer.RenderBeginTag(HtmlTextWriterTag.Legend); writer.Write(displayTitle); writer.RenderEndTag(); } }
protected virtual Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) { throw new ArgumentOutOfRangeException("chromeType"); } if ((chromeType == PartChromeType.BorderOnly) || (chromeType == PartChromeType.TitleAndBorder)) { return(this.Zone.PartChromeStyle); } if (this._chromeStyleNoBorder == null) { Style style = new Style(); style.CopyFrom(this.Zone.PartChromeStyle); if (style.BorderStyle != BorderStyle.None) { style.BorderStyle = BorderStyle.None; } if (style.BorderWidth != Unit.Empty) { style.BorderWidth = Unit.Empty; } if (style.BorderColor != Color.Empty) { style.BorderColor = Color.Empty; } this._chromeStyleNoBorder = style; } return(this._chromeStyleNoBorder); }
protected override EditorPartCollection CreateEditorParts() { EditorPartCollection parts = new EditorPartCollection(); if (this._zoneTemplate != null) { Control container = new NonParentingControl(); this._zoneTemplate.InstantiateIn(container); if (!container.HasControls()) { return(parts); } foreach (Control control2 in container.Controls) { EditorPart part = control2 as EditorPart; if (part != null) { parts.Add(part); } else { LiteralControl control3 = control2 as LiteralControl; if (((control3 == null) || (control3.Text.Trim().Length != 0)) && !base.DesignMode) { throw new InvalidOperationException(System.Web.SR.GetString("EditorZone_OnlyEditorParts", new object[] { this.ID })); } } } } return(parts); }
// Internals ////////////////////////////////////////////////////////////// private void RenderEditorPartInternal(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) throw new ArgumentNullException("editorPart"); var editorName = editorPart.GetType().Name; switch(editorName) { case "PropertyGridEditorPart": case "BehaviorEditorPart": case "AppearanceEditorPart": case "LayoutEditorPart": break; case "PropertyEditorPart" : var chromeType = this.Zone.GetEffectiveChromeType(editorPart); var style = this.CreateEditorPartChromeStyle(editorPart, chromeType); if (!style.IsEmpty) style.AddAttributesToRender(writer, this.Zone); //if ((chromeType == PartChromeType.TitleAndBorder) || (chromeType == PartChromeType.TitleOnly)) // this.RenderTitle(writer, editorPart); if (editorPart.ChromeState != PartChromeState.Minimized) RenderPartContentsInternal(writer, editorPart); break; default: // // render custom editorparts // this.RenderPartContents(writer, editorPart); break; } }
private void RenderPartContentsInternal(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) throw new ArgumentNullException("editorPart"); Style style2 = this.Zone.PartStyle; var editorName = editorPart.GetType().Name; if (!style2.IsEmpty) style2.AddAttributesToRender(writer, this.Zone); AddAttributes(writer, editorPart); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (!editorName.Equals("PropertyEditorPart")) { PropertyFieldPanel.RenderBeginTagInternal(writer, editorPart.Title, editorPart.ID); PropertyFieldPanel.RenderContentsStart(writer); } this.RenderPartContents(writer, editorPart); if (!editorName.Equals("PropertyEditorPart")) { PropertyFieldPanel.RenderContentsEnd(writer); PropertyFieldPanel.RenderEndTagInternal(writer); } writer.RenderEndTag(); this.EditorZone.EditorPartsAdded = true; }
public virtual void RenderEditorPart(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } PartChromeType chromeType = Zone.GetEffectiveChromeType(editorPart); Style partChromeStyle = CreateEditorPartChromeStyle(editorPart, chromeType); // Apply ChromeStyle to the Fieldset if (!partChromeStyle.IsEmpty) { partChromeStyle.AddAttributesToRender(writer, Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); // Use ChromeType to determine whether to render the legend if (chromeType == PartChromeType.TitleAndBorder || chromeType == PartChromeType.TitleOnly) { RenderTitle(writer, editorPart); } if (editorPart.ChromeState != PartChromeState.Minimized) { // Apply PartStyle to a <div> around the part rendering Style partStyle = Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, Zone); } // We want to have 5 pixels of spacing aroung the EditorPart contents. There are // 3 ways to accomplish this: // 1. <fieldset style="padding:5px"> - This is bad because it adds 5px of space above // the legend. It also makes the fieldset too wide. // 2. <fieldset><div style="padding:5px"> - This is bad because the PartStyle-BackColor // will now span the whole width of the legend. For consistency with WebPartChrome, // we want the PartChromeStyle-BackColor to show in the 5px of space around the contents. // 3. <fieldset><div style="margin:5px"> - This is the best option. // // For now, I don't think we should render a margin here. People writing custom // EditorParts can add a margin to their contents if they want it. This is not the // same as the WebPartChrome case, since for WebParts we allow people to use ServerControls, // that will likely not have a margin. (VSWhidbey 324397) // writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "5px"); writer.RenderBeginTag(HtmlTextWriterTag.Div); RenderPartContents(writer, editorPart); writer.RenderEndTag(); // Div } writer.RenderEndTag(); // Fieldset }
protected virtual void RenderPartContents(HtmlTextWriter writer, EditorPart editorPart) { string accessKey = editorPart.AccessKey; if (!string.IsNullOrEmpty(accessKey)) { editorPart.AccessKey = string.Empty; } editorPart.RenderControl(writer); if (!string.IsNullOrEmpty(accessKey)) { editorPart.AccessKey = accessKey; } }
protected virtual void RenderPartContents(HtmlTextWriter writer, EditorPart editorPart) { // The AccessKey is rendered by the chrome on the <legend> tag, so we don't want // the EditorPart to render it on its own tags. string accessKey = editorPart.AccessKey; if (!String.IsNullOrEmpty(accessKey)) { editorPart.AccessKey = String.Empty; } editorPart.RenderControl(writer); if (!String.IsNullOrEmpty(accessKey)) { editorPart.AccessKey = accessKey; } }
protected virtual Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) { throw new ArgumentOutOfRangeException("chromeType"); } // PERF: Cache these, since they are needed for every EditorPart in the zone. if (chromeType == PartChromeType.BorderOnly || chromeType == PartChromeType.TitleAndBorder) { // We don't want to set any border styles for ChromeType of TitleAndBorder or BorderOnly, // since the FrameSet has a default border, and it will use XP themes as long as no border styles // are set. // PERF: Just return the Zone.PartChromeStyle directly without making a copy return(Zone.PartChromeStyle); } else { if (_chromeStyleNoBorder == null) { Style style = new Style(); // create copy of PartChromeStyle so we can modify it style.CopyFrom(Zone.PartChromeStyle); if (style.BorderStyle != BorderStyle.None) { style.BorderStyle = BorderStyle.None; } if (style.BorderWidth != Unit.Empty) { style.BorderWidth = Unit.Empty; } if (style.BorderColor != Color.Empty) { style.BorderColor = Color.Empty; } _chromeStyleNoBorder = style; } return(_chromeStyleNoBorder); } }
private void RenderTitle(HtmlTextWriter writer, EditorPart editorPart) { string displayTitle = editorPart.DisplayTitle; if (String.IsNullOrEmpty(displayTitle)) { return; } // Apply TitleStyle to the Legend TableItemStyle titleTableItemStyle = Zone.PartTitleStyle; // PERF: Cache this, since it is needed for every EditorPart in the zone if (_titleTextStyle == null) { // Need to copy the TableItemStyle to a plain Style, since we are going to apply it to // the <legend> tag, which is not a table item. We ignore the horizontal align, // vertical align, and nowrap properties. Style style = new Style(); style.CopyFrom(titleTableItemStyle); _titleTextStyle = style; } if (!_titleTextStyle.IsEmpty) { _titleTextStyle.AddAttributesToRender(writer, Zone); } string description = editorPart.Description; if (!String.IsNullOrEmpty(description)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, description); } string accessKey = editorPart.AccessKey; if (!String.IsNullOrEmpty(accessKey)) { writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, accessKey); } writer.RenderBeginTag(HtmlTextWriterTag.Legend); writer.Write(displayTitle); writer.RenderEndTag(); // Legend }
protected override EditorPartCollection CreateEditorParts() { EditorPartCollection editorParts = new EditorPartCollection(); if (_zoneTemplate != null) { // PERF: Instantiate the template into a special control, that does nothing when a child control // is added. This is more performant because the child control is never parented to the temporary // control, it's ID is never generated, etc. Control container = new NonParentingControl(); _zoneTemplate.InstantiateIn(container); if (container.HasControls()) { foreach (Control control in container.Controls) { EditorPart part = control as EditorPart; if (part != null) { editorParts.Add(part); } else { LiteralControl literal = control as LiteralControl; // Throw an exception if it is *not* a literal containing only whitespace // Don't throw an exception in the designer, since we want only the offending // control to render as an error block, not the whole EditorZone. if (((literal == null) || (literal.Text.Trim().Length != 0)) && !DesignMode) { throw new InvalidOperationException(SR.GetString(SR.EditorZone_OnlyEditorParts, ID)); } } } } } return(editorParts); }
protected virtual Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) { throw new ArgumentOutOfRangeException("chromeType"); } // PERF: Cache these, since they are needed for every EditorPart in the zone. if (chromeType == PartChromeType.BorderOnly || chromeType == PartChromeType.TitleAndBorder) { // We don't want to set any border styles for ChromeType of TitleAndBorder or BorderOnly, // since the FrameSet has a default border, and it will use XP themes as long as no border styles // are set. // PERF: Just return the Zone.PartChromeStyle directly without making a copy return Zone.PartChromeStyle; } else { if (_chromeStyleNoBorder == null) { Style style = new Style(); // create copy of PartChromeStyle so we can modify it style.CopyFrom(Zone.PartChromeStyle); if (style.BorderStyle != BorderStyle.None) { style.BorderStyle = BorderStyle.None; } if (style.BorderWidth != Unit.Empty) { style.BorderWidth = Unit.Empty; } if (style.BorderColor != Color.Empty) { style.BorderColor = Color.Empty; } _chromeStyleNoBorder = style; } return _chromeStyleNoBorder; } }
internal int Add(EditorPart value) { return InnerList.Add(value); }
public override void Initialize(IComponent component) { ControlDesigner.VerifyInitializeArgument(component, typeof(EditorPart)); this._editorPart = (EditorPart) component; base.Initialize(component); }
public int IndexOf(EditorPart editorPart) { return InnerList.IndexOf(editorPart); }
internal int Add(EditorPart value) { return(base.InnerList.Add(value)); }
protected virtual new System.Web.UI.WebControls.Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) { return default(System.Web.UI.WebControls.Style); }
public virtual new void RenderEditorPart(System.Web.UI.HtmlTextWriter writer, EditorPart editorPart) { }
public void CopyTo(EditorPart[] array, int index) { }
protected override void RenderPartContents(HtmlTextWriter writer, EditorPart editorPart) { writer.Write(this._partViewRendering.Content); }
public int IndexOf(EditorPart editorPart) { return(default(int)); }
public bool Contains(EditorPart editorPart) { return(InnerList.Contains(editorPart)); }
public bool Contains(EditorPart editorPart) { return InnerList.Contains(editorPart); }
protected virtual new void RenderPartContents(System.Web.UI.HtmlTextWriter writer, EditorPart editorPart) { }
public void CopyTo(EditorPart[] array, int index) { InnerList.CopyTo(array, index); }
protected virtual new System.Web.UI.WebControls.Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) { return(default(System.Web.UI.WebControls.Style)); }
public bool Contains(EditorPart editorPart) { return(default(bool)); }
public int IndexOf(EditorPart editorPart) { return default(int); }
public void CopyTo (EditorPart[] array, int index) { ((ICollection)this).CopyTo (array, index); }
public bool Contains(EditorPart editorPart) { return default(bool); }
public int IndexOf(EditorPart editorPart) { return(InnerList.IndexOf(editorPart)); }