Example #1
0
        public NewsfeedItemPostControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem)
        {
            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = "Posted \"", ForegroundColor = Config.ColorTextOnBackgroundGrayed
            });
            formattedString.Spans.Add(new Span()
            {
                Text = item.Text, ForegroundColor = Config.ColorBlackTextOnWhite
            });
            formattedString.Spans.Add(new Span()
            {
                Text = "\"", ForegroundColor = Config.ColorTextOnBackgroundGrayed
            });

            Label labelContent = new BybLabel
            {
                FormattedText = formattedString,
                TextColor     = Config.ColorBlackTextOnWhite,
                //HorizontalOptions = LayoutOptions.FillAndExpand,
                WidthRequest = 200,
            };

            labelContent.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    await this.onOpenItem();
                }),
                NumberOfTapsRequired = 1
            });

            this.Children.Add(this.frameAthleteImage);
            var panel = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 3,
                Padding           = new Thickness(5, 0, 0, 0),
                Children          =
                {
                    labelDate,
                    this.labelAthleteName,
                    labelContent,
                }
            };

            this.Children.Add(panel);
            this.Children.Add(panelCommentsCount);
        }
Example #2
0
        public BybButtonWithImage(string imageName, string buttonText)
        {
            this.image = new Image()
            {
                WidthRequest  = 17,
                HeightRequest = 17,
                Source        = new FileImageSource()
                {
                    File = imageName
                },
                HorizontalOptions = LayoutOptions.Center,
            };
            this.label = new BybLabel()
            {
                Text = buttonText,
                HorizontalOptions = LayoutOptions.Center,
                //VerticalTextAlignment = TextAlignment.Center,
                //HeightRequest = 30,
                TextColor = Config.ColorTextOnBackground,
            };

            this.HorizontalOptions = LayoutOptions.Fill;
            this.VerticalOptions   = LayoutOptions.Fill;
            this.Padding           = new Thickness(0);
            this.ColumnSpacing     = 0;
            this.RowSpacing        = 0;
            this.BackgroundColor   = Config.ColorBlackBackground;

            this.Children.Add(new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Spacing           = 5,
                Children          =
                {
                    this.image,
                    this.label,
                }
            });

            this.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                {
                    if (this.Clicked != null)
                    {
                        this.Clicked();
                    }
                })
            });
        }
Example #3
0
        public void SetImage(string personName, string picture)
        {
            this.box   = null;
            this.image = null;

            if (string.IsNullOrEmpty(picture) && UseNameAbbreviationIfNoPicture)
            {
                this.box              = new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView();
                box.WidthRequest      = 60;
                box.HeightRequest     = 60;
                box.CornerRadius      = 30;
                box.BorderThickness   = 1;
                box.BorderColor       = Color.White;
                box.BackgroundColor   = Config.ColorGrayBackground;
                box.HorizontalOptions = LayoutOptions.Center;
                box.VerticalOptions   = LayoutOptions.Center;

                Label label = new BybLabel()
                {
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    Text      = new NameAbbreviationHelper().GetAbbreviation(personName),
                    FontSize  = Config.VeryLargeFontSize,
                    TextColor = Config.ColorBlackTextOnWhite,
                };

                layout = new Grid()
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    VerticalOptions   = LayoutOptions.Fill,
                };
                layout.Children.Add(box);
                layout.Children.Add(label);

                this.Children.Clear();
                this.Children.Add(layout);
                //this.Content = this.layout;
            }
            else
            {
                this.image = new Image()
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    VerticalOptions   = LayoutOptions.Fill,
                    Source            = App.ImagesService.GetImageSource(picture, this.Background, false),
                };

                this.Children.Clear();
                this.Children.Add(image);
            }
        }
Example #4
0
        public virtual void Fill(List <T> list)
        {
            this.List           = list;
            this.ListShown      = null;
            this.buttonShowMore = null;

            this.Children.Clear();
            this.Children.Add(this.panelTop);

            if (list == null)
            {
                this.labelFailedToLoad = new BybLabel()
                {
                    TextColor               = IsDarkBackground ? Config.ColorTextOnBackground : Config.ColorBlackTextOnWhite,
                    HeightRequest           = 60,
                    HorizontalOptions       = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    Text = this.TextForFailedToLoad,
                };
                this.Children.Add(this.labelFailedToLoad);
                return;
            }

            if (list.Count() == 0)
            {
                this.labelEmpty = new BybLabel()
                {
                    TextColor               = IsDarkBackground ? Config.ColorTextOnBackground : Config.ColorBlackTextOnWhite,
                    HeightRequest           = 60,
                    HorizontalOptions       = LayoutOptions.Center,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    Text = this.TextForEmpty,
                };
                this.Children.Add(this.labelEmpty);
                return;
            }

            this.ListShown = List.Take(MaxCountToShowByDefault).ToList();

            foreach (var item in this.ListShown)
            {
                this.Children.Add(this.createViewForSingleItem(item));
            }

            this.addOrRemoveButtonShowMore();
        }
Example #5
0
        public NewsfeedItemResultControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem)
        {
            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = "Recorded a break of ", ForegroundColor = Config.ColorTextOnBackgroundGrayed
            });
            formattedString.Spans.Add(new Span()
            {
                Text = item.Text, ForegroundColor = Config.ColorBlackTextOnWhite, FontAttributes = FontAttributes.Bold, FontSize = Config.DefaultFontSize
            });
            Label labelContent = new BybLabel
            {
                FormattedText = formattedString
            };

            labelContent.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    await this.onOpenItem();
                }),
                NumberOfTapsRequired = 1
            });

            this.Children.Add(this.frameAthleteImage);
            var panel = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(5, 0, 0, 0),
                Spacing           = 3,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    labelDate,
                    this.labelAthleteName,
                    labelContent,
                }
            };

            if (this.labelVenue != null)
            {
                panel.Children.Add(labelVenue);
            }
            this.Children.Add(panel);
            this.Children.Add(panelCommentsCount);
        }
        public VoiceButtonControl()
        {
            this.Orientation = StackOrientation.Horizontal;
            this.Padding     = new Thickness(0);
            this.Spacing     = 0;

            var label = new BybLabel()
            {
                Text              = "Voice",
                TextColor         = Config.ColorTextOnBackgroundGrayed,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };

            var container = new Grid()
            {
                //OutlineColor = Config.ColorTextOnBackgroundGrayed,
                //BackgroundColor = Color.Transparent,
                //HasShadow = false,
                Padding      = new Thickness(0, 5, 0, 5),
                WidthRequest = 50,
                //Content = label,
                Children =
                {
                    label
                }
            };

            this.Children.Add(container);
            container.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { openPopup(); })
            });

//            this.image = new Image()
//            {
//                Source = new FileImageSource() { File = "speaker60.png" },
//                HeightRequest = 25,
//                WidthRequest = 25,
//                HorizontalOptions = LayoutOptions.Start,
//            };
//            this.image.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { openPopup(); }) });

            //this.Children.Add(this.image);
        }
