protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AnimationReversing);

            var container = FindViewById <LinearLayout>(Resource.Id.container);

            var animView = new MyAnimationView(this);

            container.AddView(animView);

            var starter = FindViewById <Button>(Resource.Id.startButton);

            starter.Click += delegate
            {
                animView.StartAnimation();
            };

            var reverse = FindViewById <Button>(Resource.Id.reverseButton);

            reverse.Click += delegate
            {
                animView.ReverseAnimation();
            };
        }
示例#2
0
        private async Task finish_fun(int answer)
        {
            if (answer == 2) // results
            {
                List <Number> results = new List <Number>();
                for (int i = 0; i < FlexL.Children.Count; i++)
                {
                    results.Add((Number)SwipeCardView.ItemsSource[i]);
                    LastNumber = (Number)SwipeCardView.ItemsSource[i];
                }
                BindingContext = new TinderPageViewModel(results);
                SwipeCardView.SupportedDraggingDirections = SwipeCardDirection.Left;
                SwipeCardView.SupportedSwipeDirections    = SwipeCardDirection.Left;

                nopeVisible = false;
            }
            else if (answer == 0) // play again
            {
                BindingContext = new TinderPageViewModel();
                MyAnimationView.PlayProgressSegment(0, 1);
                timer = sec15;
                stopwatch.Restart();
                FlexL.Children.Clear();
                finished    = false;
                nopeVisible = true;
                SwipeCardView.SupportedDraggingDirections = SupportedDraggingDirections;
                SwipeCardView.SupportedSwipeDirections    = SupportedSwipingDirections;
            }
            else if (answer == 1) // quit
            {
                await Navigation.PopAsync();

                finished = false;
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AnimationSeeking);

            var container = FindViewById <LinearLayout>(Resource.Id.container);

            seekBar = FindViewById <SeekBar>(Resource.Id.seekBar);

            var animView = new MyAnimationView(this, seekBar);

            container.AddView(animView);

            seekBar.Max              = Duration;
            seekBar.ProgressChanged += (sender, e) =>
            {
                // prevent seeking on app creation
                if (animView.Height != 0)
                {
                    animView.Seek(e.Progress);
                }
            };

            var starter = FindViewById <Button>(Resource.Id.startButton);

            starter.Click += delegate
            {
                animView.StartAnimation();
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AnimatorEvents);

            var container = FindViewById <LinearLayout>(Resource.Id.container);

            var animView = new MyAnimationView(this);

            container.AddView(animView);

            startText = FindViewById <TextView>(Resource.Id.startText);
            startText.SetTextColor(Off);
            repeatText = FindViewById <TextView>(Resource.Id.repeatText);
            repeatText.SetTextColor(Off);
            cancelText = FindViewById <TextView>(Resource.Id.cancelText);
            cancelText.SetTextColor(Off);
            endText = FindViewById <TextView>(Resource.Id.endText);
            endText.SetTextColor(Off);
            startTextAnimator = FindViewById <TextView>(Resource.Id.startTextAnimator);
            startTextAnimator.SetTextColor(Off);
            repeatTextAnimator = FindViewById <TextView>(Resource.Id.repeatTextAnimator);
            repeatTextAnimator.SetTextColor(Off);
            cancelTextAnimator = FindViewById <TextView>(Resource.Id.cancelTextAnimator);
            cancelTextAnimator.SetTextColor(Off);
            endTextAnimator = FindViewById <TextView>(Resource.Id.endTextAnimator);
            endTextAnimator.SetTextColor(Off);
            var endCB = FindViewById <CheckBox>(Resource.Id.endCB);

            var starter = FindViewById <Button>(Resource.Id.startButton);

            starter.Click += delegate
            {
                animView.StartAnimation(endCB.Checked);
            };

            var canceler = FindViewById <Button>(Resource.Id.cancelButton);

            canceler.Click += delegate
            {
                animView.CancelAnimation();
            };

            var ender = FindViewById <Button>(Resource.Id.endButton);

            ender.Click += delegate
            {
                animView.EndAnimation();
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AnimationCloning);

            var container = FindViewById<LinearLayout>(Resource.Id.container);

            var animView = new MyAnimationView(this);
            container.AddView(animView);

            var starter = FindViewById<Button>(Resource.Id.startButton);
            starter.Click += delegate
            {
                animView.StartAnimation();
            };
        }
