string GetIconPath(ImageSource src)
 {
     if (src is FileImageSource fis)
     {
         return(ResourcePath.GetPath(fis.File));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        void UpdateBackgroundImage(bool initiaize)
        {
            if (initiaize && string.IsNullOrWhiteSpace(Element.BackgroundImage))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(Element.BackgroundImage))
            {
                _page.File = null;
            }
            else
            {
                _page.File = ResourcePath.GetPath(Element.BackgroundImage);
            }
        }
Ejemplo n.º 4
0
        protected virtual FormsMoreOptionItem CreateMoreOptionItem(ToolbarItem item)
        {
            var moreOptionItem = new FormsMoreOptionItem
            {
                MainText    = item.Text,
                ToolbarItem = item
            };
            var icon = item.IconImageSource as FileImageSource;

            if (icon != null)
            {
                var img = new ElmSharp.Image(_moreOption.Value);
                img.Load(ResourcePath.GetPath(icon));
                moreOptionItem.Icon = img;
            }
            return(moreOptionItem);
        }
Ejemplo n.º 5
0
        void UpdateBackgroundImage(bool initialize)
        {
            if (initialize && Element.BackgroundImageSource.IsNullOrEmpty())
            {
                return;
            }

            // TODO: investigate if we can use the other image source types: stream, font, uri

            var bgImage = Element.BackgroundImageSource as FileImageSource;

            if (bgImage.IsNullOrEmpty())
            {
                _page.File = null;
            }
            else
            {
                _page.File = ResourcePath.GetPath(bgImage);
            }
        }
        EToolbarItem AddToolbarItem(Page newItem, int index)
        {
            EToolbarItem toolbarItem;

            if (index == 0)
            {
                toolbarItem = _toolbar.Prepend(newItem.Title, string.IsNullOrEmpty(newItem.Icon) ? null : ResourcePath.GetPath(newItem.Icon));
            }
            else
            {
                toolbarItem = _toolbar.InsertAfter(_toolbarItemList[index - 1], newItem.Title, string.IsNullOrEmpty(newItem.Icon) ? null : ResourcePath.GetPath(newItem.Icon));
            }
            _toolbarItemList.Insert(index, toolbarItem);
            _itemToItemPage.Add(toolbarItem, newItem);

            if (Element.BarBackgroundColor != Color.Default)
            {
                toolbarItem.SetPartColor("bg", _toolbar.BackgroundColor);
            }

            var childContent = Platform.GetOrCreateRenderer(newItem).NativeView;

            _innerBox.PackEnd(childContent);

            newItem.PropertyChanged += OnPageTitleChanged;

            return(toolbarItem);
        }