示例#1
0
        private static IList <Control> GetAllChildren(Control parent)
        {
            var collection = UserInterfaceUtil.TraverseChildren(parent, ShouldChildrenSkiped);
            var children   = new List <Control>(collection);

            return(children);
        }
示例#2
0
        public Control FindControlRec(String controlID)
        {
            if (_controlsCache == null)
            {
                var allControls = UserInterfaceUtil.TraverseChildren(this);
                _controlsCache = allControls.ToLookup(n => n.ID);
            }

            var result = _controlsCache[controlID];

            return(result.FirstOrDefault());
        }
示例#3
0
        protected IEnumerable <HyperLink> GetCurrentUrlLinks(Control control)
        {
            var links = (from n in UserInterfaceUtil.TraverseChildren(this)
                         let l = n as HyperLink
                                 where l != null
                                 select l);

            foreach (var link in links)
            {
                var linkUrl = GetLinkAbsUrl(link);
                if (IsRequestLink(linkUrl))
                {
                    yield return(link);
                }
            }
        }
示例#4
0
        private static IEnumerable <String> GetAllPermissions(Control control)
        {
            var query = from n in ConfigSection.Permissions.Cast <PermissionElement>()
                        where !string.IsNullOrWhiteSpace(n.ResourcePath)
                        select n.ResourcePath;

            foreach (var path in query)
            {
                yield return(path);
            }

            var configSection = ConfigSection;

            if (configSection == null)
            {
                yield break;
            }

            if (ConfigSettings == null)
            {
                yield break;
            }

            if (!ConfigSettings.ResourcePathAutoGeneration)
            {
                yield break;
            }

            query                 = from n in UserInterfaceUtil.TraverseChildren(control)
                            let m = n as IPermissionDependent
                                    where m != null && string.IsNullOrWhiteSpace(m.PermissionKey)
                                    let fullName = GetControlFullName(n)
                                                   where !string.IsNullOrWhiteSpace(fullName)
                                                   select fullName;

            foreach (var path in query)
            {
                yield return(path);
            }
        }
示例#5
0
        private void DisplayPopupsIfNeeded()
        {
            var enabled = DataConverter.ToNullableBool(ConfigurationManager.AppSettings["PopupsAutoControl"]);

            if (!enabled.GetValueOrDefault())
            {
                return;
            }

            var target = PostBackControl;

            if (target == null)
            {
                return;
            }

            var parents = UserInterfaceUtil.TraverseParents(target).OfType <Panel>();

            var parentPopup = parents.OfType <ModalPopup>().FirstOrDefault();

            if (parentPopup != null)
            {
                parentPopup.Show();
                return;
            }

            var root = ((Control)base.Master ?? this);

            var popups = UserInterfaceUtil.TraverseChildren(root).OfType <ModalPopupExtender>();

            var @set = parents.Select(n => n.ID).ToHashSet();
            var pops = popups.Where(n => @set.Contains(n.PopupControlID));

            foreach (var item in pops)
            {
                item.Show();
            }
        }