Beispiel #1
0
        public static bool TryDelete(this CustomDesktopEnvironment de, ControlReference id)
        {
            bool deleted = false;

            DeleteControl(de);
            return(deleted);

            void DeleteControl(Control control)
            {
                if (!deleted)
                {
                    foreach (var child in control.Controls)
                    {
                        if (id.References(child))
                        {
                            Control.Remove(child);
                            deleted = true;
                            return;
                        }

                        DeleteControl(child);
                    }
                }
            }
        }
Beispiel #2
0
        public static bool TryGetControl(this CustomDesktopEnvironment de, ControlReference reference, out Control control)
        {
            Control controlFound = null;

            SearchControl(de);
            control = controlFound;
            return(controlFound != null);

            void SearchControl(Control currentControl)
            {
                if (controlFound is null)
                {
                    foreach (var child in currentControl.Controls)
                    {
                        if (reference.References(child))
                        {
                            controlFound = child;
                            return;
                        }
                        SearchControl(child);
                    }
                }
            }
        }