示例#1
0
        void TestIssue2393()
        {
            MainPage = new NavigationPage();

            // Hand off to website for sign in process
            var view = new WebView {
                Source = new Uri("http://google.com")
            };

            view.Navigated += (s, e) => MainPage.DisplayAlert("Navigated", $"If this popup appears multiple times, this test has failed", "ok");;

            MainPage.Navigation.PushAsync(new ContentPage {
                Content = view, Title = "Issue 2393"
            });
            //// Uncomment to verify that there is no gray screen displayed between the blue splash and red MasterDetailPage.
            //SetMainPage(new Bugzilla44596SplashPage(() =>
            //{
            //	var newTabbedPage = new TabbedPage();
            //	newTabbedPage.Children.Add(new ContentPage { BackgroundColor = Color.Red, Content = new Label { Text = "yay" } });
            //	MainPage = new MasterDetailPage
            //	{
            //		Master = new ContentPage { Title = "Master", BackgroundColor = Color.Red },
            //		Detail = newTabbedPage
            //	};
            //}));

            //// Uncomment to verify that there is no crash when switching MainPage from MDP inside NavPage
            //SetMainPage(new Bugzilla45702());

            //// Uncomment to verify that there is no crash when rapidly switching pages that contain lots of buttons
            //SetMainPage(new Issues.Issue2004());
        }
        /// <exception cref="Exception">Cannot show dialog on a non-visible page</exception>
        public async Task ShowDialog(IDialogOptions i_DialogOptions)
        {
            if (ViewStatus != VisualStatus.Visible)
            {
                throw new Exception("Cannot show dialog on a non-visible page");
            }

            await m_Page.DisplayAlert(i_DialogOptions.Title, i_DialogOptions.Message, "OK");

            i_DialogOptions.Result = true;
        }
示例#3
0
        public async Task ShowDialog(IDialogOptions dialogOptions)
        {
            if (ViewStatus == VisualStatus.Visible)
            {
                if (string.IsNullOrEmpty(dialogOptions.CancelButtonText))
                {
                    await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, string.IsNullOrEmpty(dialogOptions.OkButtonText)? "OK" : dialogOptions.OkButtonText);

                    dialogOptions.Result = true;
                }
                else
                {
                    dialogOptions.Result = await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, string.IsNullOrEmpty(dialogOptions.OkButtonText)? "OK" : dialogOptions.OkButtonText, dialogOptions.CancelButtonText);
                }
            }
            else
            {
                throw new Exception("You can not call ShowDialog on a non-visible page");
            }
        }
示例#4
0
        public App()
        {
            InitializeComponent();

            MainPage = new NavigationPage(new LoginView());

            MessagingCenter.Subscribe(this, "DisplayErrorAlert", async(App vm, string message) =>
            {
                await MainPage.DisplayAlert("Error!", message, "Ok");
            });

            MessagingCenter.Subscribe(this, "DisplaySuccessAlert", async(App vm, string message) =>
            {
                await MainPage.DisplayAlert("Success!", message, "Ok");
            });

            MessagingCenter.Subscribe(this, "DisplaySuccessInfo", async(App vm, string message) =>
            {
                await MainPage.DisplayAlert("Info", message, "Ok");
            });
        }
示例#5
0
        public async Task ShowDialog(IDialogOptions dialogOptions)
        {
            if (ViewStatus == VisualStatus.Visible)
            {
                await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, "OK");

                dialogOptions.Result = true;
            }
            else
            {
                throw new Exception("You can not call ShowDialog on a non-visible page");
            }
        }
示例#6
0
        /// <summary>
        /// Called when clock application resumes.
        /// It happens when clock application goes foreground
        /// </summary>
        async protected override void OnResume()
        {
            // Handle when your app resumes
            App currentApp = Application.Current as App;

            if (currentApp.ScreenWidth != 720 || currentApp.ScreenHeight != 1280)
            {
                await mainNavi.DisplayAlert("Notice", "The app only works in HD mobile emulator.", "OK");

                DependencyService.Get <IAppTerminator>().TerminateApp();
                return;
            }
        }