Example #7
0
        void addOrRemoveLabelMaximumPossibleCount()
        {
            if (this.labelMaxPossibleCount != null)
            {
                this.Children.Remove(labelMaxPossibleCount);
                this.labelMaxPossibleCount = null;
            }

            if (this.ListShown == null || this.List == null || this.ListShown.Count != this.List.Count || this.List.Count != MaximumPossibleCount)
            {
                return;
            }

            this.labelMaxPossibleCount = new BybLabel()
            {
                Text                    = TextForMaxPossibleShown,
                TextColor               = IsDarkBackground ? Config.ColorTextOnBackgroundGrayed : Config.ColorGrayTextOnWhite,
                HeightRequest           = 50,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            this.Children.Add(this.labelMaxPossibleCount);
        }
Example #8
0
        public EditProfilePage(bool showCancelButton, bool showSecurityPanel)
        {
            this.showCancelButton = showCancelButton;

            // name panel
            entryName = new BybStandardEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                TextColor         = Config.ColorBlackTextOnWhite,
                Placeholder       = "(required)",
            };
            entryName.Completed += (s1, e1) => { entrySnookerAbout.Focus(); };
            var panelName = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Name", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    entryName,
                }
            };

            // about panel
            entrySnookerAbout = new BybStandardEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                TextColor         = Config.ColorBlackTextOnWhite,
                Placeholder       = "(optional)",
            };
            entrySnookerAbout.Completed += (s1, e1) =>
            {
                if (this.athlete.MetroID <= 0)
                {
                    buttonFind_Clicked(s1, e1);
                }
            };
            var panelAbout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "About", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    entrySnookerAbout,
                }
            };

            // ask the phone
            this.buttonFind = new BybButton()
            {
                Text = "Ask the " + (Config.IsTablet ? "tablet" : "phone"),
                HorizontalOptions = LayoutOptions.Center,
                Style             = (Style)App.Current.Resources["SimpleButtonStyle"],
            };
            buttonFind.Clicked += buttonFind_Clicked;
            labelStatus         = new BybLabel()
            {
                VerticalTextAlignment = TextAlignment.Center, TextColor = Config.ColorBlackTextOnWhite
            };

            // country panel
            Image imageCountry = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };

            this.pickerCountry = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Title             = "Select country"
            };
            this.pickerCountry.SelectedIndexChanged += pickerCountry_SelectedIndexChanged;
            var panelCountry = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Country", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    this.pickerCountry,
                    imageCountry,
                }
            };

            panelCountry.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pickerCountry.Focus(); })
            });

            // metro panel
            Image imageMetro = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };

            this.pickerMetro = new BybNoBorderPicker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Title             = "Select city"
            };
            this.pickerMetro.SelectedIndexChanged   += pickerMetro_SelectedIndexChanged;
            this.pickerCountry.SelectedIndexChanged += pickerCountry_SelectedIndexChanged;
            var panelMetro = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "City", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    this.pickerMetro,
                    imageMetro,
                }
            };

            // pin panel
            this.labelPin = new BybLabel()
            {
                Text                    = "Set your PIN code",
                TextColor               = Color.Black,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Image imagePin = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelPin = new StackLayout
            {
                IsVisible         = showSecurityPanel,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "PIN", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelPin,
                    imagePin,
                }
            };

            panelPin.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.pinClicked(); })
            });

            // password panel
            Label labelPassword = new BybLabel()
            {
                Text                    = "Tap to reset",
                TextColor               = Color.Black,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Image imagePassword = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelPassword = new StackLayout
            {
                IsVisible         = showSecurityPanel,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "Password", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelPassword,
                    imagePassword,
                }
            };

            panelPassword.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.passwordClicked(); })
            });

            // e-mail panel
            labelEmail = new BybLabel()
            {
                Text                    = "E-mail",
                TextColor               = Color.Black,
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            Image imageEmail = new Image()
            {
                VerticalOptions = LayoutOptions.Center,
                WidthRequest    = Config.RedArrowImageSize,
                HeightRequest   = Config.RedArrowImageSize,
                Source          = new FileImageSource()
                {
                    File = "arrowRight.png"
                }
            };
            var panelEmail = new StackLayout
            {
                IsVisible         = showSecurityPanel,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = rowHeight,
                Spacing           = 0,
                Padding           = new Thickness(15, 5, 5, 5),
                BackgroundColor   = Color.White,
                Children          =
                {
                    new BybLabel {
                        Text = "E-mail", TextColor = Config.ColorGrayTextOnWhite, WidthRequest = labelWidth1, VerticalTextAlignment = TextAlignment.Center
                    },
                    labelEmail,
                    imageEmail,
                }
            };

            panelEmail.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.emailClicked(); })
            });

            // 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;
            if (showCancelButton == false)
            {
                buttonCancel.IsVisible = false;
            }

            var stackLayout = new StackLayout
            {
                Padding  = new Thickness(0),
                Spacing  = 0,
                Children =
                {
                    new BybTitle(showCancelButton ? "Edit Profile" : "Your Profile")
                    {
                        VerticalOptions = LayoutOptions.Start
                    },

                    new StackLayout
                    {
                        Padding     = new Thickness(15, 15, 15, 0),
                        Spacing     = 0,
                        Orientation = StackOrientation.Vertical,
                        Children    =
                        {
                            panelName,
                            panelAbout,

                            new BoxView()
                            {
                                HeightRequest = 10,BackgroundColor              = Config.ColorGrayBackground
                            },
                            new StackLayout
                            {
                                Orientation = StackOrientation.Horizontal,
                                Spacing     = 10,
                                Children    =
                                {
                                    //buttonEditLocation,
                                    buttonFind,
                                    labelStatus
                                }
                            },

                            panelCountry,
                            panelMetro,

                            new BoxView()
                            {
                                HeightRequest = 10,BackgroundColor              = Config.ColorGrayBackground
                            },
                            panelPin,
                            panelPassword,
                            panelEmail,
                        }
                    },

                    new BoxView()
                    {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"], VerticalOptions = LayoutOptions.FillAndExpand
                    },

                    //new BoxView() { Style = (Style)App.Current.Resources["BoxViewPadding1Style"] },
                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        //BackgroundColor = Config.ColorDarkGrayBackground,
                        HorizontalOptions = LayoutOptions.Fill,
                        HeightRequest     = Config.OkCancelButtonsHeight,
                        Padding           = Config.OkCancelButtonsPadding,
                        Spacing           = 1,
                        Children          =
                        {
                            buttonCancel,
                            buttonOk,
                        }
                    }
                }
            };

            this.Padding         = new Thickness(0);
            this.BackgroundColor = Config.ColorGrayBackground;
            this.Content         = stackLayout;

            this.fillCountriesPicker();
        }
Example #9
0
        public void Fill(List <CommentWebModel> comments)
        {
            this.Children.Clear();

            if (comments == null)
            {
                this.Children.Add(new BybLabel()
                {
                    Text      = "Couldn't load comments. Internet issues?",
                    TextColor = Config.ColorBlackTextOnWhite,
                });
                return;
            }

            if (comments.Count == 0)
            {
                //this.Children.Add(new BybLabel()
                //{
                //    Text = "No comments",
                //});
                return;
            }

            comments = comments.OrderBy(i => i.Time).ToList();

            foreach (var comment in comments)
            {
                FormattedString formattedString = new FormattedString();
                formattedString.Spans.Add(new Span()
                {
                    Text = DateTimeHelper.DateToString(comment.Time), ForegroundColor = Config.ColorTextOnBackgroundGrayed, FontSize = Config.SmallFontSize
                });
                formattedString.Spans.Add(new Span()
                {
                    Text = " " + comment.AthleteName, ForegroundColor = Config.ColorBlackTextOnWhite
                });
                var label = new BybLabel()
                {
                    FormattedText = formattedString,
                    TextColor     = Config.ColorGrayTextOnWhite,
                    FontSize      = Config.SmallFontSize
                };
                label.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(async() =>
                    {
                        await App.Navigator.GoToPersonProfile(comment.AthleteID);
                    }),
                    NumberOfTapsRequired = 1
                });

                var panel = new StackLayout()
                {
                    Orientation     = StackOrientation.Horizontal,
                    BackgroundColor = Color.White,
                    Padding         = new Thickness(0, 3, 0, 3),
                    Children        =
                    {
                        new Frame
                        {
                            BackgroundColor = Color.White,
                            Padding         = new Thickness(0),
                            Content         = new Image()
                            {
                                Source        = App.ImagesService.GetImageSource(comment.AthletePicture, BackgroundEnum.White),
                                WidthRequest  = Config.PersonImageSize / 2,
                                HeightRequest = Config.PersonImageSize / 2,
                            }
                        },
                        new StackLayout
                        {
                            Orientation = StackOrientation.Vertical,
                            Children    =
                            {
                                label,
                                new BybLabel
                                {
                                    Text      = comment.Text,
                                    TextColor = Config.ColorBlackTextOnWhite,
                                },
                            }
                        },
                    }
                };
                this.Children.Add(panel);

                panel.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(async() =>
                    {
                        if (comment.AthleteID != App.Repository.GetMyAthleteID())
                        {
                            return;
                        }

                        if (await App.Navigator.NavPage.DisplayAlert("Your comment", "Do you want to delete this comment?", "Delete", "Cancel") != true)
                        {
                            return;
                        }

                        PleaseWaitPage waitPage = new PleaseWaitPage();
                        await App.Navigator.NavPage.Navigation.PushModalAsync(waitPage);
                        bool ok = await App.WebService.DeleteComment(comment.ID);
                        await App.Navigator.NavPage.Navigation.PopModalAsync();

                        if (ok == false)
                        {
                            App.Navigator.DisplayAlertRegular("Failed to delete the comment");
                        }
                        else
                        {
                            comments.Remove(comment);
                            this.Fill(comments);
                        }
                    })
                });
            }
        }
Example #10
0
        public NewsfeedItemScoreControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem)
        {
            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = "Recorded a score ", ForegroundColor = Config.ColorTextOnBackgroundGrayed
            });
            formattedString.Spans.Add(new Span()
            {
                Text = item.Text, ForegroundColor = Config.ColorBlackTextOnWhite, FontSize = Config.DefaultFontSize
            });
            Label labelContent = new BybLabel
            {
                FormattedText = formattedString
            };

            labelContent.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    await this.onOpenItem();
                }),
                NumberOfTapsRequired = 1
            });

            this.Children.Add(new BoxView()
            {
                WidthRequest = imageSize + imageExtraPadding * 2
            });
            var panel = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(0, 0, 0, 0),
                Spacing           = 3,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    labelDate,
                    new StackLayout
                    {
                        Orientation     = StackOrientation.Horizontal,
                        VerticalOptions = LayoutOptions.Center,
                        Spacing         = 3,
                        Children        =
                        {
                            this.labelAthleteName,
                            new BybLabel {
                                Text = "vs.",      TextColor= Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.Start, VerticalTextAlignment = TextAlignment.Center
                            },
                            this.labelAthlete2Name,
                        }
                    },
                    labelContent,
                }
            };

            if (this.labelVenue != null)
            {
                panel.Children.Add(labelVenue);
            }
            this.Children.Add(panel);
            this.Children.Add(panelCommentsCount);
        }
Example #11
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;
        }
Example #12
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;
            //}
        }
