Created
April 10, 2013 09:03
-
-
Save alexszilagyi/5353052 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using Telerik.Sitefinity.Web.UI.ControlDesign; | |
using System.Web.UI; | |
using Telerik.Sitefinity.Web.UI.Fields; | |
namespace SitefinityWebApp.Widgets.CI.Designer | |
{ | |
public class CIDesigner : ControlDesignerBase | |
{ | |
private string _layoutTemplatePath = "~/Widgets/CI/Designer/CIDesigner.ascx"; | |
private string _scriptReference = "~/Widgets/CI/Designer/CIDesigner.js"; | |
#region Properties | |
/// <summary> | |
/// Gets the layout template path | |
/// </summary> | |
public override string LayoutTemplatePath | |
{ | |
get | |
{ | |
return _layoutTemplatePath; | |
} | |
} | |
/// <summary> | |
/// Gets the layout template name | |
/// </summary> | |
protected override string LayoutTemplateName | |
{ | |
get | |
{ | |
return String.Empty; | |
} | |
} | |
#endregion | |
#region control references | |
protected Control CompanyName | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("CompanyNameText", true); | |
} | |
} | |
protected Control StreetAndNumber | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("StreetAndNumberText", true); | |
} | |
} | |
protected Control PostOffice | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("PostOfficeText", true); | |
} | |
} | |
protected Control PostCodeAndCity | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("PostCodeAndCityText", true); | |
} | |
} | |
protected Control TelephoneNumber | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("TelephoneNumberText", true); | |
} | |
} | |
protected Control FaxNumber | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("FaxNumberText", true); | |
} | |
} | |
protected Control Email | |
{ | |
get | |
{ | |
return this.Container.GetControl<Control>("EmailText", true); | |
} | |
} | |
protected ImageField GoogleMapsImageSelector | |
{ | |
get | |
{ | |
return this.Container.GetControl<ImageField>("GoogleMapsImageSelector", true); | |
} | |
} | |
protected ImageField GoogleMapsRetinaImageSelector | |
{ | |
get | |
{ | |
return this.Container.GetControl<ImageField>("GoogleMapsRetinaImageSelector", true); | |
} | |
} | |
#endregion | |
#region Methods | |
protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container) | |
{ | |
// set root node for page selectors | |
//PageID.RootNodeID = Telerik.Sitefinity.Abstractions.SiteInitializer.FrontendRootNodeId; | |
// set the image selector type to use string (src) | |
GoogleMapsImageSelector.DataFieldType = typeof(Guid); | |
GoogleMapsRetinaImageSelector.DataFieldType = typeof(Guid); | |
} | |
#endregion | |
#region IScriptControl implementation | |
/// <summary> | |
/// Gets a collection of script descriptors that represent ECMAScript (JavaScript) client components. | |
/// </summary> | |
public override System.Collections.Generic.IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors() | |
{ | |
var scriptDescriptors = new List<ScriptDescriptor>(base.GetScriptDescriptors()); | |
var descriptor = (ScriptControlDescriptor)scriptDescriptors.Last(); | |
descriptor.AddElementProperty("companyname", this.CompanyName.ClientID); | |
descriptor.AddElementProperty("streetandnumber", this.StreetAndNumber.ClientID); | |
descriptor.AddComponentProperty("postoffice", this.PostOffice.ClientID); | |
descriptor.AddComponentProperty("postcodeandcity", this.PostCodeAndCity.ClientID); | |
descriptor.AddComponentProperty("telephonenumber", this.TelephoneNumber.ClientID); | |
descriptor.AddComponentProperty("faxnumber", this.FaxNumber.ClientID); | |
descriptor.AddComponentProperty("email", this.Email.ClientID); | |
descriptor.AddComponentProperty("GoogleMapsImageSelector", this.GoogleMapsImageSelector.ClientID); | |
descriptor.AddComponentProperty("GoogleMapsRetinaImageSelector", this.GoogleMapsRetinaImageSelector.ClientID); | |
return scriptDescriptors; | |
} | |
/// <summary> | |
/// Gets a collection of ScriptReference objects that define script resources that the control requires. | |
/// </summary> | |
public override System.Collections.Generic.IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences() | |
{ | |
var scripts = new List<ScriptReference>(base.GetScriptReferences()); | |
scripts.Add(new ScriptReference(_scriptReference)); | |
return scripts; | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment