示例#1
0
        async void UpdateSource()
        {
            ImageSource source = Element.Source;

            (Element as IImageController)?.SetIsLoading(true);

            if (Control != null)
            {
                bool success;
                if (source is FileImageSource fis)
                {
                    success = _image.LoadFromFile(fis.File);
                }
                else
                {
                    success = await _image.LoadFromImageSourceAsync(source);
                }

                if (!IsDisposed && success)
                {
                    (Element as IVisualElementController)?.NativeSizeChanged();
                    UpdateAfterLoading();
                }
            }

            if (!IsDisposed)
            {
                ((IImageController)Element).SetIsLoading(false);
            }
        }
示例#2
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);
            }
        }
示例#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);
                    }
                }
            };
        }
示例#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);
 }
        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);
        }
        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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
0
 async void UpdateMenuIcon()
 {
     string      file   = _hasBackButton ? _backIcon : _menuIcon;
     ImageSource source = ImageSource.FromResource(file, typeof(ShellNavBar).GetTypeInfo().Assembly);
     bool        ret    = await _menu.LoadFromImageSourceAsync(source);
 }