示例#7
0
        void TestIssue2393()
        {
            MainPage = new NavigationPage();

            // Hand off to website for sign in process
            var view = new WebView {
                Source = new Uri("http://google.com")
            };

            view.Navigated += (s, e) => MainPage.DisplayAlert("Navigated", $"If this popup appears multiple times, this test has failed", "ok");;

            MainPage.Navigation.PushAsync(new ContentPage {
                Content = view, Title = "Issue 2393"
            });
        }
示例#8
0
        public async Task ShowDialog(IDialogOptions dialogOptions)
        {
            try
            {
                if (ViewStatus == VisualStatus.Visible)
                {
                    await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, "OK");

                    dialogOptions.Result = true;
                }
                else
                {
                    dialogOptions.Result = false;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
示例#9
0
 public App()
 {
     try
     {
         // The root page of application
         MainPage = new NavigationPage(new pageMain()
         {
             Title = " St. Peters"
         })
         {
             BarTextColor       = Color.Silver,
             BarBackgroundColor = Color.Black
         };
         NavigationPage.SetHasNavigationBar(this, true);
     }
     catch (Exception ex)
     {
         MainPage.DisplayAlert("app error", ex.Message, "OK");
     }
 } //App
示例#10
0
        public App(IBluetoothLowEnergyAdapter bluetooth)
        {
            InitializeComponent();

            ServiceLocator.Current.GetInstance <IBluetoothService>().Adapter = bluetooth;

            MainPage = new NavigationPage(new Views.MainPage());

            MessagingCenter.Subscribe <CustomDisplayAlert, string[]>(this, "DisplayAlert", (sender, values) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    MainPage.DisplayAlert(values[0], values[1], "Ok");
                });
            });

            CheckPermission(Permission.Location);
            CheckPermission(Permission.LocationAlways);
            CheckPermission(Permission.LocationWhenInUse);
            CheckPermission(Permission.Storage);
        }
