Пример #1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //Calls the Shared Portable Class Library to get a list with all available competitions.
            ObservableCollection <Competition> competitions = await ScoresSource.GetCompetitions();

            //order the competitions by id
            var orderedCompetitions = competitions.OrderBy(m => m.Id);

            //set the Competitions Combox Box Items source to the list
            CompetitionsComboBox.ItemsSource = orderedCompetitions;

            //Create the tapped event for the Fetch Matches Button
            FetchMatchesButton.Tapped += async(sender, args) =>
            {
                //get the selected competition in the combobox
                var selComp = CompetitionsComboBox.SelectedValue as Competition;

                //get the matches for the selected competition
                var matches = await ScoresSource.GetLastCompetitionMatches(selComp.Id.ToString());

                //Order the matches by date
                var orderedMatches = matches.OrderByDescending(m => m.StartTime);

                MatchesListView.ItemsSource = orderedMatches;
            };
        }
Пример #2
0
        async partial void FetchMatchesButton_TouchUpInside(UIButton sender)
        {
            //Get current selected meme from the ViewPicker
            var rowSel = CompetitionPicker.SelectedRowInComponent(new nint(0));
            var competitionIdString = (CompetitionPicker.Model as CompetitionsPickerViewModel).GetId(rowSel);

            //Calls the PCL with the chosen competition Id to get the matches List
            var matchesCollection = await ScoresSource.GetLastCompetitionMatches(competitionIdString);

            //Order the matches by date
            matchesArray = matchesCollection.OrderByDescending(m => m.StartTime).ToArray();

            //Reload the tableview
            MatchesTable.ReloadData();
        }
Пример #3
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Calls the Shared Portable Class Library to get a list with all available competitions.
            ObservableCollection <Competition> competitions = await ScoresSource.GetCompetitions();

            //order the competitions by id
            var orderedCompetitionsArr = competitions.OrderBy(m => m.Id).ToArray();

            //Set the list of competitions we got to our PickerView (using the pickerViewModel we created)
            CompetitionPicker.Model = new CompetitionsPickerViewModel(orderedCompetitionsArr);

            MatchesTable.DataSource = this;
        }
Пример #4
0
        protected override async void OnCreate(Bundle bundle)
        {
            //Initialize SVG Library
            XamSvg.Setup.InitSvgLib();

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our buttom, listvew and spinner from the layout resource,
            Button   button              = FindViewById <Button> (Resource.Id.fetchMatchesButton);
            ListView listView            = FindViewById <ListView>(Resource.Id.matchesListView);
            Spinner  competitionsSpinner = FindViewById <Spinner>(Resource.Id.competitionsSpinner);

            //Calls the Shared Portable Class Library to get a list with all available competitions
            ObservableCollection <Competition> competitions = await ScoresSource.GetCompetitions();

            //Order the competitions by Id
            var orderedCompetitionsArray = competitions.OrderBy(m => m.Id).ToArray();

            //Set the competitions list on the Spinner Adapter
            var adapter = new CompetitionsAdapter(this, orderedCompetitionsArray);

            competitionsSpinner.Adapter = adapter;

            //Set a click event for the Fetch Matches button
            button.Click += async(sender, args) =>
            {
                //Get the matches of the selected competition (using the PCL)
                var matches = await ScoresSource.GetLastCompetitionMatches(competitionsSpinner.SelectedItemId.ToString());

                //Order the matches by date
                var orderedMatchesArray = matches.OrderByDescending(m => m.StartTime).ToArray();

                //Set the matches list on the ListView Adapter
                listView.Adapter = new MatchesAdapter(this, orderedMatchesArray);
            };
        }