Esempio n. 1
0
        protected override EvasObject OnGetContent(Cell cell, string part)
        {
            if (part == ImagePart)
            {
                var imgCell   = cell as ImageCell;
                int pixelSize = Forms.ConvertToScaledPixel(imgCell.RenderHeight);
                if (pixelSize <= 0)
                {
                    pixelSize = this.GetDefaultHeightPixel();
                }

                var image = new Native.Image(Forms.NativeParent)
                {
                    MinimumWidth  = pixelSize,
                    MinimumHeight = pixelSize
                };
                image.SetAlignment(-1.0, -1.0);            // fill
                image.SetWeight(1.0, 1.0);                 // expand

                var task = image.LoadFromImageSourceAsync(imgCell.ImageSource);
                return(image);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
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);
 }
Esempio n. 3
0
        EvasObject GetImageIcon(EvasObject parent)
        {
            var image = new Native.Image(parent);

            _ = image.LoadFromImageSourceAsync(s_currentDragStateData.DataPackage.Image);
            return(image);
        }
        void Initialize(EvasObject parent)
        {
            _menu = new GenList(parent)
            {
                BackgroundColor = EColor.Transparent,
                Style           = "solid/default",
            };

            _menu.ItemSelected += (s, e) =>
            {
                _flyoutMenu.TryGetValue(e.Item.Data as Item, out Element element);

                SelectedItemChanged?.Invoke(this, new SelectedItemChangedEventArgs(element, -1));
            };

            _menu.Show();
            PackEnd(_menu);

            _defaultClass = new GenItemClass("double_label")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return(((Item)obj).Title);
                    }
                    else
                    {
                        return(null);
                    }
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon")
                    {
                        var icon = ((Item)obj).Icon;
                        if (icon != null)
                        {
                            var image = new Native.Image(parent)
                            {
                                MinimumWidth  = Forms.ConvertToScaledPixel(24),
                                MinimumHeight = Forms.ConvertToScaledPixel(24)
                            };
                            var result = image.LoadFromImageSourceAsync(icon);
                            return(image);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            };
        }
Esempio n. 5
0
 Native.Image GetSearchHandlerIcon(ImageSource source)
 {
     Native.Image _icon = new Native.Image(Forms.NativeParent);
     if (source != null)
     {
         var task = _icon.LoadFromImageSourceAsync(source);
     }
     return(_icon);
 }
Esempio n. 6
0
        public Task <bool> LoadImageAsync(Native.Image image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
        {
            var urisource = imageSource as UriImageSource;

            if (urisource != null && urisource.Uri != null)
            {
                return(image.LoadAsync(urisource.Uri, cancelationToken));
            }

            return(Task.FromResult <bool>(false));
        }
        void InitializeTabsItem(EToolbarItem item, string resource)
        {
            //The source of icon resources is https://materialdesignicons.com/
            ImageSource src = ImageSource.FromResource(resource, typeof(ShellItemRenderer).GetTypeInfo().Assembly);

            Native.Image icon = new Native.Image(Forms.NativeParent);
            var          task = icon.LoadFromImageSourceAsync(src);

            item.SetPartContent("elm.swallow.icon", icon);
            item.SetPartColor("bg", _backgroudColor);
            item.SetPartColor("underline", EColor.Transparent);
        }
Esempio n. 8
0
        public Task <bool> LoadImageAsync(Native.Image image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
        {
            var filesource = imageSource as FileImageSource;

            if (filesource != null)
            {
                string file = filesource.File;
                if (!string.IsNullOrEmpty(file))
                {
                    return(image.LoadAsync(ResourcePath.GetPath(file), cancelationToken));
                }
            }
            return(Task.FromResult <bool>(false));
        }
        Native.Button GetToolbarButton(ToolbarButtonPosition position)
        {
            ToolbarItem item = _toolbarTracker.ToolbarItems.Where(
                i => (position == ToolbarButtonPosition.Right && i.Order <= ToolbarItemOrder.Primary) ||
                (position == ToolbarButtonPosition.Left && i.Order == ToolbarItemOrder.Secondary))
                               .OrderBy(i => i.Priority).FirstOrDefault();

            if (item == default(ToolbarItem))
            {
                return(null);
            }

            Native.Button button = new Native.Button(Forms.NativeParent);
            button.Clicked += (s, e) =>
            {
                IMenuItemController control = item;
                control.Activate();
            };
            button.Text            = item.Text;
            button.BackgroundColor = Color.Transparent.ToNative();

            if (string.IsNullOrEmpty(item.Icon))
            {
                if (string.IsNullOrEmpty(item.Text))
                {
                    // We assumed the default toolbar icon is "naviframe/drawer" if there are no icon and text.
                    button.Style = StyleDefaultToolbarIcon;
                }
                else
                {
                    if (position == ToolbarButtonPosition.Right)
                    {
                        button.Style = StyleRightToolbarButton;
                    }
                    else
                    {
                        button.Style = StyleLeftToolBarButton;
                    }
                }
            }
            else
            {
                Native.Image iconImage = new Native.Image(Forms.NativeParent);
                var          task      = iconImage.LoadFromImageSourceAsync(item.Icon);
                button.Image = iconImage;
            }

            return(button);
        }
Esempio n. 10
0
        public async Task <bool> LoadImageAsync(Native.Image image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
        {
            var streamsource = imageSource as StreamImageSource;

            if (streamsource != null && streamsource.Stream != null)
            {
                using (var streamImage = await((IStreamImageSource)streamsource).GetStreamAsync(cancelationToken))
                {
                    if (streamImage != null)
                    {
                        return(await image.LoadAsync(streamImage, cancelationToken));
                    }
                }
            }
            return(false);
        }
Esempio n. 11
0
        void CreateMoreToolbarItem()
        {
            if (_moreToolbarItem != null)
            {
                return;
            }

            //The source of icon resources is https://materialdesignicons.com/
            ImageSource src = ImageSource.FromResource("Xamarin.Forms.Platform.Tizen.Resource.dots_horizontal.png", typeof(ShellItemRenderer).GetTypeInfo().Assembly);

            Native.Image icon = new Native.Image(Forms.NativeParent);
            var          task = icon.LoadFromImageSourceAsync(src);

            _moreToolbarItem = _toolbar.Append("More", null);
            _moreToolbarItem.SetPartContent("elm.swallow.icon", icon);
            _moreToolbarItem.SetPartColor("bg", _backgroudColor);
            _moreToolbarItem.SetPartColor("underline", EColor.Transparent);
            _toolbarItemList.AddLast(_moreToolbarItem);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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;
        }