Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        public FVOConfigPage()
        {
            this.BackgroundColor = Config.ColorGrayBackground;
            double labelWidth1 = 160;

            // venue
            this.labelVenue = new BybLabel()
            {
                FontAttributes = FontAttributes.Bold, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center
            };
            Image imageVenue = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelVenue = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Venue", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelVenue,
                    imageVenue,
                }
            };

            panelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.buttonVenue_Clicked(); })
            });

            // table type
            this.pickerTableType = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            this.pickerTableType.Items.Add("10'");
            this.pickerTableType.Items.Add("12'");
            Image imageTableType = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelTableType = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Table size", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    pickerTableType,
                    imageTableType,
                }
            };

            panelTableType.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pickerTableType.Focus(); })
            });

            // notable break threshold
            this.pickerNotableBreakThreshold = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (int threshold in notableBreakThresholds)
            {
                this.pickerNotableBreakThreshold.Items.Add(threshold.ToString());
            }
            Image imageNotableBreakThreshold = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelNotableBreakThreshold = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //HeightRequest = Config.LargeButtonsHeight,
                Spacing         = 0,
                Padding         = new Thickness(15, 0, 15, 0),
                BackgroundColor = Color.White,
                Children        =
                {
                    new BybLabel {
                        Text = "Notable break threshold", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    pickerNotableBreakThreshold,
                    imageNotableBreakThreshold,
                }
            };

            panelNotableBreakThreshold.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pickerNotableBreakThreshold.Focus(); })
            });

            // table description
            this.entryTableDescription = new BybNoBorderEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Placeholder       = "optional",
            };
            var panelTableDescription = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Table description", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    entryTableDescription,
                }
            };

            // admi
            this.labelAdmin = new BybLabel()
            {
                FontAttributes = FontAttributes.Bold, TextColor = Config.ColorBlackTextOnWhite, HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center
            };
            Image imageAdmin = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = 20,
                HeightRequest   = 20,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelAdmin = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.LargeButtonsHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 0, 15, 0),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Admin", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelAdmin,
                    imageAdmin,
                }
            };

            panelAdmin.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                {
                    this.DisplayAlert("Byb", "To change the administrator - re-install the app.", "OK");
                })
            });

            // buttons
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "Ok"
            };

            buttonOk.Clicked += buttonOk_Clicked;
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["BlackButtonStyle"], Text = "Cancel"
            };

            buttonCancel.Clicked += buttonCancel_Clicked;

            var stackLayout = new StackLayout
            {
                Spacing         = 0,
                Padding         = new Thickness(0),
                BackgroundColor = Config.ColorGrayBackground,

                Children =
                {
                    new BybTitle("Settings")
                    {
                        VerticalOptions = LayoutOptions.Start
                    },

                    new StackLayout()
                    {
                        Orientation       = StackOrientation.Vertical,
                        WidthRequest      = 500,
                        HorizontalOptions = LayoutOptions.Center,
                        Padding           = new Thickness(20),
                        Spacing           = 5,
                        Children          =
                        {
                            panelVenue,
                            panelTableType,
                            panelTableDescription,
                            panelNotableBreakThreshold,
                            panelAdmin,

                            new StackLayout()
                            {
                                Spacing           = 1,
                                Orientation       = StackOrientation.Horizontal,
                                HorizontalOptions = LayoutOptions.Fill,
                                HeightRequest     = Config.OkCancelButtonsHeight,
                                Padding           = new Thickness(0, 10, 0, 0),
                                Children          =
                                {
                                    buttonCancel,
                                    buttonOk,
                                }
                            }
                        }
                    },
                }
            };

            this.Content = stackLayout;
            this.Padding = new Thickness(0, 0, 0, 0);

            this.fill();
        }
Esempio n. 3
0
        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;
            //}
        }
        public VoicePreferencesPage()
        {
            /// ok, cancel
            ///
            Button buttonOk = new BybButton {
                Style = (Style)App.Current.Resources["LargeButtonStyle"], Text = "OK"
            };
            Button buttonCancel = new BybButton {
                Style = (Style)App.Current.Resources["BlackButtonStyle"], Text = "Cancel"
            };

            buttonOk.Clicked     += buttonOk_Clicked;
            buttonCancel.Clicked += buttonCancel_Clicked;;
            var panelOkCancel = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = Config.ColorGrayBackground,//Config.ColorDarkGrayBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(Config.OkCancelButtonsPadding),
                Spacing           = 1,
                Children          =
                {
                    buttonCancel,
                    buttonOk,
                }
            };

            /// stack
            ///

            this.pickerVoice = new BybNoBorderPicker()
            {
                BackgroundColor = Color.White,
                HeightRequest   = 30,
            };
            this.pickerVoice.Items.Add("Default");

            this.voices = App.ScorePronouncer.GetVoices().ToList();
            foreach (var voice in voices)
            {
                this.pickerVoice.Items.Add(voice.ToString());
            }
            var voiceInPreferences = App.UserPreferences.Voice;
            var voiceToSelect      = (from i in voices
                                      where i.ToString() == voiceInPreferences
                                      select i).FirstOrDefault();

            if (voiceToSelect == null)
            {
                this.pickerVoice.SelectedIndex = 0;
            }
            else
            {
                this.pickerVoice.SelectedIndex = voices.IndexOf(voiceToSelect) + 1;
            }

            sliderRate = new Slider()
            {
                Minimum = UserPreferences.MinVoiceRate,
                Maximum = UserPreferences.MaxVoiceRate,
                Value   = App.UserPreferences.VoiceRate
            };

            sliderPitch = new Slider()
            {
                Minimum = UserPreferences.MinVoicePitch,
                Maximum = UserPreferences.MaxVoicePitch,
                Value   = App.UserPreferences.VoicePitch
            };

            buttonDefaultRateAndPitch = new BybButton()
            {
                Style = (Style)App.Current.Resources["SimpleButtonStyle"],
                Text  = "Default rate and pitch",
            };
            buttonDefaultRateAndPitch.Clicked += buttonDefaultRateAndPitch_Clicked;
            buttonTry = new BybButton()
            {
                Style        = (Style)App.Current.Resources["SimpleButtonStyle"],
                WidthRequest = 100,
                Text         = "Try"
            };
            buttonTry.Clicked += buttonTry_Clicked;

            StackLayout stack = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(20, 20, 20, 20),
                Children          =
                {
                    new BybLabel {
                        Text = "Voice & language", TextColor = Config.ColorBlackTextOnWhite,
                    },
                    pickerVoice,
                    new BybLabel {
                        Text = "Rate", TextColor = Config.ColorBlackTextOnWhite,
                    },
                    sliderRate,
                    new BybLabel {
                        Text = "Pitch", TextColor = Config.ColorBlackTextOnWhite,
                    },
                    sliderPitch,
                    new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Spacing           = 20,
                        Padding           = new Thickness(0, 20, 0, 0),
                        Children          =
                        {
                            buttonDefaultRateAndPitch,
                            buttonTry
                        }
                    }
                }
            };

            /// content
            ///
            this.Padding         = new Thickness(0);
            this.BackgroundColor = Config.ColorGrayBackground;
            var grid = new Grid()
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                Padding           = new Thickness(0),
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            grid.Children.Add(new BybTitle("Voice Configuration"), 0, 0);
            grid.Children.Add(stack, 0, 1);
            grid.Children.Add(panelOkCancel, 0, 2);
            this.Content = grid;
        }