Esempio n. 1
0
        public static List <Control> ToList(this Control.ControlCollection ControlCollection, bool IncludeChildren)
        {
            List <Control> lstControls = new List <Control>();

            ControlCollection.ForEach(ctrl =>
            {
                if (IncludeChildren)
                {
                    lstControls.AddRange(ctrl.Controls.ToList(true));
                }
                lstControls.Add(ctrl);
            });
            return(lstControls);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ControlCollection"></param>
        /// <returns></returns>
        public static List <Control> ToList(this Control.ControlCollection ControlCollection)
        {
            List <Control> lstControls = new List <Control>();

            ControlCollection.ForEach(ctrl =>
            {
                if (!(ctrl is CPanel || ctrl is CGroupBox || ctrl is CTabControl || ctrl is TabPage))
                {
                    lstControls.AddRange(ctrl.Controls.ToList(true));
                }
                lstControls.Add(ctrl);
            });
            return(lstControls);
        }
Esempio n. 3
0
        public static List <Control> Where(this Control.ControlCollection ControlCollection, Func <Control, bool> Condition, bool SearchAllChildren)
        {
            List <Control> lstControls = new List <Control>();

            ControlCollection.ForEach(ctrl =>
            {
                if (SearchAllChildren)
                {
                    lstControls.AddRange(ctrl.Controls.Where(Condition, true));
                }
                if (Condition.Invoke(ctrl))
                {
                    lstControls.Add(ctrl);
                }
            });
            return(lstControls);
        }
Esempio n. 4
0
        public static List <Control> FindControlsByType(this Control.ControlCollection ControlCollection, Type Type, bool SearchAllChildren)
        {
            List <Control> lstControls = new List <Control>();

            ControlCollection.ForEach(ctrl =>
            {
                if (SearchAllChildren)
                {
                    lstControls.AddRange(ctrl.Controls.FindControlsByType(Type, true));
                }
                if (ctrl.GetType() == Type)
                {
                    lstControls.Add(ctrl);
                }
            });

            return(lstControls);
        }
Esempio n. 5
0
        /// <summary>
        /// Znajduje kontrolki danego typu
        /// </summary>
        /// <param name="ControlCollection"></param>
        /// <param name="SearchAllChildren"></param>
        /// <param name="allowedTypes"></param>
        /// <returns></returns>
        public static List <Control> FindControlsByType(this Control.ControlCollection ControlCollection, bool SearchAllChildren, params Type[] allowedTypes)
        {
            List <Control> lstControls = new List <Control>();

            ControlCollection.ForEach(ctrl =>
            {
                if ((SearchAllChildren) && (ctrl is CPanel || ctrl is CGroupBox || ctrl is CTabControl || ctrl is TabPage))
                {
                    lstControls.AddRange(ctrl.Controls.FindControlsByType(true, allowedTypes));
                }
                if (new List <Type>(allowedTypes).Contains(ctrl.GetType()))
                {
                    lstControls.Add(ctrl);
                }
            });

            return(lstControls);
        }