| using System; |
| using System.Collections.Generic; |
| using System.Text; |
| using System.Web.UI; |
| using Telerik.Cms.Web.UI; |
| using System.IO; |
| using Telerik.Framework.Web.Design; |
| using System.Web.UI.WebControls; |
| using System.ComponentModel; |
| using Telerik.Utilities.Reflection; |
| using Telerik.Events.WebControls; |
| using Telerik.Web.UI; |
| using System.Diagnostics; |
| using System.Web; |
| using System.Web.UI.HtmlControls; |
| |
| namespace UserControls |
| { |
| using Telerik.Cms.Web.UI; |
| /// <summary> |
| /// Inherits ControlDesigner class and represents the control designer of Image web control. |
| /// </summary> |
| public class BoxControlDesigner : Telerik.Framework.Web.Design.ControlDesigner |
| { |
| private Container container; |
| |
| /// <summary> |
| /// Default constructor. Initializes a new instance of ImageControlDesigner class. |
| /// </summary> |
| public BoxControlDesigner() |
| { |
| } |
| |
| /// <summary> |
| /// Creates the child controls in ImageControlDesigner control. |
| /// </summary> |
| protected override void CreateChildControls() |
| { |
| this.Controls.Clear(); |
| |
| this.container = new Container(this); |
| |
| BoxBase box = (BoxBase)base.DesignedControl; |
| |
| // Load the ASCX template assocated with this ControlDesigner |
| string path = "~/UserControls/GSSI/BoxControlDesigner.ascx"; |
| ITemplate itemTemplate = this.Page.LoadTemplate(path); |
| |
| itemTemplate.InstantiateIn(container); |
| this.container.CssStyle.Text = box.CssStyle; |
| this.container.CssStyle.SelectedIndexChanged += new EventHandler(ItemChanged); |
| |
| this.container.Content.Html = box.Content; |
| this.container.Content.TextChanged += new EventHandler(ContentChanged); |
| |
| //this.container.Content2.Html = box.Content2; |
| //this.container.Content2.TextChanged += new EventHandler(Content2Changed); |
| |
| this.Controls.Add(this.container); |
| |
| //// The ASCX template found above contains the Control Tags that are referred to below. |
| |
| //// Attach an event to the CssStyle control found in the ASCX template. |
| //RadioButtonList rad_CssClass = (RadioButtonList)Controls[0].FindControl("CssStyle"); |
| //// Attach an event to the "CssStyle" control. |
| //rad_CssClass.SelectedIndexChanged += new EventHandler(ItemChanged); |
| |
| //// Find the "Content" control in the ASCX template. |
| //RadEditor rad_Content = (RadEditor)Controls[0].FindControl("Content"); |
| //// Preset the starting value of the "Content" control. |
| //rad_Content.Html = TypeDescriptor.GetProperties(base.DesignedControl).Find("Content", false).GetValue(base.DesignedControl).ToString(); |
| //// Attach an event to the "Content" control. |
| //rad_Content.TextChanged += new EventHandler(ContentChanged); |
| } |
| |
| /// <summary> |
| /// This code is executed just before the page renders. |
| /// </summary> |
| protected override void OnPreRender(EventArgs e) |
| { |
| base.OnPreRender(e); |
| |
| // We must use our own stylesheets for this Control Designer. |
| // This code adds our custom stylesheet to the page. |
| HtmlLink css = new HtmlLink(); |
| css.Href = "/UserControls/GSSI/ControlDesigner.css"; |
| css.Attributes.Add("rel", "stylesheet"); |
| css.Attributes.Add("type", "text/css"); |
| |
| this.Page.Header.Controls.Add(css); |
| } |
| |
| /// <summary> |
| /// Generic method that is executed when values are changed. |
| /// </summary> |
| public void ItemChanged(object sender, EventArgs e) |
| { |
| // Our Control ID's on the ASCX template match the Property names that |
| // we are changing. As near as I can tell "UpdateProperty" gets the |
| // ID of the "sender" it is passed. If the "ID" matches a Property |
| // of the Control we're editing, then it takes the "Value". |
| |
| ////base.UpdateProperty(sender, base.DesignedControl); |
| |
| ((BoxBase)base.DesignedControl).CssStyle = ((RadioButtonList)sender).Text; |
| } |
| |
| /// <summary> |
| /// Executed when Content is changed. |
| /// </summary> |
| public void ContentChanged(object sender, EventArgs e) |
| { |
| // Our Content control is a RadEditor. This control type is not |
| // accepted by "UpdateProperty". So I am going to create a |
| // "TextBox", copy the "Html" value over, and pass this new |
| // TextBox to "UpdateProperty". I'm not a fan of this. |
| // Suggestions are welcome! |
| |
| TextBox ourTextControl = new TextBox(); |
| ourTextControl.ID = "Content"; |
| ourTextControl.Text = ((RadEditor)sender).Html; |
| |
| base.UpdateProperty(ourTextControl, base.DesignedControl); |
| |
| ((BoxBase)base.DesignedControl).Content = ((RadEditor)sender).Html; |
| } |
| |
| public void Content2Changed(object sender, EventArgs e) |
| { |
| // Our Content control is a RadEditor. This control type is not |
| // accepted by "UpdateProperty". So I am going to create a |
| // "TextBox", copy the "Html" value over, and pass this new |
| // TextBox to "UpdateProperty". I'm not a fan of this. |
| // Suggestions are welcome! |
| |
| ////TextBox ourTextControl = new TextBox(); |
| ////ourTextControl.ID = "Content"; |
| ////ourTextControl.Text = ((RadEditor)sender).Html; |
| |
| ////base.UpdateProperty(ourTextControl, base.DesignedControl); |
| |
| ((BoxBase)base.DesignedControl).Content2 = ((RadEditor)sender).Html; |
| } |
| |
| private class Container : GenericContainer<BoxControlDesigner> |
| { |
| public Container(BoxControlDesigner owner) |
| : base(owner) |
| { |
| } |
| |
| public RadioButtonList CssStyle |
| { |
| get |
| { |
| if (this.cssStyle == null) |
| this.cssStyle = base.FindRequiredControl<RadioButtonList>("CssStyle"); |
| return this.cssStyle; |
| } |
| } |
| |
| public RadEditor Content |
| { |
| get |
| { |
| if (this.content == null) |
| this.content = base.FindRequiredControl<RadEditor>("Content"); |
| return this.content; |
| } |
| } |
| |
| //public RadEditor Content2 |
| //{ |
| // get |
| // { |
| // if (this.content2 == null) |
| // this.content2 = base.FindRequiredControl<RadEditor>("Content2"); |
| // return this.content2; |
| // } |
| //} |
| RadioButtonList cssStyle; |
| RadEditor content, content2; |
| } |
| } |
| } |
| |