Ejemplo n.º 1
0
        internal static void Cleanup(this VisualElement self)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }

            IVisualElementRenderer renderer = Platform.GetRenderer(self);

            foreach (Element element in self.Descendants())
            {
                var visual = element as VisualElement;
                if (visual == null)
                {
                    continue;
                }

                IVisualElementRenderer childRenderer = Platform.GetRenderer(visual);
                if (childRenderer != null)
                {
                    ((Gtk.Widget)childRenderer).Destroy();
                    Platform.SetRenderer(visual, null);
                }
            }

            if (renderer != null)
            {
                ((Gtk.Widget)renderer).Destroy();
                Platform.SetRenderer(self, null);
            }
        }
        public static void Cleanup(this VisualElement self)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }

            IVisualElementRenderer renderer = Platform.GTK.Platform.GetRenderer(self);

            foreach (Element element in self.Descendants())
            {
                var visual = element as VisualElement;
                if (visual == null)
                {
                    continue;
                }

                IVisualElementRenderer childRenderer = Platform.GTK.Platform.GetRenderer(visual);
                if (childRenderer != null)
                {
                    childRenderer.Dispose();
                    Platform.GTK.Platform.SetRenderer(visual, null);
                }
            }

            if (renderer != null)
            {
                renderer.Dispose();
                Platform.GTK.Platform.SetRenderer(self, null);
            }
        }
Ejemplo n.º 3
0
        internal static void Cleanup(this VisualElement self)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            IVisualElementRenderer renderer = Platform.GetRenderer(self);

            foreach (Element element in self.Descendants())
            {
                if (!(element is VisualElement visual))
                {
                    continue;
                }

                IVisualElementRenderer childRenderer = Platform.GetRenderer(visual);
                if (childRenderer != null)
                {
                    childRenderer.Dispose();
                    Platform.SetRenderer(visual, null);
                }
            }

            if (renderer != null)
            {
                renderer.Dispose();
                Platform.SetRenderer(self, null);
            }
        }
Ejemplo n.º 4
0
        public static void DisposeModelAndChildrenRenderers(this VisualElement view)
        {
            IVisualElementRenderer renderer;

            foreach (var child in view.Descendants().OfType <VisualElement>())
            {
                renderer = XFPlatform.GetRenderer(child);
                XFPlatform.SetRenderer(child, null);

                if (renderer == null)
                {
                    continue;
                }

                renderer.NativeView.RemoveFromSuperview();
                renderer.Dispose();
            }

            renderer = XFPlatform.GetRenderer(view);
            if (renderer != null)
            {
                renderer.NativeView.RemoveFromSuperview();
                renderer.Dispose();
            }
            XFPlatform.SetRenderer(view, null);
        }
Ejemplo n.º 5
0
        public List <NSObject> GetAccessibilityElements()
        {
            if (Container == null || Element == null)
            {
                return(null);
            }

            var children = Element.Descendants();
            SortedDictionary <int, List <VisualElement> > tabIndexes = null;
            List <NSObject> views = new List <NSObject>();

            foreach (var child in children)
            {
                if (!(child is VisualElement ve))
                {
                    continue;
                }

                tabIndexes = ve.GetSortedTabIndexesOnParentPage(out _);
                break;
            }

            if (tabIndexes == null)
            {
                return(null);
            }

            foreach (var idx in tabIndexes?.Keys)
            {
                var tabGroup = tabIndexes[idx];
                foreach (var child in tabGroup)
                {
                    if (child is Layout ||
                        !(
                            child is VisualElement ve && ve.IsTabStop &&
                            AutomationProperties.GetIsInAccessibleTree(ve) != false &&                             // accessible == true
                            ve.GetRenderer().NativeView is ITabStop tabStop)
                        )
                    {
                        continue;
                    }

                    var thisControl = tabStop.TabStop;

                    if (thisControl == null)
                    {
                        continue;
                    }

                    if (views.Contains(thisControl))
                    {
                        break;                         // we've looped to the beginning
                    }
                    views.Add(thisControl);
                }
            }

            return(views);
        }
Ejemplo n.º 6
0
        // TODO MAUI Make this work against IVIEW
        internal static void Cleanup(this VisualElement self)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }

            IViewHandler handler = self.Handler;

            foreach (Element element in self.Descendants())
            {
                var visual = element as VisualElement;
                if (visual == null)
                {
                    continue;
                }

                visual.Handler = null;
            }

            self.Handler = null;
        }