Beispiel #1
0
        private void AnswerClicked(object sender, EventArgs e)
        {
            var button = (Button)sender;

            answer.Text += button.Text;

            if (answer.Text == example.Answer)
            {
                points    += (1 - progressBar.Progress) * 10 * levelType.PointCoefficient;
                score.Text = points.ToString("F0");
                step++;

                if (step == 5 && levelId < 50)
                {
                    levelId++;
                    step      = 0;
                    levelType = LevelType.Get(levelId);
                }

                example       = levelType.CreateExample();
                question.Text = example.Question;
                answer.Text   = string.Empty;
                progressBar.AbortAnimation("SetProgress");
                StartAnimate();
            }
        }
        private void AnswerClicked(object sender, EventArgs e)
        {
            var button = (Button)sender;

            answer.Text += button.Text;

            if (answer.Text == example.Answer)
            {
                if (progressBar.Progress < 0.65)
                {
                    var repeat = repeats[example.Step];
                    repeat.Learn();
                    App.Database.ExampleRepeat.SaveItem(repeat);
                }

                var nextStep = example.Step + 1;
                if (nextStep >= countExample)
                {
                    Content = new Label
                    {
                        TextColor         = Color.Gray,
                        FontSize          = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                        Text              = AppResources.Excellent,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        VerticalOptions   = LayoutOptions.CenterAndExpand
                    };

                    Device.StartTimer(TimeSpan.FromSeconds(2), EndGame);


                    return;
                }

                var nextRepeat = repeats[nextStep];
                leadTime      = nextRepeat.LeadTime > 0 ? nextRepeat.LeadTime : 5;
                example       = new Example(nextRepeat.First, nextRepeat.Second, nextRepeat.Operation, nextStep);
                question.Text = example.Question;
                answer.Text   = string.Empty;
                progressBar.AbortAnimation("SetProgress");
                StartAnimate();
            }
        }
        private void Button_Clicked()
        {
            var startValue   = 0;
            var desiredValue = 0.6;

            if (_animation != null)
            {
                ProgressBar.AbortAnimation("Percentage");
            }

            _animation = new Animation(v =>
            {
                if (v == 0)
                {
                    ProgressBar.Percentage = 0;
                    return;
                }

                ProgressBar.Percentage = (float)(v / 100);
            }, startValue, desiredValue * 100, easing: Easing.SinInOut);

            _animation.Commit(ProgressBar, "Percentage", length: 2000,
                              finished: (l, c) => { _animation = null; });
        }