From: Kangho Date: Wed, 14 Dec 2016 21:24:59 +0000 (+0900) Subject: Add Tizen to TargetPlatform (#590) X-Git-Tag: 2.3.3.175~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c5de535739e92d0c6dca335c024503b08d1a2af;p=platform%2Fupstream%2Fxamarin-forms.git Add Tizen to TargetPlatform (#590) * Add Tizen to TargetPlatform * Adds Device.OnPlatform methods having Tizen --- diff --git a/Xamarin.Forms.Core/Device.cs b/Xamarin.Forms.Core/Device.cs index db0a274..50fdcfc 100644 --- a/Xamarin.Forms.Core/Device.cs +++ b/Xamarin.Forms.Core/Device.cs @@ -88,6 +88,21 @@ namespace Xamarin.Forms } } + public static void OnPlatform(Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null, Action Tizen = null) + { + if (OS == TargetPlatform.Tizen) + { + if (Tizen != null) + Tizen(); + else if (Default != null) + Default(); + } + else + { + OnPlatform(iOS, Android, WinPhone, Default); + } + } + public static T OnPlatform(T iOS, T Android, T WinPhone) { switch (OS) @@ -104,6 +119,18 @@ namespace Xamarin.Forms return iOS; } + public static T OnPlatform(T iOS, T Android, T WinPhone, T Tizen) + { + if (OS == TargetPlatform.Tizen) + { + return Tizen; + } + else + { + return OnPlatform(iOS, Android, WinPhone); + } + } + public static void OpenUri(Uri uri) { PlatformServices.OpenUriAction(uri); diff --git a/Xamarin.Forms.Core/OnPlatform.cs b/Xamarin.Forms.Core/OnPlatform.cs index b66167f..71879a7 100644 --- a/Xamarin.Forms.Core/OnPlatform.cs +++ b/Xamarin.Forms.Core/OnPlatform.cs @@ -8,6 +8,8 @@ namespace Xamarin.Forms public T WinPhone { get; set; } + public T Tizen { get; set; } + public static implicit operator T(OnPlatform onPlatform) { switch (Device.OS) @@ -19,9 +21,11 @@ namespace Xamarin.Forms case TargetPlatform.Windows: case TargetPlatform.WinPhone: return onPlatform.WinPhone; + case TargetPlatform.Tizen: + return onPlatform.Tizen; } return onPlatform.iOS; } } -} \ No newline at end of file +} diff --git a/Xamarin.Forms.Core/PlatformConfiguration/ExtensionPoints.cs b/Xamarin.Forms.Core/PlatformConfiguration/ExtensionPoints.cs index 341d931..b74e9b9 100644 --- a/Xamarin.Forms.Core/PlatformConfiguration/ExtensionPoints.cs +++ b/Xamarin.Forms.Core/PlatformConfiguration/ExtensionPoints.cs @@ -4,4 +4,5 @@ namespace Xamarin.Forms.PlatformConfiguration public sealed class Android : IConfigPlatform { } public sealed class iOS : IConfigPlatform { } public sealed class Windows : IConfigPlatform { } + public sealed class Tizen : IConfigPlatform { } } diff --git a/Xamarin.Forms.Core/TargetPlatform.cs b/Xamarin.Forms.Core/TargetPlatform.cs index d9fe6b7..62fbda0 100644 --- a/Xamarin.Forms.Core/TargetPlatform.cs +++ b/Xamarin.Forms.Core/TargetPlatform.cs @@ -6,6 +6,7 @@ namespace Xamarin.Forms iOS, Android, WinPhone, - Windows + Windows, + Tizen } -} \ No newline at end of file +} diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration/Tizen.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration/Tizen.xml new file mode 100644 index 0000000..de0e8fa --- /dev/null +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms.PlatformConfiguration/Tizen.xml @@ -0,0 +1,35 @@ + + + + + Xamarin.Forms.Core + 2.0.0.0 + + + System.Object + + + + Xamarin.Forms.IConfigPlatform + + + + To be added. + To be added. + + + + + + Constructor + + 2.0.0.0 + + + + To be added. + To be added. + + + + diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml index d5c3fce..1c68026 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml @@ -168,6 +168,41 @@ Device.OnPlatform (iOS: () => label.Font = Font.OfSize ("HelveticaNeue-UltraLigh + + + + Method + + 2.0.0.0 + + + System.Void + + + + + + + + + + (optional) The Action to execute on iOS. + (optional) The Action to execute on Android. + (optional) The Action to execute on WinPhone. + (optional) The Action to execute if no Action was provided for the current OS. + (optional) The Action to execute on Tizen. + Executes different Actions depending on the that Xamarin.Forms is working on. + + This example shows how to change the font of a Label on a single OS. + + + label.Font = Font.OfSize ("HelveticaNeue-UltraLight", NamedSize.Large)); + ]]> + + + + @@ -210,6 +245,44 @@ button.HeightRequest = Device.OnPlatform (20,30,30); + + + + Method + + 2.0.0.0 + + + T + + + + + + + + + + + + The type of the value to be returned. + The value for iOS. + The value for Android. + The value for WinPhone. + The value for Tizen. + Returns different values depending on the Xamarin.Forms is working on. + The value for the current OS. + + This example shows how to use different heights for a Button on different OS. + + + + + + + diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml index 3871487..1204cff 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml @@ -113,6 +113,22 @@ To be added. + + + + Property + + 2.0.0.0 + + + T + + + The type as it is implemented on the Tizen platform. + To be added. + To be added. + + diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml index 40fd72b..9dc4466 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml @@ -80,6 +80,20 @@ (Unused) Indicates that Forms is running on an undefined platform. + + + + Field + + 2.0.0.0 + + + Xamarin.Forms.TargetPlatform + + + Indicates that forms is running on the Tizen platform. + + diff --git a/docs/Xamarin.Forms.Core/index.xml b/docs/Xamarin.Forms.Core/index.xml index f13fd56..901945f 100644 --- a/docs/Xamarin.Forms.Core/index.xml +++ b/docs/Xamarin.Forms.Core/index.xml @@ -460,6 +460,7 @@ +