示例#11
0
 public App()
 {
     try
     {
         // The root page of  application
         MainPage = new NavigationPage(new pageMain()
         {
             Title = " St. Peters"
         })
         {
             //need white txt for androud but cant do if logic here :( White background hides android nav controls :(
             //BarBackgroundColor = Color.White,
             BarTextColor = Color.Silver
         };
         NavigationPage.SetHasNavigationBar(this, true);
     }
     catch (Exception ex)
     {
         MainPage.DisplayAlert("app error", ex.Message, "OK");
     }
 } //App
        // CONSTRUCTEUR
        public App(string a_filePath)
        {
            try
            {
                // Utilisation d'un fichier de base de données SQLite pour la source de données
                // Si un autre mécanisme de sauvegarde des données est à utiliser dans le futur : il faut modifier DataProvider ici, ainsi que le chemin vers le fichier dans les projets spécifiques plateforme
                DataProvider = new SQLiteDataAccess(a_filePath);

                InitializeComponent();

                // Récupération de la ressource de la couleur de fond
                Color backgoundColor = (Color)Resources["CouleurFondOrange"];

                MainPage = new NavigationPage(new MainPage());

                ((NavigationPage)MainPage).BarBackgroundColor = backgoundColor; // Nécessaire du fait de l'Aspect donné à l'image du bandeau supérieur (AspectFit), si l'image ne remplit pas en entier la zone du bandeau, la même couleur est appliquée
            }
            catch (System.Exception)
            {
                MainPage.DisplayAlert("Erreur inconnue", "Une erreur inconnue s'est produite, l'application va s'arrêter.", "Ok");
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }
示例#13
0
        public App()
        {
            try
            {
                InitializeComponent();

                if (Device.OS != TargetPlatform.Windows)
                {
                    DependencyService.Get <ILocalize>().SetLocale();
                }

                Page page = null;
                if (IsLogin)
                {
                    page = new HomeView();
                }
                else
                {
                    page = new LoadingView();
                }

                // The root page of your application
                MainPage = new NavigationPage(page)
                {
                    BarBackgroundColor = GetBackgroundColor()
                };
                if (!IsLogin)
                {
                    ValidateLoginAsync();
                }
            }
            catch
            {
                MainPage.DisplayAlert(T.GetValue("app_name"), T.GetValue("error_message"), T.GetValue("ok"));
            }
        }
示例#14
0
        public App()
        {
            App.Self = this;

            var netLanguage = DependencyService.Get <ILocalize>().GetCurrent();

            Culture.currentCulture = new CultureInfo(netLanguage);
            Langs.Culture          = new CultureInfo(netLanguage);
            DependencyService.Get <ILocalize>().SetLocale();

            try
            {
                SimpleIoc.Default.Register <ICultureInfo>(() => new CulturalInfo());
            }
            catch
            {
#if DEBUG
                Debug.WriteLine("cultureinfo restarted exception");
#endif
            }

            if (Device.RuntimePlatform == Device.Android)
            {
                Density = DependencyService.Get <IScreenDensity>().GetScreenDensity;
            }

            // Register the SQL
            DependencyService.Get <ISqLiteConnectionFactory>().GetConnection();

            try
            {
                SimpleIoc.Default.Register <IUserSettings>(() => DependencyService.Get <IUserSettings>());
            }
            catch (Exception ex)
            {
#if DEBUG
                Debug.WriteLine("usersettings restarted exception : {0}--{1}", ex.Message, ex.InnerException);
#endif
            }

            IsConnected = CrossConnectivity.Current.IsConnected;

            try
            {
                SimpleIoc.Default.Register <IConnection>(() => new NetworkConnection());
            }
            catch (Exception ex)
            {
#if DEBUG
                Debug.WriteLine("connection restarted exception : {0}--{1}", ex.Message, ex.InnerException);
#endif
            }

            var dialogService = new DialogService();
            try
            {
                SimpleIoc.Default.Register <IDialogService>(() => dialogService);
            }
            catch (Exception ex)
            {
#if DEBUG
                Debug.WriteLine("dialogservice restarted exception : {0}--{1}", ex.Message, ex.InnerException);
#endif
            }
            try
            {
                SimpleIoc.Default.Register <ILocation>(() => new Geolocation());
            }
            catch (Exception ex)
            {
#if DEBUG
                Debug.WriteLine("geolocation restarted exception : {0}--{1}", ex.Message, ex.InnerException);
#endif
            }

            Page firstPage = null;
            if (Locator.Dashboard.LoggedIn)
            {
                firstPage = new DashboardPage();
            }
            else
            {
                firstPage = new LoginPage();
            }

            dialogService.Initialize(firstPage);

            CrossConnectivity.Current.ConnectivityChanged += (sender, args) =>
            {
                Locator.Dashboard.IsConnected = IsConnected = args.IsConnected;
            };

            Locator.Dashboard.IsConnected = IsConnected = CrossConnectivity.Current.IsConnected;
            Locator.Dashboard.AppStarted  = App.Self.AppStarted;
            Locator.Dashboard.Offset      = new DateTimeOffset().Offset;
            if (Device.RuntimePlatform == Device.Windows)
            {
                Locator.Dashboard.IsConnected = true; /// HACK!
            }
            MainPage = new NavigationPage(firstPage);

            try
            {
                if (Device.RuntimePlatform != Device.Windows)
                {
                    SimpleIoc.Default.Register <IBluetoothDevices>(() => new BluetoothServices());
                }
            }
            catch
            {
#if DEBUG
                Debug.WriteLine("bluetooth restarted exception");
#endif
            }


            Messenger.Default.Register <NotificationMessage>(this, (m) =>
            {
                var message = m.Notification;
                if (m.Notification.StartsWith("$", StringComparison.CurrentCulture))
                {
                    CrossLocalNotifications.Current.Show("", message.Remove(0, 1));
                }
                else
                {
                    if (m.Notification.Contains("%"))
                    {
                        Locator.Login.CurrentSpeed = Convert.ToDouble(m.Notification.TrimStart('%'));
                    }
                    else
                    {
                        if (m.Notification.Contains("BLE"))
                        {
                            if (m.Notification.Contains("discon") || m.Notification.Contains("lost"))
                            {
                                CrossLocalNotifications.Current.Show("", Langs.Const_Label_Turn_On_Bluetooth);
                            }
                        }
                        else
                        {
                            Device.BeginInvokeOnMainThread(async() => await MainPage.Navigation.PushAsync(new ErrorPage(message)));
                        }
                    }
                }
            });

            MessagingCenter.Subscribe <string>("refresh", "doit", async(obj) =>
            {
                await Locator.Login.RefreshUserData();
            });

            MessagingCenter.Subscribe <string, string>("display", "error", async(s, t) =>
            {
                if (t == "activity")
                {
                    await MainPage.DisplayAlert(Langs.Const_Title_Error_1, Langs.Const_Label_NoPDFViewer, "OK");
                }
            });

            MessagingCenter.Subscribe <string, string>("url", "load", (s, t) =>
            {
                switch (t)
                {
                case "userguide":
                    Device.BeginInvokeOnMainThread(() => Device.OpenUri(new Uri(Locator.Dashboard.UserGuide)));
                    break;

                case "tips":
                    if (!Locator.Dashboard.FileExists(Locator.Dashboard.GetDrivingFilename))
                    {
                        Task.Run(async() =>
                                 await Locator.Dashboard.GetPDFFile(Locator.Dashboard.DrivingHints, Locator.Dashboard.GetDrivingFilename));
                    }
                    break;

                case "terms":
                    if (!Locator.Dashboard.FileExists(Locator.Dashboard.GetTermsFilename))
                    {
                        Task.Run(async() =>
                                 await Locator.Dashboard.GetPDFFile(Locator.Dashboard.TermsConditions, Locator.Dashboard.GetTermsFilename));
                    }
                    break;
                }
            });
        }
        public App() {
            _ViewModel = new TestModel();
            var insetLabel = new Label();
            insetLabel.SetBinding(Label.TextProperty, nameof(TestModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
            var resourcePicker = new Picker() {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            foreach (var resourceName in TestModel.AvailableResourceNames) {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider() {
                Minimum = 0,
                Maximum = 35,
                Value = _ViewModel.AllSidesInset,
            };
            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImage() {
                SvgAssembly = typeof(App).GetTypeInfo().Assembly,
                WidthRequest = 300,
                HeightRequest = 300,
            };
            slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(TestModel.SvgResourcePath));
            var svgButton = new Button() {
                WidthRequest = 300,
                HeightRequest = 300,
            };

            // The root page of your application
            MainPage = new NavigationPage (new ContentPage {
                Title = "9-Slice SVG Scaling",
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        insetLabel,
                        resourcePicker,
                        insetSlider,
                        new AbsoluteLayout() {
                            WidthRequest = 300,
                            HeightRequest = 300,
                            Children = {
                                slicingSvg,
                                svgButton,
                            },
                        },
                    },
                    BindingContext = _ViewModel,
                },
            });
            svgButton.Clicked += (sender, e) => {
                MainPage.DisplayAlert("Tapped!", "SVG button tapped!", "OK");
            };
        }
        public App()
        {
            _ViewModel = new TestModel();
            var insetLabel = new Label();

            insetLabel.SetBinding(Label.TextProperty, nameof(TestModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
            var resourcePicker = new Picker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            foreach (var resourceName in TestModel.AvailableResourceNames)
            {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider()
            {
                Minimum = 0,
                Maximum = 35,
                Value   = _ViewModel.AllSidesInset,
            };

            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImage()
            {
                SvgAssembly   = typeof(App).GetTypeInfo().Assembly,
                WidthRequest  = 300,
                HeightRequest = 300,
            };

            slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(TestModel.SvgResourcePath));
            var svgButton = new Button()
            {
                WidthRequest  = 300,
                HeightRequest = 300,
            };

            // The root page of your application
            MainPage = new NavigationPage(new ContentPage {
                Title   = "9-Slice SVG Scaling",
                Content = new StackLayout {
                    VerticalOptions   = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Center,
                    Children          =
                    {
                        insetLabel,
                        resourcePicker,
                        insetSlider,
                        new AbsoluteLayout()
                        {
                            WidthRequest  = 300,
                            HeightRequest = 300,
                            Children      =
                            {
                                slicingSvg,
                                svgButton,
                            },
                        },
                    },
                    BindingContext = _ViewModel,
                },
            });
            svgButton.Clicked += (sender, e) => {
                MainPage.DisplayAlert("Tapped!", "SVG button tapped!", "OK");
            };
        }
示例#17
0
 protected Task DisplayAlert(string title, string message, string cancel) =>
 _navPage.DisplayAlert(title, message, cancel);
示例#18
0
 public void ShowMessage(string title, string message)
 {
     _nav.DisplayAlert(title, message, "Ok");
 }
示例#19
0
 public Task <bool> DisplayAlert(string title, string message, string accept = "ok", string cancel = "cancel")
 {
     return(NavPage.DisplayAlert(title, message, accept, cancel));
 }