/// <summary>
        /// Setup our SwipeRefreshLayout and register for property changed notifications.
        /// </summary>
        /// <param name="element">Element.</param>
        public void SetElement(VisualElement element)
        {
            var oldElement = Element;

            //unregister old and re-register new
            if (oldElement != null)
                oldElement.PropertyChanged -= HandlePropertyChanged;

            Element = element;
            if (Element != null)
            {
                UpdateContent();
                Element.PropertyChanged += HandlePropertyChanged;
            }

            if (!init)
            {
                init = true;
                //sizes to match the forms view
                //updates properties, handles visual element properties
                Tracker = new VisualElementTracker(this);
                SetOnRefreshListener(this);
            }

            UpdateColors();
            UpdateIsRefreshing();
            UpdateIsSwipeToRefreshEnabled();

            if (ElementChanged != null)
                ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element));
        }
		public void SetElement(VisualElement element)
		{
			ScrollView oldElement = _view;
			_view = (ScrollView)element;

			if (oldElement != null)
			{
				oldElement.PropertyChanged -= HandlePropertyChanged;
				((IScrollViewController)oldElement).ScrollToRequested -= OnScrollToRequested;
			}
			if (element != null)
			{
				OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

				if (_container == null)
				{
					Tracker = new VisualElementTracker(this);
					_container = new ScrollViewContainer(_view, Forms.Context);
				}

				_view.PropertyChanged += HandlePropertyChanged;
				Controller.ScrollToRequested += OnScrollToRequested;

				LoadContent();
				UpdateBackgroundColor();

				UpdateOrientation();

				element.SendViewInitialized(this);

				if (!string.IsNullOrEmpty(element.AutomationId))
					ContentDescription = element.AutomationId;
			}
		}
    public void SetElement (VisualElement element)
    {
      var oldElement = this.Element;

      if (oldElement != null)
        oldElement.PropertyChanged -= HandlePropertyChanged;

      this.Element = element;
      if (this.Element != null) {
        //UpdateContent ();
        this.Element.PropertyChanged += HandlePropertyChanged;
      }

      ViewGroup.RemoveAllViews ();
      //sizes to match the forms view
      //updates properties, handles visual element properties
      Tracker = new VisualElementTracker (this);

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

      UseCompatPadding = true;

      SetContentPadding ((int)TheView.Padding.Left, (int)TheView.Padding.Top,
        (int)TheView.Padding.Right, (int)TheView.Padding.Bottom);

      Radius = TheView.CornderRadius;
 
      this.SetCardBackgroundColor(TheView.BackgroundColor.ToAndroid ());
                
                

               
          

      if (ElementChanged != null)
        ElementChanged (this, new VisualElementChangedEventArgs (oldElement, this.Element));
    }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

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

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

                Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;

                if (_page != null)
                {
                    MasterDetailPageController.BackButtonPressed -= OnBackButtonPressed;
                    _page.PropertyChanged -= HandlePropertyChanged;
                    _page.Appearing       -= MasterDetailPageAppearing;
                    _page.Disappearing    -= MasterDetailPageDisappearing;
                    _page.ClearValue(Platform.RendererProperty);
                    _page = null;
                }
            }

            base.Dispose(disposing);
        }
		/// <summary>
		/// Setup our SwipeRefreshLayout and register for property changed notifications.
		/// </summary>
		/// <param name="element">Element.</param>
		public void SetElement (VisualElement element)
		{
			var oldElement = this.Element;

			//unregister old and re-register new
			if (oldElement != null)
				oldElement.PropertyChanged -= HandlePropertyChanged;

			this.Element = element;
			if (this.Element != null) {
				UpdateContent ();
				this.Element.PropertyChanged += HandlePropertyChanged;
			}

			if (!init) {
				init = true;
				//sizes to match the forms view
				//updates properties, handles visual element properties
				Tracker = new VisualElementTracker (this);
				//add and remove children automatically
				//this is broken right now so I do it manually, but might
				//be fixed in the future.
				//packager = new VisualElementPackager (this);
				//packager.Load ();

				//TODO: this is hardcoded for now via resources, but could be bindable.
				SetColorSchemeResources (Resource.Color.xam_dark_blue,
					Resource.Color.xam_purple,
					Resource.Color.xam_gray,
					Resource.Color.xam_green);

				this.SetOnRefreshListener (this);
			}

			if(ElementChanged != null)
				ElementChanged (this, new VisualElementChangedEventArgs (oldElement, this.Element));
		}
