コード例 #1
0
        void OnLayout()
        {
            // Page layout was updated on base class
            // It only update ActionButton

            var content = (Element as IElementController).LogicalChildren.FirstOrDefault();

            if (content == null)
            {
                return;
            }

            var topmostView = Platform.GetRenderer(content)?.NativeView;

            var bound = Control.Geometry;

            if (_actionButton != null)
            {
                var btnRect = _actionButton.Geometry;
                var btnW    = Math.Max(_actionButton.MinimumWidth, btnRect.Width);
                var btnH    = Math.Max(_actionButton.MinimumHeight, btnRect.Height);
                var btnX    = bound.X + (bound.Width - btnW) / 2;
                var btnY    = bound.Y + bound.Height - btnH;
                _actionButton.Geometry = new ERect(btnX, btnY, btnW, btnH);
                _actionButton.StackAbove(topmostView);
                topmostView = _actionButton;
            }

            _surfaceLayout.Geometry = bound;
            _surfaceLayout.StackAbove(topmostView);
        }
コード例 #2
0
        protected override void OnAttached()
        {
            var rect = Control.Geometry;

            _surfaceLayout = new ElmSharp.Layout(Container);
            _surfaceLayout.Show();
            _surface = new ElmSharp.Wearable.CircleSurface(_surfaceLayout);
            _surfaceLayout.Geometry = rect;
            _surfaceLayout.StackAbove(Control);

            CircleSurfaceEffectBehavior.SetSurface(Element, _surface);

            _showEvent    = new EvasObjectEvent(Control, EvasObjectCallbackType.Show);
            _hideEvent    = new EvasObjectEvent(Control, EvasObjectCallbackType.Hide);
            _restackEvent = new EvasObjectEvent(Control, EvasObjectCallbackType.Restack);
            _moveEvent    = new EvasObjectEvent(Control, EvasObjectCallbackType.Move);
            _resizeEvent  = new EvasObjectEvent(Control, EvasObjectCallbackType.Resize);

            _showEvent.On    += ControlShowed;
            _hideEvent.On    += ControlHided;
            _restackEvent.On += ControlRestacked;
            _moveEvent.On    += ControlChanged;
            _resizeEvent.On  += ControlChanged;

            Element.PropertyChanging += ElementPropertyChanging;
            Element.PropertyChanged  += ElementPropertyChanged;

            EcoreMainloop.Post(() =>
            {
                var obj = CircleSurfaceEffectBehavior.GetRotaryFocusObject(Element);
                ActivateRotaryFocusable(obj);
            });
        }
コード例 #3
0
 void ControlRestacked(object sender, EventArgs e)
 {
     _surfaceLayout.StackAbove(Control);
 }
コード例 #4
0
        void InitializeComponent()
        {
            _outterBox.SetLayoutCallback(OnLayout);

            _surfaceLayout = new ELayout(this);
            _surfaceLayout.Show();
            _surface = new CircleSurface(_surfaceLayout);

            _naviMenu = new CircleGenList(this, _surface)
            {
                Homogeneous     = true,
                BackgroundColor = ElmSharp.Color.Gray
            };
            _naviMenu.Show();

            _draggedUpCallback     = new SmartEvent(_naviMenu, "drag,start,up");
            _draggedUpCallback.On += (s, e) =>
            {
                if (_footer.TrackObject.IsVisible)
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.EdgeBottom));
                }
                else
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.Up));
                }
            };

            _draggedDownCallback     = new SmartEvent(_naviMenu, "drag,start,down");
            _draggedDownCallback.On += (s, e) =>
            {
                if (_header.TrackObject.IsVisible)
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.EdgeTop));
                }
                else
                {
                    Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.Down));
                }
            };

            _outterBox.PackEnd(_naviMenu);
            _outterBox.PackEnd(_surfaceLayout);

            _surfaceLayout.StackAbove(_naviMenu);

            _defaultClass = new GenItemClass("1icon_1text")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return((obj as Item).Text);
                    }
                    return(null);
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon" && obj is Item menuItem && !string.IsNullOrEmpty(menuItem.Icon))
                    {
                        var icon = new ElmSharp.Image(Xamarin.Forms.Forms.NativeParent)
                        {
                            AlignmentX    = -1,
                            AlignmentY    = -1,
                            WeightX       = 1.0,
                            WeightY       = 1.0,
                            MinimumWidth  = _dafaultIconSize,
                            MinimumHeight = _dafaultIconSize,
                        };
                        icon.Show();
                        icon.Load(menuItem.Icon);
                        return(icon);
                    }
                    return(null);
                }
            };

            _naviMenu.ItemSelected += OnItemSelected;
        }

        void OnItemSelected(object sender, GenListItemEventArgs e)
        {
            ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs((e.Item.Data as Item).Source, -1));
        }

        void OnLayout()
        {
            _surfaceLayout.Geometry = Geometry;
            _naviMenu.Geometry      = Geometry;
        }

        bool IsUpdated(List <List <Element> > items)
        {
            if (_itemCache == null)
            {
                return(true);
            }

            if (_itemCache.Count != items.Count)
            {
                return(true);
            }

            for (int i = 0; i < items.Count; i++)
            {
                if (_itemCache[i].Count != items[i].Count)
                {
                    return(true);
                }

                for (int j = 0; j < items[i].Count; j++)
                {
                    if (_itemCache[i][j] != items[i][j])
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
    }