From 0b7b9ed6e21ea852163f12306fd469ce6572ef6e Mon Sep 17 00:00:00 2001 From: Junian Date: Sat, 6 Feb 2016 14:14:22 +0700 Subject: [PATCH 1/2] Changed System.Timers into Device.StartTimer to make it compatible with Xamarin.Forms PCL project --- src/CustomLayouts/Controls/CarouselLayout.cs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/CustomLayouts/Controls/CarouselLayout.cs b/src/CustomLayouts/Controls/CarouselLayout.cs index 58cc324..8475c54 100644 --- a/src/CustomLayouts/Controls/CarouselLayout.cs +++ b/src/CustomLayouts/Controls/CarouselLayout.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Timers; using Xamarin.Forms; namespace CustomLayouts.Controls @@ -17,7 +16,6 @@ public enum IndicatorStyleEnum } readonly StackLayout _stack; - Timer _selectedItemTimer; int _selectedIndex; @@ -31,13 +29,6 @@ public CarouselLayout () }; Content = _stack; - - _selectedItemTimer = new Timer { - AutoReset = false, - Interval = 300 - }; - - _selectedItemTimer.Elapsed += SelectedItemTimerElapsed; } public IndicatorStyleEnum IndicatorStyle { get; set; } @@ -80,12 +71,10 @@ protected override void LayoutChildren (double x, double y, double width, double void UpdateSelectedItem () { - _selectedItemTimer.Stop (); - _selectedItemTimer.Start (); - } - - void SelectedItemTimerElapsed (object sender, ElapsedEventArgs e) { - SelectedItem = SelectedIndex > -1 ? Children [SelectedIndex].BindingContext : null; + Device.StartTimer (TimeSpan.FromMilliseconds (300), () => { + SelectedItem = SelectedIndex > -1 ? Children [SelectedIndex].BindingContext : null; + return false; + }); } public static readonly BindableProperty ItemsSourceProperty = From a6f086ea9add979ea8513b090922eea9ea44cf09 Mon Sep 17 00:00:00 2001 From: Junian Date: Wed, 16 Nov 2016 10:37:29 +0700 Subject: [PATCH 2/2] using PCL instead of Shared Project for better portability --- src/CustomLayouts.sln | 16 ++++- src/CustomLayouts/CustomLayouts.csproj | 58 +++++++++++++++++++ src/CustomLayouts/CustomLayouts.projitems | 26 --------- src/CustomLayouts/CustomLayouts.shproj | 11 ---- src/CustomLayouts/Properties/AssemblyInfo.cs | 26 +++++++++ src/CustomLayouts/ViewModels/BaseViewModel.cs | 5 +- src/CustomLayouts/packages.config | 4 ++ src/Droid/CustomLayouts.Droid.csproj | 6 +- src/Droid/Resources/Resource.designer.cs | 2 +- src/iOS/CustomLayouts.iOS.csproj | 7 ++- 10 files changed, 113 insertions(+), 48 deletions(-) create mode 100644 src/CustomLayouts/CustomLayouts.csproj delete mode 100644 src/CustomLayouts/CustomLayouts.projitems delete mode 100644 src/CustomLayouts/CustomLayouts.shproj create mode 100644 src/CustomLayouts/Properties/AssemblyInfo.cs create mode 100644 src/CustomLayouts/packages.config diff --git a/src/CustomLayouts.sln b/src/CustomLayouts.sln index 8d92b84..0a40ba2 100644 --- a/src/CustomLayouts.sln +++ b/src/CustomLayouts.sln @@ -1,12 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CustomLayouts", "CustomLayouts\CustomLayouts.shproj", "{77990895-4247-4E5A-9474-E3456B62A28D}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomLayouts.iOS", "iOS\CustomLayouts.iOS.csproj", "{E97C5E1F-83A0-4CD5-B1E1-91897B8C9F86}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomLayouts.Droid", "Droid\CustomLayouts.Droid.csproj", "{26422919-3EAD-440B-B516-E41B10D2AC56}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomLayouts", "CustomLayouts\CustomLayouts.csproj", "{DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|iPhoneSimulator = Debug|iPhoneSimulator @@ -41,5 +41,17 @@ Global {E97C5E1F-83A0-4CD5-B1E1-91897B8C9F86}.Release|iPhone.Build.0 = Release|iPhone {E97C5E1F-83A0-4CD5-B1E1-91897B8C9F86}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator {E97C5E1F-83A0-4CD5-B1E1-91897B8C9F86}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Release|iPhone.ActiveCfg = Release|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Release|iPhone.Build.0 = Release|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Debug|iPhone.Build.0 = Debug|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/CustomLayouts/CustomLayouts.csproj b/src/CustomLayouts/CustomLayouts.csproj new file mode 100644 index 0000000..caa23f6 --- /dev/null +++ b/src/CustomLayouts/CustomLayouts.csproj @@ -0,0 +1,58 @@ + + + + Debug + AnyCPU + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660} + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + Library + CustomLayouts + CustomLayouts + v4.5 + Profile259 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + + + true + bin\Release + prompt + 4 + + + + + + + + + + + + + + + + ..\packages\Xamarin.Forms.1.4.2.6359\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll + + + ..\packages\Xamarin.Forms.1.4.2.6359\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\packages\Xamarin.Forms.1.4.2.6359\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll + + + + + + + + \ No newline at end of file diff --git a/src/CustomLayouts/CustomLayouts.projitems b/src/CustomLayouts/CustomLayouts.projitems deleted file mode 100644 index 3a66d2b..0000000 --- a/src/CustomLayouts/CustomLayouts.projitems +++ /dev/null @@ -1,26 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {77990895-4247-4E5A-9474-E3456B62A28D} - - - CustomLayouts - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/CustomLayouts/CustomLayouts.shproj b/src/CustomLayouts/CustomLayouts.shproj deleted file mode 100644 index 37d1490..0000000 --- a/src/CustomLayouts/CustomLayouts.shproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - {77990895-4247-4E5A-9474-E3456B62A28D} - - - - - - - \ No newline at end of file diff --git a/src/CustomLayouts/Properties/AssemblyInfo.cs b/src/CustomLayouts/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7ed3ffc --- /dev/null +++ b/src/CustomLayouts/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("CustomLayouts")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Junian.Net")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("(c) Junian Triajianto")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/src/CustomLayouts/ViewModels/BaseViewModel.cs b/src/CustomLayouts/ViewModels/BaseViewModel.cs index fefa63c..b4cfb71 100644 --- a/src/CustomLayouts/ViewModels/BaseViewModel.cs +++ b/src/CustomLayouts/ViewModels/BaseViewModel.cs @@ -1,11 +1,8 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Threading.Tasks; using Xamarin.Forms; -using System.Security.Cryptography; -using System.Text; namespace CustomLayouts.ViewModels { diff --git a/src/CustomLayouts/packages.config b/src/CustomLayouts/packages.config new file mode 100644 index 0000000..8475a70 --- /dev/null +++ b/src/CustomLayouts/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Droid/CustomLayouts.Droid.csproj b/src/Droid/CustomLayouts.Droid.csproj index 76b5421..a74cd2e 100644 --- a/src/Droid/CustomLayouts.Droid.csproj +++ b/src/Droid/CustomLayouts.Droid.csproj @@ -15,7 +15,7 @@ True True CustomLayouts.Droid - v5.0 + v7.0 true @@ -85,7 +85,7 @@ - - + + \ No newline at end of file diff --git a/src/Droid/Resources/Resource.designer.cs b/src/Droid/Resources/Resource.designer.cs index b99da62..f11310d 100644 --- a/src/Droid/Resources/Resource.designer.cs +++ b/src/Droid/Resources/Resource.designer.cs @@ -2,7 +2,7 @@ // ------------------------------------------------------------------------------ // // This code was generated by a tool. -// Mono Runtime Version: 4.0.30319.17020 +// Mono Runtime Version: 4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/src/iOS/CustomLayouts.iOS.csproj b/src/iOS/CustomLayouts.iOS.csproj index c487d4c..62842a2 100644 --- a/src/iOS/CustomLayouts.iOS.csproj +++ b/src/iOS/CustomLayouts.iOS.csproj @@ -114,10 +114,15 @@ - + + + {DF4E0FFF-BF2D-4BCB-BFB8-14F7CE6D1660} + CustomLayouts + + \ No newline at end of file