Beispiel #1
0
		public void SetElement(VisualElement element)
		{
			var oldElement = Element;
			Element = element;
			Element.PropertyChanged += HandlePropertyChanged;
			((WebView)Element).EvalRequested += OnEvalRequested;
			((WebView)Element).GoBackRequested += OnGoBackRequested;
			((WebView)Element).GoForwardRequested += OnGoForwardRequested;
			Delegate = new CustomWebViewDelegate(this);

			BackgroundColor = UIColor.Clear;

			AutosizesSubviews = true;

			_tracker = new VisualElementTracker(this);

			_packager = new VisualElementPackager(this);
			_packager.Load();

			_events = new EventTracker(this);
			_events.LoadEvents(this);

			Load();

			OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

			if (Element != null && !string.IsNullOrEmpty(Element.AutomationId))
				AccessibilityIdentifier = Element.AutomationId;

			if (element != null)
				element.SendViewInitialized(this);
		}
Beispiel #2
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var uiTapGestureRecognizer = new UITapGestureRecognizer(a => View.EndEditing(true));

			uiTapGestureRecognizer.ShouldRecognizeSimultaneously = (recognizer, gestureRecognizer) => true;
			uiTapGestureRecognizer.ShouldReceiveTouch = OnShouldReceiveTouch;
			uiTapGestureRecognizer.DelaysTouchesBegan =
				uiTapGestureRecognizer.DelaysTouchesEnded = uiTapGestureRecognizer.CancelsTouchesInView = false;
			View.AddGestureRecognizer(uiTapGestureRecognizer);

			UpdateBackground();

			_packager = new VisualElementPackager(this);
			_packager.Load();

			Element.PropertyChanged += OnHandlePropertyChanged;
			_tracker = new VisualElementTracker(this);

			_events = new EventTracker(this);
			_events.LoadEvents(View);

			Element.SendViewInitialized(View);
		}
Beispiel #3
0
		protected override void Dispose(bool disposing)
		{
			if (disposing && !_disposed)
			{
				Element.PropertyChanged -= OnHandlePropertyChanged;
				Platform.SetRenderer(Element, null);
				if (_appeared)
					((Page)Element).SendDisappearing();

				_appeared = false;

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

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

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

				Element = null;
				_disposed = true;
			}

			base.Dispose(disposing);
		}
Beispiel #4
0
        public void SetElement(VisualElement element)
        {
            _requestedScroll = null;
            var oldElement = Element;

            Element = element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= HandlePropertyChanged;
                ((ScrollView)oldElement).ScrollToRequested -= OnScrollToRequested;
            }

            if (element != null)
            {
                element.PropertyChanged += HandlePropertyChanged;
                ((ScrollView)element).ScrollToRequested += OnScrollToRequested;
                if (_packager == null)
                {
                    _packager = new VisualElementPackager(this);
                    _packager.Load();

                    _tracker = new VisualElementTracker(this);
                    _tracker.NativeControlUpdated += OnNativeControlUpdated;
                    _events = new EventTracker(this);
                    _events.LoadEvents(this);


                    _insetTracker = new KeyboardInsetTracker(this, () => Window, insets =>
                    {
                        ContentInset = ScrollIndicatorInsets = insets;
                    },
                                                             point =>
                    {
                        var offset = ContentOffset;
                        offset.Y  += point.Y;
                        SetContentOffset(offset, true);
                    }, this);
                }

                UpdateDelaysContentTouches();
                UpdateContentSize();
                UpdateBackgroundColor();
                UpdateBackground();
                UpdateIsEnabled();
                UpdateVerticalScrollBarVisibility();
                UpdateHorizontalScrollBarVisibility();

                OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

                EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

                if (element != null)
                {
                    element.SendViewInitialized(this);
                }

                if (!string.IsNullOrEmpty(element.AutomationId))
                {
                    AccessibilityIdentifier = element.AutomationId;
                }
            }
        }