Ejemplo n.º 1
0
        protected override void OnStart()
        {
            //xlarge screens are at least 960dp x 720dp
            //large screens are at least 640dp x 480dp
            //normal screens are at least 470dp x 320dp
            //small screens are at least 426dp x 320dp

            float dens = DependencyService.Get <IDisplaySize>().GetDensity();
            int   wd = DependencyService.Get <IDisplaySize>().GetWidthDiP();
            int   hd = DependencyService.Get <IDisplaySize>().GetHeightDiP();
            int   bigger, smaller;

            if (wd > hd) //landscape
            {
                bigger  = wd;
                smaller = hd;
            }
            else //portrait
            {
                bigger  = hd;
                smaller = wd;
            }

            if (Device.Idiom == TargetIdiom.Tablet)
            {
                if (smaller >= 500 && smaller < 700) //SW500
                {
                    StatusPageSW500 sp = new StatusPageSW500();
                    sp.Title = Translation.GetString("Status");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, sp, StatusVM);
                    MainPage = new NavigationPage(sp);

                    TorLogPageSW500 tlp = new TorLogPageSW500();
                    tlp.Title = Translation.GetString("Tor log");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                    CountriesPageSW500 cap = new CountriesPageSW500();
                    cap.Title = Translation.GetString("Countries");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                    CitiesPageSW500 cip = new CitiesPageSW500();
                    cip.Title = Translation.GetString("Cities");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);
                }
            }

            if (Device.Idiom == TargetIdiom.Phone)
            {
                if (smaller >= 500) //SW500
                {
                    StatusPageSW500 sp = new StatusPageSW500();
                    sp.Title = Translation.GetString("Status");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, sp, StatusVM);
                    MainPage = new NavigationPage(sp);

                    TorLogPageSW500 tlp = new TorLogPageSW500();
                    tlp.Title = Translation.GetString("Tor log");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                    CountriesPageSW500 cap = new CountriesPageSW500();
                    cap.Title = Translation.GetString("Countries");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                    CitiesPageSW500 cip = new CitiesPageSW500();
                    cip.Title = Translation.GetString("Cities");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);

                    AboutPage ap = new AboutPage();
                    ap.Title = Translation.GetString("About");
                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, ap, AboutVM);
                }
                else
                {
                    if (smaller >= 400) //SW400
                    {
                        if (wd > hd)
                        {
                            StatusPagePhoneL       = new StatusPageSW400();
                            StatusPagePhoneL.Title = Translation.GetString("Status");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneL, StatusVM);
                            Application.Current.MainPage.Navigation.PopAsync();
                            MainPage = new NavigationPage(StatusPagePhoneL);
                            StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                        }
                        else
                        {
                            /*
                             * StatusPagePhoneP = new StatusPageSW400p();
                             * StatusPagePhoneP.Title = Translation.GetString("Status");
                             * FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneP, StatusVM);
                             * Application.Current.MainPage.Navigation.PopAsync();
                             * MainPage = new NavigationPage(StatusPagePhoneP);
                             * StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                             */
                            var tabbedNavigation = new FreshTabbedNavigationContainer();

                            StatusPageSW400p tab1 = new StatusPageSW400p();
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tab1, StatusVM);

                            tabbedNavigation.AddTab()
                            tabbedNavigation.AddTab <CountriesViewModel>("Countries", null);
                            MainPage = tabbedNavigation;
                        }

                        TorLogPageSW400 tlp = new TorLogPageSW400();
                        tlp.Title = Translation.GetString("Tor log");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                        CountriesPageSW400 cap = new CountriesPageSW400();
                        cap.Title = Translation.GetString("Countries");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                        CitiesPageSW400 cip = new CitiesPageSW400();
                        cip.Title = Translation.GetString("Cities");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);

                        AboutPageSW400 ap = new AboutPageSW400();
                        ap.Title = Translation.GetString("About");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, ap, AboutVM);
                    }
                    else
                    {
                        if (smaller >= 300) //SW300
                        {
                            if (wd > hd)
                            {
                                StatusPagePhoneL       = new StatusPageSW300();
                                StatusPagePhoneL.Title = Translation.GetString("Status");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneL, StatusVM);
                                Application.Current.MainPage.Navigation.PopAsync();
                                MainPage = new NavigationPage(StatusPagePhoneL);
                                StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                            }
                            else
                            {
                                /*
                                 * StatusPagePhoneP = new StatusPageSW300p();
                                 * StatusPagePhoneP.Title = Translation.GetString("Status");
                                 * FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneP, StatusVM);
                                 * Application.Current.MainPage.Navigation.PopAsync();
                                 */
                                var tabbedNavigation = new FreshTabbedNavigationContainer();
                                tabbedNavigation.AddTab <StatusViewModel>("Status", null);
                                tabbedNavigation.AddTab <CountriesViewModel>("Countries", null);
                                MainPage = tabbedNavigation;
                                //MainPage = new NavigationPage(StatusPagePhoneP);
                                //StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                            }

                            /*
                             * StatusPageSW300 sp = new StatusPageSW300();
                             * sp.Title = Translation.GetString("Status");
                             * FreshMvvm.FreshPageModelResolver.BindingPageModel(null, sp, StatusVM);
                             * MainPage = new NavigationPage(sp);*/

                            TorLogPageSW300 tlp = new TorLogPageSW300();
                            tlp.Title = Translation.GetString("Tor log");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                            CountriesPageSW300 cap = new CountriesPageSW300();
                            cap.Title = Translation.GetString("Countries");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                            CitiesPageSW300 cip = new CitiesPageSW300();
                            cip.Title = Translation.GetString("Cities");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);

                            AboutPageSW300 ap = new AboutPageSW300();
                            ap.Title = Translation.GetString("About");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, ap, AboutVM);
                        }
                        else //small (< 300) SW200
                        {
                            //
                        }
                    }
                }
            }
            if (Device.Idiom != TargetIdiom.Tablet && Device.Idiom != TargetIdiom.Phone) //something strange
            {
                if (smaller < 700)
                {
                    if (smaller >= 500) //SW500
                    {
                        StatusPageSW500 sp = new StatusPageSW500();
                        sp.Title = Translation.GetString("Status");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, sp, StatusVM);
                        MainPage = new NavigationPage(sp);

                        TorLogPageSW500 tlp = new TorLogPageSW500();
                        tlp.Title = Translation.GetString("Tor log");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                        CountriesPageSW500 cap = new CountriesPageSW500();
                        cap.Title = Translation.GetString("Countries");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                        CitiesPageSW500 cip = new CitiesPageSW500();
                        cip.Title = Translation.GetString("Cities");
                        FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);
                    }
                    else
                    {
                        if (smaller >= 400) //SW400
                        {
                            if (wd > hd)
                            {
                                StatusPagePhoneL       = new StatusPageSW400();
                                StatusPagePhoneL.Title = Translation.GetString("Status");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneL, StatusVM);
                                Application.Current.MainPage.Navigation.PopAsync();
                                MainPage = new NavigationPage(StatusPagePhoneL);
                                StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                            }
                            else
                            {
                                StatusPagePhoneP       = new StatusPageSW400p();
                                StatusPagePhoneP.Title = Translation.GetString("Status");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneP, StatusVM);
                                Application.Current.MainPage.Navigation.PopAsync();
                                MainPage = new NavigationPage(StatusPagePhoneP);
                                StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                            }

                            TorLogPageSW400 tlp = new TorLogPageSW400();
                            tlp.Title = Translation.GetString("Tor log");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                            CountriesPageSW400 cap = new CountriesPageSW400();
                            cap.Title = Translation.GetString("Countries");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                            CitiesPageSW400 cip = new CitiesPageSW400();
                            cip.Title = Translation.GetString("Cities");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);

                            AboutPageSW400 ap = new AboutPageSW400();
                            ap.Title = Translation.GetString("About");
                            FreshMvvm.FreshPageModelResolver.BindingPageModel(null, ap, AboutVM);
                        }
                        else
                        {
                            if (smaller >= 300) //SW300
                            {
                                if (wd > hd)
                                {
                                    StatusPagePhoneL       = new StatusPageSW300();
                                    StatusPagePhoneL.Title = Translation.GetString("Status");
                                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneL, StatusVM);
                                    Application.Current.MainPage.Navigation.PopAsync();
                                    MainPage = new NavigationPage(StatusPagePhoneL);
                                    StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                                }
                                else
                                {
                                    StatusPagePhoneP       = new StatusPageSW300p();
                                    StatusPagePhoneP.Title = Translation.GetString("Status");
                                    FreshMvvm.FreshPageModelResolver.BindingPageModel(null, StatusPagePhoneP, StatusVM);
                                    Application.Current.MainPage.Navigation.PopAsync();
                                    MainPage = new NavigationPage(StatusPagePhoneP);
                                    StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                                }

                                /*
                                 * StatusPageSW300 sp = new StatusPageSW300();
                                 * sp.Title = Translation.GetString("Status");
                                 * FreshMvvm.FreshPageModelResolver.BindingPageModel(null, sp, StatusVM);
                                 * MainPage = new NavigationPage(sp);*/

                                TorLogPageSW300 tlp = new TorLogPageSW300();
                                tlp.Title = Translation.GetString("Tor log");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, tlp, TorLogVM);

                                CountriesPageSW300 cap = new CountriesPageSW300();
                                cap.Title = Translation.GetString("Countries");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cap, CountriesVM);

                                CitiesPageSW300 cip = new CitiesPageSW300();
                                cip.Title = Translation.GetString("Cities");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, cip, CitiesVM);

                                AboutPageSW300 ap = new AboutPageSW300();
                                ap.Title = Translation.GetString("About");
                                FreshMvvm.FreshPageModelResolver.BindingPageModel(null, ap, AboutVM);
                            }
                            else //small (< 300) SW200
                            {
                                //
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnStart()
        {
            //xlarge screens are at least 960dp x 720dp
            //large screens are at least 640dp x 480dp
            //normal screens are at least 470dp x 320dp
            //small screens are at least 426dp x 320dp

            MobileCenter.Start("android=7d19d3ff-dec3-42f0-80d7-3d5b74bc3593;", typeof(Analytics), typeof(Crashes));

            float dens = DependencyService.Get <IDisplaySize>().GetDensity();
            int   wd   = DependencyService.Get <IDisplaySize>().GetWidthDiP();
            int   hd   = DependencyService.Get <IDisplaySize>().GetHeightDiP();

            int bigger, smaller;

            if (wd > hd) //landscape
            {
                bigger  = wd;
                smaller = hd;
            }
            else //portrait
            {
                bigger  = hd;
                smaller = wd;
            }

            if (smaller >= 700) //SW700 and above
            {
                StatusPage sp = new StatusPage();
                sp.Title = AppStrings.Status;
                MainTabs.Children.Add(sp);

                CountriesPage cap = new CountriesPage();
                cap.Title = AppStrings.Countries;
                MainTabs.Children.Add(cap);

                CitiesPage cip = new CitiesPage();
                cip.Title = AppStrings.Cities;
                MainTabs.Children.Add(cip);

                TorLogPage tlp = new TorLogPage();
                tlp.Title = AppStrings.TorLog;
                MainTabs.Children.Add(tlp);

                AboutPage ap = new AboutPage();
                ap.Title = AppStrings.About;
                MainTabs.Children.Add(ap);

                MainPage = new NavigationPage(MainTabs);
            }
            else
            {
                if (smaller >= 500 && smaller < 700) //SW500
                {
                    StatusPageSW500 sp = new StatusPageSW500();
                    sp.Title = AppStrings.Status;
                    MainTabs.Children.Add(sp);

                    CountriesPageSW500 cap = new CountriesPageSW500();
                    cap.Title = AppStrings.Countries;
                    MainTabs.Children.Add(cap);

                    TorLogPageSW500 tlp = new TorLogPageSW500();
                    tlp.Title = AppStrings.TorLog;
                    MainTabs.Children.Add(tlp);

                    AboutPageSW400 ap = new AboutPageSW400();
                    ap.Title = AppStrings.About;
                    MainTabs.Children.Add(ap);

                    MainPage = new NavigationPage(MainTabs);
                }
                else
                {
                    if (smaller >= 400) //SW400
                    {
                        if (wd > hd)
                        {
                            StatusPagePhoneL       = new StatusPageSW400();
                            StatusPagePhoneL.Title = AppStrings.Status;
                            //Application.Current.MainPage.Navigation.PopAsync();
                            MainTabs.Children.Add(StatusPagePhoneL);
                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                        }
                        else
                        {
                            StatusPagePhoneP       = new StatusPageSW400p();
                            StatusPagePhoneP.Title = AppStrings.Status;
                            MainTabs.Children.Add(StatusPagePhoneP);
                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                        }

                        TorLogPageSW400 tlp = new TorLogPageSW400();
                        tlp.Title = AppStrings.TorLog;
                        MainTabs.Children.Add(tlp);

                        CountriesPageSW400 cap = new CountriesPageSW400();
                        cap.Title = AppStrings.Countries;
                        MainTabs.Children.Add(cap);

                        AboutPageSW400 ap = new AboutPageSW400();
                        ap.Title = AppStrings.About;
                        MainTabs.Children.Add(ap);
                    }
                    else//SW300
                    {
                        if (wd > hd)
                        {
                            StatusPagePhoneL       = new StatusPageSW300();
                            StatusPagePhoneL.Title = AppStrings.Status;
                            MainTabs.Children.Add(StatusPagePhoneL);
                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneL.DisplayPosition = DisplayPos.Landscape;
                        }
                        else
                        {
                            StatusPagePhoneP       = new StatusPageSW300p();
                            StatusPagePhoneP.Title = AppStrings.Status;
                            MainTabs.Children.Add(StatusPagePhoneP);

                            MainPage = new NavigationPage(MainTabs);
                            StatusPagePhoneP.DisplayPosition = DisplayPos.Portrait;
                        }

                        TorLogPageSW300 tlp = new TorLogPageSW300();
                        tlp.Title = AppStrings.TorLog;
                        MainTabs.Children.Add(tlp);

                        CountriesPageSW300 cap = new CountriesPageSW300();
                        cap.Title = AppStrings.Countries;
                        MainTabs.Children.Add(cap);

                        AboutPageSW300 ap = new AboutPageSW300();
                        ap.Title = AppStrings.About;
                        MainTabs.Children.Add(ap);
                    }
                }
            }
        }