Esempio n. 1
0
        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();

                    this.RegisterControlResourcesInManager(manager, ctrl);
                }
            }

            List <BaseControl> foundControls = new List <BaseControl>();

            foreach (Control control in seed.Controls)
            {
                if (this.ExcludeControl(seed, control))
                {
                    continue;
                }

                bool 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();

                        this.RegisterControlResourcesInManager(manager, ctrl);
                    }
                }

                if (ControlUtils.HasControls(control))
                {
                    foundControls.AddRange(this.FindControls(control, searchOnly, null, icons, ns));
                }
            }

            if (sb != null && !searchOnly)
            {
                this.RegisterNS(sb, ns);
            }

            return(foundControls);
        }
Esempio n. 2
0
        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;
                }

                if (ReflectionUtils.IsTypeOf(control, typeof(BaseControl), false) && !(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);
        }
Esempio n. 3
0
        protected List <XControl> FindControls(Control seed, bool searchOnly, StringBuilder sb, List <Icon> icons)
        {
            if (seed == null)
            {
                return(null);
            }

            ResourceManager manager = ResourceManager.GetInstance(HttpContext.Current);

            if (icons == null)
            {
                icons = new List <Icon>();
            }

            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 e)
                {
                }
            }

            if (ReflectionUtils.IsTypeOf(seed, typeof(XControl), false))
            {
                XControl ctrl = (XControl)seed;
                if (!searchOnly)
                {
                    this.CheckIcon(ctrl, icons);
                    this.CheckResources(ctrl);
                }
                ctrl.IsDynamic = true;
                ctrl.EnsureChildControlsInternal();
                if (!searchOnly)
                {
                    ctrl.CallOnPreRender();

                    ctrl.RegisterStyles(manager);
                    ctrl.RegisterScripts(manager);
                }
            }

            List <XControl> foundControls = new List <XControl>();

            foreach (Control control in seed.Controls)
            {
                if (this.ExcludeControl(seed, control))
                {
                    continue;
                }

                if (ReflectionUtils.IsTypeOf(control, typeof(XControl), false))
                {
                    XControl ctrl = (XControl)control;
                    if (!searchOnly)
                    {
                        this.CheckIcon(ctrl, icons);
                        this.CheckResources(ctrl);
                    }
                    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));
                }
            }

            if (sb != null && !searchOnly && 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);
            }

            return(foundControls);
        }