Пример #1
0
 protected override void OnElementChanged(ElementChangedEventArgs <ImageButton> e)
 {
     if (Control == null)
     {
         SetNativeControl(new Box(Forms.NativeParent));
         Control.SetLayoutCallback(OnLayout);
         _round = new Native.RoundRectangle(Forms.NativeParent);
         _round.Show();
         _border = new Native.BorderRectangle(Forms.NativeParent);
         _border.Show();
         _image = new Native.Image(Forms.NativeParent);
         _image.Show();
         _button = new EButton(Forms.NativeParent)
         {
             Style = "transparent"
         };
         _button.Clicked  += OnClicked;
         _button.Pressed  += OnPressed;
         _button.Released += OnReleased;
         _button.Show();
         Control.PackEnd(_round);
         Control.PackEnd(_image);
         Control.PackEnd(_border);
         Control.PackEnd(_button);
     }
     base.OnElementChanged(e);
 }
Пример #2
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);
        }
Пример #3
0
        public ShellNavBar(IFlyoutController flyoutController, ShellSectionNavigation shellSectionNavigation) : base(Forms.NativeParent)
        {
            _flyoutController       = flyoutController;
            _shellSectionNavigation = shellSectionNavigation;

            _menu          = new Native.Image(Forms.NativeParent);
            _menu.Clicked += OnMenuClicked;
            UpdateMenuIcon();
            _menu.Show();

            _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;
            PackEnd(_menu);
            PackEnd(_title);
            LayoutUpdated += OnLayoutUpdated;
        }