Example #13
0
        protected override View createViewForSingleItem(SnookerMatchScore match)
        {
            // opponent
            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = string.IsNullOrEmpty(match.YourName) ? "-" : match.YourName, FontAttributes = FontAttributes.Bold, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
            });
            formattedString.Spans.Add(new Span()
            {
                Text = " vs. ", ForegroundColor = Config.ColorGrayTextOnWhite
            });
            formattedString.Spans.Add(new Span()
            {
                Text = string.IsNullOrEmpty(match.OpponentName) ? "-" : match.OpponentName, FontAttributes = FontAttributes.Bold, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
            });
            Label labelOpponent = new BybLabel()
            {
                FormattedText = formattedString, VerticalTextAlignment = TextAlignment.Center
            };

            if (match.OpponentAthleteID > 0)
            {
                labelOpponent.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(async() =>
                    {
                        await App.Navigator.GoToPersonProfile(match.OpponentAthleteID);
                    }),
                    NumberOfTapsRequired = 1
                });
            }

            // venue
            //string venueName = match.VenueName;
            //if (string.IsNullOrEmpty(venueName))
            //    venueName = "-";
            //Label labelVenue = new BybLabel()
            //{
            //    Text = venueName,
            //    VerticalTextAlignment = TextAlignment.Center,
            //    TextColor = Config.ColorGrayTextOnWhite,
            //    IsVisible = this.Type != ListTypeEnum.Venue
            //};
            //if (match.VenueID > 0)
            //    labelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
            //    {
            //        Command = new Command(async () =>
            //        {
            //            await App.Navigator.GoToVenueProfile(match.VenueID);
            //        }),
            //        NumberOfTapsRequired = 1
            //    });

            // frames
            Label labelForFrames = new BybLabel()
            {
                LineBreakMode           = LineBreakMode.WordWrap,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Start,
            };

            if (match.HasFrameScores)
            {
                FormattedString formattedStringScores = new FormattedString();

                foreach (var frame in match.FrameScores)
                {
                    if (match.FrameScores.First() != frame)
                    {
                        formattedStringScores.Spans.Add(new Span()
                        {
                            Text            = " , ",
                            FontAttributes  = FontAttributes.None,
                            FontSize        = Config.DefaultFontSize,
                            FontFamily      = Config.FontFamily,
                            ForegroundColor = Config.ColorGrayTextOnWhite,
                        });
                    }

                    Color color = Config.ColorGray;
                    if (frame.A > frame.B)
                    {
                        color = Config.ColorGreen;
                    }
                    else if (frame.A < frame.B)
                    {
                        color = Config.ColorRed;
                    }

                    formattedStringScores.Spans.Add(new Span()
                    {
                        Text            = frame.A + ":" + frame.B,
                        FontAttributes  = FontAttributes.Bold,
                        FontSize        = Config.DefaultFontSize,
                        FontFamily      = Config.FontFamily,
                        ForegroundColor = color,
                    });
                }

                labelForFrames.FormattedText = formattedStringScores;
            }

            // match color
            //Color matchColor = match.MatchScoreA > match.MatchScoreB ? Config.ColorGreen : (match.MatchScoreA < match.MatchScoreB ? Config.ColorRed : Config.ColorGray);
            Color matchColor = Config.ColorGray;

            if (match.IsUnfinished)
            {
                matchColor = Config.ColorGray;
            }

            var panel1_1 = new StackLayout
            {
                Orientation         = StackOrientation.Vertical,
                Padding             = new Thickness(0, 8, 0, 0),
                WidthRequest        = Config.IsTablet ? 120 : 80,
                MinimumWidthRequest = Config.IsTablet ? 100 : 80,
                HeightRequest       = Config.IsTablet ? 55 : 45,
                HorizontalOptions   = LayoutOptions.Center,
                VerticalOptions     = LayoutOptions.Start,
                BackgroundColor     = matchColor,
                Spacing             = 2,
                Children            =
                {
                    new BybLabel
                    {
                        Text              = match.IsUnfinished ? "PAUSED" : "Score",
                        FontAttributes    = match.IsUnfinished ? Xamarin.Forms.FontAttributes.Bold : FontAttributes.None,
                        TextColor         = match.IsUnfinished ? Config.ColorBlackBackground : Color.White,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    new BybLabel
                    {
                        Text              = match.MatchScoreA.ToString() + " : " + match.MatchScoreB.ToString(),
                        FontSize          = Config.LargerFontSize,
                        FontAttributes    = Xamarin.Forms.FontAttributes.Bold,
                        TextColor         = Color.White,
                        HorizontalOptions = LayoutOptions.Center
                    },
                }
            };

            var panel1_0 = new StackLayout
            {
                Padding           = new Thickness(10, 10, 0, 5),
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                WidthRequest      = widthOfLeftColumn,
                VerticalOptions   = LayoutOptions.Start,
                Children          =
                {
                    labelOpponent,
                    labelForFrames,
                }
            };

            this.panelsToResize.Add(panel1_0);

            var panel1 = new StackLayout()
            {
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.White,
                Padding         = new Thickness(0, 0, 0, 0),
                Children        =
                {
                    panel1_0,
                    panel1_1,
                }
            };
            var panel2 = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.White,
                Padding         = new Thickness(5, 0, 5, 0),
                Children        =
                {
                    new Grid
                    {
                        Padding           = new Thickness(5, 5, 0, 5),
                        HorizontalOptions = LayoutOptions.StartAndExpand,
                        Children          =
                        {
                            new BybLabel()
                            {
                                Text = DateTimeHelper.DateToString(match.Date),//match.Date.ToShortDateString(),
                                VerticalTextAlignment = TextAlignment.Center,
                                TextColor             = Config.ColorGrayTextOnWhite
                            }
                        }
                    },
                    //new Grid
                    //{
                    //    Padding = new Thickness(0,5,5,5),
                    //    HorizontalOptions = LayoutOptions.EndAndExpand,
                    //    Children =
                    //    {
                    //        labelVenue
                    //    }
                    //},
                }
            };

            panel1.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.showMenu(match); })
            });
            panel2.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.showMenu(match); })
            });
            panel1_1.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() => { this.showMenu(match); })
            });

            var panel = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 1,
                Children    =
                {
                    panel1,
                    panel2,
                }
            };

            return(panel);
        }
        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();
        }
Example #15
0
        void fillTop()
        {
            this.stackTop.Children.Clear();

            // friends
            if (AllowFriendsSelection)
            {
                this.stackTop.Children.Add(this.createItem(CommunitySelection.CreateFriendsOnly()));
            }

            // planet Earth
            this.stackTop.Children.Add(this.createItem(CommunitySelection.CreateAsPlanetEarth()));

            // your city
            if (myAthlete.MetroID > 0)
            {
                var myMetro = App.Cache.Metroes.Get(myAthlete.MetroID);
                if (myMetro == null)
                {
                    myMetro = new MetroWebModel()
                    {
                        ID = myAthlete.MetroID, Name = "Your city", Country = myCountry != null ? myCountry.ThreeLetterCode : "?"
                    }
                }
                ;
                this.stackTop.Children.Add(this.createItem(CommunitySelection.CreateAsMetro(myMetro)));
            }
        }

        void fillCountries(bool showAll)
        {
            // list of countries
            List <Country> listOfCountries;

            if (showAll)
            {
                listOfCountries = Country.ListWithoutImportance0.ToList();
                if (myCountry != null)
                {
                    listOfCountries.Insert(0, myCountry);
                }
            }
            else
            {
                listOfCountries = Country.List.Where(i => i.Snooker == CountryImportanceEnum.Importance9).ToList();
                if (this.Selection != null && this.Selection.Country != null && listOfCountries.Contains(this.Selection.Country) == false)
                {
                    listOfCountries.Insert(0, this.Selection.Country);
                }
                if (myCountry != null && listOfCountries.Contains(myCountry) == false)
                {
                    listOfCountries.Insert(0, myCountry);
                }
            }

            // fill the stack
            this.stackCountries.Children.Clear();
            foreach (var country in listOfCountries)
            {
                this.stackCountries.Children.Add(this.createItem(CommunitySelection.CreateAsCountry(country)));
            }

            if (showAll == false)
            {
                var labelShowAll = new BybLabel()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    HeightRequest     = itemHeight,
                    FontSize          = Config.LargerFontSize,
                    TextColor         = Color.White,
                    Text = "More countries...",
                    HorizontalTextAlignment = TextAlignment.Start,
                    VerticalTextAlignment   = TextAlignment.Center,
                };
                this.stackCountries.Children.Add(new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    BackgroundColor   = Config.ColorBlackBackground,
                    HorizontalOptions = LayoutOptions.Fill,
                    VerticalOptions   = LayoutOptions.Fill,
                    Padding           = new Thickness(15, 0, 0, 0),
                    HeightRequest     = itemHeight,
                    Children          =
                    {
                        labelShowAll
                    }
                });
                labelShowAll.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(() => { this.fillCountries(true); })
                });
            }
        }

        async Task fillMetros()
        {
            this.stackMetros.Children.Clear();

            if (this.Selection == null || this.Selection.Country == null)
            {
                this.stackMetros.Children.Add(this.createInfoLabel("Cities populate when the country is picked", false));
                return;
            }

            // load metros
            this.stackMetros.Children.Add(this.createInfoLabel("Loading cities...", false));
            var metros = await App.WebService.GetMetros(this.Selection.Country.ThreeLetterCode);

            if (metros == null)
            {
                this.stackMetros.Children.Clear();
                this.stackMetros.Children.Add(this.createInfoLabel("Couldn't load cities. Internet issues?", false));
                return;
            }

            // save metros to cache
            App.Cache.Metroes.Put(metros);

            // fill metros
            metros = (from i in metros
                      orderby i.Name
                      select i).ToList();
            this.stackMetros.Children.Clear();
            foreach (var metro in metros)
            {
                this.stackMetros.Children.Add(this.createItem(CommunitySelection.CreateAsMetro(metro)));
            }
        }

        StackLayout createDivider(string text)
        {
            return(new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                BackgroundColor = Config.ColorBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Fill,
                Padding = new Thickness(15, 0, 0, 0),
                HeightRequest = itemHeight,
                Children =
                {
                    new BybLabel()
                    {
                        Text = text,
                        FontSize = Config.LargerFontSize,
                        VerticalOptions = LayoutOptions.Center,
                        TextColor = Config.ColorTextOnBackgroundGrayed,
                    }
                }
            });
        }

        StackLayout createInfoLabel(string text, bool error)
        {
            return(new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                BackgroundColor = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Fill,
                Padding = new Thickness(15, 0, 0, 0),
                HeightRequest = itemHeight,
                Children =
                {
                    new BybLabel()
                    {
                        Text = text,
                        FontSize = Config.LargerFontSize,
                        VerticalOptions = LayoutOptions.Center,
                        TextColor = error ? Color.Red : Color.White,
                    }
                }
            });
        }

        StackLayout createItem(CommunitySelection item)
        {
            StackLayout stack = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                BackgroundColor   = Config.ColorBlackBackground,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = itemHeight,
                Padding           = new Thickness(15, 0, 15, 0),
            };

            if (DoNotCheckSelection == false && Selection != null &&
                item.Country == Selection.Country && item.MetroID == Selection.MetroID && item.IsFriendsOnly == Selection.IsFriendsOnly)
            {
                var image = new Image()
                {
                    Source = new FileImageSource()
                    {
                        File = "checkmarkRed.png"
                    },
                    HeightRequest = itemHeight * 0.4,
                    WidthRequest  = itemHeight * 0.4,
                };
                stack.Children.Add(image);
            }

            stack.Children.Add(new BybLabel()
            {
                FontSize                = Config.LargerFontSize,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.Center,
                TextColor               = Color.White,
                BackgroundColor         = Config.ColorBlackBackground,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                Text = item.ToString(),
            });

            stack.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(async() =>
                {
                    this.Selection = item;
                    await App.Navigator.NavPage.Navigation.PopModalAsync();
                    if (this.SelectionChanged != null)
                    {
                        this.SelectionChanged(this, EventArgs.Empty);
                    }
                })
            });

            return(stack);
        }
    }
