/// <summary> /// Initializes a new instance of the <see cref="T:Ipheidi.CustomTabbedPage"/> class. /// </summary> public PheidiTabbedPage() { //Cache la nav bar NavigationPage.SetHasNavigationBar(this, false); NavigationPage.SetHasBackButton(this, false); On <Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(false); BrowserPage browser = new BrowserPage(); SettingPage setting = new SettingPage(); LocationPage location = new LocationPage(); NotificationPage notification = new NotificationPage(); MenuPage menu = new MenuPage(); PropertyChanged += (sender, e) => Debug.WriteLine("TabbedPage: " + e.PropertyName + " changed"); Children.Add(browser); Children.Add(setting); #if DEBUG App.LocationManager.Page = location; Children.Add(location); #endif Children.Add(notification); Children.Add(menu); ClearTitles(); foreach (var p in Children) { p.Appearing += (sender, e) => Debug.WriteLine(p.GetType().ToString() + ": Appearing"); p.Disappearing += (sender, e) => Debug.WriteLine(p.GetType().ToString() + ": Disappearing"); } CurrentPageChanged += (sender, e) => { indexLastPage = indexCurrentPage; indexCurrentPage = Children.IndexOf(CurrentPage); }; }
/// <summary> /// Refresh the browser. /// </summary> public void RefreshBrowser() { var browser = NavBar.Children.Where(p => p is BrowserPage).Single(); int index = NavBar.Children.IndexOf(browser); NavBar.Children.Remove(browser); browser = new BrowserPage(); NavBar.Children.Insert(index, browser); NavBar.CurrentPage = browser; }
/// <summary> /// Initializes a new instance of the <see cref="T:Ipheidi.MenuPage"/> class. /// </summary> public MenuPage() { NavigationPage.SetHasNavigationBar(this, false); pages = new List <Page>(); Icon = "menu_hamburger.png"; InitializeComponent(); //Bouton de logout ContentPage logout = new ContentPage(); logout.Icon = "logout.png"; logout.Title = AppResources.DeconnexionBouton; //Bouton de refresh ContentPage refresh = new ContentPage(); refresh.Icon = "refresh.png"; refresh.Title = AppResources.RegenererBrowserBouton; pages.Add(logout); pages.Add(refresh); #if DEBUG pages.Add(new ContactPage()); #endif var MenuCell = new DataTemplate(typeof(MenuCellView)); MenuCell.SetBinding(MenuCellView.ImageSourceProperty, "Icon"); MenuCell.SetBinding(MenuCellView.TextProperty, "Title"); listViewMenu.ItemTemplate = MenuCell; listViewMenu.ItemsSource = pages; listViewMenu.SeparatorColor = Color.Transparent; listViewMenu.ItemSelected += (sender, e) => { if (listViewMenu.SelectedItem != null) { Page p = (Page)listViewMenu.SelectedItem; if (p.Title == AppResources.DeconnexionBouton) { App.CookieManager.ClearCookies(); BrowserPage.CheckWebSession(); } else if (p.Title == AppResources.RegenererBrowserBouton) { Device.BeginInvokeOnMainThread(App.Instance.RefreshBrowser); } else { Navigation.PushAsync(p); } } listViewMenu.SelectedItem = null; }; }
/// <summary> /// Initializes a new instance of the <see cref="T:Ipheidi.BrowserPage"/> class. /// </summary> public BrowserPage() { this.Icon = "home.png"; //Cache la nav bar NavigationPage.SetHasNavigationBar(this, false); InitializeComponent(); BrowserWeb.Source = App.CurrentServer.Address + "/connect"; /* * var htmlSource = new HtmlWebViewSource(); * htmlSource.Html = @"<html> * * <head> * <style> * ul{ * list-style:none; * max-height:300px; * margin:0; * overflow:auto; * padding:0; * text-indent:10px; * } * li{ * line-height:25px; * } * li:nth-child(even) * { * background:#ccc; * } * </style> * </head> * <body> * <h1>Xamarin.Forms</h1> * <p>Welcome to WebView.</p> * <ul>"; * for (int i = 0; i < 100; i++) * { * htmlSource.Html += "<li>" + i + "</li>"; * } * * htmlSource.Html += @"</ul> * </body></html>"; * * BrowserWeb.Source = htmlSource.Html; */ instance = this; }
public static void RunActionAnswer(Action action) { try { var fields = PheidiNetworkManager.GetFields(action.ActionAnswer); if (fields != null) { foreach (var f in fields) { var field = f as Dictionary <string, object>; if (field != null) { if (field.ContainsKey("autoClick")) { var autoClick = field["autoClick"] as string; string script = "AutoClick(" + autoClick + ",0,0);"; BrowserPage.InsertJavscript(script); } if (field.ContainsKey("message" + App.Language.ToUpper())) { string lang = App.Language.ToUpper(); string message = field["message" + lang] as string; string title = "Pheidi"; string textConfirm = "Ok"; string textCancel = "Cancel"; foreach (var key in field.Keys) { if (key == "bCancel" + lang) { textCancel = field["bCancel" + lang] as string; } else if (key == "bConfirm" + lang) { textConfirm = field["bConfirm" + lang] as string; } else if (key == "title" + lang) { title = field["title" + lang] as string; } } if (App.IsInBackground) { Debug.WriteLine("ActionManger - RunActionAnswer - SendNotification"); App.NotificationManager.SendNotification(message, title, "nearby_square", action); } else { Debug.WriteLine("ActionManger - RunActionAnswer - DisplayAlert"); System.Action confirm = () => { }; confirm = () => { action.Event = "onConfirm"; ExecuteAction(action); }; System.Action cancel = () => { action.Event = "onCancel"; ExecuteAction(action); }; if (!string.IsNullOrEmpty(textCancel)) { App.NotificationManager.DisplayAlert(message, title, textConfirm, textCancel, confirm, cancel); } else { App.NotificationManager.DisplayAlert(message, title, textConfirm, confirm); } } } } } } } catch (Exception e) { Debug.WriteLine(e.Message); } }