Example #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);
            }
        }
Example #2
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);
        }
Example #3
0
        public ShellNavBar() : base(Forms.NativeParent)
        {
            SetLayoutCallback(OnLayout);

            _menuButton          = new EButton(Forms.NativeParent);
            _menuButton.Clicked += OnMenuClicked;

            _menuIcon = new EImage(Forms.NativeParent);
            UpdateMenuIcon();

            _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);
        }