コード例 #1
0
        public MapPage()
        {
            InitializeComponent();
            CAPI = new CovidAPI();
            map  = new Xamarin.Forms.Maps.Map();
            map.HasZoomEnabled   = false;        //disable zoom on the map
            map.HasScrollEnabled = false;        //disable Scroll on the map
            map.Pins.Clear();                    // clear all the pins form the map

            mainStackLayout = new StackLayout(); // the main layout

            country = new Entry
            {
                Placeholder      = "Enter in the Country",
                PlaceholderColor = Color.Olive
            };
            findLocationBTN = new Button
            {
                Text = "Check Covid-19 in this Country"
            };
            findLocationBTN.Clicked += getLoction; // get the country location

            // add all the elements to the main layout
            mainStackLayout.Children.Add(map);
            mainStackLayout.Children.Add(country);
            mainStackLayout.Children.Add(findLocationBTN);

            Content = mainStackLayout; // add main layout to the page

            // Thread.Sleep(2000);
            // _ = FindTheLocation("", "", "New Zealand");
        }
コード例 #2
0
        public CountryListPage()
        {
            InitializeComponent();

            CAPI = new CovidAPI();

            //List of Countries
            String[] CountryArr = new string[20];
            CountryArr[0]  = "Australia";
            CountryArr[1]  = "Brazil";
            CountryArr[2]  = "Canada";
            CountryArr[3]  = "China";
            CountryArr[4]  = "France";
            CountryArr[5]  = "Germany";
            CountryArr[6]  = "Greenland";
            CountryArr[7]  = "India";
            CountryArr[8]  = "Italy";
            CountryArr[9]  = "Japan";
            CountryArr[10] = "Mexico";
            CountryArr[11] = "New Zealand";
            CountryArr[12] = "Norway";
            CountryArr[13] = "Philippines";
            CountryArr[14] = "Russia";
            CountryArr[15] = "South Africa";
            CountryArr[16] = "Spain";
            CountryArr[17] = "Sweden";
            CountryArr[18] = "UK";
            CountryArr[19] = "USA";

            Label ThisLabel;
            //Image ThisImage;

            //Making Grid
            Grid grid = new Grid();

            int CountryCount = 0;

            //For (Country) Loop
            for (int r = 0; r < (CountryArr.Length * 3); r++)
            {
                string Country = CountryArr[CountryCount];

                //Row 1
                //Country
                BoxView CountryBox = new BoxView
                {
                    Color = Color.Gray
                };
                Grid.SetRow(CountryBox, r);
                Grid.SetColumnSpan(CountryBox, 6);

                Label CountryLbl = new Label
                {
                    Text              = Country,
                    FontAttributes    = FontAttributes.Bold,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center
                };
                Grid.SetRow(CountryLbl, r);
                Grid.SetColumnSpan(CountryLbl, 6);

                //Adding Country to Grid
                grid.Children.Add(CountryBox);
                grid.Children.Add(CountryLbl);
                //Country ENDS
                //Row 1 ENDS

                r++;

                //Row 2
                //Death Label
                BoxView DeathBox = new BoxView
                {
                    Color = Color.LightGray
                };
                Grid.SetRow(DeathBox, r);
                Grid.SetColumn(DeathBox, 0);
                Grid.SetColumnSpan(DeathBox, 2);

                Label DeathBoxLbl = new Label
                {
                    Text = "'Deaths':",
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center
                };
                Grid.SetRow(DeathBoxLbl, r);
                Grid.SetColumn(DeathBoxLbl, 0);
                Grid.SetColumnSpan(DeathBoxLbl, 2);

                //Adding Death to Grid
                grid.Children.Add(DeathBox);
                grid.Children.Add(DeathBoxLbl);
                //Death Label ENDS

                //Confirmed Label
                BoxView ConfirmBox = new BoxView
                {
                    Color = Color.LightGray
                };
                Grid.SetRow(ConfirmBox, r);
                Grid.SetColumn(ConfirmBox, 2);
                Grid.SetColumnSpan(ConfirmBox, 2);

                Label ConfirmLbl = new Label
                {
                    Text = "'Confirmed' Cases:",
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center
                };
                Grid.SetRow(ConfirmLbl, r);
                Grid.SetColumn(ConfirmLbl, 2);
                Grid.SetColumnSpan(ConfirmLbl, 2);

                //Adding Confirmed to Grid
                grid.Children.Add(ConfirmBox);
                grid.Children.Add(ConfirmLbl);
                //Confirmed Label ENDS

                //Recovered Label
                BoxView RecoverBox = new BoxView
                {
                    Color = Color.LightGray
                };
                Grid.SetRow(RecoverBox, r);
                Grid.SetColumn(RecoverBox, 4);
                Grid.SetColumnSpan(RecoverBox, 2);

                Label RecoverLbl = new Label
                {
                    Text = "'Recovered':",
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center
                };
                Grid.SetRow(RecoverLbl, r);
                Grid.SetColumn(RecoverLbl, 4);
                Grid.SetColumnSpan(RecoverLbl, 2);

                //Adding Recovered to Grid
                grid.Children.Add(RecoverBox);
                grid.Children.Add(RecoverLbl);
                //Recovered Label ENDS
                //Row 2 ENDS

                r++;

                //Row 3
                //The Data Columns
                for (int c = 0; c < 6; c++)
                {
                    grid.Children.Add(new BoxView
                    {
                        Margin        = 0,
                        HeightRequest = 25
                    }, 1, 1);

                    //Between Each Column Data
                    switch (c)
                    {
                    //Death Num
                    case 0:
                        grid.Children.Add(ThisLabel = new Label()
                        {
                            HeightRequest     = 25,
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions   = LayoutOptions.Center
                        }, c, r);
                        GetDeathNum(Country, ThisLabel);
                        break;

                    /*
                     * //Death Image
                     * case 1:
                     *  grid.Children.Add(ThisImage = new Image()
                     *  {
                     *      HeightRequest = 25,
                     *      HorizontalOptions = LayoutOptions.Center,
                     *      VerticalOptions = LayoutOptions.Center
                     *  }, c, r);
                     *  GiveArrow(3, ThisImage, false);
                     *  break;
                     */

                    //Confirmed Num
                    case 2:
                        grid.Children.Add(ThisLabel = new Label()
                        {
                            HeightRequest     = 25,
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions   = LayoutOptions.Center
                        }, c, r);
                        GetConfirmNum(Country, ThisLabel);
                        break;

                    /*
                     * //Confirmed Image
                     * case 3:
                     *  grid.Children.Add(ThisImage = new Image()
                     *  {
                     *      HeightRequest = 25,
                     *      HorizontalOptions = LayoutOptions.Center,
                     *      VerticalOptions = LayoutOptions.Center
                     *  }, c, r);
                     *  GiveArrow(175, ThisImage, false);
                     *  break;
                     */

                    //Recovered Num
                    case 4:
                        grid.Children.Add(ThisLabel = new Label()
                        {
                            HeightRequest     = 25,
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions   = LayoutOptions.Center
                        }, c, r);
                        GetRecoverNum(Country, ThisLabel);
                        break;

                        /*
                         * //Recovered Image
                         * case 5:
                         *  grid.Children.Add(ThisImage = new Image()
                         *  {
                         *      HeightRequest = 25,
                         *      HorizontalOptions = LayoutOptions.Center,
                         *      VerticalOptions = LayoutOptions.Center
                         *  }, c, r);
                         *  GiveArrow(7, ThisImage, true);
                         *  break;
                         */
                    } //Switch For Columns ENDS
                }     //The Data Columns ENDS
                  //Row 3 ENDS

                CountryCount++;
            } //For (Country) Loop ENDS



            //Adds Scroll
            ScrollView scrollview = new ScrollView {
                Content = grid
            };

            Content = scrollview;
        } //Loading CountryLists() Page ENDS
