public SnookerMatchMetadata FromBreak(SnookerBreak snookerBreak) { var me = App.Repository.GetMyAthlete(); SnookerMatchMetadata metadata = new SnookerMatchMetadata() { Date = snookerBreak.Date, PrimaryAthleteID = me.AthleteID, PrimaryAthleteName = me.Name, PrimaryAthletePicture = me.Picture, OpponentAthleteID = snookerBreak.OpponentAthleteID, OpponentAthleteName = snookerBreak.OpponentName, OpponentPicture = null, TableSize = snookerBreak.TableSize, VenueID = snookerBreak.VenueID, VenueName = snookerBreak.VenueName, }; if (metadata.OpponentAthleteID > 0) { var person = App.Cache.People.Get(metadata.OpponentAthleteID); if (person != null) { metadata.OpponentAthleteName = person.Name; metadata.OpponentPicture = person.Picture; } } return(metadata); }
public RecordBreakPage(SnookerBreak snookerBreak, bool isOpponentsBreak, bool isSingleNotableMode) { this.IsSingleNotableMode = isSingleNotableMode; this.SnookerBreak = snookerBreak.Clone(); this.IsOpponentsBreak = isOpponentsBreak; this.metadata = new MetadataHelper().FromBreak(snookerBreak); this.init(); this.fill(); }
public RecordBreakPage(SnookerMatchMetadata metadata, bool isOpponentsBreak, bool isSingleNotableMode) { this.IsSingleNotableMode = isSingleNotableMode; this.SnookerBreak = new SnookerBreak(); this.IsOpponentsBreak = isOpponentsBreak; this.metadata = metadata; this.init(); this.fill(); }
public void ToScore(SnookerMatchMetadata metadata, SnookerMatchScore score) { score.YourAthleteID = metadata.PrimaryAthleteID; score.YourName = metadata.PrimaryAthleteName; score.YourPicture = metadata.PrimaryAthletePicture; score.Date = metadata.Date; score.TableSize = metadata.TableSize; score.OpponentAthleteID = metadata.OpponentAthleteID; score.OpponentName = metadata.OpponentAthleteName; score.OpponentPicture = metadata.OpponentPicture; score.VenueID = metadata.VenueID; score.VenueName = metadata.VenueName; }
public SnookerMatchMetadata CreateDefault() { var myAthlete = App.Repository.GetMyAthlete(); var metadata = new SnookerMatchMetadata(); metadata.Date = DateTime.Now; metadata.TableSize = SnookerTableSizeEnum.Table12Ft; metadata.PrimaryAthleteID = myAthlete.AthleteID; metadata.PrimaryAthleteName = myAthlete.Name; metadata.PrimaryAthletePicture = myAthlete.Picture; return(metadata); }
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); }; }
public SnookerMatchMetadata FromScoreForYou(SnookerMatchScore score) { var me = App.Repository.GetMyAthlete(); SnookerMatchMetadata metadata = new SnookerMatchMetadata() { Date = score.Date, PrimaryAthleteID = me.AthleteID, PrimaryAthleteName = me.Name ?? "", PrimaryAthletePicture = me.Picture, OpponentAthleteID = score.OpponentAthleteID, OpponentAthleteName = score.OpponentName ?? "", OpponentPicture = score.OpponentPicture, TableSize = score.TableSize, VenueID = score.VenueID, VenueName = score.VenueName, }; if (metadata.OpponentAthleteID > 0) { var person = App.Cache.People.Get(metadata.OpponentAthleteID); if (person != null) { metadata.OpponentAthleteName = person.Name; metadata.OpponentPicture = person.Picture; } } if (metadata.VenueID > 0) { var venue = App.Cache.Venues.Get(metadata.VenueID); if (venue != null) { metadata.VenueName = venue.Name; } } return(metadata); }
public RecordControl() { this.metadata = new MetadataHelper().CreateDefault(); this.Padding = new Thickness(0); this.BackgroundColor = Config.ColorGrayBackground; // new match panel this.metadataControl = new SnookerMatchMetadataControl(this.metadata, true); this.metadataControl.Padding = new Thickness(0, 0, 0, 0); this.buttonNewMatch = new BybButton() { Text = "Record a match", Style = (Style)App.Current.Resources["BlackButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand, }; this.buttonNewBreak = new BybButton() { Text = "Record a break", Style = (Style)App.Current.Resources["BlackButtonStyle"], HorizontalOptions = LayoutOptions.FillAndExpand }; this.buttonNewMatch.Clicked += buttonNewMatch_Clicked; this.buttonNewBreak.Clicked += buttonNewBreak_Clicked; this.panelNewMatch = new StackLayout() { Orientation = StackOrientation.Vertical, Spacing = 0, Padding = new Thickness(0), Children = { this.metadataControl, new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(0, 12, 0, 0), Spacing = Config.SpaceBetweenButtons, Children = { this.buttonNewBreak, this.buttonNewMatch, } } } }; // paused matches panel this.panelPausedMatches = new StackLayout() { Orientation = StackOrientation.Vertical, Spacing = 0, Padding = new Thickness(0, 0, 0, 0) }; // the top level stack this.stackTopLevel = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = new Thickness(12, 12, 12, 12), Spacing = 0, Children = { this.panelPausedMatches, this.panelNewMatch, } }; this.Content = this.stackTopLevel; this.stackTopLevel.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { App.Navigator.ShowInternalOptions(); }), NumberOfTapsRequired = 2, }); }
public SnookerBreakControl(SnookerMatchMetadata metadata, Label labelPointsLeft, BallsOnTable ballsOnTable, LargeNumberEntry2 entryA, LargeNumberEntry2 entryB) { this.metadata = metadata; this.sbcLabelPointsLeft = labelPointsLeft; this.localBallsOnTable = ballsOnTable; this.framePointsEntryA = entryA; this.framePointsEntryB = entryB; if ((this.framePointsEntryA.Number != null) && (this.framePointsEntryB.Number != null)) { curA = (int)this.framePointsEntryA.Number; curB = (int)this.framePointsEntryB.Number; } else { curA = 0; curB = 0; } updatePointsDiff(); /// pocketed balls /// this.panelPocketedBalls1 = new StackLayout() { HeightRequest = Config.SmallBallSize + (Config.IsTablet ? 5 : 2), Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Spacing = Config.IsTablet ? 3 : 1, Padding = new Thickness(0), }; this.panelPocketedBalls2 = new StackLayout() { HeightRequest = Config.SmallBallSize + (Config.IsTablet ? 5 : 2), Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Spacing = Config.IsTablet ? 3 : 1, Padding = new Thickness(0), }; this.panelPocketedBalls3 = new StackLayout() { HeightRequest = Config.SmallBallSize + (Config.IsTablet ? 5 : 2), Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Spacing = Config.IsTablet ? 3 : 1, Padding = new Thickness(0), }; this.labelPoints = new BybLabel() { Text = "", TextColor = Config.ColorTextOnBackground, VerticalOptions = LayoutOptions.Center, }; this.labelNoPoints = new BybLabel() { IsVisible = true, Text = "Tap on balls, then swipe here to finish break", //Text = "Tap on balls\r\nThen swipe here to assign to a player", //Text = "Tap balls, then swipe here to assign to player", TextColor = Config.ColorGrayTextOnWhite, //FontFamily = Config.FontFamily, //FontSize = Config.DefaultFontSize - 1, VerticalOptions = LayoutOptions.Fill, VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Fill, HorizontalTextAlignment = TextAlignment.Center, }; this.buttonDelete = new BybLabel() { Text = "X", TextColor = Config.ColorTextOnBackground, WidthRequest = Config.IsTablet ? 35 : 25, HeightRequest = Config.IsTablet ? 35 : 30, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, }; this.buttonDelete.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.buttonDelete_Clicked(this, EventArgs.Empty); }) }); this.foulCheckbox = new CheckBox() { Checked = false, DefaultText = "- tap here if a foul -", UncheckedText = "- tap here if a foul -", CheckedText = "Foul", FontSize = Config.DefaultFontSize, FontName = Config.FontFamily, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, }; this.foulCheckbox.CheckedChanged += (s1, e1) => { updateFoul(this.foulCheckbox.Checked); }; // container for balls and delete button var panelPocketedBallsActualBallsContainer = new StackLayout() { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.Center, Spacing = 0, Padding = new Thickness(0), //BackgroundColor = Color.Yellow, Children = { this.labelNoPoints, this.labelPoints, new StackLayout() { Orientation = StackOrientation.Vertical, Padding = new Thickness(0), Spacing = 0, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Children = { this.panelPocketedBalls1, this.panelPocketedBalls2, this.panelPocketedBalls3, } }, this.buttonDelete, this.foulCheckbox } }; /// the panel with pocketed balls and tips /// // draggable panel this.swipePanel = new SwipePanel( panelPocketedBallsActualBallsContainer, "Add to " + (this.metadata.OpponentAthleteName ?? "Opponent"), "Add to " + (this.metadata.PrimaryAthleteName ?? "You"), this.panelPocketedBallsHeight) { Opacity = 0.01, HeightRequest = this.panelPocketedBallsHeight, Padding = new Thickness(0, 0, 0, 0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start, BackgroundColor = Config.ColorBlackBackground, }; this.swipePanel.breakOwnerChanged += swipePanel_breakOwnerChanged; this.swipePanel.DraggedLeft += () => { if (true == this.swipePanel.getIsOpponentBreak()) { // if Swiped left, but was counting for opponent: // - change the break owner first // - and update the frame score this.swipePanel.setIsOpponentBreak(false); updateOwnerChanged(); } localBallsOnTable.breakFinished(); updatePointsDiff(); if (this.DoneLeft != null) { this.DoneLeft(this, EventArgs.Empty); } }; this.swipePanel.DraggedRight += () => { if (false == this.swipePanel.getIsOpponentBreak()) { // if Swiped right, but was counting for "me": // - change the break owner first // - and update the frame score this.swipePanel.setIsOpponentBreak(true); updateOwnerChanged(); } localBallsOnTable.breakFinished(); updatePointsDiff(); if (this.DoneRight != null) { this.DoneRight(this, EventArgs.Empty); } }; /// balls /// buttonsBalls = new List <Button>(); foreach (var color in Config.BallColors) { Color textColor = Color.White; if (Config.BallColors.IndexOf(color) == 0) { textColor = Color.Gray; } if (Config.BallColors.IndexOf(color) == 2) { textColor = Color.Gray; } Color borderColor = Color.Black; if (Config.BallColors.IndexOf(color) == 7) { borderColor = Config.ColorTextOnBackgroundGrayed; } var buttonBall = new BybButton { Text = Config.BallColors.IndexOf(color) == 0 ? "x" : Config.BallColors.IndexOf(color).ToString(), BackgroundColor = color, BorderColor = borderColor, TextColor = textColor, BorderWidth = 1, BorderRadius = (int)(sizeOfBalls / 2), HeightRequest = sizeOfBalls, MinimumHeightRequest = sizeOfBalls, WidthRequest = sizeOfBalls, MinimumWidthRequest = sizeOfBalls, FontFamily = Config.FontFamily, FontSize = Config.LargerFontSize, FontAttributes = Config.BallColors.IndexOf(color) == 1 ? FontAttributes.Bold : FontAttributes.None }; buttonBall.Clicked += buttonBall_Clicked; buttonsBalls.Add(buttonBall); } this.grid = new Grid() { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, ColumnSpacing = 0, RowSpacing = 0, Padding = new Thickness(0, padding, 0, 0), BackgroundColor = Config.ColorBlackBackground, ColumnDefinitions = { //new ColumnDefinition() { Width = new GridLength(90, GridUnitType.Absolute) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, //new ColumnDefinition() { Width = new GridLength(90, GridUnitType.Absolute) }, }, RowDefinitions = { new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) } }, }; this.buildPanelBalls(); //grid.Children.Add(panelBalls, 0, 0);//1, 0); this.HelpButtonControl = new HelpButtonControl() { HorizontalOptions = LayoutOptions.Start, Padding = new Thickness(0, 0, 0, 0), }; this.label_ballsOnTable = new BybLabel() { Text = "On table", TextColor = Config.ColorGrayTextOnWhite, VerticalOptions = LayoutOptions.Fill, VerticalTextAlignment = TextAlignment.Start, HorizontalOptions = LayoutOptions.Fill, HorizontalTextAlignment = TextAlignment.Start, }; // add a ball this.label_redsOnTable = new BybLabel() { Text = "15", TextColor = Config.ColorTextOnBackground, VerticalOptions = LayoutOptions.Center, }; int ballScore = 1; // or for lowest colored Color color2 = Config.BallColors[ballScore]; Color borderColor2 = color2; Color textColor2 = Color.Black; int ballSizeMedium = (int)(Config.SmallBallSize * 1.5); redBall = new BybButton { IsEnabled = true, Text = "", BackgroundColor = color2, BorderColor = borderColor2, FontFamily = Config.FontFamily, FontSize = Config.LargerFontSize, TextColor = textColor2, BorderWidth = 1, BorderRadius = (int)(ballSizeMedium / 2), HeightRequest = ballSizeMedium, MinimumHeightRequest = ballSizeMedium, WidthRequest = ballSizeMedium, MinimumWidthRequest = ballSizeMedium, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }; redBall.Clicked += (object sender, EventArgs e) => { Console.WriteLine("Red ball clicked "); pickerReds.IsEnabled = true; pickerReds.Focus(); }; this.pickerReds = new BybNoBorderPicker() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, IsVisible = false, IsEnabled = false }; this.pickerReds.Items.Add("0"); this.pickerReds.Items.Add("1"); this.pickerReds.Items.Add("2"); this.pickerReds.Items.Add("3"); this.pickerReds.Items.Add("4"); this.pickerReds.Items.Add("5"); this.pickerReds.Items.Add("6"); this.pickerReds.Items.Add("7"); this.pickerReds.Items.Add("8"); this.pickerReds.Items.Add("9"); this.pickerReds.Items.Add("10"); this.pickerReds.Items.Add("11"); this.pickerReds.Items.Add("12"); this.pickerReds.Items.Add("13"); this.pickerReds.Items.Add("14"); this.pickerReds.Items.Add("15"); this.pickerReds.SelectedIndex = 0; this.pickerReds.SelectedIndexChanged += pickerReds_SelectedIndexChanged; this.pickerColors = new BybNoBorderPicker() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, //HeightRequest = 50 }; this.pickerColors.Items.Add("2"); this.pickerColors.Items.Add("3"); this.pickerColors.Items.Add("4"); this.pickerColors.Items.Add("5"); this.pickerColors.Items.Add("6"); this.pickerColors.Items.Add("7"); this.pickerColors.SelectedIndex = 0; this.pickerColors.SelectedIndexChanged += pickerColors_SelectedIndexChanged; // add colored ball ballScore = 2; // or for lowest colored color2 = Config.BallColors[ballScore]; borderColor2 = color2; textColor2 = Color.Gray; coloredBall = new BybButton { IsEnabled = true, Text = "", BackgroundColor = color2, BorderColor = borderColor2, FontFamily = Config.FontFamily, FontSize = Config.LargerFontSize, TextColor = textColor2, BorderWidth = 1, BorderRadius = (int)(ballSizeMedium / 2), HeightRequest = ballSizeMedium, MinimumHeightRequest = ballSizeMedium, WidthRequest = ballSizeMedium, MinimumWidthRequest = ballSizeMedium, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }; coloredBall.Clicked += (object sender, EventArgs e) => { if (0 != localBallsOnTable.numberOfReds) { Console.WriteLine("Colored ball clicked: but there are reds on the table, so ignore"); } else { Console.WriteLine("Colored ball clicked "); pickerColors.IsEnabled = true; pickerColors.Focus(); } }; this.stack_ballsOnTable = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(Config.IsTablet ? 30 : 15, 0, 0, 0), Spacing = 10, //HorizontalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, Children = { label_ballsOnTable, new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Start, Spacing = buttonSpacing, Padding = new Thickness(0), Children = { redBall, label_redsOnTable, pickerReds } }, new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Start, Spacing = buttonSpacing, Padding = new Thickness(0), Children = { coloredBall, pickerColors } }, } }; this.VoiceButtonControl = new VoiceButtonControl() { HorizontalOptions = LayoutOptions.Start, Padding = new Thickness(0, 0, 0, 0), }; grid.Children.Add(new StackLayout() { Orientation = StackOrientation.Vertical, Padding = new Thickness(Config.IsTablet ? 30 : 15, 0, 0, 0), Spacing = 10, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, Children = { this.stack_ballsOnTable, (new BoxView() { HeightRequest = 40, BackgroundColor = Config.ColorBlackBackground, }), this.HelpButtonControl, this.VoiceButtonControl, } }, 0, 0); /// content /// this.BackgroundColor = Config.ColorBlackBackground; this.Padding = new Thickness(0); this.Spacing = 0; this.Orientation = StackOrientation.Vertical; this.Children.Add(new BoxView() { HeightRequest = 1, BackgroundColor = Config.ColorBackground, }); this.Children.Add(this.swipePanel); this.Children.Add(new BoxView() { HeightRequest = 1, BackgroundColor = Config.ColorBackground, }); this.Children.Add(grid); this.updateControls(); // update pickers updateBallsOnTable_ballsChanged(); }
public PickOwnerOfABreakPage(SnookerMatchMetadata metadata) { this.metadata = metadata; this.title = new BybTitle("Whose Break Is It?") { VerticalOptions = LayoutOptions.Start }; double imageSize = Config.DeviceScreenHeightInInches < 4 ? 70 : 100; // images this.imageYou = new Image() { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Source = App.ImagesService.GetImageSource(null) }; this.imageOpponent = new Image() { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Source = App.ImagesService.GetImageSource(null) }; this.labelYou = new BybLabel() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Text = "You" }; this.labelOpponent = new BybLabel() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, }; Grid gridWithImages = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0), ColumnSpacing = 0, RowSpacing = 0, BackgroundColor = Color.White, }; gridWithImages.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); gridWithImages.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Absolute) }); gridWithImages.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); gridWithImages.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(10, GridUnitType.Absolute) }); gridWithImages.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(imageSize, GridUnitType.Absolute) }); gridWithImages.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40, GridUnitType.Absolute) }); gridWithImages.Children.Add(this.imageYou, 0, 1); gridWithImages.Children.Add(this.imageOpponent, 2, 1); gridWithImages.Children.Add(this.labelYou, 0, 2); gridWithImages.Children.Add(this.labelOpponent, 2, 2); this.imageYou.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { youClicked(); }), NumberOfTapsRequired = 1 }); this.labelYou.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { youClicked(); }), NumberOfTapsRequired = 1 }); this.imageOpponent.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { opponentClicked(); }), NumberOfTapsRequired = 1 }); this.labelOpponent.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { opponentClicked(); }), NumberOfTapsRequired = 1 }); // cancel button Button buttonCancel = new BybButton { Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Cancel" }; buttonCancel.Clicked += (s1, e1) => { if (this.UserMadeSelection != null) { this.UserMadeSelection(this, null); } }; var panelOkCancel = new StackLayout() { Orientation = StackOrientation.Horizontal, //BackgroundColor = Config.ColorBackground, HorizontalOptions = LayoutOptions.Fill, HeightRequest = Config.OkCancelButtonsHeight, Padding = new Thickness(Config.OkCancelButtonsPadding), Spacing = 1, Children = { buttonCancel } }; // content Content = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, Children = { new ScrollView { Padding = new Thickness(0), VerticalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Padding = new Thickness(0), Spacing = 0, Orientation = StackOrientation.Vertical, Children = { title, gridWithImages } } }, panelOkCancel } }; Padding = new Thickness(0, 0, 0, 0); this.labelYou.Text = metadata.PrimaryAthleteName; this.imageYou.Source = App.ImagesService.GetImageSource(metadata.PrimaryAthletePicture); if (this.metadata.HasOpponentAthlete == false) { this.imageOpponent.Source = new FileImageSource() { File = "plus.png" }; this.labelOpponent.Text = "Pick"; } else { this.imageOpponent.Source = App.ImagesService.GetImageSource(this.metadata.OpponentPicture); this.labelOpponent.Text = this.metadata.OpponentAthleteName; } }
public void Fill(SnookerMatchMetadata metadata) { this.Metadata = metadata; this.isOpponentMarkedAsUnknown = false; this.fill(); }
public SnookerMatchMetadataControl(SnookerMatchMetadata metadata, bool showPlayers)//, bool pausedMatchMode = false) { //this.PausedMatchMode = pausedMatchMode; this.Orientation = StackOrientation.Vertical; this.BackgroundColor = Config.ColorGrayBackground; this.Padding = new Thickness(0); this.Spacing = 0; this.HorizontalOptions = LayoutOptions.FillAndExpand; this.VerticalOptions = LayoutOptions.Start; // date Label labelDateLabel = new BybLabel() { Text = "Date", WidthRequest = 65, TextColor = Config.ColorTextOnBackgroundGrayed, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, }; this.pickerDate = new BybDatePicker() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, HeightRequest = Config.LargeButtonsHeight + 8, Format = "D", MinimumDate = new DateTime(1980, 1, 1), MaximumDate = DateTime.Now.Date, }; this.pickerDate.DateSelected += pickerDate_DateSelected; Image imageDate = new Image() { VerticalOptions = LayoutOptions.Center, WidthRequest = Config.RedArrowImageSize, HeightRequest = Config.RedArrowImageSize, Source = new FileImageSource() { File = "arrowRight.png" } }; var panelDate = new StackLayout() { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.White, Padding = new Thickness(12, 0, 12, 0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Children = { labelDateLabel, this.pickerDate, imageDate, } }; // imageDate.GestureRecognizers.Add (new TapGestureRecognizer () { // Command = new Command (() => { // this.pickerDate.Focus(); // }), // }); labelDateLabel.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.pickerDate.Focus(); }) }); panelDate.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.pickerDate.Focus(); }) }); this.Children.Add(panelDate); this.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = 1 }); // venue Label labelVenueLabel = new BybLabel { Text = "Venue", TextColor = Config.ColorTextOnBackgroundGrayed, WidthRequest = 65, VerticalTextAlignment = TextAlignment.Center }; this.labelVenue = new BybLabel() { TextColor = Color.Black, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, //BackgroundColor = Color.Aqua, }; Image imageVenue = new Image() { VerticalOptions = LayoutOptions.Center, WidthRequest = Config.RedArrowImageSize, HeightRequest = Config.RedArrowImageSize, Source = new FileImageSource() { File = "arrowRight.png" }, BackgroundColor = Color.White, }; Image imageClearVenue = new Image() { VerticalOptions = LayoutOptions.Center, WidthRequest = Config.RedArrowImageSize, HeightRequest = Config.RedArrowImageSize, Source = new FileImageSource() { File = "delete.png" }, BackgroundColor = Color.White, }; this.frameClearVenue = new Frame() { WidthRequest = 30, HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(0), BackgroundColor = Color.White, Content = imageClearVenue, IsVisible = false, }; this.frameClearVenue.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.clearVenueClicked(); }) }); var panelVenue = new StackLayout() { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(12, 0, 12, 0), HeightRequest = Config.LargeButtonsHeight + 8, //50, Children = { labelVenueLabel, labelVenue, frameClearVenue, imageVenue, } }; labelVenueLabel.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { venueClicked(); }) }); labelVenue.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { venueClicked(); }) }); panelVenue.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { venueClicked(); }) }); this.Children.Add(panelVenue); this.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = 1 }); // table Label labelTableLabel = new BybLabel { Text = "Table", TextColor = Config.ColorTextOnBackgroundGrayed, WidthRequest = 65, VerticalTextAlignment = TextAlignment.Center }; this.pickerTable = new BybNoBorderPicker() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, }; this.pickerTable.Items.Add("10' table"); this.pickerTable.Items.Add("12' table"); this.pickerTable.SelectedIndex = 1; this.pickerTable.SelectedIndexChanged += pickerTable_SelectedIndexChanged; Image imageTable = new Image() { VerticalOptions = LayoutOptions.Center, WidthRequest = Config.RedArrowImageSize, HeightRequest = Config.RedArrowImageSize, Source = new FileImageSource() { File = "arrowRight.png" } }; var panelTable = new StackLayout() { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(12, 0, 12, 0), HeightRequest = Config.LargeButtonsHeight + 8, // 50, Children = { labelTableLabel, this.pickerTable, imageTable, } }; labelTableLabel.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.pickerTable.Focus(); }) }); // imageTable.GestureRecognizers.Add (new TapGestureRecognizer () { // Command = new Command (() => { // this.pickerTable.Focus(); // }) // }); panelTable.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.pickerTable.Focus(); }) }); this.Children.Add(panelTable); this.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = 1 }); // what should be the image size? double imageSize = 100;// Config.DeviceScreenHeightInInches < 4 ? 80 : 110; // you vs opponent this.imageYou = new BybPersonImage() { //HorizontalOptions = LayoutOptions.Fill, //VerticalOptions = LayoutOptions.Center, Background = BackgroundEnum.White, UseNameAbbreviationIfNoPicture = false, //BackgroundColor = Color.Red, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 200, HeightRequest = 200, }; this.imageOpponent = new BybPersonImage() { //HorizontalOptions = LayoutOptions.Fill, //VerticalOptions = LayoutOptions.Center, Background = BackgroundEnum.White, UseNameAbbreviationIfNoPicture = false, //BackgroundColor = Color.Yellow, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, WidthRequest = 200, HeightRequest = 200, }; this.labelYou = new BybLabel() { TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, Text = "You" }; this.labelOpponent = new BybLabel() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, TextColor = Config.ColorBlackTextOnWhite, }; Grid gridWithImages = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0), ColumnSpacing = 0, RowSpacing = 0, BackgroundColor = Color.White, }; if (showPlayers) { this.Children.Add(gridWithImages); } gridWithImages.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); gridWithImages.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Absolute) }); gridWithImages.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); gridWithImages.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(12, GridUnitType.Absolute) }); gridWithImages.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(imageSize, GridUnitType.Absolute) }); gridWithImages.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40, GridUnitType.Absolute) }); gridWithImages.Children.Add(this.imageYou, 0, 1); gridWithImages.Children.Add(this.imageOpponent, 2, 1); gridWithImages.Children.Add(this.labelYou, 0, 2); gridWithImages.Children.Add(this.labelOpponent, 2, 2); gridWithImages.Children.Add(new BoxView() { BackgroundColor = Config.ColorGrayBackground }, 1, 2, 0, 3); this.imageYou.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { youClicked(); }), NumberOfTapsRequired = 1 }); this.labelYou.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { youClicked(); }), NumberOfTapsRequired = 1 }); this.imageOpponent.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { opponentClicked(); }), NumberOfTapsRequired = 1 }); this.labelOpponent.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { opponentClicked(); }), NumberOfTapsRequired = 1 }); this.Children.Add(new BoxView { Color = Color.Transparent, HeightRequest = 1 }); this.Fill(metadata); //if (this.PausedMatchMode) //{ // this.pickerDate.IsEnabled = false; // this.pickerTable.IsEnabled = false; // this.labelVenue.IsEnabled = false; // this.labelYou.IsEnabled = false; // this.labelOpponent.IsEnabled = false; // this.pickerDate.Opacity = 0.5; // this.pickerTable.Opacity = 0.5; // this.labelVenue.Opacity = 0.5; // this.labelYou.Opacity = 0.5; // this.labelOpponent.Opacity = 0.5; //} }