示例#1
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                SetElement(_element, null);

                if (_renderer != null)
                {
                    _renderer.ElementChanged -= RendererOnElementChanged;

                    if (_renderer.View.IsAlive() && _attachTracker.IsAlive())
                    {
                        _renderer.View.RemoveOnAttachStateChangeListener(_attachTracker);
                        _attachTracker = null;
                    }

                    _renderer = null;
                    _context  = null;
                }
            }
        }
示例#2
0
        public VisualElementTracker(IVisualElementRenderer renderer)
        {
            _batchCommittedHandler  = HandleRedrawNeeded;
            _propertyChangedHandler = HandlePropertyChanged;

            _renderer = renderer ?? throw new ArgumentNullException(nameof(renderer));
            _context  = renderer.View.Context;
            _renderer.ElementChanged += RendererOnElementChanged;

            VisualElement view = renderer.Element;

            SetElement(null, view);

            renderer.View.SetCameraDistance(3600);

            if (!_context.IsDesignerContext())
            {
                _attachTracker = AttachTracker.Instance;
                renderer.View.AddOnAttachStateChangeListener(_attachTracker);
            }
            else
            {
                _attachTracker = new AttachTracker();
            }
        }