From 760f80d8d8e363bd89f463fd4a47e1d4c54cf05f Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Wed, 4 Jan 2017 14:10:17 +0900 Subject: [PATCH] Add Tizen.Xamarin.Forms.Extension project - This change include sample extensions (Cells) to guide how to use it Change-Id: I59775664287cf1ff7def3b65d41b00474b1b8f4c --- .../Cells/BaseTypeCell.cs | 97 ++++++++++++++++++++++ .../Cells/DoubleLabelCell.cs | 91 ++++++++++++++++++++ .../Cells/MultilineCell.cs | 90 ++++++++++++++++++++ Tizen.Xamarin.Forms.Extension/Cells/Type1Cell.cs | 8 ++ Tizen.Xamarin.Forms.Extension/Cells/Type2Cell.cs | 8 ++ .../Properties/AssemblyInfo.cs | 15 ++++ .../Tizen.Xamarin.Forms.Extension.csproj | 95 +++++++++++++++++++++ Tizen.Xamarin.Forms.Extension/packages.config | 4 + 8 files changed, 408 insertions(+) create mode 100644 Tizen.Xamarin.Forms.Extension/Cells/BaseTypeCell.cs create mode 100644 Tizen.Xamarin.Forms.Extension/Cells/DoubleLabelCell.cs create mode 100644 Tizen.Xamarin.Forms.Extension/Cells/MultilineCell.cs create mode 100644 Tizen.Xamarin.Forms.Extension/Cells/Type1Cell.cs create mode 100644 Tizen.Xamarin.Forms.Extension/Cells/Type2Cell.cs create mode 100644 Tizen.Xamarin.Forms.Extension/Properties/AssemblyInfo.cs create mode 100644 Tizen.Xamarin.Forms.Extension/Tizen.Xamarin.Forms.Extension.csproj create mode 100644 Tizen.Xamarin.Forms.Extension/packages.config diff --git a/Tizen.Xamarin.Forms.Extension/Cells/BaseTypeCell.cs b/Tizen.Xamarin.Forms.Extension/Cells/BaseTypeCell.cs new file mode 100644 index 0000000..5eeaa37 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Cells/BaseTypeCell.cs @@ -0,0 +1,97 @@ +using System; +using Xamarin.Forms; + +namespace Tizen.Xamarin.Forms.Extension +{ + public abstract class BaseTypeCell : Cell + { + public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(BaseTypeCell), default(string)); + + public static readonly BindableProperty TextEndProperty = BindableProperty.Create("TextEnd", typeof(string), typeof(BaseTypeCell), default(string)); + + public static readonly BindableProperty SubProperty = BindableProperty.Create("Sub", typeof(string), typeof(TextCell), default(string)); + + public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(ImageSource), typeof(BaseTypeCell), null, + propertyChanged: (bindable, oldvalue, newvalue) => ((BaseTypeCell)bindable).OnSourcePropertyChanged((ImageSource)oldvalue, (ImageSource)newvalue)); + + public static readonly BindableProperty IsCheckedProperty = BindableProperty.Create("IsChecked", typeof(bool), typeof(BaseTypeCell), false, + propertyChanged: (obj, oldValue, newValue) => + { + var baseTypeCell = (BaseTypeCell)obj; + baseTypeCell.Toggled?.Invoke(obj, new ToggledEventArgs((bool)newValue)); + }, defaultBindingMode: BindingMode.TwoWay); + + public static readonly BindableProperty IsCheckVisibleProperty = BindableProperty.Create("IsCheckVisible", typeof(bool), typeof(MultilineCell), false); + + public static readonly BindableProperty IconWidthProperty = BindableProperty.Create("IconWidth", typeof(int), typeof(MultilineCell), 0); + + public static readonly BindableProperty IconHeightProperty = BindableProperty.Create("IconHeight", typeof(int), typeof(MultilineCell), 0); + + public BaseTypeCell() + { + Disappearing += (sender, e) => + { + Icon?.Cancel(); + }; + } + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public string TextEnd + { + get { return (string)GetValue(TextEndProperty); } + set { SetValue(TextEndProperty, value); } + } + + public string Sub + { + get { return (string)GetValue(SubProperty); } + set { SetValue(SubProperty, value); } + } + + [TypeConverter(typeof(ImageSourceConverter))] + public ImageSource Icon + { + get { return (ImageSource)GetValue(IconProperty); } + set { SetValue(IconProperty, value); } + } + + public bool IsCheckVisible + { + get { return (bool)GetValue(IsCheckVisibleProperty); } + set { SetValue(IsCheckVisibleProperty, value); } + } + + public bool IsChecked + { + get { return (bool)GetValue(IsCheckedProperty); } + set { SetValue(IsCheckedProperty, value); } + } + + public int IconWidth + { + get { return (int)GetValue(IconWidthProperty); } + set { SetValue(IconWidthProperty, value); } + } + + public int IconHeight + { + get { return (int)GetValue(IconHeightProperty); } + set { SetValue(IconHeightProperty, value); } + } + + public event EventHandler Toggled; + + void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) + { + if (newvalue != null) + { + SetInheritedBindingContext(newvalue, BindingContext); + } + } + } +} diff --git a/Tizen.Xamarin.Forms.Extension/Cells/DoubleLabelCell.cs b/Tizen.Xamarin.Forms.Extension/Cells/DoubleLabelCell.cs new file mode 100644 index 0000000..58d2409 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Cells/DoubleLabelCell.cs @@ -0,0 +1,91 @@ +using Xamarin.Forms; + +namespace Tizen.Xamarin.Forms.Extension +{ + public class DoubleLabelCell : Cell + { + public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(DoubleLabelCell), default(string)); + + public static readonly BindableProperty SubProperty = BindableProperty.Create("Sub", typeof(string), typeof(DoubleLabelCell), default(string)); + + public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(ImageSource), typeof(DoubleLabelCell), null, + propertyChanged: (bindable, oldvalue, newvalue) => ((DoubleLabelCell)bindable).OnSourcePropertyChanged((ImageSource)oldvalue, (ImageSource)newvalue)); + + public static readonly BindableProperty IconWidthProperty = BindableProperty.Create("IconWidth", typeof(int), typeof(DoubleLabelCell), 0); + + public static readonly BindableProperty IconHeightProperty = BindableProperty.Create("IconHeight", typeof(int), typeof(DoubleLabelCell), 0); + + public static readonly BindableProperty EndProperty = BindableProperty.Create("End", typeof(ImageSource), typeof(DoubleLabelCell), null, + propertyChanged: (bindable, oldvalue, newvalue) => ((DoubleLabelCell)bindable).OnSourcePropertyChanged((ImageSource)oldvalue, (ImageSource)newvalue)); + + public static readonly BindableProperty EndWidthProperty = BindableProperty.Create("EndWidth", typeof(int), typeof(DoubleLabelCell), 0); + + public static readonly BindableProperty EndHeightProperty = BindableProperty.Create("EndHeight", typeof(int), typeof(DoubleLabelCell), 0); + + public DoubleLabelCell() + { + Disappearing += (sender, e) => + { + Icon?.Cancel(); + }; + } + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public string Sub + { + get { return (string)GetValue(SubProperty); } + set { SetValue(SubProperty, value); } + } + + [TypeConverter(typeof(ImageSourceConverter))] + public ImageSource Icon + { + get { return (ImageSource)GetValue(IconProperty); } + set { SetValue(IconProperty, value); } + } + + public int IconWidth + { + get { return (int)GetValue(IconWidthProperty); } + set { SetValue(IconWidthProperty, value); } + } + + public int IconHeight + { + get { return (int)GetValue(IconHeightProperty); } + set { SetValue(IconHeightProperty, value); } + } + + [TypeConverter(typeof(ImageSourceConverter))] + public ImageSource End + { + get { return (ImageSource)GetValue(EndProperty); } + set { SetValue(EndProperty, value); } + } + + public int EndWidth + { + get { return (int)GetValue(EndWidthProperty); } + set { SetValue(EndWidthProperty, value); } + } + + public int EndHeight + { + get { return (int)GetValue(IconHeightProperty); } + set { SetValue(IconHeightProperty, value); } + } + + void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) + { + if (newvalue != null) + { + SetInheritedBindingContext(newvalue, BindingContext); + } + } + } +} diff --git a/Tizen.Xamarin.Forms.Extension/Cells/MultilineCell.cs b/Tizen.Xamarin.Forms.Extension/Cells/MultilineCell.cs new file mode 100644 index 0000000..f0f03e2 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Cells/MultilineCell.cs @@ -0,0 +1,90 @@ +using System; +using Xamarin.Forms; + +namespace Tizen.Xamarin.Forms.Extension +{ + public class MultilineCell : Cell + { + public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(MultilineCell), default(string)); + + public static readonly BindableProperty MultilineProperty = BindableProperty.Create("Multiline", typeof(string), typeof(TextCell), default(string)); + + public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(ImageSource), typeof(MultilineCell), null, + propertyChanged: (bindable, oldvalue, newvalue) => ((MultilineCell)bindable).OnSourcePropertyChanged((ImageSource)oldvalue, (ImageSource)newvalue)); + + public static readonly BindableProperty IsCheckedProperty = BindableProperty.Create("IsChecked", typeof(bool), typeof(MultilineCell), false, + propertyChanged: (obj, oldValue, newValue) => + { + var multilineCell = (MultilineCell)obj; + multilineCell.Toggled?.Invoke(obj, new ToggledEventArgs((bool)newValue)); + }, defaultBindingMode: BindingMode.TwoWay); + + public static readonly BindableProperty IsCheckVisibleProperty = BindableProperty.Create("IsCheckVisible", typeof(bool), typeof(MultilineCell), false); + + public static readonly BindableProperty IconWidthProperty = BindableProperty.Create("IconWidth", typeof(int), typeof(MultilineCell), 0); + + public static readonly BindableProperty IconHeightProperty = BindableProperty.Create("IconHeight", typeof(int), typeof(MultilineCell), 0); + + + public MultilineCell() + { + Disappearing += (sender, e) => + { + Icon?.Cancel(); + }; + } + + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public string Multiline + { + get { return (string)GetValue(MultilineProperty); } + set { SetValue(MultilineProperty, value); } + } + + [TypeConverter(typeof(ImageSourceConverter))] + public ImageSource Icon + { + get { return (ImageSource)GetValue(IconProperty); } + set { SetValue(IconProperty, value); } + } + + public bool IsCheckVisible + { + get { return (bool)GetValue(IsCheckVisibleProperty); } + set { SetValue(IsCheckVisibleProperty, value); } + } + + public bool IsChecked + { + get { return (bool)GetValue(IsCheckedProperty); } + set { SetValue(IsCheckedProperty, value); } + } + + public int IconWidth + { + get { return (int)GetValue(IconWidthProperty); } + set { SetValue(IconWidthProperty, value); } + } + + public int IconHeight + { + get { return (int)GetValue(IconHeightProperty); } + set { SetValue(IconHeightProperty, value); } + } + + public event EventHandler Toggled; + + void OnSourcePropertyChanged(ImageSource oldvalue, ImageSource newvalue) + { + if (newvalue != null) + { + SetInheritedBindingContext(newvalue, BindingContext); + } + } + } +} diff --git a/Tizen.Xamarin.Forms.Extension/Cells/Type1Cell.cs b/Tizen.Xamarin.Forms.Extension/Cells/Type1Cell.cs new file mode 100644 index 0000000..88e8e50 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Cells/Type1Cell.cs @@ -0,0 +1,8 @@ +using Xamarin.Forms; + +namespace Tizen.Xamarin.Forms.Extension +{ + public class Type1Cell : BaseTypeCell + { + } +} diff --git a/Tizen.Xamarin.Forms.Extension/Cells/Type2Cell.cs b/Tizen.Xamarin.Forms.Extension/Cells/Type2Cell.cs new file mode 100644 index 0000000..b185e48 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Cells/Type2Cell.cs @@ -0,0 +1,8 @@ +using Xamarin.Forms; + +namespace Tizen.Xamarin.Forms.Extension +{ + public class Type2Cell : BaseTypeCell + { + } +} diff --git a/Tizen.Xamarin.Forms.Extension/Properties/AssemblyInfo.cs b/Tizen.Xamarin.Forms.Extension/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..28da6bc --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using Xamarin.Forms; + +[assembly: AssemblyVersion("0.0.1")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCopyright("Copyright © Samsung Electronics 2016")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyProduct("Tizen")] +[assembly: AssemblyTitle("Tizen.Xamarin.Forms.Extension")] +[assembly: AssemblyTrademark("")] +[assembly: CompilationRelaxations(8)] +[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] diff --git a/Tizen.Xamarin.Forms.Extension/Tizen.Xamarin.Forms.Extension.csproj b/Tizen.Xamarin.Forms.Extension/Tizen.Xamarin.Forms.Extension.csproj new file mode 100644 index 0000000..41a6509 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/Tizen.Xamarin.Forms.Extension.csproj @@ -0,0 +1,95 @@ + + + + + 10.0 + Debug + AnyCPU + {62531FB2-271B-4669-804E-7287A744CFD0} + Library + Properties + Tizen.Xamarin.Forms.Extension + Tizen.Xamarin.Forms.Extension + v4.5 + Profile259 + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + + true + bin\Turkey\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + true + + + + + + + + + + + + + + ..\packages\Xamarin.Forms.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll + True + + + ..\packages\Xamarin.Forms.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll + True + + + ..\packages\Xamarin.Forms.2.3.3.175\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll + True + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/Tizen.Xamarin.Forms.Extension/packages.config b/Tizen.Xamarin.Forms.Extension/packages.config new file mode 100644 index 0000000..97f92f4 --- /dev/null +++ b/Tizen.Xamarin.Forms.Extension/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- 2.7.4