예제 #1
0
        /*
         * public override CGSize SizeThatFits (CGSize size)
         * {
         *      return new CGSize ((nfloat)0, (nfloat)0);
         * }
         */

        protected override void Dispose(bool disposing)
        {
            if ((this.flags & VisualElementRendererFlags.Disposed) != (VisualElementRendererFlags)0)
            {
                return;
            }
            this.flags = this.flags | VisualElementRendererFlags.Disposed;
            if (disposing)
            {
                if (this.events != null)
                {
                    this.events.Dispose();
                    this.events = (EventTracker)null;
                }
                if (this.tracker != null)
                {
                    this.tracker.Dispose();
                    this.tracker = (VisualElementTracker)null;
                }
                if (this.packager != null)
                {
                    this.packager.Dispose();
                    this.packager = (VisualElementPackager)null;
                }
                Platform.SetRenderer((VisualElement)this.Element, (IVisualElementRenderer)null);
                this.SetElement(default(TElement));
                this.Element = default(TElement);
            }

            base.Dispose(disposing);
        }
예제 #2
0
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                if (_events != null)
                {
                    _events.Dispose();
                    _events = null;
                }
                if (_tracker != null)
                {
                    _tracker.Dispose();
                    _tracker = null;
                }
                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                Platform.SetRenderer(Element, null);
                SetElement(null);
                Element = null;
            }
            base.Dispose(disposing);
        }
예제 #3
0
        public void Init(IVisualElementRenderer renderer, VisualElementRendererFlags flags = VisualElementRendererFlags.AutoPackage | VisualElementRendererFlags.AutoTrack)
        {
            _flags    = flags;
            _packager = new VisualElementPackager(renderer);
            _events   = new EventTracker(renderer);
            _tracker  = new VisualElementTracker(renderer);
            _tracker.NativeControlUpdated += OnNativeControlUpdated;

            if (AutoTrack)
            {
                if (renderer is UIView uiView)
                {
                    _events.LoadEvents(uiView);
                }
                else
                {
                    throw new InvalidRendererException("IVisualElementRenderer must be of type 'UIView'");
                }
            }

            if (AutoPackage)
            {
                _packager?.Load();
            }
        }
예제 #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed || !disposing)
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (_events != null)
            {
                _events.Dispose();
                _events = null;
            }
            if (_tracker != null)
            {
                _tracker.Dispose();
                _tracker = null;
            }
            if (_packager != null)
            {
                _packager.Dispose();
                _packager = null;
            }
        }
예제 #5
0
        protected override void Dispose(bool disposing)
        {
            if (CheckFlagsForDisposed())
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                EffectUtilities.UnregisterEffectControlProvider(this, Element);

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (_gestureManager != null)
                {
                    _gestureManager.Dispose();
                    _gestureManager = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Disposes of underlying resources.
        /// </summary>
        /// <param name="disposing">True if the memory release was requested on demand.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                // This is the reason why I call SendDisappearing() here.
                // When OnChildRemove is called first like how it is called in Navigation.PopToRootAsync(),
                // you can not controll using SendDisappearing() on the lower class.
                (Element as IPageController)?.SendDisappearing();

                if (Element != null)
                {
                    Element.PropertyChanged -= OnElementPropertyChanged;
                    Element.BatchCommitted  -= OnBatchCommitted;

                    Element.ChildAdded        -= OnChildAdded;
                    Element.ChildRemoved      -= OnChildRemoved;
                    Element.ChildrenReordered -= OnChildrenReordered;

                    Element.FocusChangeRequested -= OnFocusChangeRequested;

                    var logicalChildren = (Element as IElementController).LogicalChildren;
                    foreach (var child in logicalChildren)
                    {
                        Platform.GetRenderer(child)?.Dispose();
                    }

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    // Reset Element geometry, to re-calculate when Renderer was re-attached
                    Element.Layout(new Rectangle(0, 0, -1, -1));

                    Element = default(TElement);
                }

                if (NativeView != null)
                {
                    NativeView.Deleted -= NativeViewDeleted;
                    NativeView.Unrealize();
                    NativeView = null;
                }

                if (_customFocusManager.IsValueCreated)
                {
                    _customFocusManager.Value.Dispose();
                }
            }
        }
        public void Init(IVisualElementRenderer renderer, VisualElementRendererFlags flags = VisualElementRendererFlags.AutoPackage | VisualElementRendererFlags.AutoTrack)
        {
            _flags          = flags;
            _packager       = new VisualElementPackager(renderer);
            _tracker        = new VisualElementTracker(renderer);
            _gestureManager = new GestureManager(renderer);

            if (AutoPackage)
            {
                _packager?.Load();
            }
        }