Beispiel #6
0
        public void SetElement(VisualElement element)
        {
            ScrollView oldElement = _view;

            _view = (ScrollView)element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= HandlePropertyChanged;
                ((IScrollViewController)oldElement).ScrollToRequested -= OnScrollToRequested;
            }
            if (element != null)
            {
                OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

                if (_container == null)
                {
                    Tracker    = new VisualElementTracker(this);
                    _container = new ScrollViewContainer(_view, Forms.Context);
                }

                _view.PropertyChanged        += HandlePropertyChanged;
                Controller.ScrollToRequested += OnScrollToRequested;

                LoadContent();
                UpdateBackgroundColor();

                UpdateOrientation();

                element.SendViewInitialized(this);

                if (!string.IsNullOrEmpty(element.AutomationId))
                {
                    ContentDescription = element.AutomationId;
                }
            }
        }
Beispiel #7
0
        void SetUpNewElement(IndicatorView newElement)
        {
            if (newElement == null)
            {
                IndicatorsView = null;
                return;
            }

            IndicatorsView = newElement;

            IndicatorsView.PropertyChanged += OnElementPropertyChanged;

            if (Tracker == null)
            {
                _visualElementTracker = new VisualElementTracker(this);
                //_visualElementPackager = new VisualElementPackager(this);
                //_visualElementPackager.Load();
            }

            this.EnsureId();

            UpdateBackgroundColor();

            if (IndicatorsView.IndicatorTemplate != null)
            {
                var control = IndicatorsView.IndicatorLayout.GetRenderer() ?? Platform.CreateRendererWithContext(IndicatorsView.IndicatorLayout, Context);
                Platform.SetRenderer(IndicatorsView.IndicatorLayout, control);
                AddView(control as AView);
            }
            else
            {
                UpdateItemsSource();
            }

            ElevationHelper.SetElevation(this, newElement);
        }
Beispiel #8
0
 protected void SetTracker(VisualElementTracker tracker)
 {
     Tracker = tracker;
 }
Beispiel #9
0
        public void SetElement(VisualElement element)
        {
            MasterDetailPage oldElement = _page;

            _page = element as MasterDetailPage;

            _detailLayout = new MasterDetailContainer(_page, false, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
            };

            _masterLayout = new MasterDetailContainer(_page, true, Context)
            {
                LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
                {
                    Gravity = (int)GravityFlags.Start
                }
            };

            AddView(_detailLayout);

            AddView(_masterLayout);

            var activity = Context as Activity;

            activity.ActionBar.SetDisplayShowHomeEnabled(true);
            activity.ActionBar.SetHomeButtonEnabled(true);

            UpdateBackgroundColor(_page);
            UpdateBackgroundImage(_page);

            OnElementChanged(oldElement, element);

            if (oldElement != null)
            {
                ((IMasterDetailPageController)oldElement).BackButtonPressed -= OnBackButtonPressed;
            }

            if (_page != null)
            {
                MasterDetailPageController.BackButtonPressed += OnBackButtonPressed;
            }

            if (Tracker == null)
            {
                Tracker = new VisualElementTracker(this);
            }

            _page.PropertyChanged += HandlePropertyChanged;
            _page.Appearing       += MasterDetailPageAppearing;
            _page.Disappearing    += MasterDetailPageDisappearing;

            UpdateMaster();
            UpdateDetail();

            Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
            SetGestureState();

            Presented = _page.IsPresented;

            AddDrawerListener(this);

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

            if (element != null && !string.IsNullOrEmpty(element.AutomationId))
            {
                ContentDescription = element.AutomationId;
            }
        }
