/// <summary> /// Returns contents of specified part. /// </summary> /// <param name="cell">Multiline cell.</param> /// <param name="part">Part.</param> /// <returns>Eves object in specified part.</returns> protected override EvasObject OnGetContent(Cell cell, string part) { MultilineCell multilineCell = (MultilineCell)cell; if (part == _iconPart && multilineCell.Icon != null) { var image = new NImage(Forms.NativeParent); SetUpImage(multilineCell, image); return(image); } else if (part == _endPart && multilineCell.IsCheckVisible) { var check = new Check(Forms.NativeParent); check.SetAlignment(-1, -1); check.SetWeight(1, 1); check.IsChecked = multilineCell.IsChecked; //It is a temporary way to prevent that the check of the Cell gets focus until the UX about views in the Cell for TV is defined. if (Device.Idiom == TargetIdiom.TV) { check.AllowFocus(false); } return(check); } return(null); }
public Task <bool> LoadImageAsync(NativeImage image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken)) { ImageSource newSource = null; switch (imageSource) { case SKImageImageSource imageImageSource: newSource = ImageSource.FromStream(() => ToStream(imageImageSource.Image)); break; case SKBitmapImageSource bitmapImageSource: newSource = ImageSource.FromStream(() => ToStream(SKImage.FromBitmap(bitmapImageSource.Bitmap))); break; case SKPixmapImageSource pixmapImageSource: newSource = ImageSource.FromStream(() => ToStream(SKImage.FromPixels(pixmapImageSource.Pixmap))); break; case SKPictureImageSource pictureImageSource: newSource = ImageSource.FromStream(() => ToStream(SKImage.FromPicture(pictureImageSource.Picture, pictureImageSource.Dimensions))); break; } return(handler.LoadImageAsync(image, newSource, cancelationToken)); }
/// <summary> /// Returns EvasObject which constitutes the cell /// </summary> /// <param name="cell">Cell</param> /// <param name="part">Cell's style name</param> /// <returns>EvasObject</returns> protected override EvasObject OnGetContent(Cell cell, string part) { MultilineCell multilineCell = (MultilineCell)cell; if (part == _iconPart && multilineCell.Icon != null) { var image = new NImage(Forms.Context.MainWindow); SetUpImage(multilineCell, image); return(image); } else if (part == _endPart && multilineCell.IsCheckVisible) { var check = new Check(Forms.Context.MainWindow) { Style = "toggle" }; check.SetAlignment(-1, -1); check.SetWeight(1, 1); check.IsChecked = multilineCell.IsChecked; check.StateChanged += (sender, e) => { multilineCell.IsChecked = e.NewState; }; return(check); } return(null); }
/// <summary> /// Creates new item with icon. /// </summary> /// <param name="item">New item to set.</param> /// <returns>Item with updated values.</returns> EContextPopupItem AppendOrModifyItemWithIcon(ContextPopupItem item) { EContextPopupItem nativeItem = null; EIcon icon = new EIcon(_popup); icon.StandardIconName = item.Icon; if (!string.IsNullOrEmpty(icon.StandardIconName)) { if (!_items.ContainsKey(item)) { nativeItem = _popup.Append(item.Label, icon); } else { _items[item].SetPartContent("icon", icon); } } else { //Not a standard icon XFPlatformTizen.Native.Image iconImage = new XFPlatformTizen.Native.Image(_popup); var task = iconImage.LoadFromImageSourceAsync(item.Icon); if (!_items.ContainsKey(item)) { nativeItem = _popup.Append(item.Label, iconImage); } else { _items[item].SetPartContent("icon", iconImage); } } return(nativeItem); }
void SetUpImage(BaseTypeCell cell, NImage image) { if (cell.IconHeight > 0 && cell.IconWidth > 0) { image.MinimumWidth = cell.IconWidth; image.MinimumHeight = cell.IconHeight; } else { image.LoadingCompleted += (sender, e) => { image.MinimumWidth = image.ObjectSize.Width; image.MinimumHeight = image.ObjectSize.Height; }; } image.LoadFromImageSourceAsync(cell.Icon); }