示例#6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AnimationCloning);

            var container = FindViewById <LinearLayout>(Resource.Id.container);

            var animView = new MyAnimationView(this);

            container.AddView(animView);

            var starter = FindViewById <Button>(Resource.Id.startButton);

            starter.Click += delegate
            {
                animView.StartAnimation();
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AnimationReversing);

            var container = FindViewById<LinearLayout>(Resource.Id.container);

            var animView = new MyAnimationView(this);
            container.AddView(animView);

            var starter = FindViewById<Button>(Resource.Id.startButton);
            starter.Click += delegate
            {
                animView.StartAnimation();
            };

            var reverse = FindViewById<Button>(Resource.Id.reverseButton);
            reverse.Click += delegate
            {
                animView.ReverseAnimation();
            };
        }
示例#8
0
        private async void OnSwiping(object sender, SwipedCardEventArgs e)
        {
            if (finished)
            {
                if (!nopeVisible)
                {
                    if (((Number)e.Item).Id == LastNumber.Id)
                    {
                        bool answer = await DisplayAlert("Next game?", "Play another game?", "Yes", "No");

                        if (answer)
                        {
                            await  finish_fun(0);
                        }
                        else
                        {
                            await finish_fun(1);
                        }
                    }
                }
                return;
            }
            uint timeout = 50;

            if ((e.Direction == SwipeCardDirection.Left && !((Number)e.Item).Prime)
                ||
                (e.Direction == SwipeCardDirection.Right && ((Number)e.Item).Prime))
            {
                ((Number)e.Item).Correct = true;


                ViewModel.ViewExtensions.CancelAnimation(MyStack);
                MyStack.ColorTo(Color.Green, Color.White, c => MyStack.BackgroundColor = c, 500);
                var v = new AnimationView();
                v.Animation     = "4964-check-mark-success-animation.json";
                v.IsPlaying     = true;
                v.WidthRequest  = 25;
                v.HeightRequest = 25;


                FlexL.Children.Add(v);

                timer = Math.Min(sec15, timer - stopwatch.Elapsed.TotalMilliseconds + 1000);
                var segment = (float)Math.Min(1, 1 - (timer) / sec15);
                MyAnimationView.PlayProgressSegment((float)segment, 1);
                stopwatch.Restart();
            }
            else if ((e.Direction == SwipeCardDirection.Left && ((Number)e.Item).Prime)
                     ||
                     (e.Direction == SwipeCardDirection.Right && !((Number)e.Item).Prime))
            {
                ((Number)e.Item).Correct = false;
                ViewModel.ViewExtensions.CancelAnimation(MyStack);
                MyStack.ColorTo(Color.Red, Color.White, c => MyStack.BackgroundColor = c, 500);
                await MyStack.TranslateTo(-15, 0, timeout);

                await MyStack.TranslateTo(15, 0, timeout);

                await MyStack.TranslateTo(-9, 0, timeout);

                await MyStack.TranslateTo(9, 0, timeout);

                await MyStack.TranslateTo(-5, 0, timeout);

                await MyStack.TranslateTo(5, 0, timeout);

                await MyStack.TranslateTo(-2, 0, timeout);

                await MyStack.TranslateTo(2, 0, timeout);

                MyStack.TranslationX = 0;

                var v = new AnimationView();
                v.Animation     = "4970-unapproved-cross.json";
                v.IsPlaying     = true;
                v.WidthRequest  = 25;
                v.HeightRequest = 25;

                timer = Math.Max(0, timer - stopwatch.Elapsed.TotalMilliseconds - 2000);
                var segment = (float)Math.Min(1, 1 - (timer) / sec15);
                MyAnimationView.PlayProgressSegment((float)segment, 1);
                stopwatch.Restart();


                FlexL.Children.Add(v);
            }
            else if (e.Direction == SwipeCardDirection.Up)
            {
                ViewModel.ViewExtensions.CancelAnimation(MyStack);
                MyStack.ColorTo(Color.Yellow, Color.White, c => MyStack.BackgroundColor = c, 500);

                var v = new AnimationView();
                v.Animation     = "4975-question-mark.json";
                v.IsPlaying     = true;
                v.WidthRequest  = 25;
                v.HeightRequest = 25;


                FlexL.Children.Add(v);
            }
        }