private async Task EventHandlerMenuCategory (SpringboardButton btn) { Boolean isSecondLevel = false; Categories c = Global.K_Categories.First (x => x.IDCategory == btn.Tag && x.IDLanguage == Global.currentLanguage); if (c.IDCategoryFather == null) isSecondLevel = true; //unfocus foreach (SpringboardButton btnTmp in (b2.Children[0] as Grid).Children) { if (btnTmp.HasFocus) { btnTmp.HasFocus = false; btnTmp.ManageFocus (); } } if (b3.IsVisible) { foreach (SpringboardButton btnTmp in (b3.Children[0] as Grid).Children) { if (btnTmp.HasFocus) { btnTmp.HasFocus = false; btnTmp.ManageFocus (); } } } //focus button btn.HasFocus = true; btn.ManageFocus (); if (Device.OS == TargetPlatform.iOS) //20150719 await b2.RotateTo (0, 10, Easing.Linear); //determine the number of lines //var tq = await sqliteHelper.sqlite_GetTableQueryFromExistingLocalTable<Categories> (Global.databaseName); var n = Global.K_Categories.Where (x => x.IDCategoryFather != null && x.IDCategoryFather == btn.Tag && x.IDLanguage == Global.currentLanguage).ToList ().Count; if (n > 0) { var hMenu = this.Height; hMenu += 1; if (n < 4) this.b3H = (hMenu / 2) - 140; if (n >= 4 && n <= 6) this.b3H = (hMenu / 2) - 70; if (n >= 7) this.b3H = (hMenu / 2); //b3 b2 b1 this.al.Children.Remove (b3); //this.al.Children.Remove (b2); b3.HeightRequest = b3H; this.al.Children.Add (b3, new Point (0, hMenu - b3H)); //this.al.Children.Add (b2, new Point (0, hMenu - b2H)); this.al.RaiseChild (b2); await createMenu (b3, MenuKindEnum.Level3CatChild, btn.Tag); //animations b1.IsVisible = false; b2.IsVisible = true; b3.IsVisible = true; await b2.TranslateTo (0, 0); await b3.TranslateTo (0, -this.b2H); } else { //await DisplayAlert ("Messaggio", "Open Poi list", "OK"); if (b3.IsVisible && isSecondLevel) { //b3 b2 b3.IsVisible = false; b1.IsVisible = true; await b2.TranslateTo (0, -this.b1H); } PosList myPosList = null; try { //if (Device.OS == TargetPlatform.iOS) //await Global.getGPSPositionForIOS (); myPosList = new PosList (btn.SpringboardLabel.Text, btn.Tag, 0, false); } catch (Exception ex) { Int32 aaaaa = 1; } if (btn.Tag == 118 || btn.Tag == 166) { //20150617 //http://facchini-ts.it/imagobe/updateinfo.aspx /* var request = WebRequest.Create ("http://facchini-ts.it/imagobe/updateinfo.aspx") as HttpWebRequest; request.Method = "GET"; DateTime dataUltimoAggiornamentoServerData; using (var response = await request.GetResponseAsync ()) { Stream st = response.GetResponseStream (); StreamReader reader = new StreamReader (st); string body = reader.ReadToEnd (); Int32 i = body.IndexOf ("Data ultimo aggiornamento:|"); string dataUltimoAggiornamentoServerString = body.Substring (i + 27, 19); DateTime.TryParseExact (dataUltimoAggiornamentoServerString, "dd/MM/yyyy HH:mm:ss", null, DateTimeStyles.None, out dataUltimoAggiornamentoServerData); } DateTime dataUltimoAggiornamentoClientData; string pathLog = currentPlataform.getLocalDatabasePath (); var arrbyteLog = currentPlataform.readfile (System.IO.Path.Combine (pathLog, "imagolight.log")); var str = System.Text.Encoding.UTF8.GetString (arrbyteLog, 0, arrbyteLog.Length); string dataUltimoAggiornamentoClientString = str.Split ('|') [1].Substring (0, 19); DateTime.TryParseExact (dataUltimoAggiornamentoClientString, "dd/MM/yyyy HH:mm:ss", null, DateTimeStyles.None, out dataUltimoAggiornamentoClientData); if (dataUltimoAggiornamentoServerData > dataUltimoAggiornamentoClientData) { */ var updateAvailable = await IsThereAnUpdate (); if (updateAvailable) { var dresult = await this.DisplayAlert ("Aggiornamento", "E' disponibile un nuovo aggiornamento. Vuoi scaricare le nuove informazioni", "Si", "No"); if (dresult) { await Update (); await DisplayAlert ("Messaggio", "Aggiornamento completato.", "OK"); } } else { await DisplayAlert ("Messaggio", "Nessun aggiornamento disponibile.", "OK"); } return; } if (btn.Tag == 121 || btn.Tag == 171) { string url = "http://178.239.178.170/imagobe/crediti/crediti.html"; //url = "http://www.google.com"; var web = new UICustomWebView (url); if (Device.OS == TargetPlatform.iOS) NavigationPage.SetHasBackButton (web, false); await Navigation.PushAsync (web); return; //http://178.239.178.170/imagobe/crediti/crediti.html } if (btn.Tag == 119 || btn.Tag == 169) { string versione_build = "versione: " + this.currentPlataform.getApplicationVersion () + "; build: " + currentPlataform.getApplicationBuild () + ""; await DisplayAlert ("Imago" + " " + Global.PositionChangedNumber.ToString (), versione_build, "OK"); return; } if (Device.OS == TargetPlatform.iOS) NavigationPage.SetHasBackButton (myPosList, false); await Navigation.PushAsync (myPosList, true); } }
private async Task EventHandlerMenuMacro (SpringboardButton btn) { //unfocus foreach (SpringboardButton btnTmp in (b1.Children[0] as Grid).Children) { if (btnTmp.HasFocus) { btnTmp.HasFocus = false; btnTmp.ManageFocus (); } } //focus button btn.HasFocus = true; btn.ManageFocus (); if (Device.OS == TargetPlatform.iOS) //20150719 await b2.RotateTo (0, 10, Easing.Linear); //determine the number of lines //var tq = await sqliteHelper.sqlite_GetTableQueryFromExistingLocalTable<MacroCategories> (Global.databaseName); MacroCategories m = Global.k_MacroCategories.Where (x => x.IDMacroCategory == btn.Tag).ToList () [0]; //var tq2 = await sqliteHelper.sqlite_GetTableQueryFromExistingLocalTable<Categories> (Global.databaseName); var n = Global.K_Categories.Where (x => x.IDMacroCategory == btn.Tag && x.IDCategoryFather == null && x.IDLanguage == Global.currentLanguage).ToList ().Count; var hMenu = this.Height; hMenu += 1; if (n < 4) this.b2H = (hMenu / 2) - 140; if (n >= 4 && n <= 6) this.b2H = (hMenu / 2) - 70; if (n >= 7) this.b2H = (hMenu / 2); //b3 b2 b1 this.al.Children.Remove (b3); this.al.Children.Remove (b2); b2.HeightRequest = b2H; this.al.Children.Add (b3, new Point (0, hMenu - b3H)); this.al.Children.Add (b2, new Point (0, hMenu - b2H)); this.al.RaiseChild (b1); if (btn.Tag == 99 || btn.Tag == 101) { //... //string p = Global.currentPosition.Latitude.ToString () + " - " + Global.currentPosition.Longitude.ToString (); //await DisplayAlert ("Numero di cambi posizione", Global.PositionChangedNumber.ToString () + " - " + p, "OK"); //return; } if (btn.Tag == 103 || btn.Tag == 94) { var map = new Map (); if (Device.OS == TargetPlatform.iOS) NavigationPage.SetHasBackButton (map, false); Navigation.PushAsync (map); if (b2.IsVisible) { b2.IsVisible = false; await b2.TranslateTo (0, -this.b1H); } return; } await createMenu (b2, MenuKindEnum.Level2CatFather, btn.Tag); //animations b2.IsVisible = true; b3.IsVisible = false; await b2.TranslateTo (0, -this.b1H); }