diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2016-12-16 11:00:07 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-04-24 13:36:43 +0900 |
commit | 18ad8a74707a1b36581f7123be74d2b34510e016 (patch) | |
tree | 92eeac43c2cd01690a321a80e123e957053c4d7d /Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs | |
parent | 80e5482487f8a37d89b620f54f4ff3c12bcc5b83 (diff) | |
download | xamarin-forms-18ad8a74707a1b36581f7123be74d2b34510e016.tar.gz xamarin-forms-18ad8a74707a1b36581f7123be74d2b34510e016.tar.bz2 xamarin-forms-18ad8a74707a1b36581f7123be74d2b34510e016.zip |
Add Tizen backend renderer
- Xamarin.Forms.Platform.Tizen has been added
- Xamarin.Forms.Maps.Tizen has been added
- RPM build spec has been added
Change-Id: I0021e0f040d97345affc87512ee0f6ce437f4e6d
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs new file mode 100644 index 00000000..9492e7c6 --- /dev/null +++ b/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs @@ -0,0 +1,60 @@ +using ElmSharp; +using System.Collections.Generic; + +namespace Xamarin.Forms.Platform.Tizen +{ + public class ImageCellRenderer : TextCellRenderer + { + const int _defaultHeight = 100; + Dictionary<EvasObject, Native.Image> _realizedViews = new Dictionary<EvasObject, Native.Image>(); + + public ImageCellRenderer() : this("type1") + { + ImagePart = "elm.swallow.icon"; + } + protected ImageCellRenderer(string style) : base(style) { } + + protected string ImagePart { get; set; } + + protected override EvasObject OnGetContent(Cell cell, string part) + { + if (part == ImagePart) + { + var imgCell = cell as ImageCell; + var size = imgCell.RenderHeight; + if (size <= 0) + { + size = _defaultHeight; + } + + var image = new Native.Image(Forms.Context.MainWindow) + { + MinimumWidth = (int)size, + MinimumHeight = (int)size + }; + image.SetAlignment(-1.0, -1.0); // fill + image.SetWeight(1.0, 1.0); // expand + + image.LoadFromImageSourceAsync(imgCell.ImageSource); + return image; + } + else + { + return null; + } + } + + protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary<string, EvasObject> realizedView) + { + if (property == ImageCell.ImageSourceProperty.PropertyName) + { + EvasObject image; + realizedView.TryGetValue(ImagePart, out image); + (image as Native.Image)?.LoadFromImageSourceAsync((cell as ImageCell)?.ImageSource); + return false; + } + return base.OnCellPropertyChanged(cell, property, realizedView); + } + + } +} |