protected override EvasObject OnGetContent(Cell cell, string part) { if (part == ImagePart) { var imgCell = cell as ImageCell; int pixelSize = System.Maui.Maui.ConvertToScaledPixel(imgCell.RenderHeight); if (pixelSize <= 0) { pixelSize = System.Maui.Maui.ConvertToPixel(_defaultHeight); } var image = new Native.Image(System.Maui.Maui.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); } }
Native.Image GetSearchHandlerIcon(ImageSource source) { Native.Image _icon = new Native.Image(System.Maui.Maui.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(System.Maui.Maui.NativeParent); var task = icon.LoadFromImageSourceAsync(src); item.SetPartContent("elm.swallow.icon", icon); item.SetPartColor("bg", _backgroudColor); item.SetPartColor("underline", EColor.Transparent); }
EvasObject GetContent(object data, string part) { ShellSection section = data as ShellSection; var box = new Native.Box(System.Maui.Maui.NativeParent); box.Show(); var icon = new Native.Image(System.Maui.Maui.NativeParent) { MinimumWidth = System.Maui.Maui.ConvertToScaledPixel(44), MinimumHeight = System.Maui.Maui.ConvertToScaledPixel(27) }; var task = icon.LoadFromImageSourceAsync(section.Icon); icon.Show(); var title = new Native.Label(System.Maui.Maui.NativeParent) { Text = section.Title, FontSize = System.Maui.Maui.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); }
async void UpdateSource() { ImageSource source = Element.Source; (Element as IImageController)?.SetIsLoading(true); if (Control != null) { bool success = await _image.LoadFromImageSourceAsync(source); if (!IsDisposed && success) { (Element as IVisualElementController)?.NativeSizeChanged(); UpdateAfterLoading(); } } if (!IsDisposed) { ((IImageController)Element).SetIsLoading(false); } }
void Initialize(EvasObject parent) { _box = new Native.Box(parent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1 }; SetContent(_box); _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(); _box.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 = System.Maui.Maui.ConvertToScaledPixel(24), MinimumHeight = System.Maui.Maui.ConvertToScaledPixel(24) }; var result = image.LoadFromImageSourceAsync(icon); return(image); } else { return(null); } } else { return(null); } } }; }