public static Rectangle GetViewGroupPosition(this ViewGroup viewGroup)
        {
            //int left = viewGroup.Left;
            //int top = viewGroup.Top;
            int[] viewLocation = { 0, 0 };
            viewGroup?.GetLocationInWindow(viewLocation);

            int width  = viewGroup.Width;
            int height = viewGroup.Height;

            //return DIP.ToRectangle((double)left, (double)top, (double)width, (double)height);
            return(DIP.ToRectangle(viewLocation[0], viewLocation[1], width, height));
        }
Exemple #2
0
        ParticleSystem(ViewGroup view, int maxParticles, long timeToLive)
        {
            mRandom   = new Random();
            mRootView = view;

            mModifiers    = new List <IParticleModifier>();
            mInitializers = new List <IParticleInitializer>();

            mMaxParticles = maxParticles;
            // Create the particles
            mActiveParticles = new List <Particle>();
            mParticles       = new List <Particle> ();
            mTimeToLive      = timeToLive;

            mParentLocation = new int[2];
            mRootView.GetLocationInWindow(mParentLocation);
        }
Exemple #3
0
        public override Animator CreateAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues)
        {
            if (startValues == null || endValues == null)
            {
                return(null);
            }
            var startBounds = (Rect)startValues.Values[PROPERTY_BOUNDS];
            var endBounds   = (Rect)endValues.Values[PROPERTY_BOUNDS];

            if (startBounds == null || endBounds == null || startBounds.Equals(endBounds))
            {
                return(null);
            }

            var      startImage      = (Bitmap)startValues.Values[PROPERTY_IMAGE];
            Drawable startBackground = new BitmapDrawable(sceneRoot.Context.Resources, startImage);

            _startView = AddViewToOverlay(sceneRoot, startImage.Width,
                                          startImage.Height, startBackground);
            Drawable shrinkingBackground = new ColorDrawable(new Color(_color));

            _shrinkingView = AddViewToOverlay(sceneRoot, startImage.Width,
                                              startImage.Height, shrinkingBackground);

            var sceneRootLoc = new int[2];

            sceneRoot.GetLocationInWindow(sceneRootLoc);
            var startLoc          = (int[])startValues.Values[PROPERTY_POSITION];
            var startTranslationX = startLoc[0] - sceneRootLoc[0];
            var startTranslationY = startLoc[1] - sceneRootLoc[1];

            _startView.TranslationX     = startTranslationX;
            _startView.TranslationY     = startTranslationY;
            _shrinkingView.TranslationX = startTranslationX;
            _shrinkingView.TranslationY = startTranslationY;

            _endView = endValues.View;
            var startRadius = CalculateMaxRadius(_shrinkingView);
            var minRadius   = Math.Min(CalculateMinRadius(_shrinkingView), CalculateMinRadius(_endView));

            var circleBackground = new ShapeDrawable(new OvalShape());

            circleBackground.Paint.Color = new Color(_color);
            _circleView = AddViewToOverlay(sceneRoot, minRadius * 2, minRadius * 2,
                                           circleBackground);
            float circleStartX = startLoc[0] - sceneRootLoc[0] +
                                 ((_startView.Width - _circleView.Width) / 2);
            float circleStartY = startLoc[1] - sceneRootLoc[1] +
                                 ((_startView.Height - _circleView.Height) / 2);

            _circleView.TranslationX = circleStartX;
            _circleView.TranslationY = circleStartY;

            _circleView.Visibility = ViewStates.Invisible;
            _shrinkingView.Alpha   = 0f;
            _endView.Alpha         = 0f;

            var shrinkingAnimator = CreateCircularReveal(_shrinkingView, startRadius, minRadius);

            shrinkingAnimator.AddListener(new ShrinkingAnimator());

            var startAnimator  = CreateCircularReveal(_startView, startRadius, minRadius);
            var fadeInAnimator = ObjectAnimator.OfFloat(_shrinkingView, "angle", 0, 1);  // <<<<==================

            var shrinkFadeSet = new AnimatorSet();

            shrinkFadeSet.PlayTogether(shrinkingAnimator, startAnimator, fadeInAnimator);

            var   endLoc     = (int[])endValues.Values[PROPERTY_POSITION];
            float circleEndX = endLoc[0] - sceneRootLoc[0] +
                               ((_endView.Width - _circleView.Width) / 2);
            float circleEndY = endLoc[1] - sceneRootLoc[1] +
                               ((_endView.Height - _circleView.Height) / 2);
            var      circlePath     = PathMotion.GetPath(circleStartX, circleStartY, circleEndX, circleEndY);
            Animator circleAnimator = ObjectAnimator.OfFloat(_circleView, View.X,
                                                             View.Y, circlePath);

            _growingView = AddViewToOverlay(sceneRoot, _endView.Width,
                                            _endView.Height, shrinkingBackground);
            _growingView.Visibility = ViewStates.Invisible;
            float endTranslationX = endLoc[0] - sceneRootLoc[0];
            float endTranslationY = endLoc[1] - sceneRootLoc[1];

            _growingView.TranslationX = endTranslationX;
            _growingView.TranslationY = endTranslationY;

            var endRadius = CalculateMaxRadius(_endView);

            circleAnimator.AddListener(new CircleAnimator());

            Animator fadeOutAnimator = ObjectAnimator.OfFloat(_growingView, "angle", 1, 0); //<<<============
            var      endAnimator     = CreateCircularReveal(_endView, minRadius, endRadius);
            var      growingAnimator = CreateCircularReveal(_growingView, minRadius, endRadius);

            growingAnimator.AddListener(new GrowingAnimator(sceneRoot));
            var growingFadeSet = new AnimatorSet();

            growingFadeSet.PlayTogether(fadeOutAnimator, endAnimator, growingAnimator);

            var animatorSet = new AnimatorSet();

            animatorSet.PlaySequentially(shrinkFadeSet, circleAnimator, growingFadeSet);
            return(animatorSet);
        }