Example #1
0
        protected virtual void OnElementChanged(ElementChangedEventArgs <RadioButton> e)
        {
            if (e.NewElement != null && !_isDisposed)
            {
                this.EnsureId();

                _textColorSwitcher = new Lazy <TextColorSwitcher>(
                    () => new TextColorSwitcher(TextColors, e.NewElement.UseLegacyColorManagement()));

                UpdateFont();
                UpdateTextColor();
                UpdateInputTransparent();
                UpdateBackgroundColor();
                UpdateIsChecked();
                UpdateContent();
                ElevationHelper.SetElevation(this, e.NewElement);
            }

            ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement));
        }
        //todo: make virtual when unsealed
        void OnElementChanged(ElementChangedEventArgs <MediaElement> e)
        {
            if (e.OldElement != null)
            {
            }

            if (e.NewElement != null)
            {
                this.EnsureId();

                UpdateKeepScreenOn();
                UpdateLayoutParameters();
                UpdateShowPlaybackControls();
                UpdateSource();
                UpdateBackgroundColor();

                ElevationHelper.SetElevation(this, e.NewElement);
            }

            ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement));
        }
Example #3
0
        void EnsureChildOrder(bool onlyUpdateElevations)
        {
            float elevationToSet = 0;

            for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
            {
                Element child   = ElementController.LogicalChildren[i];
                var     element = (VisualElement)child;
                if (element != null)
                {
                    IVisualElementRenderer r = Platform.GetRenderer(element);
                    if (r != null)
                    {
                        if (Forms.IsLollipopOrNewer)
                        {
                            var elevation        = ElevationHelper.GetElevation(r.View) ?? 0;
                            var elementElevation = ElevationHelper.GetElevation(element, r.View.Context);

                            if (elementElevation == null)
                            {
                                if (elevation > elevationToSet)
                                {
                                    elevationToSet = elevation;
                                }

                                if (r.View.Elevation != elevationToSet)
                                {
                                    r.View.Elevation = elevationToSet;
                                }
                            }
                        }

                        if (!onlyUpdateElevations)
                        {
                            (_renderer.View as ViewGroup)?.BringChildToFront(r.View);
                        }
                    }
                }
            }
        }
Example #4
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);
        }