Example #16
0
        protected override View createViewForSingleItem(SnookerBreak snookerBreak)
        {
            // score
            Label labelPoints = new BybLabel
            {
                Text                    = snookerBreak.Points.ToString(),
                TextColor               = Config.ColorBlackTextOnWhite,
                FontSize                = Config.LargerFontSize,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center
            };
            Label labelBalls = new BybLabel
            {
                Text                    = snookerBreak.NumberOfBallsDisplay,
                TextColor               = Config.ColorBlackTextOnWhite,
                FontSize                = Config.LargerFontSize,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center
            };

            // balls
            StackLayout stackForBalls = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 1,
                Padding     = new Thickness(0)
            };
            ScrollView scrollViewForBalls = new ScrollView()
            {
                Orientation = ScrollOrientation.Horizontal,
                Padding     = new Thickness(0),
                Content     = stackForBalls
            };

            if (true)
            {
                List <int> balls = snookerBreak.GetBallsEvenWhenUnknown();
                for (int iBall = 0; iBall < balls.Count; ++iBall)
                {
                    int   ball  = balls[iBall];
                    Color color = Config.BallColors[ball];
                    var   btn   = new BybButton
                    {
                        Text                 = "",
                        BackgroundColor      = color,
                        BorderColor          = Color.Transparent,
                        TextColor            = Color.White,
                        BorderWidth          = 1,
                        BorderRadius         = (int)(Config.ExtraSmallBallSize / 2),
                        HeightRequest        = Config.ExtraSmallBallSize,
                        MinimumHeightRequest = Config.ExtraSmallBallSize,
                        WidthRequest         = Config.ExtraSmallBallSize,
                        MinimumWidthRequest  = Config.ExtraSmallBallSize,
                        VerticalOptions      = LayoutOptions.Center
                    };
                    if (snookerBreak.NumberOfBalls == 0)
                    {
                        btn.Opacity = (balls.Count - iBall) / ((double)balls.Count + 1);
                    }
                    stackForBalls.Children.Add(btn);
                }
            }

            // date
            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = DateTimeHelper.DateToString(snookerBreak.Date), ForegroundColor = Config.ColorBlackTextOnWhite,
            });
            if (snookerBreak.OpponentConfirmation == OpponentConfirmationEnum.Confirmed)
            {
                //formattedString.Spans.Add(new Span() { Text = "  confirmed", ForegroundColor = Config.ColorGrayTextOnWhite });
            }
            else if (snookerBreak.OpponentConfirmation == OpponentConfirmationEnum.Declined)
            {
                formattedString.Spans.Add(new Span()
                {
                    Text = "  (declined)", ForegroundColor = Config.ColorTextOnBackgroundGrayed
                });
            }
            else
            {
                formattedString.Spans.Add(new Span()
                {
                    Text = "  (unconfirmed)", ForegroundColor = Config.ColorTextOnBackgroundGrayed
                });
            }
            Label labelDate = new BybLabel()
            {
                HorizontalOptions     = LayoutOptions.Start,
                FormattedText         = formattedString,
                VerticalTextAlignment = TextAlignment.Center
            };

            // person name / opponent name
            int    personID;
            string personName;

            if (this.Type == ListTypeEnum.FVO)
            {
                personID   = snookerBreak.AthleteID;
                personName = (string.IsNullOrEmpty(snookerBreak.AthleteName) ? "-" : snookerBreak.AthleteName) +
                             " vs. " + (string.IsNullOrEmpty(snookerBreak.OpponentName) ? "-" : snookerBreak.OpponentName);
            }
            else if (this.Type == ListTypeEnum.Venue)
            {
                personID   = snookerBreak.AthleteID;
                personName = string.IsNullOrEmpty(snookerBreak.AthleteName) ? "-" : (snookerBreak.AthleteName);
            }
            else
            {
                personID   = snookerBreak.OpponentAthleteID;
                personName = string.IsNullOrEmpty(snookerBreak.OpponentName) ? "-" : ("vs. " + snookerBreak.OpponentName);
            }
            Label labelPerson = new BybLabel()
            {
                Text = personName,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor             = Config.ColorGrayTextOnWhite
            };

            if (personID > 0)
            {
                labelPerson.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(async() =>
                    {
                        await App.Navigator.GoToPersonProfile(personID);
                    }),
                    NumberOfTapsRequired = 1
                });
            }

            // venue
            string venueName = snookerBreak.VenueName;

            if (string.IsNullOrEmpty(venueName))
            {
                venueName = "-";
            }
            Label labelVenueName = new BybLabel()
            {
                Text = venueName,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalOptions       = LayoutOptions.EndAndExpand,
                HorizontalTextAlignment = TextAlignment.End,
                TextColor = Config.ColorGrayTextOnWhite,
                IsVisible = Type != ListTypeEnum.Venue && Type != ListTypeEnum.FVO
            };

            if (snookerBreak.VenueID > 0)
            {
                labelVenueName.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = new Command(async() =>
                    {
                        await App.Navigator.GoToVenueProfile(snookerBreak.VenueID);
                    }),
                    NumberOfTapsRequired = 1
                });
            }

            var panel1 = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.White,
                Padding         = new Thickness(0, 10, 0, 5),
                Children        =
                {
                    new StackLayout
                    {
                        Padding           = new Thickness(10, 0, 0, 0),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.Start,
                        Children          =
                        {
                            labelDate,
                            scrollViewForBalls
                        }
                    },
                    new StackLayout
                    {
                        Orientation         = StackOrientation.Vertical,
                        Padding             = new Thickness(0, 0, 0, 0),
                        WidthRequest        = Config.IsTablet ? 80 : 40,
                        MinimumWidthRequest = Config.IsTablet ? 80 : 40,
                        HorizontalOptions   = LayoutOptions.Center,
                        VerticalOptions     = LayoutOptions.Start,
                        Spacing             = 2,
                        Children            =
                        {
                            new BybLabel {
                                Text = "Balls", TextColor = Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.Center
                            },
                            labelBalls
                        }
                    },
                    new StackLayout
                    {
                        Orientation         = StackOrientation.Vertical,
                        Padding             = new Thickness(0, 0, 10, 0),
                        WidthRequest        = Config.IsTablet ? 80 : 40,
                        MinimumWidthRequest = Config.IsTablet ? 80 : 40,
                        HorizontalOptions   = LayoutOptions.Center,
                        VerticalOptions     = LayoutOptions.Start,
                        Spacing             = 2,
                        Children            =
                        {
                            new BybLabel {
                                Text = "Points", TextColor = Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.Center
                            },
                            labelPoints
                        }
                    }
                }
            };

            if (this.Type == ListTypeEnum.PrimaryAthlete)
            {
                var recognizer = new TapGestureRecognizer
                {
                    Command = new Command(() => { this.showMenu(snookerBreak); }),
                    NumberOfTapsRequired = 1
                };
                panel1.GestureRecognizers.Add(recognizer);
            }

            var panel = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Spacing     = 1,
                Children    =
                {
                    panel1,
                    new StackLayout
                    {
                        Orientation     = StackOrientation.Horizontal,
                        BackgroundColor = Color.White,
                        Padding         = new Thickness(10,                 5, 10, 5),
                        Children        =
                        {
                            labelPerson,
                            labelVenueName,
                        }
                    }
                }
            };

            return(panel);
        }
Example #17
0
        public CurrentBreakScoreGrid(int pointsYou, int pointsOpponent)
        {
            //HorizontalOptions = LayoutOptions.Fill; - default
            VerticalOptions = LayoutOptions.Center;
            Padding         = new Thickness(1);
            ColumnSpacing   = 0;
            RowSpacing      = 0;
            BackgroundColor = Config.ColorBackground;

            string a = pointsYou.ToString();

            a.PadLeft(3);
            string b = pointsOpponent.ToString();

            b.PadRight(3);
            string c = a + ":" + b;

            // make sure frameScore string is always 7 characters
            // (including spaces): "xxx:xxx", e.g "  1:22 "
            BybLabel frameScoreA_label = new BybLabel()
            {
                Text            = pointsYou.ToString(),
                BackgroundColor = Config.ColorBackground,
                TextColor       = Color.White,
                //VerticalTextAlignment = TextAlignment.Center - default
                HorizontalTextAlignment = TextAlignment.End
            };

            BybLabel frameScoreMiddle_label = new BybLabel()
            {
                Text            = ":",
                BackgroundColor = Config.ColorBackground,
                TextColor       = Color.White,
                //VerticalTextAlignment = TextAlignment.Center  - default
                HorizontalTextAlignment = TextAlignment.Center
            };

            BybLabel frameScoreB_label = new BybLabel()
            {
                Text            = pointsOpponent.ToString(),
                BackgroundColor = Config.ColorBackground,
                TextColor       = Color.White,
                //VerticalTextAlignment = TextAlignment.Center - default
                HorizontalTextAlignment = TextAlignment.Start
            };

            this.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(5, GridUnitType.Star)
            });
            this.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            this.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(5, GridUnitType.Star)
            });

            this.Children.Add(frameScoreA_label, 0, 0);
            this.Children.Add(frameScoreMiddle_label, 1, 0);
            this.Children.Add(frameScoreB_label, 2, 0);
        }
Example #18
0
        void addSnookerBreakControls(SnookerBreak snookerBreak, bool isOpponentsBreak)
        {
            StackLayout[] horizontalStack = new StackLayout[5];
            int           lineIdx;

            // Determine number of lines needed to display all balls in a break
            int numLines = (int)(snookerBreak.Balls.Count / maxNumberOfBallsPerLine) + 1;

            for (lineIdx = 0; lineIdx < numLines; lineIdx++)
            {
                horizontalStack[lineIdx] = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    Padding           = new Thickness(1, 0, 1, 0),
                    BackgroundColor   = Config.ColorBackground,
                    Spacing           = 2,
                    HorizontalOptions = (!isOpponentsBreak || (lineIdx > 0)) ? LayoutOptions.Start : LayoutOptions.End
                };
            }

            // if more than one line, start adding opponent's balls from the left
            if (snookerBreak.Balls.Count >= maxNumberOfBallsPerLine)
            {
                horizontalStack[0].HorizontalOptions = LayoutOptions.Start;
            }

            double sizeOfPocketedBalls = Config.ExtraSmallBallSize;

            // Fill horizonal stack lines with the balls
            lineIdx = 0;
            if (snookerBreak.HasBalls)
            {
                int ballIdx = 0;
                foreach (var ballScore in snookerBreak.Balls)
                {
                    Color color       = Config.BallColors[ballScore];
                    Color borderColor = color;
                    if (ballScore == 7)
                    {
                        borderColor = Color.Gray;
                    }

                    RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView ball = new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView {
                        WidthRequest         = sizeOfPocketedBalls,
                        HeightRequest        = sizeOfPocketedBalls,
                        MinimumWidthRequest  = sizeOfPocketedBalls,
                        MinimumHeightRequest = sizeOfPocketedBalls,
                        Color           = color,
                        BorderColor     = borderColor,
                        BackgroundColor = color,
                        BorderThickness = 1,
                        CornerRadius    = (int)(sizeOfPocketedBalls / 2),
                        VerticalOptions = LayoutOptions.Center
                    };

                    // if 8 balls in each line:
                    //   0/8 - 0, 7/8 - 0, 8/8 - 1, 9/8 - 1 ...
                    //
                    lineIdx = (int)(ballIdx / maxNumberOfBallsPerLine);
                    horizontalStack[lineIdx].Children.Insert(horizontalStack[lineIdx].Children.Count, ball);

                    ballIdx++;
                }
            }

            if (snookerBreak.IsFoul)
            {
                // add "foul":
                //   if on right side "foul xxx 15"
                //   if on left side  "xxx 15 foul"

                string foulLabelString = isOpponentsBreak ?
                                         "foul ": // if on right side "foul xxx 15"
                                         " foul"; // if on left side  "xxx 15 foul"

                BybLabel foulLabel = new BybLabel()
                {
                    Text         = foulLabelString,
                    TextColor    = Config.ColorRed,
                    WidthRequest = Config.IsTablet ? 35 : 27,
                    //VerticalTextAlignment = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Start
                };

                if (isOpponentsBreak)
                {
                    horizontalStack[0].Children.Insert(0, foulLabel);                     // insert "foul " in the beginning "foul xxx 15"
                }
                else
                {
                    horizontalStack[0].Children.Add(foulLabel);                        // add " foul" to the end "15 xxx foul"
                }
            }

            // This grid hold all the break info
            BybBreakGrid breakGrid = new BybBreakGrid(isOpponentsBreak);

            // Add all the lines of balls to stack
            for (lineIdx = 0; lineIdx < numLines; lineIdx++)
            {
                breakGrid.ballsStack.Children.Add(horizontalStack[lineIdx]);
            }

            // Break score - 3 character string
            string   breakPointsString = String.Format("{0,3}", snookerBreak.Points.ToString());
            BybLabel breakPointsLabel  = new BybLabel()
            {
                Text                    = breakPointsString,
                BackgroundColor         = Config.ColorBackground,
                TextColor               = snookerBreak.IsFoul ? Config.ColorRed : Color.White,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = (isOpponentsBreak) ? TextAlignment.End : TextAlignment.Start
            };

            breakGrid.ballsStack.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    if (this.UserTappedOnBreak != null)
                    {
                        this.UserTappedOnBreak(this, snookerBreak);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            breakPointsLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    if (this.UserTappedOnBreak != null)
                    {
                        this.UserTappedOnBreak(this, snookerBreak);
                    }
                }),
                NumberOfTapsRequired = 1
            });

            // Add to the player who scored,
            // leave the other player's corresponding fields empty:
            //  - balls
            //  - break score field
            if (isOpponentsBreak)
            {
                breakGrid.Children.Add(breakGrid.ballsStack, 3, 0);
                breakGrid.Children.Add(breakPointsLabel, 4, 0);
            }
            else
            {
                breakGrid.Children.Add(breakPointsLabel, 0, 0);
                breakGrid.Children.Add(breakGrid.ballsStack, 1, 0);
            }
            int childIdx = breakGrid.Children.Count();

            // If running frame score is valid, add it in the middle
            if (frameScoreValid)
            {
                Grid frameScoreGrid = new CurrentBreakScoreGrid(frameScoreYou, frameScoreOpponent);
                breakGrid.Children.Add(frameScoreGrid, 2, 0);
            }

            // I think this might not be necessary
            breakGrid.RaiseChild(breakGrid.Children.ElementAt(childIdx - 1));
            breakGrid.RaiseChild(breakGrid.Children.ElementAt(childIdx - 2));

            // add the new break to the list of breaks
            this.Children.Add(breakGrid);
        } // addSnookerBreakControls()
Example #19
0
        public void Fill(List <SnookerMatchScore> matches)
        {
            try
            {
                this.Matches = matches;

                var itemsToRemove = this.Children.ToList();
                itemsToRemove.Remove(panelTop);

                this.panelsToResize = new List <StackLayout>();

                if (this.Matches == null)
                {
                    this.SortedMatches = new List <SnookerMatchScore>();
                }
                else
                {
                    this.SortedMatches = SnookerMatchScore.Sort(matches, SortType);
                }

                if (Matches == null)
                {
                    string text = "Couldn't load data. Internet issues?";
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                    this.Children.Add(new BybLabel
                    {
                        Text = text,
                        HorizontalOptions = LayoutOptions.Center
                    });
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                }
                else if (this.SortedMatches.Count == 0)
                {
                    string text = "No matches have been recorded yet";
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                    this.Children.Add(new BybLabel
                    {
                        Text = text,
                        HorizontalOptions       = LayoutOptions.Center,
                        HorizontalTextAlignment = TextAlignment.Center
                    });
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                }

                foreach (var match in this.SortedMatches)
                {
                    // opponent
                    FormattedString formattedString = new FormattedString();
                    formattedString.Spans.Add(new Span()
                    {
                        Text = string.IsNullOrEmpty(match.YourName) ? "-" : match.YourName, FontAttributes = FontAttributes.Bold, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
                    });
                    formattedString.Spans.Add(new Span()
                    {
                        Text = " vs. ", ForegroundColor = Config.ColorGrayTextOnWhite
                    });
                    formattedString.Spans.Add(new Span()
                    {
                        Text = string.IsNullOrEmpty(match.OpponentName) ? "-" : match.OpponentName, FontAttributes = FontAttributes.Bold, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
                    });
                    //if (match.OpponentConfirmation == OpponentConfirmationEnum.Confirmed)
                    //{
                    //}
                    //else if (match.OpponentConfirmation == OpponentConfirmationEnum.Declined)
                    //    formattedString.Spans.Add(new Span() { Text = "  (declined)", ForegroundColor = Config.ColorTextOnBackgroundGrayed });
                    //else
                    //    formattedString.Spans.Add(new Span() { Text = "  (unconfirmed)", ForegroundColor = Config.ColorTextOnBackgroundGrayed });
                    Label labelOpponent = new BybLabel()
                    {
                        FormattedText = formattedString, VerticalTextAlignment = TextAlignment.Center
                    };
                    if (match.OpponentAthleteID > 0)
                    {
                        labelOpponent.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            Command = new Command(async() =>
                            {
                                await App.Navigator.GoToPersonProfile(match.OpponentAthleteID);
                            }),
                            NumberOfTapsRequired = 1
                        });
                    }

                    // venue
                    string venueName = match.VenueName;
                    if (string.IsNullOrEmpty(venueName))
                    {
                        venueName = "-";
                    }
                    Label labelVenue = new BybLabel()
                    {
                        Text = venueName, VerticalTextAlignment = TextAlignment.Center, TextColor = Config.ColorGrayTextOnWhite
                    };
                    if (match.VenueID > 0)
                    {
                        labelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            Command = new Command(async() =>
                            {
                                await App.Navigator.GoToVenueProfile(match.VenueID);
                            }),
                            NumberOfTapsRequired = 1
                        });
                    }

                    // frames
                    Label labelForFrames = new BybLabel()
                    {
                        LineBreakMode           = LineBreakMode.WordWrap,
                        HorizontalOptions       = LayoutOptions.Fill,
                        HorizontalTextAlignment = TextAlignment.Start,
                    };
                    if (match.HasFrameScores)
                    {
                        FormattedString formattedStringScores = new FormattedString();

                        foreach (var frame in match.FrameScores)
                        {
                            if (match.FrameScores.First() != frame)
                            {
                                formattedStringScores.Spans.Add(new Span()
                                {
                                    Text            = " , ",
                                    FontAttributes  = FontAttributes.None,
                                    FontSize        = Config.DefaultFontSize,
                                    FontFamily      = Config.FontFamily,
                                    ForegroundColor = Config.ColorGrayTextOnWhite,
                                });
                            }

                            Color color = Config.ColorGray;
                            if (frame.A > frame.B)
                            {
                                color = Config.ColorGreen;
                            }
                            else if (frame.A < frame.B)
                            {
                                color = Config.ColorRed;
                            }

                            formattedStringScores.Spans.Add(new Span()
                            {
                                Text            = frame.A + ":" + frame.B,
                                FontAttributes  = FontAttributes.Bold,
                                FontSize        = Config.DefaultFontSize,
                                FontFamily      = Config.FontFamily,
                                ForegroundColor = color,
                            });
                        }

                        labelForFrames.FormattedText = formattedStringScores;
                    }
                    //                    StackLayout stackForFrames = new StackLayout()
                    //                    {
                    //                        Orientation = StackOrientation.Horizontal,
                    //                        Spacing = 8,
                    //                        Padding = new Thickness(0,0,0,0)
                    //                    };
                    //                    ScrollView scrollViewForFrames = new ScrollView()
                    //                    {
                    //                        Orientation = ScrollOrientation.Horizontal,
                    //                        Padding = new Thickness(0),
                    //                        Content = stackForFrames
                    //                    };
                    //                    if (match.HasFrameScores)
                    //                    {
                    //                        foreach (var frame in match.FrameScores)
                    //                        {
                    //                            Color color = Config.ColorGray;
                    //                            if (frame.A > frame.B)
                    //                                color = Config.ColorGreen;
                    //                            else if (frame.A < frame.B)
                    //                                color = Config.ColorRed;
                    //
                    //                            Label label = new BybLabel()
                    //                            {
                    //                                Text = frame.A + ":" + frame.B,
                    //                                FontAttributes = FontAttributes.Bold,
                    //                                TextColor = color,
                    //                                VerticalOptions = LayoutOptions.Center
                    //                            };
                    //                            stackForFrames.Children.Add(label);
                    //                        }
                    //                    }

                    // match color
                    //Color matchColor = match.MatchScoreA > match.MatchScoreB ? Config.ColorGreen : (match.MatchScoreA < match.MatchScoreB ? Config.ColorRed : Config.ColorGray);
                    Color matchColor = Config.ColorGray;
                    if (match.IsUnfinished)
                    {
                        matchColor = Config.ColorGray;
                    }

                    var panel1_1 = new StackLayout
                    {
                        Orientation         = StackOrientation.Vertical,
                        Padding             = new Thickness(0, 8, 0, 0),
                        WidthRequest        = Config.IsTablet ? 120 : 80,
                        MinimumWidthRequest = Config.IsTablet ? 100 : 80,
                        HeightRequest       = Config.IsTablet ? 55 : 45,
                        HorizontalOptions   = LayoutOptions.Center,
                        VerticalOptions     = LayoutOptions.Start,
                        BackgroundColor     = matchColor,
                        Spacing             = 2,
                        Children            =
                        {
                            new BybLabel
                            {
                                Text              = match.IsUnfinished ? "PAUSED" : "Score",
                                FontAttributes    = match.IsUnfinished ? Xamarin.Forms.FontAttributes.Bold : FontAttributes.None,
                                TextColor         = match.IsUnfinished ? Config.ColorBlackBackground : Color.White,
                                HorizontalOptions = LayoutOptions.Center
                            },
                            new BybLabel
                            {
                                Text              = match.MatchScoreA.ToString() + " : " + match.MatchScoreB.ToString(),
                                FontSize          = Config.LargerFontSize,
                                FontAttributes    = Xamarin.Forms.FontAttributes.Bold,
                                TextColor         = Color.White,
                                HorizontalOptions = LayoutOptions.Center
                            },
                        }
                    };

                    var panel1_0 = new StackLayout
                    {
                        Padding           = new Thickness(10, 10, 0, 5),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        WidthRequest      = widthOfLeftColumn,
                        VerticalOptions   = LayoutOptions.Start,
                        Children          =
                        {
                            labelOpponent,
                            labelForFrames,//scrollViewForFrames
                        }
                    };
                    this.panelsToResize.Add(panel1_0);

                    var panel1 = new StackLayout()
                    {
                        Orientation     = StackOrientation.Horizontal,
                        BackgroundColor = Color.White,
                        Padding         = new Thickness(0, 0, 0, 0),
                        Children        =
                        {
                            panel1_0,
                            panel1_1,
                        }
                    };
                    var panel2 = new StackLayout
                    {
                        Orientation     = StackOrientation.Horizontal,
                        BackgroundColor = Color.White,
                        Padding         = new Thickness(5, 0, 5, 0),
                        Children        =
                        {
                            new Frame
                            {
                                Padding           = new Thickness(5, 5, 0, 5),
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                                Content           = new BybLabel()
                                {
                                    Text = DateTimeHelper.DateToString(match.Date),//match.Date.ToShortDateString(),
                                    VerticalTextAlignment = TextAlignment.Center,
                                    TextColor             = Config.ColorGrayTextOnWhite
                                }
                            },
                            new Frame
                            {
                                Padding           = new Thickness(0, 5, 5, 5),
                                HorizontalOptions = LayoutOptions.EndAndExpand,
                                Content           = labelVenue
                            },
                        }
                    };

                    panel1.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() => { this.tapped(match); })
                    });
                    panel2.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() => { this.tapped(match); })
                    });
                    panel1_1.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() => { this.tapped(match); })
                    });
                    //scrollViewForFrames.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.tapped(match); }) });

                    this.Children.Add(new StackLayout()
                    {
                        Orientation = StackOrientation.Vertical,
                        Spacing     = 1,
                        Children    =
                        {
                            panel1,
                            panel2,
                        }
                    });
                }

                // remove previous items now, to avoid unnecessary scrolling
                foreach (var item in itemsToRemove)
                {
                    this.Children.Remove(item);
                }
            }
            catch (Exception exc)
            {
                this.Children.Add(new BybLabel()
                {
                    Text = "Error: " + TraceHelper.ExceptionToString(exc)
                });
            }
        }
Example #20
0
        protected override View createViewForSingleItem(GameHostWebModel gameHost)
        {
            try
            {
                bool youAreHosting = gameHost.HostPersonID == myAthleteID;
                bool youAreInvited = gameHost.IsInvited(myAthleteID);

                // host person
                FormattedString formattedStringPerson = new FormattedString();
                formattedStringPerson.Spans.Add(new Span()
                {
                    Text            = gameHost.HostPersonName,
                    ForegroundColor = Config.ColorBlackTextOnWhite,
                    FontAttributes  = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold,
                    FontFamily      = Config.FontFamily,
                    FontSize        = Config.DefaultFontSize
                });

                //formattedStringPerson.Spans.Add(new Span() { Text = " wants to play", ForegroundColor = Config.ColorGrayTextOnWhite, FontAttributes = FontAttributes.None, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize });
                Label labelPersonHost = new BybLabel()
                {
                    FormattedText     = formattedStringPerson,
                    HorizontalOptions = LayoutOptions.Start,
                    FontAttributes    = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold,
                    FontFamily        = Config.FontFamily,
                    TextColor         = Config.ColorBlackTextOnWhite,
                };

                // when
                FormattedString formattedStringWhen = new FormattedString();
                formattedStringWhen.Spans.Add(new Span()
                {
                    Text            = "on ",
                    ForegroundColor = Config.ColorGrayTextOnWhite,
                });
                formattedStringWhen.Spans.Add(new Span()
                {
                    Text            = DateTimeHelper.DateAndTimeToString(gameHost.When),
                    ForegroundColor = Config.ColorBlackTextOnWhite,
                    FontFamily      = Config.FontFamily,
                    FontSize        = Config.DefaultFontSize
                });

                // venue
                FormattedString formattedStringVenue = new FormattedString();
                formattedStringVenue.Spans.Add(new Span()
                {
                    Text = "at ", ForegroundColor = Config.ColorGrayTextOnWhite, FontAttributes = FontAttributes.None, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
                });
                formattedStringVenue.Spans.Add(new Span()
                {
                    Text            = gameHost.VenueName,
                    ForegroundColor = Config.ColorBlackTextOnWhite,
                    FontAttributes  = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold,
                    FontFamily      = Config.FontFamily,
                    FontSize        = Config.DefaultFontSize
                });
                Label labelVenue = new BybLabel()
                {
                    FormattedText = formattedStringVenue,
                };

                // lists of people
                ScrollView panel1 = this.createScrollViewWithNames(gameHost, gameHost.AthleteIDs_Going, "Accepted", false, false);
                ScrollView panel2 = this.createScrollViewWithNames(gameHost, gameHost.GetAthleteIDs_Unresponded(), "Not responded", false, true);
                ScrollView panel3 = this.createScrollViewWithNames(gameHost, gameHost.AthleteIDs_CannotGo, "Declined", false, true);
                ScrollView panel4 = this.createScrollViewWithNames(gameHost, gameHost.AthleteIDs_WantToGo, "Wants to be invited", youAreHosting ? true : false, true);

                // accept button
                Button buttonAccept = new BybButton()
                {
                    Style             = (Style)App.Current.Resources["ConfirmButtonStyle"],
                    HorizontalOptions = LayoutOptions.Start,
                    WidthRequest      = 130 + (Config.IsAndroid ? 30 : 0) + (Config.IsTablet ? 30 : 0),
                    HeightRequest     = Config.IsAndroid ? 40 : 30,
                };
                if (this.IsForPast)
                {
                    buttonAccept.IsVisible = false;
                }
                else if (youAreHosting)
                {
                    buttonAccept.Text      = "You are hosting";
                    buttonAccept.Style     = (Style)App.Current.Resources["SimpleButtonStyle"];
                    buttonAccept.IsEnabled = false;
                }
                else if (gameHost.IsGoing(myAthleteID))
                {
                    buttonAccept.Text      = "You are going!";
                    buttonAccept.IsEnabled = false;
                }
                else if (youAreInvited)
                {
                    buttonAccept.Text = "Accept invitation";
                }
                else if (gameHost.IsWantToGo(myAthleteID))
                {
                    buttonAccept.Text      = "Already asked to be invited";
                    buttonAccept.Style     = (Style)App.Current.Resources["SimpleButtonStyle"];
                    buttonAccept.IsEnabled = false;
                }
                else
                {
                    buttonAccept.Text = "Ask to be invited";
                }
                bool buttonAcceptIsDisabled = buttonAccept.IsEnabled == false;
                if (Config.IsAndroid && buttonAcceptIsDisabled)
                {
                    // explanation: On Android disabled buttons become invisible on the white background... so make it enabled but make it look differently
                    buttonAccept.IsEnabled = true;
                    buttonAccept.TextColor = Color.Black;
                    buttonAccept.Opacity   = 0.5;
                }
                buttonAccept.Clicked += (s1, e1) =>
                {
                    if (buttonAcceptIsDisabled)
                    {
                        return;
                    }
                    if (youAreInvited)
                    {
                        this.doOnUserWantsToAcceptAnInvite(gameHost);
                    }
                    else if (youAreHosting == false)
                    {
                        this.doOnUserWantsToBeInvited(gameHost);
                    }
                };


                // decline button
                Button buttonDecline = new BybButton()
                {
                    Style             = (Style)App.Current.Resources["DenyButtonStyle"],
                    HorizontalOptions = LayoutOptions.Start,
                    WidthRequest      = 130 + (Config.IsAndroid ? 30 : 0) + (Config.IsTablet ? 30 : 0),
                    HeightRequest     = Config.IsAndroid ? 40 : 30,
                    Text = "Decline invitation",//buttonText,
                    //IsEnabled = buttonText != ""
                };
                if (this.IsForPast)
                {
                    buttonDecline.IsVisible = false;
                }
                else if (youAreHosting)
                {
                    buttonDecline.Text      = "";
                    buttonDecline.IsVisible = false;
                }
                else if (gameHost.IsCannotGo(myAthleteID))
                {
                    buttonDecline.Text      = "You declined";
                    buttonDecline.IsEnabled = false;
                }
                else if (youAreInvited || gameHost.IsGoing(myAthleteID))
                {
                    buttonDecline.Text = "Decline invitation";
                }
                else
                {
                    buttonDecline.Text      = "";
                    buttonDecline.IsVisible = false;
                }
                bool buttonDeclineIsDisabled = buttonDecline.IsEnabled == false;
                if (Config.IsAndroid && buttonDeclineIsDisabled)
                {
                    // explanation: On Android disabled buttons become invisible on the white background... so make it enabled but make it look differently
                    buttonDecline.IsEnabled = true;
                    buttonDecline.TextColor = Color.Black;
                    buttonDecline.Opacity   = 0.5;
                }
                buttonDecline.Clicked += (s1, e1) =>
                {
                    if (buttonDeclineIsDisabled)
                    {
                        return;
                    }
                    this.doOnUserWantsToDecline(gameHost);
                };

                /// likes and comments
                ///
                var imageLike = new Image()
                {
                    Source = new FileImageSource()
                    {
                        File = "like1.png"
                    },
                    HeightRequest = Config.LikeImageSize,
                    WidthRequest  = Config.LikeImageSize,
                };
                var imageComments = new Image()
                {
                    Source = new FileImageSource()
                    {
                        File = "right.png"
                    },
                    HeightRequest = Config.CommentImageSize,
                    WidthRequest  = Config.CommentImageSize,
                };
                var labelLikesCount = new BybLabel
                {
                };
                var panelLikes = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Center,
                    Padding           = new Thickness(0, 0, 0, 5),
                    Spacing           = 3,
                    Children          =
                    {
                        labelLikesCount,
                        imageLike
                    }
                };
                var labelCommentsCount = new BybLabel
                {
                };
                var panelComments = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Center,
                    Padding           = new Thickness(0, 5, 0, 0),
                    Spacing           = 5,
                    Children          =
                    {
                        labelCommentsCount,
                        imageComments,
                    }
                };
                var panelCommentsCount = new StackLayout
                {
                    Orientation       = StackOrientation.Vertical,
                    Spacing           = 0,
                    HorizontalOptions = LayoutOptions.End,
                    VerticalOptions   = LayoutOptions.Center,
                    Children          =
                    {
                        panelLikes,
                        panelComments
                    }
                };
                imageLike.Source = new FileImageSource()
                {
                    File = gameHost.Liked ? "like2.png" : "like1.png"
                };
                imageComments.Source = new FileImageSource()
                {
                    File = gameHost.CommentsCount > 0 ? "right2.png" : "right1.png"
                };
                labelLikesCount.Text         = gameHost.LikesCount.ToString();
                labelLikesCount.TextColor    = gameHost.LikesCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite;
                labelCommentsCount.Text      = gameHost.CommentsCount.ToString();
                labelCommentsCount.TextColor = gameHost.CommentsCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite;
                panelComments.IsVisible      = ShowCommentsCount;
                panelLikes.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(async() =>
                    {
                        if (gameHost.Liked)
                        {
                            gameHost.LikesCount -= 1;
                        }
                        else
                        {
                            gameHost.LikesCount += 1;
                        }
                        gameHost.Liked = !gameHost.Liked;

                        imageLike.Source = new FileImageSource()
                        {
                            File = gameHost.Liked ? "like2.png" : "like1.png"
                        };
                        labelLikesCount.Text      = gameHost.LikesCount.ToString();
                        labelLikesCount.TextColor = gameHost.LikesCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite;

                        bool ok = await App.WebService.SetLike(NewsfeedItemTypeEnum.GameHost, gameHost.GameHostID, gameHost.Liked);
                        if (ok == false)
                        {
                            App.Navigator.DisplayAlertError("Couldn't set the like. Internet issues?");
                        }
                    }),
                    NumberOfTapsRequired = 1
                });

                var labelInfo = new BybLabel
                {
                    Text                    = this.IsForPast ? "Invited to play snooker" : "Invites to play snooker",
                    TextColor               = Config.ColorGrayTextOnWhite,
                    HorizontalOptions       = LayoutOptions.Fill,
                    HorizontalTextAlignment = TextAlignment.Start
                };

                Label labelInfo2 = new BybLabel
                {
                    Text = (gameHost.EventType == EventTypeEnum.Private ? "Private event" : "Public event") +
                           (gameHost.LimitOnNumberOfPlayers > 0 ? (", max. " + gameHost.LimitOnNumberOfPlayers.ToString() + " can join") : ""),
                    TextColor               = Config.ColorGrayTextOnWhite,
                    HorizontalOptions       = LayoutOptions.Fill,
                    HorizontalTextAlignment = TextAlignment.Start
                };

                var labelWhen = new BybLabel
                {
                    FormattedText = formattedStringWhen,
                    //Text = DateTimeHelper.DateAndTimeToString(gameHost.When),// gameHost.When.ToShortDateString() + " - " + gameHost.When.ToShortTimeString(),
                    TextColor = Config.ColorBlackTextOnWhite
                };

                var panel0 = new StackLayout
                {
                    Orientation     = StackOrientation.Horizontal,
                    Spacing         = 10,
                    Padding         = new Thickness(5, 5, 5, 5),
                    BackgroundColor = Color.White,
                    Children        =
                    {
                        new Grid
                        {
                            //BackgroundColor = Color.Transparent,
                            Padding  = new Thickness(Config.IsTablet ? 10 : 0, 0, Config.IsTablet ? 10 : 0, 0),
                            Children =
                            {
                                new Image()
                                {
                                    Source        = App.ImagesService.GetImageSource(gameHost.HostPersonPicture, BackgroundEnum.White),
                                    WidthRequest  = Config.PersonImageSize,
                                    HeightRequest = Config.PersonImageSize,
                                }
                            }
                        },
                        new StackLayout
                        {
                            Orientation       = StackOrientation.Vertical,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions   = LayoutOptions.Center,
                            Spacing           = 5,
                            Children          =
                            {
                                labelPersonHost,
                                labelInfo,
                                labelWhen,
                                labelVenue,
                                labelInfo2,
                            },
                        },
                        panelCommentsCount
                    }
                };

                var panelButtons = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = new Thickness(12, 5, 5, 5),
                    BackgroundColor   = Color.White,
                    Spacing           = 0,
                    Children          =
                    {
                        buttonAccept,
                        buttonDecline
                    }
                };

                var stackGameHost = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Spacing     = 1,
                    //Opacity = IsForPast ? 0.5 : 1.0,
                    Children =
                    {
                        panel0,
                        panel1,
                        panel2,
                        panel3,
                        panel4,
                        panelButtons,
                    }
                };

                /// event handlers
                ///

                var recognizer = new TapGestureRecognizer
                {
                    Command = new Command(async() => { await this.openGameHostPage(gameHost.GameHostID); })
                };

                panel0.GestureRecognizers.Add(recognizer);
                panel1.Content.GestureRecognizers.Add(recognizer);
                panel2.Content.GestureRecognizers.Add(recognizer);
                panel3.Content.GestureRecognizers.Add(recognizer);
                panel4.Content.GestureRecognizers.Add(recognizer);
                panelButtons.GestureRecognizers.Add(recognizer);

                if (this.TreatAsASingleItem == false)
                {
                    labelPersonHost.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() => { await App.Navigator.GoToPersonProfile(gameHost.HostPersonID); })
                    });
                    labelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() => { await App.Navigator.GoToVenueProfile(gameHost.VenueID); })
                    });
                }

                return(stackGameHost);
            }
            catch (Exception exc)
            {
                return(new BybLabel()
                {
                    Text = TraceHelper.ExceptionToString(exc)
                });
            }
        }
        public ProfilePersonInfoControl()
        {
            HorizontalOptions = LayoutOptions.FillAndExpand;
            BackgroundColor   = Config.ColorBackground;
            Spacing           = 0;

            // Location
            this.labelLocation = new BybLabel()
            {
                Text = "", Style = (Style)App.Current.Resources["LabelOnBackgroundStyle"], HorizontalOptions = LayoutOptions.Center
            };
            this.Children.Add(new StackLayout()
            {
                BackgroundColor   = Config.ColorBackground,
                Padding           = new Thickness(0, 0, 0, 10),
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    this.labelLocation
                }
            });

            // image
            this.image = new Image()
            {
                HeightRequest     = Config.MyImageSize,
                WidthRequest      = Config.MyImageSize,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.Center,
            };
            StackLayout panelImage = new StackLayout()
            {
                BackgroundColor   = Config.ColorBackground,
                Padding           = new Thickness(0, Config.IsTablet ? 15 : 0, 0, Config.IsTablet ? 15 : 10),
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    this.image,
                }
            };

            this.Children.Add(panelImage);

            // The 3 numbers
            Label labelBestBreakLabel = new BybLabel {
                Text = "Best break", Style = (Style)App.Current.Resources["LabelOnBackgroundStyle"], VerticalTextAlignment = TextAlignment.Center, HeightRequest = 30,
            };

            this.labelBestBreak = new BybLabel()
            {
                Text                  = "",
                FontFamily            = Config.FontFamily,
                FontAttributes        = FontAttributes.Bold,
                FontSize              = Config.LargerFontSize,
                BackgroundColor       = Color.Transparent,
                TextColor             = Config.ColorRedBackground,
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center
            };
            Label labelBestFrameLabel = new BybLabel {
                Text = "Max frame", Style = (Style)App.Current.Resources["LabelOnBackgroundStyle"], VerticalTextAlignment = TextAlignment.Center, HeightRequest = 30,
            };

            this.labelBestFrame = new BybLabel()
            {
                Text                  = "",
                FontFamily            = Config.FontFamily,
                FontAttributes        = FontAttributes.Bold,
                FontSize              = Config.LargerFontSize,
                BackgroundColor       = Color.Transparent,
                TextColor             = Config.ColorRedBackground,
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center
            };
            Label labelContributionsLabel = new BybLabel {
                Text = "Contributions", Style = (Style)App.Current.Resources["LabelOnBackgroundStyle"], VerticalTextAlignment = TextAlignment.Center, HeightRequest = 30,
            };

            this.labelContributions = new BybLabel()
            {
                Text                  = "",
                FontFamily            = Config.FontFamily,
                FontAttributes        = FontAttributes.Bold,
                FontSize              = Config.LargerFontSize,
                BackgroundColor       = Color.Transparent,
                TextColor             = Config.ColorRedBackground,
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center
            };
            this.Children.Add(new StackLayout()
            {
                Padding           = new Thickness(0, 0, 0, 0),
                Spacing           = 5,
                BackgroundColor   = Config.ColorBackground,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Children          =
                {
                    labelBestBreakLabel,
                    this.labelBestBreak,
                    new BoxView()
                    {
                        WidthRequest = Config.IsTablet ? 10 : 2
                    },
                    labelBestFrameLabel,
                    this.labelBestFrame,
                    new BoxView()
                    {
                        WidthRequest = Config.IsTablet ? 10 : 2
                    },
                    labelContributionsLabel,
                    this.labelContributions
                }
            });

            // about
            this.labelAbout = new BybLabel()
            {
                LineBreakMode           = LineBreakMode.WordWrap,
                Style                   = (Style)App.Current.Resources["LabelOnBackgroundStyle"],
                VerticalTextAlignment   = TextAlignment.Start,
                HorizontalTextAlignment = TextAlignment.Center
            };
            this.Children.Add(this.labelAbout);

            /// Event handlers
            ///
            this.image.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    this.doOnImageClicked();
                }),
                NumberOfTapsRequired = 1
            });
            this.labelBestBreak.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    if (ClickedOnBestBreak != null)
                    {
                        ClickedOnBestBreak(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            labelBestBreakLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    if (ClickedOnBestBreak != null)
                    {
                        ClickedOnBestBreak(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            this.labelBestFrame.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    if (ClickedOnBestFrame != null)
                    {
                        ClickedOnBestFrame(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            labelBestFrameLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    if (ClickedOnBestFrame != null)
                    {
                        ClickedOnBestFrame(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            this.labelContributions.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    if (ClickedOnContributions != null)
                    {
                        ClickedOnContributions(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            labelContributionsLabel.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    if (ClickedOnContributions != null)
                    {
                        ClickedOnContributions(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
            this.labelAbout.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    if (ClickedOnAbout != null)
                    {
                        ClickedOnAbout(this, EventArgs.Empty);
                    }
                }),
                NumberOfTapsRequired = 1
            });
        }
Example #22
0
        ScrollView createScrollViewWithNames(GameHostWebModel gameHost, List <int> ids, string text, bool allowButton, bool canBeInvisible)
        {
            StackLayout panel = new StackLayout()
            {
                Orientation   = StackOrientation.Horizontal,
                Padding       = new Thickness(10, 0, 5, 0),
                HeightRequest = 23 + (Config.IsAndroid ? 3 : 0) + (Config.IsTablet ? 4 : 0),
                //HeightRequest = Config.IsIOS ? 20 : 23,
            };

            int count = ids != null ? ids.Count : 0;

            string labelText = text + ": ";

            if (count == 0)
            {
                labelText += " -";
            }

            Label label = new BybLabel()
            {
                Text                  = labelText,
                TextColor             = Config.ColorBlackTextOnWhite,
                VerticalTextAlignment = TextAlignment.Center,
            };

            panel.Children.Add(label);

            if (count > 0)
            {
                foreach (int id in ids)
                {
                    var person = App.Cache.People.Get(id);

                    string personName = "unknown";
                    if (person != null && string.IsNullOrEmpty(person.Name) == false)
                    {
                        personName = person.Name;
                    }

                    Label labelPerson = new BybLabel()
                    {
                        Text            = personName,
                        FontAttributes  = FontAttributes.Bold,
                        VerticalOptions = LayoutOptions.Center,
                        TextColor       = Config.ColorBlackTextOnWhite,
                    };
                    labelPerson.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(async() => { await App.Navigator.GoToPersonProfile(id); })
                    });
                    panel.Children.Add(labelPerson);
                    if (person == null)
                    {
                        this.labelsToUpdate.Add(new KeyValuePair <Label, int> (labelPerson, id));
                    }

                    if (allowButton)
                    {
                        Label buttonAllow = new BybLabel()
                        {
                            Text            = "accept this player",
                            FontAttributes  = FontAttributes.Bold,
                            TextColor       = Config.ColorGreen,
                            VerticalOptions = LayoutOptions.Center,
                        };
                        buttonAllow.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            Command = new Command(() => { this.doOnUserWantsToAcceptPlayer(gameHost, id); })
                        });
                        panel.Children.Add(buttonAllow);
                    }
                }
            }

            ScrollView scrollView = new ScrollView()
            {
                Padding         = new Thickness(0),
                BackgroundColor = Color.White,
                Content         = panel
            };

            if (canBeInvisible && count == 0)
            {
                scrollView.IsVisible = false;
            }

            return(scrollView);
        }
Example #23
0
        public NewsfeedItemGameHostControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem)
        {
            DateTime when = item.TimeOfEvent.Value.ToLocalTime();

            Label labelText = new BybLabel
            {
                Text              = "Invites to play snooker",
                TextColor         = Config.ColorGrayTextOnWhite,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            labelText.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    await this.onOpenItem();
                }),
                NumberOfTapsRequired = 1
            });

            FormattedString formattedString = new FormattedString();

            formattedString.Spans.Add(new Span()
            {
                Text = "On ", ForegroundColor = Config.ColorTextOnBackgroundGrayed
            });
            formattedString.Spans.Add(new Span()
            {
                Text = DateTimeHelper.DateAndTimeToString(when), ForegroundColor = Config.ColorBlackTextOnWhite, FontSize = Config.DefaultFontSize
            });
            Label labelWhen = new BybLabel {
                FormattedText = formattedString
            };

            labelWhen.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    await this.onOpenItem();
                }),
                NumberOfTapsRequired = 1
            });

            this.Children.Add(this.frameAthleteImage);
            var panel = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(5, 0, 0, 0),
                Spacing           = 3,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    labelDate,
                    new StackLayout
                    {
                        Orientation     = StackOrientation.Horizontal,
                        VerticalOptions = LayoutOptions.Center,
                        Spacing         = 3,
                        Children        =
                        {
                            this.labelAthleteName,
                        }
                    },
                    labelText,
                    labelWhen,
                }
            };

            if (this.labelVenue != null)
            {
                panel.Children.Add(labelVenue);
            }
            this.Children.Add(panel);
            this.Children.Add(panelCommentsCount);
        }