예제 #1
0
        public FVOMainPage()
        {
            this.labelTitle = new BybLabel()
            {
                Text      = "Pick Opponents",
                TextColor = Config.ColorTextOnBackgroundGrayed,
                FontSize  = Config.VeryLargeFontSize,
            };

            this.labelSyncStatus = new BybLabel()
            {
                Text              = "",
                TextColor         = Config.ColorTextOnBackground,
                FontSize          = Config.LargerFontSize,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
            };

            /// selected players
            ///

            // player A
            imageA = new BybPersonImage()
            {
                WidthRequest      = imageSize,
                HeightRequest     = imageSize,
                HorizontalOptions = LayoutOptions.End,   //.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start, //.FillAndExpand,
                BackgroundColor   = Config.ColorBlackBackground,
            };
            imageA.SetImagePickOpponent();
            labelA = new BybLabel()
            {
                Text                    = "",
                TextColor               = Config.ColorTextOnBackground,
                HeightRequest           = 50,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            var panelA = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.End,
                Padding           = new Thickness(0),
                Spacing           = 0,
                Children          =
                {
                    imageA,
                    labelA,
                }
            };

            panelA.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.panelA_Clicked(); })
            });

            // player B
            imageB = new BybPersonImage()
            {
                WidthRequest      = imageSize,
                HeightRequest     = imageSize,
                HorizontalOptions = LayoutOptions.Start, //.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start, //.FillAndExpand,
                BackgroundColor   = Config.ColorBlackBackground,
            };
            imageB.SetImagePickOpponent();
            labelB = new BybLabel()
            {
                Text                    = "Select Player 2",
                TextColor               = Config.ColorTextOnBackground,
                HeightRequest           = 50,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            var panelB = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(0),
                Spacing           = 0,
                Children          =
                {
                    imageB,
                    labelB,
                }
            };

            panelB.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.panelB_Clicked(); })
            });

            Grid gridSelectedPlayers = new Grid()
            {
                //BackgroundColor = Color.Red,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Padding           = new Thickness(0),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(0.01, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1.00, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(0.01, GridUnitType.Star)
                    },
                }
            };

            gridSelectedPlayers.Children.Add(panelA, 1, 0);
            gridSelectedPlayers.Children.Add(new Frame()
            {
                Padding         = new Thickness(0, 0, 0, 50),
                HasShadow       = false,
                BackgroundColor = Color.Transparent,
                Content         = new BybLabel()
                {
                    Text                    = "vs.",
                    FontSize                = Config.VeryLargeFontSize + 20,
                    TextColor               = Config.ColorTextOnBackgroundGrayed,
                    VerticalOptions         = LayoutOptions.Center,
                    HorizontalOptions       = LayoutOptions.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                }
            }, 2, 0);
            gridSelectedPlayers.Children.Add(panelB, 3, 0);

            /// start/reset buttons
            ///
            this.buttonStartMatch = new BybButton()
            {
                Text  = "Start Match",
                Style = (Style)App.Current.Resources["LargeButtonStyle"]
            };
            buttonStartMatch.Clicked += buttonStartMatch_Clicked;
            this.buttonReset          = new BybButton()
            {
                Text  = "Reset",
                Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            buttonReset.Clicked += buttonReset_Clicked;

            /// bottom panel
            ///
            this.buttonSettings = new BybButton()
            {
                Text            = "Settings",
                Style           = (Style)App.Current.Resources["SimpleButtonStyle"],
                TextColor       = Config.ColorTextOnBackground,
                VerticalOptions = LayoutOptions.Center,
            };
            buttonSettings.Clicked += buttonSettings_Clicked;
            this.buttonHistory      = new BybButton()
            {
                Text            = "History",
                Style           = (Style)App.Current.Resources["SimpleButtonStyle"],
                TextColor       = Config.ColorTextOnBackground,
                VerticalOptions = LayoutOptions.Center,
            };
            this.buttonHistory.Clicked += buttonHistory_Clicked;
            //this.buttonHistory = new BybLabel()
            //{
            //    Text = "History",
            //    TextColor = Config.ColorTextOnBackground,
            //    VerticalOptions = LayoutOptions.Center,
            //    WidthRequest = 100,
            //    HeightRequest = 40,
            //    HorizontalTextAlignment = TextAlignment.End,
            //    VerticalTextAlignment = TextAlignment.Center,
            //};
            Label labelInfo = new BybLabel()
            {
                Text = "Tip: Install 'Snooker Byb' app on your personal mobile device.",
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.Center,
                TextColor = Config.ColorGrayTextOnWhite,
            };
            StackLayout panelBottom = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = Config.TitleHeight,
                Padding           = new Thickness(20, 0, 20, 0),
                BackgroundColor   = Config.ColorBackground,
                Children          =
                {
                    buttonSettings,
                    labelInfo,
                    buttonHistory,
                }
            };

            /// picking athletes panel
            ///

            // tab buttons
            this.buttonExisting = new BybButtonWithNumber("Existing")
            {
                IsNumberVisible = false, HeightRequest = Config.OkCancelButtonsHeight
            };
            this.buttonExisting.Clicked += (s1, e1) =>
            {
                this.registerControl.Clear();
                this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing;
            };
            this.buttonRegister = new BybButtonWithNumber("Register")
            {
                IsNumberVisible = false, HeightRequest = Config.OkCancelButtonsHeight
            };
            this.buttonRegister.Clicked += (s1, e1) =>
            {
                if (this.alertAboutSettingsIfNecessary())
                {
                    return;
                }
                this.PickingAthleteStatus = PickingAthleteStatusEnum.Register;
            };

            Grid panelPickingAthletes = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Config.ColorBackground,
            };

            this.findPeopleControl = new FindPeopleControl(false);
            this.findPeopleControl.UserClickedOnPerson += findPeopleControl_UserClickedOnPerson;
            this.findPeopleControl.BackgroundColor      = Config.ColorBackground;
            this.findPeopleControl.Padding              = new Thickness(0, 60, 10, 0);

            this.registerControl = new FVORegisterControl();
            this.registerControl.UserClickedCancel += registerControl_UserClickedCancel;
            this.registerControl.UserRegistered    += registerControl_UserRegistered;
            this.registerControl.Padding            = new Thickness(20, 80, 20, 20);

            panelPickingAthletes.Children.Add(this.findPeopleControl);
            panelPickingAthletes.Children.Add(this.registerControl);

            panelPickingAthletes.Children.Add(new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = Config.ColorBackground,
                Padding           = new Thickness(0, 0, 0, 0),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Children          =
                {
                    this.buttonExisting,
                    this.buttonRegister,
                }
            });

            /// layout
            ///
            Grid panelRoot = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(Config.TitleHeight, GridUnitType.Absolute)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(Config.TitleHeight - 20, GridUnitType.Absolute)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(3, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                }
            };

            panelRoot.Children.Add(
                new BybLabel()
            {
                Text              = "Snooker Byb",
                FontSize          = Config.VeryLargeFontSize,
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            }, 0, 2, 0, 1);
            panelRoot.Children.Add(
                new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.End,
                Padding           = new Thickness(0, 0, 20, 0),
                Children          =
                {
                    this.labelSyncStatus
                }
            }, 0, 2, 0, 1);
            panelRoot.Children.Add(
                new BoxView()
            {
                BackgroundColor   = Config.ColorBackground,
                HeightRequest     = 2,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.End,
            }, 0, 2, 0, 1);
            panelRoot.Children.Add(new Frame()
            {
                HasShadow         = false,
                BackgroundColor   = Color.Transparent,
                Padding           = new Thickness(40, 40, 0, 0),
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                Content           = labelTitle
            }, 0, 1);
            panelRoot.Children.Add(panelBottom, 0, 2, 2, 3);
            panelRoot.Children.Add(
                new BoxView()
            {
                BackgroundColor   = Config.ColorBlackBackground,
                HeightRequest     = 2,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
            }, 0, 2, 2, 3);
            panelRoot.Children.Add(new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(20, 0, 20, 20),
                Spacing           = 0,
                Children          =
                {
                    buttonReset,
                    buttonStartMatch,
                }
            }, 0, 1);
            panelRoot.Children.Add(gridSelectedPlayers, 0, 1);
            panelRoot.Children.Add(panelPickingAthletes, 1, 1);

            this.BackgroundColor = Config.ColorBlackBackground;
            this.Content         = panelRoot;
            NavigationPage.SetHasNavigationBar(this, false);

            this.fill();
            this.fillPickingAthletesPanel();

            this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing;

            App.Sync.StatusChanged += sync_StatusChanged;
        }