Beispiel #10
0
        void IVisualElementRenderer.SetElement(VisualElement element)
        {
            FlyoutPage oldElement = Element;
            FlyoutPage newElement = Element = element as FlyoutPage;

            if (oldElement != null)
            {
                Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;

                ((IFlyoutPageController)oldElement).BackButtonPressed -= OnBackButtonPressed;

                oldElement.PropertyChanged -= HandlePropertyChanged;
                oldElement.Appearing       -= FlyoutPageAppearing;
                oldElement.Disappearing    -= FlyoutPageDisappearing;

                RemoveDrawerListener(this);

                if (_detailLayout != null)
                {
                    RemoveView(_detailLayout);
                }

                if (_flyoutLayout != null)
                {
                    RemoveView(_flyoutLayout);
                }
            }

            if (newElement != null)
            {
                if (_detailLayout == null)
                {
                    _detailLayout = new FlyoutPageContainer(newElement, false, Context)
                    {
                        LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
                    };

                    _flyoutLayout = new FlyoutPageContainer(newElement, true, Context)
                    {
                        LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
                        {
                            Gravity = (int)GravityFlags.Start
                        }
                    };

                    if (_fragmentManager != null)
                    {
                        _detailLayout.SetFragmentManager(_fragmentManager);
                        _flyoutLayout.SetFragmentManager(_fragmentManager);
                    }

                    AddView(_detailLayout);
                    AddView(_flyoutLayout);

                    Device.Info.PropertyChanged += DeviceInfoPropertyChanged;

                    AddDrawerListener(this);
                }

                UpdateBackgroundColor(newElement);
                UpdateBackgroundImage(newElement);

                UpdateFlyout();
                UpdateDetail();

                UpdateFlowDirection();

                ((IFlyoutPageController)newElement).BackButtonPressed += OnBackButtonPressed;
                newElement.PropertyChanged += HandlePropertyChanged;
                newElement.Appearing       += FlyoutPageAppearing;
                newElement.Disappearing    += FlyoutPageDisappearing;

                SetGestureState();

                Presented = newElement.IsPresented;

                newElement.SendViewInitialized(this);
            }

            OnElementChanged(oldElement, newElement);

            // Make sure to initialize this AFTER event is fired
            if (_tracker == null)
            {
                _tracker = new VisualElementTracker(this);
            }

            if (element != null && !string.IsNullOrEmpty(element.AutomationId))
            {
                SetAutomationId(element.AutomationId);
            }

            SetContentDescription();
        }
 void SetTracker(VisualElementTracker tracker)
 {
     _tracker = tracker;
 }
		public void SetElement(VisualElement element)
		{
			MasterDetailPage oldElement = _page;
			_page = element as MasterDetailPage;

			_detailLayout = new MasterDetailContainer(_page, false, Context) { LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) };

			_masterLayout = new MasterDetailContainer(_page, true, Context)
			{
				LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = (int)GravityFlags.Start }
			};

			AddView(_detailLayout);

			AddView(_masterLayout);

			var activity = Context as Activity;
			activity.ActionBar.SetDisplayShowHomeEnabled(true);
			activity.ActionBar.SetHomeButtonEnabled(true);

			UpdateBackgroundColor(_page);
			UpdateBackgroundImage(_page);

			OnElementChanged(oldElement, element);

			if (oldElement != null)
				((IMasterDetailPageController)oldElement).BackButtonPressed -= OnBackButtonPressed;

			if (_page != null)
				MasterDetailPageController.BackButtonPressed += OnBackButtonPressed;

			if (Tracker == null)
				Tracker = new VisualElementTracker(this);

			_page.PropertyChanged += HandlePropertyChanged;
			_page.Appearing += MasterDetailPageAppearing;
			_page.Disappearing += MasterDetailPageDisappearing;

			UpdateMaster();
			UpdateDetail();

			Device.Info.PropertyChanged += DeviceInfoPropertyChanged;
			SetGestureState();

			Presented = _page.IsPresented;

			AddDrawerListener(this);

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

			if (element != null && !string.IsNullOrEmpty(element.AutomationId))
				ContentDescription = element.AutomationId;
		}
Beispiel #13
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 (_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 as IElementController).EffectControlProvider = null;

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }