summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-01-06 15:43:46 +0900
committerKangho Hur <kangho.hur@samsung.com>2017-01-06 15:43:46 +0900
commitf4e3f04d5d689f28997d16cbe62389108e3398b8 (patch)
treee34b3bd2903b07d1ef2add1525673fe1e67cd58b
parentc0d90757699475eb6d9a04c0bbce35b2f83d25c9 (diff)
downloadxamarin-forms-f4e3f04d5d689f28997d16cbe62389108e3398b8.tar.gz
xamarin-forms-f4e3f04d5d689f28997d16cbe62389108e3398b8.tar.bz2
xamarin-forms-f4e3f04d5d689f28997d16cbe62389108e3398b8.zip
Support BlendColor to Image as a TizenSpecific API
Change-Id: Ic3068b3c0834605be5d45cc5f1a96d6933a0856f
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs30
-rw-r--r--Xamarin.Forms.Core/Xamarin.Forms.Core.csproj5
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs45
3 files changed, 75 insertions, 5 deletions
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs
new file mode 100644
index 00000000..2c86fd04
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs
@@ -0,0 +1,30 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Image;
+
+ public static class Image
+ {
+ public static readonly BindableProperty BlendColorProperty = BindableProperty.Create("BlendColor", typeof(Color), typeof(FormsElement), Color.Default);
+
+ public static Color GetBlendColor(BindableObject element)
+ {
+ return (Color)element.GetValue(BlendColorProperty);
+ }
+
+ public static void SetBlendColor(BindableObject element, Color color)
+ {
+ element.SetValue(BlendColorProperty, color);
+ }
+
+ public static Color GetBlendColor(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetBlendColor(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetBlendColor(this IPlatformElementConfiguration<Tizen, FormsElement> config, Color color)
+ {
+ SetBlendColor(config.Element, color);
+ return config;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
index 8f217e58..07dc83ea 100644
--- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
+++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -99,6 +99,7 @@
<Compile Include="PlatformConfiguration\iOSSpecific\StatusBarHiddenMode.cs" />
<Compile Include="PlatformConfiguration\iOSSpecific\UIStatusBarAnimation.cs" />
<Compile Include="PlatformConfiguration\iOSSpecific\VisualElement.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Image.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
@@ -460,4 +461,4 @@
</PostBuildEvent>
</PropertyGroup>
<ItemGroup />
-</Project>
+</Project> \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
index ca06a669..09353b2a 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
@@ -1,15 +1,15 @@
+using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Image;
+
namespace Xamarin.Forms.Platform.Tizen
{
public class ImageRenderer : ViewRenderer<Image, Native.Image>
{
public ImageRenderer()
{
- RegisterPropertyHandler(Image.SourceProperty, UpdateSource);
- RegisterPropertyHandler(Image.AspectProperty, UpdateAspect);
- RegisterPropertyHandler(Image.IsOpaqueProperty, UpdateIsOpaque);
}
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
@@ -20,9 +20,35 @@ namespace Xamarin.Forms.Platform.Tizen
SetNativeControl(image);
}
+ if (e.NewElement != null)
+ {
+ UpdateAll();
+ }
+
base.OnElementChanged(e);
}
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+ if (e.PropertyName == Image.SourceProperty.PropertyName)
+ {
+ UpdateSource();
+ }
+ else if (e.PropertyName == Image.AspectProperty.PropertyName)
+ {
+ UpdateAspect();
+ }
+ else if (e.PropertyName == Image.IsOpaqueProperty.PropertyName)
+ {
+ UpdateIsOpaque();
+ }
+ else if (e.PropertyName == Specific.BlendColorProperty.PropertyName)
+ {
+ UpdateBlendColor();
+ }
+ }
+
async void UpdateSource()
{
ImageSource source = Element.Source;
@@ -49,6 +75,19 @@ namespace Xamarin.Forms.Platform.Tizen
{
Control.IsOpaque = Element.IsOpaque;
}
+
+ void UpdateBlendColor()
+ {
+ Control.Color = Specific.GetBlendColor(Element).ToNative();
+ }
+
+ void UpdateAll()
+ {
+ UpdateSource();
+ UpdateAspect();
+ UpdateIsOpaque();
+ UpdateBlendColor();
+ }
}
public interface IImageSourceHandler : IRegisterable