예제 #2
0
        void init()
        {
            /// top panel
            ///

            this.buttonBack = new BybBackButton()
            {
                LabelText = Config.App == MobileAppEnum.SnookerForVenues ? "All frames" : ""
            };
            this.buttonBack.Clicked += (s1, e1) =>
            {
                if (this.UserTappedBack != null)
                {
                    UserTappedBack();
                }
            };
            this.labelTop = new BybLabel()
            {
                Text              = "Frame " + (MatchScore.FrameScores.IndexOf(CurrentFrameScore) + 1).ToString(),
                TextColor         = Color.White,
                FontFamily        = Config.FontFamily,
                FontSize          = Config.LargerFontSize,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };
            this.labelDone = new BybLabel()
            {
                Text                    = "Done",
                TextColor               = Color.White,
                FontFamily              = Config.FontFamily,
                FontSize                = Config.LargerFontSize,
                HorizontalOptions       = LayoutOptions.End,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.End,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Grid buttonDone = new Grid()
            {
                Padding           = new Thickness(0, 0, Config.IsTablet ? 20 : 10, 0),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                //HasShadow = false,
                BackgroundColor = Config.ColorBlackBackground,
                //Content = this.labelDone,
                Children =
                {
                    this.labelDone
                }
            };

            buttonDone.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    if (this.UserTappedDone != null)
                    {
                        UserTappedDone();
                    }
                })
            });
            this.panelTop = new Grid()
            {
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Fill,
                Padding           = new Thickness(0, 20, 0, 0),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                RowDefinitions    =
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(Config.App == MobileAppEnum.SnookerForVenues ? 200 : 100, GridUnitType.Absolute)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(Config.App == MobileAppEnum.SnookerForVenues ? 200 : 100, GridUnitType.Absolute)
                    },
                }
            };
            panelTop.Children.Add(buttonBack, 0, 0);
            panelTop.Children.Add(this.labelTop, 1, 0);
            panelTop.Children.Add(buttonDone, 2, 0);
            if (Config.App == MobileAppEnum.SnookerForVenues)
            {
                // add a horizontal line
                panelTop.Children.Add(new BoxView()
                {
                    HeightRequest     = 1,
                    BackgroundColor   = Config.ColorBackground,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.End,
                }, 0, 3, 0, 1);
            }

            /// panel with the frame score, inside secondPanel
            ///
            this.entryCurrentFrameA = new LargeNumberEntry2(Config.ColorBlackBackground)
            {
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0, Config.IsTablet ? 15 : 5, 0, 0),
                WidthRequest      = Config.App == MobileAppEnum.SnookerForVenues ? 200 : (Config.IsTablet ? 70 : 60),
                TextAlignment     = TextAlignment.End,
            };
            this.entryCurrentFrameB = new LargeNumberEntry2(Config.ColorBlackBackground)
            {
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0, Config.IsTablet ? 15 : 5, 0, 0),
                WidthRequest      = Config.App == MobileAppEnum.SnookerForVenues ? 200 : (Config.IsTablet ? 70 : 60),
                TextAlignment     = TextAlignment.Start,
            };
            this.labelMatchScore = new BybLabel()
            {
                //Text = "Edit score",
                Text              = "Match score",
                TextColor         = Config.ColorTextOnBackgroundGrayed,
                HorizontalOptions = LayoutOptions.Center,
            };
            this.labelMatchScoreDigits = new BybLabel()
            {
                //Text = "Edit score",
                Text              = (this.MatchScore.MatchScoreA).ToString() + ":" + (this.MatchScore.MatchScoreB).ToString(),
                TextColor         = Config.ColorTextOnBackgroundGrayed,
                HorizontalOptions = LayoutOptions.Center,
            };

            /*
             *          this.labelTapToEditFrameScore = new BybLabel ()
             *          {
             *                  //Text = "Edit score",
             *                  Text = "Frame score",
             *                  TextColor = Config.ColorTextOnBackgroundGrayed,
             *                  HorizontalOptions = LayoutOptions.Center,
             *          };
             */
            this.labelPointsLeft = new BybLabel()
            {
                Text                  = "",
                TextColor             = Config.ColorTextOnBackgroundGrayed,
                HorizontalOptions     = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
            };
            if (Config.IsTablet)
            {
                this.labelPointsLeft.HeightRequest = 40;
            }
            this.entryCurrentFrameA.FocusedOnNumber     += entryCurrentFrameA_FocusedOnNumber;
            this.entryCurrentFrameB.FocusedOnNumber     += entryCurrentFrameB_FocusedOnNumber;
            this.entryCurrentFrameA.UnfocusedFromNumber += entryCurrentFrameA_UnfocusedFromNumber;
            this.entryCurrentFrameB.UnfocusedFromNumber += entryCurrentFrameB_UnfocusedFromNumber;
            this.entryCurrentFrameA.NumberChanged       += entryCurrentFrameA_NumberChanged;
            this.entryCurrentFrameB.NumberChanged       += entryCurrentFrameB_NumberChanged;
            this.panelFrame = new StackLayout()
            {
                IsVisible         = true,
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Spacing           = 0,
                Padding           = new Thickness(0, 0, 0, 0),
                //BackgroundColor = Color.Olive,
                Children =
                {
                    this.labelMatchScore,
                    this.labelMatchScoreDigits,
                    //this.labelTapToEditFrameScore,
                    new StackLayout()
                    {
                        //BackgroundColor = Color.Red,
                        Orientation       = StackOrientation.Horizontal,
                        Spacing           = 0,
                        Padding           = new Thickness(0,      0, 0, 0),
                        HorizontalOptions = LayoutOptions.Center,
                        Children          =
                        {
                            this.entryCurrentFrameA,
                            new BybLabel()
                            {
                                Text                    = ":",
                                FontSize                = Config.App == MobileAppEnum.SnookerForVenues ? 50 : Config.VeryLargeFontSize,
                                TextColor               = Config.ColorTextOnBackgroundGrayed,
                                WidthRequest            = 15,
                                HeightRequest           = Config.App == MobileAppEnum.SnookerForVenues ? 100 : 38,
                                VerticalOptions         = LayoutOptions.End,
                                HorizontalTextAlignment = TextAlignment.Center,
                                VerticalTextAlignment   = TextAlignment.Center,
                            },
                            this.entryCurrentFrameB,
                        }
                    },
                    this.labelPointsLeft,
                }
            };

            /// second panel
            ///
            this.imageYou = new BybPersonImage()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                WidthRequest      = imageSize,
                HeightRequest     = imageSize,
                BackgroundColor   = Color.Transparent,
                Background        = BackgroundEnum.Black,
            };
            this.imageOpponent = new BybPersonImage()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                WidthRequest      = imageSize,
                HeightRequest     = imageSize,
                BackgroundColor   = Color.Transparent,
                Background        = BackgroundEnum.Black,
            };
            this.imageYou.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => { this.imageYou_Clicked(); }),
                NumberOfTapsRequired = 1
            });
            this.imageOpponent.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => { this.imageOpponent_Clicked(); }),
                NumberOfTapsRequired = 1
            });
            this.panelSecond = new Grid
            {
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Padding           = new Thickness(15, panelSecondPaddingTop, 15, panelSecondPaddingBottom),
                ColumnSpacing     = 0,
                RowSpacing        = 0,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            panelSecond.Children.Add(this.imageYou, 0, 0);
            panelSecond.Children.Add(this.panelFrame, 1, 0);
            panelSecond.Children.Add(this.imageOpponent, 2, 0);

            /// a panel for entering frame score
            ///
            this.labelEnteringFrameScore = new BybLabel
            {
                Text                    = "",
                TextColor               = Config.ColorTextOnBackground,
                HeightRequest           = 40,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
            };
            panelEnteringFrameScore = new StackLayout()
            {
                IsVisible         = false,
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(0, 20, 0, 0),
                Spacing           = 5,
                BackgroundColor   = Config.ColorBlackBackground,
                Children          =
                {
                    this.labelEnteringFrameScore,
                    new BybLabel
                    {
                        Text                    = "Tap here when done.",
                        TextColor               = Config.ColorTextOnBackground,
                        HorizontalOptions       = LayoutOptions.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        //VerticalTextAlignment = TextAlignment.Center
                    }
                }
            };

            /// the current snooker break
            ///
            this.snookerBreakControl                   = new SnookerBreakControl(new MetadataHelper().FromScoreForYou(this.MatchScore), labelPointsLeft, CurrentFrameScore.ballsOnTable, entryCurrentFrameA, entryCurrentFrameB);
            this.snookerBreakControl.Padding           = new Thickness(0, 0, 0, 0);
            this.snookerBreakControl.VerticalOptions   = LayoutOptions.FillAndExpand;
            this.snookerBreakControl.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.snookerBreakControl.DoneLeft         += snookerBreakControl_DoneLeft;
            this.snookerBreakControl.DoneRight        += snookerBreakControl_DoneRight;
            this.snookerBreakControl.BallsChanged     += snookerBreakControl_BallsChanged;

            /// list of past breaks
            ///
            this.listOfBreaksInMatchControl                    = new ListOfBreaksInMatchControl();
            this.listOfBreaksInMatchControl.Padding            = new Thickness(Config.IsTablet ? 15 : 0, 0, Config.IsTablet ? 15 : 0, 0);
            this.listOfBreaksInMatchControl.UserTappedOnBreak += this.listOfBreaksInMatchControl_UserTappedOnBreak;
            this.labelPastBreaks = new SimpleButtonWithLittleDownArrow(false)
            {
                Text   = "Show previous",
                IsBold = false,
                //IsSmallerFont = true,
                HeightRequest     = heightOfLabelPastBreaks,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                IsVisible         = Config.App != MobileAppEnum.SnookerForVenues,
            };
            this.labelPastBreaks2 = new BybLabel()
            {
                IsVisible         = false,
                Text              = "",
                TextColor         = Config.ColorTextOnBackgroundGrayed,
                HeightRequest     = heightOfLabelPastBreaks,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };
            this.panelPastBreaks = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Spacing           = 0,
                BackgroundColor   = Config.ColorBackground,//Color.Black,
                Children          =
                {
                    new BoxView()
                    {
                        HeightRequest   = 1,
                        BackgroundColor = Config.ColorBackground,
                    },
                    this.labelPastBreaks,
//                    new Frame
//                    {
//                        IsVisible = Config.App != MobileAppEnum.SnookerForVenues,
//                        HeightRequest = heightOfLabelPastBreaks,
//                        Padding = new Thickness(0),
//                        HorizontalOptions = LayoutOptions.Center,
//                        VerticalOptions = LayoutOptions.Start,
//                        HasShadow = false,
//                        BackgroundColor = Color.Transparent,
//                        Content = this.labelPastBreaks,
//                    },
                    this.labelPastBreaks2,
                    this.listOfBreaksInMatchControl,
                }
            };
            this.labelPastBreaks.Clicked += (s1, e1) => { this.panelPastBreaksTapped(); };
            this.panelPastBreaks.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.panelPastBreaksTapped(); })
            });

            /// content
            ///
            this.absoluteLayout = new AbsoluteLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
            };
            this.absoluteLayout.Children.Add(this.panelTop);
            this.absoluteLayout.Children.Add(this.panelSecond);
            this.absoluteLayout.Children.Add(this.snookerBreakControl);
            this.absoluteLayout.Children.Add(this.panelPastBreaks);
            this.absoluteLayout.Children.Add(this.panelEnteringFrameScore);
            Content = this.absoluteLayout;

            this.Padding         = new Thickness(0, 0, 0, 0);
            this.BackgroundColor = Color.Black;

            this.snookerBreakControl.VoiceButtonControl.PageTopLevelLayout = absoluteLayout;
            this.snookerBreakControl.HelpButtonControl.PageTopLevelLayout  = absoluteLayout;
        }
예제 #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;
            //}
        }