コード例 #3
0
        public MainPage()
        {
            InitializeComponent();

            CAPI = new CovidAPI();

            // Color line.
            BoxView BoxLine = new BoxView
            {
                Color             = Color.DarkGreen,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            // Welcome message
            Label message = new Label
            {
                Text              = "Welcome to Covid-19 Data!",
                TextColor         = Color.Blue,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                FontSize          = 29
            };

            // Color line.
            BoxView BoxLine2 = new BoxView
            {
                Color             = Color.DarkGreen,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            // CountryList button as btnCList
            Button btnCList = new Button
            {
                Text      = "Country List",
                FontSize  = 25,
                TextColor = Color.Purple
            };

            btnCList.Clicked += BtnCList_Clicked;

            // Map button as btnMap
            Button btnMap = new Button
            {
                Text      = "Map",
                FontSize  = 25,
                TextColor = Color.DarkCyan
            };

            btnMap.Clicked += BtnMap_Clicked;

            // Exit button as btnExit
            Button btnExit = new Button
            {
                Text      = "Exit",
                FontSize  = 25,
                TextColor = Color.Red
            };

            btnExit.Clicked += BtnExit_Clicked;

            // SubPage button as btnSub
            //Button btnSub = new Button
            //{
            //    Text = "Sub Page",
            //    FontSize = 25,
            //    TextColor = Color.Red
            //};
            //btnSub.Clicked += BtnSub_Clicked;

            // Layout setting
            Content = new StackLayout
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    BoxLine,
                    message,
                    BoxLine2,
                    btnCList,
                    btnMap,
                    btnExit,
                    //btnSub,
                }
            };
        }