예제 #8
0
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                RemoveAllViews();

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
예제 #9
0
        /// <summary>
        /// Disposes of underlying resources.
        /// </summary>
        /// <param name="disposing">True if the memory release was requested on demand.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                if (Element != null)
                {
                    Element.PropertyChanged -= OnElementPropertyChanged;
                    Element.BatchCommitted  -= OnBatchCommitted;

                    Element.ChildAdded        -= OnChildAdded;
                    Element.ChildRemoved      -= OnChildRemoved;
                    Element.ChildrenReordered -= OnChildrenReordered;

                    Element.FocusChangeRequested -= OnFocusChangeRequested;

                    var logicalChildren = (Element as IElementController).LogicalChildren;
                    foreach (var child in logicalChildren)
                    {
                        Platform.GetRenderer(child)?.Dispose();
                    }

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    // Reset Element geometry, to re-calculate when Renderer was re-attached
                    Element.Layout(new Rectangle(0, 0, -1, -1));

                    Element = default(TElement);
                }

                if (NativeView != null)
                {
                    NativeView.Deleted -= NativeViewDeleted;
                    NativeView.Unrealize();
                    _view = null;
                }

                if (_customFocusManager.IsValueCreated)
                {
                    _customFocusManager.Value.Dispose();
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Notification that the property of the associated element has changed.
        /// </summary>
        /// <param name="sender">Object which sent the notification.</param>
        /// <param name="e">Event parameters.</param>
        protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (Element.Batched)
            {
                if (e.PropertyName == VisualElement.XProperty.PropertyName ||
                    e.PropertyName == VisualElement.YProperty.PropertyName ||
                    e.PropertyName == VisualElement.WidthProperty.PropertyName ||
                    e.PropertyName == VisualElement.HeightProperty.PropertyName)
                {
                    _flags |= VisualElementRendererFlags.NeedsLayout;
                }
                else if (e.PropertyName == VisualElement.TranslationXProperty.PropertyName ||
                         e.PropertyName == VisualElement.TranslationYProperty.PropertyName ||
                         e.PropertyName == VisualElement.RotationProperty.PropertyName ||
                         e.PropertyName == VisualElement.RotationXProperty.PropertyName ||
                         e.PropertyName == VisualElement.RotationYProperty.PropertyName ||
                         e.PropertyName == VisualElement.ScaleProperty.PropertyName ||
                         e.PropertyName == VisualElement.AnchorXProperty.PropertyName ||
                         e.PropertyName == VisualElement.AnchorYProperty.PropertyName)
                {
                    _flags |= VisualElementRendererFlags.NeedsTransformation;
                }
                else
                {
                    _batchedProperties.Add(e.PropertyName);
                }
                return;
            }

            Action <bool> init;

            if (_propertyHandlersWithInit.TryGetValue(e.PropertyName, out init))
            {
                init(false);
            }
            else
            {
                Action handler;
                if (_propertyHandlers.TryGetValue(e.PropertyName, out handler))
                {
                    handler();
                }
            }
        }
예제 #11
0
        void OnBatchCommitted(object sender, EventArg <VisualElement> e)
        {
            if (_flags.HasFlag(VisualElementRendererFlags.NeedsLayout))
            {
                UpdateLayout();
                // UpdateLayout already updates transformation, clear NeedsTranformation flag then
                _flags &= ~VisualElementRendererFlags.NeedsTransformation;

                _flags ^= VisualElementRendererFlags.NeedsLayout;
            }
            if (_flags.HasFlag(VisualElementRendererFlags.NeedsTransformation))
            {
                ApplyTransformation();
                _flags ^= VisualElementRendererFlags.NeedsTransformation;
            }

            foreach (string property in _batchedProperties)
            {
                OnElementPropertyChanged(this, new PropertyChangedEventArgs(property));
            }
            _batchedProperties.Clear();
        }
예제 #12
0
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                if (_events != null)
                {
                    _events.Dispose();
                    _events = null;
                }
                if (_tracker != null)
                {
                    _tracker.Dispose();
                    _tracker = null;
                }
                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                // The ListView can create renderers and unhook them from the Element before Dispose is called in CalculateHeightForCell.
                // Thus, it is possible that this work is already completed.
                if (Element != null)
                {
                    Element.ClearValue(Platform.RendererProperty);
                    SetElement(null);
                }
            }
            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (_scaleDetector != null && _scaleDetector.IsValueCreated)
                {
                    _scaleDetector.Value.Dispose();
                    _scaleDetector = null;
                }

                if (_gestureListener != null)
                {
                    _gestureListener.Dispose();
                    _gestureListener = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                RemoveAllViews();

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;
                    UnsubscribeGestureRecognizers(Element);

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }