Пример #1
0
        const int QuestionCount = 10; //HardCoded....for now...

        public QuestionSessionManager(IWeirdDatabase weirdDatabase)
        {
            _questions       = weirdDatabase.GetRandomQuestions(QuestionCount);
            _questionSession = new QuestionSession {
                TotalQuestions = _questions.Count
            };
        }
Пример #2
0
        public QuestionPage(IWeirdDatabase database)
        {
            _testSm = new QuestionSessionManager(database);

            _header = new Label
            {
                FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes    = FontAttributes.None,
                HorizontalOptions = LayoutOptions.Center,
                FontFamily        = FontFamily,
                Margin            = 5,
                TextColor         = Color.FromHex("#373a3c")
            };



            var relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.FromHex("#f9f9f9"),
                //TODO does not work ... Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            relativeLayout.Children.Add(_header, Constraint.RelativeToParent((parent) => { return(0); }));


            _contentView = new ContentView();


            _stackLayout = new StackLayout
            {
                Spacing           = 10,
                HorizontalOptions =
                    LayoutOptions.FillAndExpand,
                Padding = new Thickness(5, 5, 5, 5)
            };


            _button = new Button
            {
                Text        = "Check",
                Font        = Font.SystemFontOfSize(NamedSize.Large),
                BorderWidth = 1,
                IsEnabled   = false,
            };

            _button.Clicked += OnButtonClicked;

            relativeLayout.Children.Add(_button,
                                        Constraint.RelativeToParent((parent) => { return(5); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Height - 50); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Width - 10); })
                                        );

            relativeLayout.Children.Add(
                _stackLayout,
                Constraint.RelativeToView(_header, (parent, sibling) => { return(10); }),
                Constraint.RelativeToView(_header, (parent, sibling) => { return(sibling.Height + 30); }),
                Constraint.RelativeToParent((parent) => { return(parent.Width - 20); })
                );


            _contentViewContent = new Label {
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };
            //Label... no padding!!!

            _contentView.Content          = _contentViewContent;
            _contentViewContent.IsVisible = false;

            //var parentContainer = (RelativeLayout)Content;


            relativeLayout.Children.Add(_contentView,
                                        Constraint.RelativeToParent((parent) => { return(0); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Height / 3); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Width - 20); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Height / 3); }));


            this.Content = relativeLayout;
            LoadQuestion();
        }