예제 #1
0
        EvasObject GetDefaultIcon(EvasObject parent)
        {
            if (!string.IsNullOrEmpty(s_currentDragStateData.DataPackage.Text))
            {
                var label = new Native.Label(parent);
                label.Text = s_currentDragStateData.DataPackage.Text;

                if (Renderer.Element is Label lb)
                {
                    label.FontSize = lb.FontSize;
                }
                else if (Renderer.Element is Entry et)
                {
                    label.FontSize = et.FontSize;
                }
                else if (Renderer.Element is Editor ed)
                {
                    label.FontSize = ed.FontSize;
                }

                return(label);
            }
            else
            {
                var box = new ElmSharp.Rectangle(parent);
                box.Color = new ElmSharp.Color(128, 128, 128, 128);
                return(box);
            }
        }
예제 #2
0
        public ShellNavBar() : base(Forms.NativeParent)
        {
            SetLayoutCallback(OnLayout);

            _menuButton          = new EButton(Forms.NativeParent);
            _menuButton.Clicked += OnMenuClicked;
            _menuIcon            = new EImage(Forms.NativeParent);
            UpdateMenuIcon();
            _menuIcon.Show();
            _menuButton.Show();

            _menuButton.SetIconPart(_menuIcon);

            _title = new Native.Label(Forms.NativeParent)
            {
                FontSize = this.GetDefaultTitleFontSize(),
                VerticalTextAlignment = Native.TextAlignment.Center,
                TextColor             = _titleColor,
                FontAttributes        = FontAttributes.Bold,
            };
            _title.Show();

            BackgroundColor             = _backgroudColor;
            _menuButton.BackgroundColor = _backgroudColor;
            PackEnd(_menuButton);
            PackEnd(_title);
        }
예제 #3
0
        public ShellNavBar(IFlyoutController flyoutController) : base(Forms.NativeParent)
        {
            _flyoutController = flyoutController;

            _menuButton          = new EButton(Forms.NativeParent);
            _menuButton.Clicked += OnMenuClicked;
            _menu = new EImage(Forms.NativeParent);
            UpdateMenuIcon();
            _menu.Show();
            _menuButton.Show();

            _menuButton.SetPartContent("icon", _menu);

            _title = new Native.Label(Forms.NativeParent)
            {
                FontSize = Device.Idiom == TargetIdiom.TV ? 60 : 23,
                VerticalTextAlignment = Native.TextAlignment.Center,
                TextColor             = _backgroudColor,
                FontAttributes        = FontAttributes.Bold,
            };
            _title.Show();

            BackgroundColor             = _backgroudColor;
            _menuButton.BackgroundColor = _backgroudColor;
            PackEnd(_menuButton);
            PackEnd(_title);
            LayoutUpdated += OnLayoutUpdated;
        }
예제 #4
0
        EvasObject GetContent(object data, string part)
        {
            ShellSection section = data as ShellSection;

            var box = new EBox(Forms.NativeParent);

            box.Show();

            EImage icon = null;

            if (section.Icon != null)
            {
                icon = new EImage(Forms.NativeParent);
                icon.Show();
                box.PackEnd(icon);
                _ = icon.LoadFromImageSourceAsync(section.Icon);
            }

            var title = new Native.Label(Forms.NativeParent)
            {
                Text     = section.Title,
                FontSize = Forms.ConvertToEflFontPoint(14),
                HorizontalTextAlignment = Native.TextAlignment.Start,
                VerticalTextAlignment   = Native.TextAlignment.Center,
            };

            title.Show();
            box.PackEnd(title);
            int iconPadding = Forms.ConvertToScaledPixel(this.GetIconPadding());
            int iconSize    = Forms.ConvertToScaledPixel(this.GetIconSize());
            int cellHeight  = iconPadding * 2 + iconSize;

            box.SetLayoutCallback(() =>
            {
                var bound      = box.Geometry;
                int leftMargin = iconPadding;

                if (icon != null)
                {
                    var iconBound    = bound;
                    iconBound.X     += iconPadding;
                    iconBound.Y     += iconPadding;
                    iconBound.Width  = iconSize;
                    iconBound.Height = iconSize;
                    icon.Geometry    = iconBound;
                    leftMargin       = (2 * iconPadding + iconSize);
                }

                bound.X       += leftMargin;
                bound.Width   -= leftMargin;
                title.Geometry = bound;
            });

            box.MinimumHeight = cellHeight;
            return(box);
        }
예제 #5
0
        EvasObject GetContent(object data, string part)
        {
            ShellSection section = data as ShellSection;

            var box = new Native.Box(Forms.NativeParent);

            box.Show();

            var icon = new Native.Image(Forms.NativeParent)
            {
                MinimumWidth  = Forms.ConvertToScaledPixel(44),
                MinimumHeight = Forms.ConvertToScaledPixel(27)
            };
            var task = icon.LoadFromImageSourceAsync(section.Icon);

            icon.Show();

            var title = new Native.Label(Forms.NativeParent)
            {
                Text     = section.Title,
                FontSize = Forms.ConvertToEflFontPoint(14),
                HorizontalTextAlignment = Native.TextAlignment.Start,
                VerticalTextAlignment   = Native.TextAlignment.Center
            };

            title.Show();

            box.PackEnd(icon);
            box.PackEnd(title);
            box.LayoutUpdated += (object sender, LayoutEventArgs e) =>
            {
                icon.Move(e.Geometry.X + _iconPadding, e.Geometry.Y + _iconPadding);
                icon.Resize(_iconSize, _iconSize);

                title.Move(e.Geometry.X + 2 * _iconPadding + _iconSize, e.Geometry.Y);
                title.Resize(e.Geometry.Width - (2 * _iconPadding + _iconSize), e.Geometry.Height);
            };
            box.MinimumHeight = _cellHeight;
            return(box);
        }