void ctrl_UserWantsToViewScore(object sender, SnookerEventArgs e) { var me = App.Repository.GetMyAthlete(); SnookerMatchScore match = e.MatchScore; match.YourName = "Unknown"; if (match.YourAthleteID == me.AthleteID) { match.YourName = me.Name; match.YourPicture = me.Picture; } else { var person = App.Cache.People.Get(match.YourAthleteID); if (person != null) { match.YourName = person.Name; match.YourPicture = person.Picture; } } if (match.OpponentAthleteID > 0) { var person = App.Cache.People.Get(match.OpponentAthleteID); if (person != null) { match.OpponentPicture = person.Picture; } } var page = new RecordMatchPage(match, true); // NewMatch2Page(match, true); App.Navigator.NavPage.Navigation.PushModalAsync(page); }
void ctrl_UserWantsToEditScore(object sender, SnookerEventArgs e) { var me = App.Repository.GetMyAthlete(); SnookerMatchScore match = e.MatchScore; match.YourName = "Unknown"; if (match.YourAthleteID != me.AthleteID) { App.Navigator.DisplayAlertRegular("Cannot edit someone else's match."); return; } if (match.OpponentConfirmation == OpponentConfirmationEnum.Confirmed) { App.Navigator.DisplayAlertRegular("Cannot edit a confirmed match."); return; } match.YourName = me.Name; match.YourPicture = me.Picture; if (match.OpponentAthleteID > 0) { var person = App.Cache.People.Get(match.OpponentAthleteID); if (person != null) { match.OpponentPicture = person.Picture; } } var page = new RecordMatchPage(match, false); // NewMatch2Page(match, false); App.Navigator.NavPage.Navigation.PushModalAsync(page); }
private void buttonStartMatch_Clicked(object sender, EventArgs e) { if (alertAboutSettingsIfNecessary()) { return; } this.registerControl.Clear(); FVOConfig config = FVOConfig.LoadFromKeyChain(App.KeyChain); if (config.IsOk == false) { return; } if (personA == null || personB == null) { this.DisplayAlert("Byb", "Select both players before starting the match.", "OK"); return; } SnookerMatchMetadata metadata = new SnookerMatchMetadata(); metadata.Date = DateTime.Now; if (this.personA != null) { metadata.PrimaryAthleteID = this.personA.ID; metadata.PrimaryAthleteName = this.personA.Name; metadata.PrimaryAthletePicture = this.personA.Picture; } if (this.personB != null) { metadata.OpponentAthleteID = this.personB.ID; metadata.OpponentAthleteName = this.personB.Name; metadata.OpponentPicture = this.personB.Picture; } metadata.TableSize = config.TableSize; metadata.VenueID = config.VenueID; metadata.VenueName = config.VenueName; RecordMatchPage page = new RecordMatchPage(metadata); this.Navigation.PushModalAsync(page); page.Disappearing += (s1, e1) => { this.buttonReset_Clicked(this, EventArgs.Empty); this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing; }; }
private async void buttonNewMatch_Clicked(object sender, EventArgs e) { if (App.Navigator.GetOpenedPage(typeof(RecordMatchPage)) != null) { return; } var page2 = new RecordMatchPage(this.metadata); await App.Navigator.NavPage.Navigation.PushModalAsync(page2); page2.Disappearing += (s1, e1) => { this.metadata = new MetadataHelper().FromScoreForYou(page2.MatchScore); this.metadataControl.Fill(this.metadata); }; }
void fillPausedMatches() { // incompleted matches in the db var scoreObjs = (from i in App.Repository.GetScores(false) where i.IsUnfinished == true orderby i.TimeModified descending select i).ToList(); this.panelNewMatch.IsVisible = scoreObjs.Count() == 0; this.panelPausedMatches.Children.Clear(); foreach (var scoreObj in scoreObjs) { var match = SnookerMatchScore.FromScore(scoreObj.AthleteAID, scoreObj); var matchMetadata = new MetadataHelper().FromScoreForYou(match); var metadataControl = new SnookerMatchMetadataControl(matchMetadata, true) { Padding = new Thickness(0, 0, 0, 0) }; this.panelPausedMatches.Children.Add(metadataControl); var buttonDelete = new BybButton() { Text = "Cancel the match", Style = (Style)App.Current.Resources["BlackButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand, }; buttonDelete.Clicked += async(s1, e1) => { if (await App.Navigator.NavPage.DisplayAlert("Byb", "Delete this match?", "Yes, delete", "Cancel") == true) { App.Repository.SetIsDeletedOnScore(scoreObj.ScoreID, true); this.DoOnOpen(); } }; var buttonContinue = new BybButton() { Text = "Continue the match", Style = (Style)App.Current.Resources["LargeButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand, }; buttonContinue.Clicked += async(s1, e1) => { new MetadataHelper().ToScore(matchMetadata, match); var page = new RecordMatchPage(match, false); await App.Navigator.NavPage.Navigation.PushModalAsync(page); }; this.panelPausedMatches.Children.Add(new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(0, 12, 0, 0), Spacing = 1, Children = { buttonDelete, buttonContinue } }); this.panelPausedMatches.Children.Add(new BoxView() { HeightRequest = 25 }); // load opponent names from web if it's not loaded yet if (matchMetadata.OpponentAthleteID > 0 && string.IsNullOrEmpty(matchMetadata.OpponentAthleteName) == true) { Task.Run(async() => { await App.Cache.LoadFromWebserviceIfNecessary_People(new List <int> () { matchMetadata.OpponentAthleteID }); var person = App.Cache.People.Get(matchMetadata.OpponentAthleteID); if (person != null) { Device.BeginInvokeOnMainThread(() => { match.OpponentName = person.Name; match.OpponentPicture = person.Picture; matchMetadata.OpponentAthleteName = person.Name; matchMetadata.OpponentPicture = person.Picture; metadataControl.Refill(); }); } }); } ; } }