protected BaseScriptBuilder(BaseControl control) { this.control = control; if (!this.control.HasOwnIDMode || this.control.IDMode == IDMode.Inherit) { this.control.IDMode = IDMode.Explicit; } }
protected ContentScriptBuilder(BaseControl control) : base(control) { items = new List<object>(0); if (control is IItems) { items = ((IItems) control).ItemsList; layoutItems = items; } if (control is IContent) { contentContainer = ((IContent) control).ContentContainer; } }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="icons"></param> protected virtual void CheckIcon(BaseControl control, List<Icon> icons) { if (control is IIcon) { List<Icon> cIcons = ((IIcon)control).Icons; foreach (Icon icon in cIcons) { if (!icons.Contains(icon) && icon != Icon.None) { icons.Add(icon); } } } }
public ComponentAddedEventArgs(BaseControl control) { this.control = control; }
protected DefaultScriptBuilder(BaseControl control) : base(control) { }
public void RegisterScript(BaseControl c, PropertyInfo property) { c.AddScript(this.GetScript(c, property)); }
/// <summary> /// /// </summary> public Labelable(BaseControl owner) : base(owner) { }
protected virtual void RegisterControlResourcesInManager(ResourceManager manager, BaseControl ctrl) { ctrl.RegisterStyles(manager); ctrl.RegisterScripts(manager); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="icons"></param> protected override void CheckIcon(BaseControl control, List<Icon> icons) { }
/// <summary> /// /// </summary> /// <param name="control"></param> protected override void CheckResources(BaseControl control, ResourceManager manager) { }
public string GetScript(BaseControl c, PropertyInfo property) { StringBuilder sb = new StringBuilder(); if (!c.CallbackValues.ContainsKey(property.Name)) { return null; } object value = c.CallbackValues[property.Name]; if (this.Script.IsNotEmpty()) { sb.AppendFormat(this.Script, c.ClientID, JSON.Serialize(value)); } else if (this.MethodName.IsNotEmpty()) { MethodInfo method = c.GetType().GetMethod(this.MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { property.PropertyType }, null); if (method != null) { method.Invoke(c, new object[] { value }); } } else //simple script generating { switch (this.GenerateMode) { case AutoGeneratingScript.Simple: sb.AppendFormat(DirectEventUpdateAttribute.AutoGenerateFormat, c.ClientID, JSON.Serialize(value), property.Name.ToLowerCamelCase()); break; case AutoGeneratingScript.WithSet: sb.AppendFormat("{0}.set{2}({1});", c.ClientID, JSON.Serialize(value), property.Name); break; default: throw new ArgumentOutOfRangeException(); } } return sb.ToString(); }
private static void CheckResources(BaseControl control, InsertOrderedDictionary<string, string> scripts, InsertOrderedDictionary<string, string> styles) { foreach (ClientScriptItem item in control.GetScripts()) { string resourcePath = GlobalConfig.Settings.ScriptMode == ScriptMode.Debug && item.PathEmbeddedDebug.IsNotEmpty() ? item.PathEmbeddedDebug : item.PathEmbedded; if (!scripts.ContainsKey(resourcePath)) { scripts.Add(resourcePath, ExtNetTransformer.GetWebResourceUrl(item.Type, resourcePath)); } } foreach (ClientStyleItem item in control.GetStyles()) { if (!styles.ContainsKey(item.PathEmbedded) && item.Theme.Equals(Theme.Default)) { styles.Add(item.PathEmbedded, ExtNetTransformer.GetWebResourceUrl(item.Type, item.PathEmbedded)); } } }
private static void CheckNS(BaseControl ctrl, List<string> ns) { if (ctrl.HasOwnNamespace) { string _namespace = ctrl.ClientNamespace; if (_namespace.IsNotEmpty() && !ns.Contains(_namespace)) { ns.Add(_namespace); } } }
protected List <BaseControl> FindControls(Control seed, bool searchOnly, StringBuilder sb, List <Icon> icons, List <string> ns) { if (seed == null) { return(null); } if (icons == null) { icons = new List <Icon>(); } if (ns == null) { ns = new List <string>(); } ResourceManager manager = this.ResourceManager; if (sb != null && !searchOnly && manager != null) { try { List <UserControl> userControls = ControlUtils.FindControls <UserControl>(this.Control); foreach (UserControl userControl in userControls) { manager.AddDirectMethodControl(userControl, true); } string proxies = manager.BuildDirectMethodProxies(true); foreach (UserControl userControl in userControls) { manager.RemoveDirectMethodControl(userControl, true); } if (!string.IsNullOrEmpty(proxies)) { sb.Append(proxies); } } catch (Exception) { } } if (ReflectionUtils.IsTypeOf(seed, typeof(BaseControl), false)) { BaseControl ctrl = (BaseControl)seed; if (!searchOnly) { this.CheckIcon(ctrl, icons); this.CheckNS(ctrl, ns); this.CheckResources(ctrl, manager); } ctrl.IsDynamic = true; ctrl.EnsureChildControlsInternal(); if (!searchOnly) { ctrl.CallOnPreRender(); ctrl.RegisterStyles(manager); ctrl.RegisterScripts(manager); } } List <BaseControl> foundControls = new List <BaseControl>(); foreach (Control control in seed.Controls) { if (this.ExcludeControl(seed, control)) { continue; } var isBaseControl = ReflectionUtils.IsTypeOf(control, typeof(BaseControl), false); if (!isBaseControl && (control.ID.IsEmpty() || BaseScriptBuilder.autoIDRegEx.IsMatch(control.ID))) { control.ID = BaseControl.GenerateID(); } if (isBaseControl && !(control is UserControlLoader)) { BaseControl ctrl = (BaseControl)control; if (!searchOnly) { this.CheckIcon(ctrl, icons); this.CheckResources(ctrl, manager); } foundControls.Add(ctrl); ctrl.IsDynamic = true; ctrl.EnsureChildControlsInternal(); if (!searchOnly) { ctrl.CallOnPreRender(); ctrl.RegisterStyles(manager); ctrl.RegisterScripts(manager); } } if (ControlUtils.HasControls(control)) { foundControls.AddRange(this.FindControls(control, searchOnly, null, icons, ns)); } } if (sb != null && !searchOnly) { /*if (icons.Count > 0) * { * string[] arr = new string[icons.Count]; * * for (int i = 0; i < icons.Count; i++) * { * arr[i] = icons[i].ToString(); * } * * sb.Append("Ext.net.ResourceMgr.registerIcon("); * sb.Append(JSON.Serialize(arr)); * sb.Append(");"); * sb.Append(script); * }*/ if (ns.Count > 0) { sb.Append("Ext.ns("); foreach (var n in ns) { sb.Append("\"").Append(n).Append("\","); } sb.Remove(sb.Length - 1, 1); sb.Append(");"); } } return(foundControls); }
protected virtual void CheckNS(BaseControl control, List<string> ns) { if (control.HasOwnNamespace) { string _namespace = control.ClientNamespace; if (_namespace.IsNotEmpty() && !ns.Contains(_namespace)) { ns.Add(_namespace); } } }
/// <summary> /// /// </summary> /// <param name="control"></param> protected virtual void CheckResources(BaseControl control, ResourceManager manager) { if (HttpContext.Current.CurrentHandler is Page && !(HttpContext.Current.CurrentHandler is ISelfRenderingPage) && !this.ForceResources) { return; } foreach (ClientScriptItem item in control.GetScripts()) { string resourcePath = manager != null && manager.ScriptMode == ScriptMode.Debug && item.PathEmbeddedDebug.IsNotEmpty() ? item.PathEmbeddedDebug : item.PathEmbedded; if (!scriptsResources.ContainsKey(resourcePath)) { scriptsResources.Add(resourcePath, GetWebResourceUrl(item.Type, resourcePath)); } } foreach (ClientStyleItem item in control.GetStyles()) { if (!stylesResources.ContainsKey(item.PathEmbedded) && item.Theme.Equals(Theme.Default)) { stylesResources.Add(item.PathEmbedded, GetWebResourceUrl(item.Type, item.PathEmbedded)); } } }
protected override void RegisterControlResourcesInManager(ResourceManager manager, BaseControl ctrl) { }
public ConfigScriptBuilder(BaseControl control) : base(control) { }
public virtual void Show(BaseControl control) { this.Call("show", new JRawValue(control.ClientID)); }
public static ContentScriptBuilder Create(BaseControl control) { return new ContentScriptBuilder(control); }
public static DefaultScriptBuilder Create(BaseControl control) { return new DefaultScriptBuilder(control); }
/// <summary> /// /// </summary> public SimpleStore(BaseControl control, ListItemCollection items) { this.control = control; this.items = items; }
public static ContentScriptBuilder Create(BaseControl control) { return(new ContentScriptBuilder(control)); }