From 4340ace933e53c1eb1da31d29687317f6c9e1af4 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 3 Mar 2017 00:13:15 +0100 Subject: [PATCH] refactoring --- ZicMoove/ZicMoove/Pages/PinPage.cs | 88 ++++++++++--------- .../WorkflowDatesPage.cs} | 2 +- .../Pages/Workflow/WorkflowProfilesPage.cs | 20 +++++ ZicMoove/ZicMoove/Strings.Designer.cs | 27 ++++++ ZicMoove/ZicMoove/Strings.resx | 9 ++ ZicMoove/ZicMoove/ZicMoove.csproj | 20 ++--- 6 files changed, 111 insertions(+), 55 deletions(-) rename ZicMoove/ZicMoove/Pages/{ClientPages/Workflow/WFBookPage.cs => Workflow/WorkflowDatesPage.cs} (87%) create mode 100644 ZicMoove/ZicMoove/Pages/Workflow/WorkflowProfilesPage.cs diff --git a/ZicMoove/ZicMoove/Pages/PinPage.cs b/ZicMoove/ZicMoove/Pages/PinPage.cs index afd6338b..ed40ca8d 100644 --- a/ZicMoove/ZicMoove/Pages/PinPage.cs +++ b/ZicMoove/ZicMoove/Pages/PinPage.cs @@ -12,8 +12,8 @@ namespace ZicMoove.Pages { public class PinPage : ContentPage { - Map map; - + protected Map map; + protected async Task GetPos() { var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; @@ -39,8 +39,35 @@ namespace ZicMoove.Pages { base.OnAppearing (); } + protected virtual void OnInitMap () + { + double lat = 0; + double lon = 0; + int pc = 0; + foreach (var query in DataManager.Instance.BookQueries) + { + var pin = new Pin + { + Type = PinType.Generic, + Position = new Xamarin.Forms.Maps.Position( + query.Location.Latitude, query.Location.Longitude), + Label = query.Reason, + Address = query.Location.Address + }; + pin.BindingContext = query; + map.Pins.Add(pin); + // TODO find a true solution :-/ + lat = (lat * pc + query.Location.Latitude) / (pc + 1); + lon = (lon * pc + query.Location.Longitude) / (pc + 1); + pc++; + } + // TODO build a MapSpan covering events + map.MoveToRegion(MapSpan.FromCenterAndRadius( + new Xamarin.Forms.Maps.Position(lat, lon), Distance.FromMeters(100))); - public PinPage () + } + + public PinPage () { map = new Map { @@ -50,29 +77,8 @@ namespace ZicMoove.Pages HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; - double lat=0; - double lon=0; - int pc = 0; - foreach (var query in DataManager.Instance.BookQueries) - { - var pin = new Pin { - Type = PinType.SearchResult, - Position = new Xamarin.Forms.Maps.Position( - query.Location.Latitude, query.Location.Longitude), - Label = query.Reason, - Address = query.Location.Address - }; - pin.BindingContext = query; - map.Pins.Add (pin); - // TODO find a true solution - lat = (lat * pc + query.Location.Latitude) / (pc + 1); - lon = (lon * pc + query.Location.Longitude) / (pc + 1); - pc++; - } - // TODO build a MapSpan covering events - map.MoveToRegion(MapSpan.FromCenterAndRadius ( - new Xamarin.Forms.Maps.Position(lat,lon), Distance.FromMeters(100))); - /* + OnInitMap(); + /* // A "relocate" button : useless, since it yet exists var reLocate = new Button { Text = "Re-centrer" }; @@ -89,10 +95,10 @@ namespace ZicMoove.Pages } }; */ - // create map style buttons - var street = new Button { Text = "Street" }; - var hybrid = new Button { Text = "Hybrid" }; - var satellite = new Button { Text = "Satellite" }; + // create map style buttons + var street = new Button { Text = Strings.Street }; + var hybrid = new Button { Text = Strings.Hybrid }; + var satellite = new Button { Text = Strings.Satellite }; street.Clicked += HandleMapStyleClicked; hybrid.Clicked += HandleMapStyleClicked; @@ -111,21 +117,21 @@ namespace ZicMoove.Pages segments }}; } + protected StackLayout StackLayout + { get + { + return Content as StackLayout; + } } - void HandleMapStyleClicked (object sender, EventArgs e) + void HandleMapStyleClicked (object sender, EventArgs e) { var b = sender as Button; - switch (b.Text) { - case "Street": + if (b.Text== Strings.Street) map.MapType = MapType.Street; - break; - case "Hybrid": - map.MapType = MapType.Hybrid; - break; - case "Satellite": - map.MapType = MapType.Satellite; - break; - } + else if (b.Text == Strings.Hybrid) + map.MapType = MapType.Hybrid; + else if (b.Text == Strings.Satellite) + map.MapType = MapType.Satellite; } } } diff --git a/ZicMoove/ZicMoove/Pages/ClientPages/Workflow/WFBookPage.cs b/ZicMoove/ZicMoove/Pages/Workflow/WorkflowDatesPage.cs similarity index 87% rename from ZicMoove/ZicMoove/Pages/ClientPages/Workflow/WFBookPage.cs rename to ZicMoove/ZicMoove/Pages/Workflow/WorkflowDatesPage.cs index 83ee8997..92a0202e 100644 --- a/ZicMoove/ZicMoove/Pages/ClientPages/Workflow/WFBookPage.cs +++ b/ZicMoove/ZicMoove/Pages/Workflow/WorkflowDatesPage.cs @@ -10,7 +10,7 @@ using Plugin.Geolocator; namespace ZicMoove.Pages.ClientPages { - public class WorkflowBookPage : PinPage + public class DatesPage : PinPage { diff --git a/ZicMoove/ZicMoove/Pages/Workflow/WorkflowProfilesPage.cs b/ZicMoove/ZicMoove/Pages/Workflow/WorkflowProfilesPage.cs new file mode 100644 index 00000000..b9fb646b --- /dev/null +++ b/ZicMoove/ZicMoove/Pages/Workflow/WorkflowProfilesPage.cs @@ -0,0 +1,20 @@ +using ZicMoove.Model.Social; +using System; +using Xamarin.Forms; +using Xamarin.Forms.Maps; +using Yavsc; +using ZicMoove.Data; +using System.Threading.Tasks; +using XLabs.Platform.Services.Geolocation; +using Plugin.Geolocator; + +namespace ZicMoove.Pages.ClientPages +{ + public class ProfilesPage : PinPage + { + + + + } +} + diff --git a/ZicMoove/ZicMoove/Strings.Designer.cs b/ZicMoove/ZicMoove/Strings.Designer.cs index b6512e9b..ba17da42 100644 --- a/ZicMoove/ZicMoove/Strings.Designer.cs +++ b/ZicMoove/ZicMoove/Strings.Designer.cs @@ -232,6 +232,15 @@ namespace ZicMoove { } } + /// + /// Recherche une chaîne localisée semblable à Hybride. + /// + public static string Hybrid { + get { + return ResourceManager.GetString("Hybrid", resourceCulture); + } + } + /// /// Recherche une chaîne localisée semblable à Valeur invalide. /// @@ -331,6 +340,15 @@ namespace ZicMoove { } } + /// + /// Recherche une chaîne localisée semblable à Satellite. + /// + public static string Satellite { + get { + return ResourceManager.GetString("Satellite", resourceCulture); + } + } + /// /// Recherche une chaîne localisée semblable à Rechercher un artiste. /// @@ -358,6 +376,15 @@ namespace ZicMoove { } } + /// + /// Recherche une chaîne localisée semblable à Rue. + /// + public static string Street { + get { + return ResourceManager.GetString("Street", resourceCulture); + } + } + /// /// Recherche une chaîne localisée semblable à Incontournable. /// diff --git a/ZicMoove/ZicMoove/Strings.resx b/ZicMoove/ZicMoove/Strings.resx index 94bed157..764e7615 100644 --- a/ZicMoove/ZicMoove/Strings.resx +++ b/ZicMoove/ZicMoove/Strings.resx @@ -239,4 +239,13 @@ Signez ici + + Hybride + + + Satellite + + + Rue + \ No newline at end of file diff --git a/ZicMoove/ZicMoove/ZicMoove.csproj b/ZicMoove/ZicMoove/ZicMoove.csproj index 4b8fecd8..68fdc862 100644 --- a/ZicMoove/ZicMoove/ZicMoove.csproj +++ b/ZicMoove/ZicMoove/ZicMoove.csproj @@ -110,7 +110,8 @@ ActivityPage.xaml - + + SearchPage.xaml @@ -153,9 +154,6 @@ Strings.en.resx - - DocSigning.xaml - @@ -205,7 +203,7 @@ DashboardPage.xaml - + EventDetail.xaml @@ -297,7 +295,7 @@ - + MSBuild:UpdateDesignTimeXaml Designer @@ -306,7 +304,9 @@ Designer - + + + ..\..\packages\ExifLib.PCL.1.0.1\lib\portable-net45+sl50+win+WindowsPhoneApp81+wp80+Xamarin.iOS10+MonoAndroid10+MonoTouch10\ExifLib.dll @@ -538,12 +538,6 @@ - - - MSBuild:UpdateDesignTimeXaml - Designer - - MSBuild:UpdateDesignTimeXaml