示例#1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            View rootView = inflater.Inflate(Resource.Layout.fragment_snap, container, false);

            View circle = rootView.FindViewById(Resource.Id.circle);

            MotionImitator motionImitator = new MotionImitator(MotionProperty.X);

            motionImitator.Release = (obj) =>
            {
                // snap to left or right depending on current location
                if (motionImitator.mSpring.CurrentValue > rootView.MeasuredWidth / 2 - circle.MeasuredWidth / 2)
                {
                    motionImitator.mSpring.SetEndValue(rootView.MeasuredWidth - circle.MeasuredWidth);
                }
                else
                {
                    motionImitator.mSpring.SetEndValue(0);
                }
            };

            new Actor.Builder(SpringSystem.Create(), circle)
            .AddTranslateMotion(MotionProperty.Y)
            .AddMotion(motionImitator, ViewHelper.TranslationX)
            .Build();

            return(rootView);

            //return base.OnCreateView(inflater, container, savedInstanceState);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_constrain, container, false);

            View constraintView = rootView.FindViewById(Resource.Id.constraint);

            View circle = rootView.FindViewById(Resource.Id.circle);

            InertialImitator motionImitatorX = new InertialImitator(MotionProperty.X, Imitator.TRACK_DELTA, Imitator.FOLLOW_SPRING, 0, 0);

            InertialImitator motionImitatorY = new InertialImitator(MotionProperty.Y, Imitator.TRACK_DELTA, Imitator.FOLLOW_SPRING, 0, 0);

            new Actor.Builder(SpringSystem.Create(), circle)
            .AddMotion(motionImitatorX, ViewHelper.TranslationX)
            .AddMotion(motionImitatorY, ViewHelper.TranslationY)
            .Build();

            EventHandler globalHandler = null;

            globalHandler += (sender, e) =>
            {
                motionImitatorX.SetMinValue(-constraintView.MeasuredWidth / 2 + circle.MeasuredWidth / 2);
                motionImitatorX.SetMaxValue(constraintView.MeasuredWidth / 2 - circle.MeasuredWidth / 2);
                motionImitatorY.SetMinValue(-constraintView.MeasuredHeight / 2 + circle.MeasuredWidth / 2);
                motionImitatorY.SetMaxValue(constraintView.MeasuredHeight / 2 - circle.MeasuredWidth / 2);
                rootView.ViewTreeObserver.GlobalLayout -= globalHandler;
            };

            rootView.ViewTreeObserver.GlobalLayout += globalHandler;

            return(rootView);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_press, container, false);

            new Actor.Builder(SpringSystem.Create(), rootView.FindViewById(Resource.Id.circle))
            .AddMotion(new ToggleImitator(null, 1.0, 0.5), View.ScaleXs, View.ScaleYs)
            .Build();

            return(rootView);
        }
示例#4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_move, container, false);

            new Actor.Builder(SpringSystem.Create(), rootView.FindViewById(Resource.Id.circle))
            .AddTranslateMotion(Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.X)
            .AddTranslateMotion(Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.Y)
            .Build();

            return(rootView);
        }
        private void render()
        {
            for (int i = 0; i < mImageViews.Count; i++)
            {
                ImageView imageView = mImageViews[i];
                if (mSpring.IsAtRest && mSpring.CurrentValue == 0)
                {
                    // Performing the initial entry transition animation.

                    //Spring spring = mSpringChain.getAllSprings().get(i);
                    Spring spring = SpringSystem.Create().CreateSpring();

                    float val = (float)spring.CurrentValue;
                    imageView.ScaleX = val;
                    imageView.ScaleY = val;
                    imageView.Alpha  = val;
                    Point pos = mPositions[i];
                    imageView.TranslationX = pos.X;
                    imageView.TranslationY = pos.Y;
                }
                else
                {
                    // Scaling up a photo to fullscreen size.
                    Point pos = mPositions[i];
                    if (i == mActiveIndex)
                    {
                        float ww    = imageView.Width;
                        float hh    = imageView.Height;
                        float sx    = imageView.Width / ww;
                        float sy    = imageView.Height / hh;
                        float s     = sx > sy ? sx : sy;
                        float xlatX = (float)SpringUtil.MapValueFromRangeToRange(mSpring.CurrentValue, 0, 1, pos.X, 0);
                        float xlatY = (float)SpringUtil.MapValueFromRangeToRange(mSpring.CurrentValue, 0, 1, pos.Y, 0);
                        imageView.PivotX       = 0;
                        imageView.PivotY       = 0;
                        imageView.TranslationX = xlatX;
                        imageView.TranslationY = xlatY;

                        float ss = (float)SpringUtil.MapValueFromRangeToRange(mSpring.CurrentValue, 0, 1, 1, s);
                        imageView.ScaleX = ss;
                        imageView.ScaleY = ss;
                    }
                    else
                    {
                        float val = (float)Math.Max(0, 1 - mSpring.CurrentValue);
                        imageView.Alpha = val;
                    }
                }
            }
        }
示例#6
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            mHandler      = new Handler();
            mSpringSystem = SpringSystem.Create();

            mCoasting         = SpringConfig.FromOrigamiTensionAndFriction(0, 0);
            mCoasting.Tension = 0;

            // this is very much a hack, since the end value is set to 9001 to simulate constant
            // acceleration.
            mGravity         = SpringConfig.FromOrigamiTensionAndFriction(0, 0);
            mGravity.Tension = 1;

            // Create your fragment here
        }
示例#7
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_scale, container, false);

            View rect = rootView.FindViewById(Resource.Id.rect);

            SpringSystem springSystem = SpringSystem.Create();

            Spring spring = springSystem.CreateSpring();

            spring.AddListener(new Performer(rect, View.ScaleXs));
            spring.AddListener(new Performer(rect, View.ScaleYs));


            rootView.Touch += (sender, e) => {
                switch (e.Event.Action)
                {
                case MotionEventActions.Down:
                    spring.SetVelocity(0);
                    goto case MotionEventActions.Move;

                //break;
                case MotionEventActions.Move:
                    // can't use Imitation here because there is no nice mapping from
                    // an event property to a Spring
                    float scaleX, scaleY;
                    float delta = e.Event.GetX() - (rect.GetX() + rect.MeasuredWidth / 2);
                    scaleX = Math.Abs(delta) / (rect.MeasuredWidth / 2);
                    delta  = e.Event.GetY() - (rect.GetY() + rect.MeasuredHeight / 2);
                    scaleY = Math.Abs(delta) / (rect.MeasuredHeight / 2);
                    float scale = Math.Max(scaleX, scaleY);
                    spring.SetEndValue(scale);
                    break;

                case MotionEventActions.Up:
                    spring.SetEndValue(1f);
                    break;
                }
                e.Handled = true;
                //return true;
            };

            return(rootView);
        }
示例#8
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            //return base.OnCreateView(inflater, container, savedInstanceState);
            View rootView = inflater.Inflate(Resource.Layout.origami_example, container, false);

            mPhotoGrid     = rootView.FindViewById <View>(Resource.Id.grid);
            mSelectedPhoto = rootView.FindViewById <View>(Resource.Id.selection);
            mFeedbackBar   = rootView.FindViewById <View>(Resource.Id.feedback);

            SpringSystem springSystem = SpringSystem.Create();

            mSpring = springSystem.CreateSpring().SetSpringConfig(ORIGAMI_SPRING_CONFIG);

            mSpring.AddListener(new MapPerformer(mSelectedPhoto, View.ScaleXs, 0f, 1f, 0.33f, 1));
            mSpring.AddListener(new MapPerformer(mSelectedPhoto, View.ScaleYs, 0f, 1f, 0.33f, 1));
            mSpring.AddListener(new MapPerformer(mSelectedPhoto, ViewHelper.TranslationX, 0, 1, Util.DpToPx(-106.667f, Resources), 0));
            mSpring.AddListener(new MapPerformer(mSelectedPhoto, ViewHelper.TranslationY, 0, 1, Util.DpToPx(46.667f, Resources), 0));
            mSpring.AddListener(new MapPerformer(mPhotoGrid, ViewHelper.Alpha, 0, 1, 1, 0));
            mSpring.AddListener(new MapPerformer(mPhotoGrid, View.ScaleXs, 0f, 1f, 1f, 0.95f));
            mSpring.AddListener(new MapPerformer(mPhotoGrid, View.ScaleYs, 0f, 1f, 1f, 0.95f));

            EventHandler globalHandler = null;

            globalHandler += (sender, e) =>
            {
                float barPosition = (float)SpringUtil.MapValueFromRangeToRange(mSpring.CurrentValue, 0, 1, mFeedbackBar.Height, 0);
                mFeedbackBar.TranslationY = barPosition;
                mSpring.AddListener(new MapPerformer(mFeedbackBar, ViewHelper.TranslationY, 0, 1, mFeedbackBar.Height, 0));
                rootView.ViewTreeObserver.GlobalLayout -= globalHandler;
            };

            rootView.ViewTreeObserver.GlobalLayout += globalHandler;

            ToggleImitator imitator = new ToggleImitator(mSpring, 0, 1);

            rootView.SetOnTouchListener(imitator);

            mSpring.SetCurrentValue(0);

            return(rootView);
        }
示例#9
0
        public SpringListenerViewActivity(Context context) : base(context)
        {
            mBitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon);
            SpringSystem ss = SpringSystem.Create();
            Spring       s;

            for (int i = 0; i < NUM_ELEMS; i++)
            {
                s = ss.CreateSpring();
                s.SetSpringConfig(new MySpringConfig(200, i == 0 ? 8 : 15 + i * 2, i, true));
                s.AddListener(this);
                mXSprings[i] = s;

                s = ss.CreateSpring();
                s.SetSpringConfig(new MySpringConfig(200, i == 0 ? 8 : 15 + i * 2, i, false));
                s.AddListener(this);
                mYSprings[i] = s;
            }
        }
示例#10
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_scale, container, false);

            View rect = rootView.FindViewById(Resource.Id.rect);

            SpringSystem springSystem = SpringSystem.Create();
            Spring       spring       = springSystem.CreateSpring();

            spring.AddListener(new Performer(rect, View.ScaleXs));
            spring.AddListener(new Performer(rect, View.ScaleYs));

            spring.SetCurrentValue(1.0f);

            ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector(this.Activity, new OnScaleGestureListener(spring));

            rootView.Touch += (sender, e) =>
            {
                e.Handled = scaleGestureDetector.OnTouchEvent(e.Event);
            };

            return(rootView);
        }
示例#11
0
            private static void createCircle(Context context, ViewGroup rootView, SpringSystem springSystem, SpringConfig coasting, SpringConfig gravity, int diameter, Drawable backgroundDrawable)
            {
                Spring xSpring = springSystem.CreateSpring().SetSpringConfig(coasting);
                Spring ySpring = springSystem.CreateSpring().SetSpringConfig(gravity);

                // create view
                View view = new View(context);

                RelativeLayout.LayoutParams paramss = new RelativeLayout.LayoutParams(diameter, diameter);
                paramss.AddRule(LayoutRules.CenterInParent);
                view.LayoutParameters = paramss;
                view.Background       = backgroundDrawable;

                rootView.AddView(view);

                // generate random direction and magnitude
                double magnitude = new Random().NextDouble() * 1000 + 3000;
                double angle     = new Random().NextDouble() * System.Math.PI / 2 + System.Math.PI / 4;

                xSpring.SetVelocity(magnitude * System.Math.Cos(angle));
                ySpring.SetVelocity(-magnitude * System.Math.Sin(angle));

                int maxX = rootView.MeasuredWidth / 2 + diameter;

                xSpring.AddListener(new Destroyer(rootView, view, -maxX, maxX));

                int maxY = rootView.MeasuredHeight / 2 + diameter;

                ySpring.AddListener(new Destroyer(rootView, view, -maxY, maxY));

                xSpring.AddListener(new Performer(view, ViewHelper.TranslationX));
                ySpring.AddListener(new Performer(view, ViewHelper.TranslationY));

                // set a different end value to cause the animation to play
                xSpring.SetEndValue(2);
                ySpring.SetEndValue(9001);
            }
示例#12
0
 /**
  * Animates the given view with the default {@link com.facebook.rebound.SpringConfig} and
  * automatically creates a {@link com.facebook.rebound.SpringSystem}.
  *
  * @param springSystem
  *      the spring system to use
  * @param view
  *      the view to animate
  */
 public Builder(SpringSystem springSystem, View view)
 {
     mView         = view;
     mSpringSystem = springSystem;
 }
示例#13
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            mRootView = (ViewGroup)inflater.Inflate(Resource.Layout.fragment_follow, container, false);

            mCircle = mRootView.FindViewById(Resource.Id.circle);

            FrameLayout.LayoutParams leaderParams = (FrameLayout.LayoutParams)mCircle.LayoutParameters;

            mFollowers = new View[4];

            float diameter = TypedValue.ApplyDimension(ComplexUnitType.Dip, DIAMETER, Resources.DisplayMetrics);

            Android.Content.Res.TypedArray circles = Resources.ObtainTypedArray(Resource.Array.circles);

            // create the circle views
            int colorIndex = 1;

            for (int i = 0; i < mFollowers.Length; i++)
            {
                mFollowers[i] = new View(this.Activity);

                FrameLayout.LayoutParams par = new FrameLayout.LayoutParams((int)diameter, (int)diameter);
                par.Gravity = leaderParams.Gravity;
                mFollowers[i].LayoutParameters = par;

                mFollowers[i].SetBackgroundDrawable(Resources.GetDrawable(circles.GetResourceId(colorIndex, -1)));

                colorIndex++;
                if (colorIndex >= circles.Length())
                {
                    colorIndex = 0;
                }

                mRootView.AddView(mFollowers[i]);
            }

            circles.Recycle();

            /* Animation code */

            SpringSystem springSystem = SpringSystem.Create();

            // create the springs that control movement
            Spring springX = springSystem.CreateSpring();
            Spring springY = springSystem.CreateSpring();

            // bind circle movement to events
            new Actor.Builder(springSystem, mCircle).AddMotion(springX, MotionProperty.X).AddMotion(springY, MotionProperty.Y).Build();

            // add springs to connect between the views
            Spring[] followsX = new Spring[mFollowers.Length];
            Spring[] followsY = new Spring[mFollowers.Length];

            Random rnd = new Random();

            for (int i = 0; i < mFollowers.Length; i++)
            {
                // create spring to bind views
                followsX[i] = springSystem.CreateSpring();
                followsY[i] = springSystem.CreateSpring();
                //followsX[i] = springSystem.CreateSpring().SetSpringConfig(new SpringConfig(rnd.Next(300), rnd.Next(22)));
                //followsY[i] = springSystem.CreateSpring().SetSpringConfig(new SpringConfig(rnd.Next(300), rnd.Next(22)));
                followsX[i].AddListener(new Performer(mFollowers[i], ViewHelper.TranslationX));
                followsY[i].AddListener(new Performer(mFollowers[i], ViewHelper.TranslationY));

                // imitates another character
                SpringImitator followX = new SpringImitator(followsX[i]);
                SpringImitator followY = new SpringImitator(followsY[i]);

                //  imitate the previous character
                if (i == 0)
                {
                    springX.AddListener(followX);
                    springY.AddListener(followY);
                }
                else
                {
                    followsX[i - 1].AddListener(followX);
                    followsY[i - 1].AddListener(followY);
                }
            }

            return(mRootView);
        }
示例#14
0
        public static void makeText(Context context, string msg, ToastLength length, int type)
        {
            Toast    toast = new Toast(context);
            View     layout;
            TextView text;

            switch (type)
            {
            case 1:
                layout           = LayoutInflater.From(context).Inflate(Resource.Layout.success_toast_layout, null, false);
                text             = (TextView)layout.FindViewById(Resource.Id.toastMessage);
                text.Text        = msg;
                successToastView = (SuccessToastView)layout.FindViewById(Resource.Id.successView);
                successToastView.startAnim();
                text.SetBackgroundResource(Resource.Drawable.success_toast);
                text.SetTextColor(Color.ParseColor("#FFFFFF"));
                toast.View = layout;
                break;

            case 2:
                layout    = LayoutInflater.From(context).Inflate(Resource.Layout.warning_toast_layout, null, false);
                text      = (TextView)layout.FindViewById(Resource.Id.toastMessage);
                text.Text = msg;

                warningToastView = (WarningToastView)layout.FindViewById(Resource.Id.warningView);
                SpringSystem springSystem = SpringSystem.create();

                Spring spring = springSystem.createSpring();
                spring.setCurrentValue(1.8);
                SpringConfig config = new SpringConfig(40, 5);
                spring.setSpringConfig(config);
                spring.addListener(new SimpleSpringListener()
                {
                    SpringUpdate = (_spring) =>
                    {
                        float value = (float)_spring.getCurrentValue();
                        float scale = (float)(0.9f - (value * 0.5f));

                        warningToastView.ScaleX = scale;
                        warningToastView.ScaleY = scale;
                    }
                });

                Thread t = new Thread(new Runnable(() =>
                {
                    try
                    {
                        Thread.Sleep(500);
                    }
                    catch (InterruptedException e)
                    {
                    }
                    spring.setEndValue(0.4f);
                }));
                t.Start();
                text.SetBackgroundResource(Resource.Drawable.warning_toast);
                text.SetTextColor(Color.ParseColor("#FFFFFF"));
                toast.View = layout;
                break;

            case 3:
                layout         = LayoutInflater.From(context).Inflate(Resource.Layout.error_toast_layout, null, false);
                text           = (TextView)layout.FindViewById(Resource.Id.toastMessage);
                text.Text      = msg;
                errorToastView = (ErrorToastView)layout.FindViewById(Resource.Id.errorView);
                errorToastView.startAnim();
                text.SetBackgroundResource(Resource.Drawable.error_toast);
                text.SetTextColor(Color.ParseColor("#FFFFFF"));
                toast.View = layout;
                break;

            case 4:
                layout        = LayoutInflater.From(context).Inflate(Resource.Layout.info_toast_layout, null, false);
                text          = (TextView)layout.FindViewById(Resource.Id.toastMessage);
                text.Text     = msg;
                infoToastView = (InfoToastView)layout.FindViewById(Resource.Id.infoView);
                infoToastView.startAnim();
                text.SetBackgroundResource(Resource.Drawable.info_toast);
                text.SetTextColor(Color.ParseColor("#FFFFFF"));
                toast.View = layout;
                break;

            case 5:
                layout           = LayoutInflater.From(context).Inflate(Resource.Layout.default_toast_layout, null, false);
                text             = (TextView)layout.FindViewById(Resource.Id.toastMessage);
                text.Text        = msg;
                defaultToastView = (DefaultToastView)layout.FindViewById(Resource.Id.defaultView);
                defaultToastView.startAnim();
                text.SetBackgroundResource(Resource.Drawable.default_toast);
                text.SetTextColor(Color.ParseColor("#FFFFFF"));
                toast.View = layout;
                break;

            case 6:
                layout             = LayoutInflater.From(context).Inflate(Resource.Layout.confusing_toast_layout, null, false);
                text               = (TextView)layout.FindViewById(Resource.Id.toastMessage);
                text.Text          = msg;
                confusingToastView = (ConfusingToastView)layout.FindViewById(Resource.Id.confusingView);
                confusingToastView.startAnim();
                text.SetBackgroundResource(Resource.Drawable.confusing_toast);
                text.SetTextColor(Color.ParseColor("#FFFFFF"));
                toast.View = layout;
                break;
            }
            toast.Duration = length;
            toast.Show();
        }
示例#15
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mRootView = (RelativeLayout)inflater.Inflate(Resource.Layout.fragment_bloom, container, false);

            mCircles = new View[6];

            float diameter = TypedValue.ApplyDimension(ComplexUnitType.Dip, DIAMETER, Resources.DisplayMetrics);

            TypedArray circles = Resources.ObtainTypedArray(Resource.Array.circles);

            // layout params
            RelativeLayout.LayoutParams paramss = new RelativeLayout.LayoutParams((int)diameter, (int)diameter);
            paramss.AddRule(LayoutRules.CenterInParent);

            // create the circle views
            int colorIndex = 0;

            for (int i = 0; i < mCircles.Length; i++)
            {
                mCircles[i] = new View(Activity);

                mCircles[i].LayoutParameters = paramss;

                mCircles[i].SetBackgroundDrawable(Resources.GetDrawable(circles.GetResourceId(colorIndex, -1)));

                colorIndex++;
                if (colorIndex >= circles.Length())
                {
                    colorIndex = 0;
                }

                mRootView.AddView(mCircles[i]);
            }

            circles.Recycle();

            /* Animations! */

            SpringSystem springSystem = SpringSystem.Create();

            // create spring
            Spring spring = springSystem.CreateSpring();

            // add listeners along arc
            double arc = 2 * Math.PI / mCircles.Length;

            for (int i = 0; i < mCircles.Length; i++)
            {
                View view = mCircles[i];

                // map spring to a line segment from the center to the edge of the ring
                spring.AddListener(new MapPerformer(view, ViewHelper.TranslationX, 0, 1, 0, (float)(RING_DIAMETER * Math.Cos(i * arc))));

                spring.AddListener(new MapPerformer(view, ViewHelper.TranslationY, 0, 1, 0, (float)(RING_DIAMETER * Math.Sin(i * arc))));

                spring.SetEndValue(CLOSED);
            }

            mRootView.SetOnTouchListener(new ToggleImitator(spring, CLOSED, OPEN));

            return(mRootView);
        }
示例#16
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mRootView = inflater.Inflate(Resource.Layout.fragment_appear, container, false);

            // grab the circles
            mCircles    = new View[6];
            mCircles[0] = mRootView.FindViewById(Resource.Id.circle0);
            mCircles[1] = mRootView.FindViewById(Resource.Id.circle1);
            mCircles[2] = mRootView.FindViewById(Resource.Id.circle2);
            mCircles[3] = mRootView.FindViewById(Resource.Id.circle3);
            mCircles[4] = mRootView.FindViewById(Resource.Id.circle4);
            mCircles[5] = mRootView.FindViewById(Resource.Id.circle5);

            springSystem = SpringSystem.Create();

            springs = new Spring[6];
            actors  = new Actor[6];

            // attach listeners
            for (int i = 0; i < mCircles.Length; i++)
            {
                springs[i] = springSystem.CreateSpring();

                springs[i].AddListener(new Performer(mCircles[i], ViewHelper.TranslationY));

                mCircles[i].Tag = springs[i];

                mCircles[i].SetOnClickListener(new CustomClickListener(this));

                actors[i] = new Actor.Builder(springSystem, mCircles[i])
                            .AddTranslateMotion(MotionProperty.X)
                            .AddTranslateMotion(MotionProperty.Y)
                            .Build();
            }


            mRootView.Touch += (sender, e) => {
                // grab location of root view so we can compensate for it
                int[] rootLocation = new int[2];
                ((View)sender).GetLocationInWindow(rootLocation);

                int[] location = new int[2];

                for (int i = 0; i < mCircles.Length; i++)
                {
                    if (springs[i].EndValue == 0)
                    {                             // hide
                        mCircles[i].GetLocationInWindow(location);

                        // if the end values are different, they will move at different speeds
                        springs[i].SetEndValue(mRootView.MeasuredHeight - location[1] + rootLocation[1] + 2 * new Random().Next() * mCircles[i].MeasuredHeight);
                    }
                    else
                    {
                        actors[i].SetTouchEnabled(true);

                        foreach (Actor.Motion motion in actors[i].GetMotions())
                        {
                            foreach (EventImitator imitator in motion.GetImitators())
                            {
                                if (imitator is MotionImitator)
                                {
                                    MotionImitator motionImitator = (MotionImitator)imitator;
                                    imitator.GetSpring().SetCurrentValue(0);

                                    // TODO: re-enable the y motion.
                                    //	if (imitator.getProperty() == MotionProperty.Y && !imitator.getSpring().isRegistered()) {
                                    //	     imitator.getSpring().register();
                                    //	}
                                }
                            }
                        }

                        springs[i].SetEndValue(0);                                 // appear
                    }
                }
            };

            return(mRootView);
        }
示例#17
0
        // @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        public SpringConfiguratorView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            SpringSystem springSystem = SpringSystem.create();

            springConfigRegistry = SpringConfigRegistry.getInstance();
            spinnerAdapter       = new SpinnerAdapter(context);

            Resources resources = this.Resources;

            mRevealPx = Util.dpToPx(40, resources);
            mStashPx  = Util.dpToPx(280, resources);

            mRevealerSpring = springSystem.createSpring();
            mRevealerSpring
            .setCurrentValue(1)
            .setEndValue(1)
            .addListener(new SimpleSpringListener()
            {
                SpringUpdate = (spring) =>
                {
                    float val          = (float)spring.getCurrentValue();
                    float minTranslate = mRevealPx;
                    float maxTranslate = mStashPx;
                    float range        = maxTranslate - minTranslate;
                    float yTranslate   = (val * range) + minTranslate;
                    this.TranslationY  = yTranslate;
                }
            });

            AddView(generateHierarchy(context));

            SeekbarListener seekbarListener = new SeekbarListener()
            {
                ProgressChanged = (seekBar, val, b) =>
                {
                    float tensionRange  = MAX_TENSION - MIN_TENSION;
                    float frictionRange = MAX_FRICTION - MIN_FRICTION;
                    if (seekBar == mTensionSeekBar)
                    {
                        float scaledTension = ((val) * tensionRange) / MAX_SEEKBAR_VAL + MIN_TENSION;
                        mSelectedSpringConfig.tension =
                            OrigamiValueConverter.tensionFromOrigamiValue(scaledTension);
                        string roundedTensionLabel = DECIMAL_FORMAT.Format(scaledTension);
                        mTensionLabel.Text = "T:" + roundedTensionLabel;
                    }

                    if (seekBar == mFrictionSeekBar)
                    {
                        float scaledFriction = ((val) * frictionRange) / MAX_SEEKBAR_VAL + MIN_FRICTION;
                        mSelectedSpringConfig.friction =
                            OrigamiValueConverter.frictionFromOrigamiValue(scaledFriction);
                        string roundedFrictionLabel = DECIMAL_FORMAT.Format(scaledFriction);
                        mFrictionLabel.Text = "F:" + roundedFrictionLabel;
                    }
                }
            };

            mTensionSeekBar.Max = MAX_SEEKBAR_VAL;
            mTensionSeekBar.SetOnSeekBarChangeListener(seekbarListener);

            mFrictionSeekBar.Max = MAX_SEEKBAR_VAL;
            mFrictionSeekBar.SetOnSeekBarChangeListener(seekbarListener);

            mSpringSelectorSpinner.Adapter = spinnerAdapter;
            mSpringSelectorSpinner.OnItemSelectedListener = new SpringSelectedListener()
            {
                ItemSelected = (ad, v, i, l) =>
                {
                    mSelectedSpringConfig = mSpringConfigs[i];
                    updateSeekBarsForSpringConfig(mSelectedSpringConfig);
                }
            };
            refreshSpringConfigurations();
            this.TranslationY = mStashPx;
        }
示例#18
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            double anchorThreshold         = 0.01;
            double pointDuplicateThreshold = 0.01;
            bool   isSheetMesh             = false;


            GH_Structure <IGH_Goo>   springTree          = new GH_Structure <IGH_Goo>();
            GH_Structure <GH_Vector> velTree             = new GH_Structure <GH_Vector>();
            GH_Structure <GH_Number> massTree            = new GH_Structure <GH_Number>();
            GH_Structure <GH_Number> lengthTree          = new GH_Structure <GH_Number>();
            GH_Structure <GH_Number> stiffnessTree       = new GH_Structure <GH_Number>();
            List <double>            sheetStiffeningList = new List <double>();
            GH_Structure <IGH_Goo>   anchorTree          = new GH_Structure <IGH_Goo>();
            List <bool> selfCollisionList = new List <bool>();
            List <int>  groupIndexList    = new List <int>();

            List <SpringSystem> springSystems = new List <SpringSystem>();

            DA.GetDataTree(0, out springTree);
            DA.GetDataTree(1, out velTree);
            DA.GetDataTree(2, out massTree);
            DA.GetDataTree(3, out lengthTree);
            DA.GetDataTree(4, out stiffnessTree);
            DA.GetDataList(5, sheetStiffeningList);
            DA.GetDataList(6, selfCollisionList);
            DA.GetDataTree(7, out anchorTree);
            DA.GetDataList(8, groupIndexList);

            #region simplify trees and if(branch.Count == 1) make sure everything sits in path {0}
            if (!springTree.IsEmpty)
            {
                springTree.Simplify(GH_SimplificationMode.CollapseAllOverlaps);
            }
            if (!velTree.IsEmpty)
            {
                velTree.Simplify(GH_SimplificationMode.CollapseAllOverlaps);
            }
            if (!massTree.IsEmpty)
            {
                massTree.Simplify(GH_SimplificationMode.CollapseAllOverlaps);
            }
            if (!lengthTree.IsEmpty)
            {
                lengthTree.Simplify(GH_SimplificationMode.CollapseAllOverlaps);
            }
            if (!stiffnessTree.IsEmpty)
            {
                stiffnessTree.Simplify(GH_SimplificationMode.CollapseAllOverlaps);
            }
            if (!anchorTree.IsEmpty)
            {
                anchorTree.Simplify(GH_SimplificationMode.CollapseAllOverlaps);
            }

            if (springTree.Branches.Count != groupIndexList.Count || springTree.Branches.Count != selfCollisionList.Count)
            {
                throw new Exception("Line tree doesn't fit either groupIndices count or selfCollision count!");
            }

            if (springTree.Branches.Count == 1)
            {
                GH_Structure <IGH_Goo> lT = new GH_Structure <IGH_Goo>();
                lT.AppendRange(springTree.Branches[0], new GH_Path(0));
                springTree = lT;
            }
            if (velTree.Branches.Count == 1)
            {
                GH_Structure <GH_Vector> vT = new GH_Structure <GH_Vector>();
                vT.AppendRange(velTree.Branches[0], new GH_Path(0));
                velTree = vT;
            }
            if (massTree.Branches.Count == 1)
            {
                GH_Structure <GH_Number> mT = new GH_Structure <GH_Number>();
                mT.AppendRange(massTree.Branches[0], new GH_Path(0));
                massTree = mT;
            }
            if (lengthTree.Branches.Count == 1)
            {
                GH_Structure <GH_Number> leT = new GH_Structure <GH_Number>();
                leT.AppendRange(lengthTree.Branches[0], new GH_Path(0));
                lengthTree = leT;
            }
            if (stiffnessTree.Branches.Count == 1)
            {
                GH_Structure <GH_Number> sT = new GH_Structure <GH_Number>();
                sT.AppendRange(stiffnessTree.Branches[0], new GH_Path(0));
                stiffnessTree = sT;
            }
            if (anchorTree.Branches.Count == 1)
            {
                GH_Structure <IGH_Goo> aT = new GH_Structure <IGH_Goo>();
                aT.AppendRange(anchorTree.Branches[0], new GH_Path(0));
                anchorTree = aT;
            }
            #endregion

            for (int branchIndex = 0; branchIndex < springTree.Branches.Count; branchIndex++)
            {
                List <float> positions         = new List <float>();
                List <float> velocities        = new List <float>();
                List <float> invMasses         = new List <float>();
                List <int>   springPairIndices = new List <int>();
                List <float> targetLengths     = new List <float>();
                List <float> stiffnesses       = new List <float>();
                List <int>   anchorIndices     = new List <int>();
                List <float> initialLengths    = new List <float>(); //just for info

                GH_Path path = new GH_Path(branchIndex);

                List <Line> lines = new List <Line>();
                Curve       c;
                Line        l;
                Mesh        mesh = new Mesh();
                foreach (IGH_Goo springObject in springTree.get_Branch(path))
                {
                    if (springObject.CastTo <Mesh>(out mesh))
                    {
                        break;
                    }
                    else if (springObject.CastTo <Curve>(out c))
                    {
                        if (c.IsPolyline())
                        {
                            Polyline pl;
                            c.TryGetPolyline(out pl);
                            for (int i = 0; i < pl.SegmentCount; i++)
                            {
                                lines.Add(pl.SegmentAt(i));
                            }
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Polyline in branch " + branchIndex + " was split into its segments!");
                        }
                        else
                        {
                            lines.Add(new Line(c.PointAtStart, c.PointAtEnd));
                        }
                    }
                    else if (springObject.CastTo <Line>(out l))
                    {
                        lines.Add(l);
                    }
                }

                #region isMesh
                if (mesh != null && mesh.IsValid)
                {
                    mesh.Vertices.CombineIdentical(true, true);
                    mesh.Weld(Math.PI);
                    mesh.UnifyNormals();

                    Rhino.Geometry.Collections.MeshTopologyVertexList mv = mesh.TopologyVertices;
                    Rhino.Geometry.Collections.MeshTopologyEdgeList   me = mesh.TopologyEdges;

                    //Add everything related to particles
                    for (int i = 0; i < mv.Count; i++)
                    {
                        //add position
                        positions.Add(mv[i].X);
                        positions.Add(mv[i].Y);
                        positions.Add(mv[i].Z);

                        //add velocity
                        Vector3d vel = new Vector3d(0.0, 0.0, 0.0);
                        if (velTree.PathExists(path))
                        {
                            if (velTree.get_Branch(path).Count > i)
                            {
                                vel = velTree.get_DataItem(path, i).Value;
                            }
                            else
                            {
                                vel = velTree.get_DataItem(path, 0).Value;
                            }
                        }
                        velocities.Add((float)vel.X);
                        velocities.Add((float)vel.Y);
                        velocities.Add((float)vel.Z);

                        //add inverse mass
                        float invMass = 1.0f;
                        if (massTree.PathExists(path))
                        {
                            if (massTree.get_Branch(path).Count > i)
                            {
                                invMass = 1.0f / (float)massTree.get_DataItem(path, i).Value;
                            }
                            else
                            {
                                invMass = 1.0f / (float)massTree.get_DataItem(path, 0).Value;
                            }
                        }
                        invMasses.Add(invMass);
                    }

                    //Add everything related to spring lines
                    for (int i = 0; i < me.Count; i++)
                    {
                        springPairIndices.Add(me.GetTopologyVertices(i).I);
                        springPairIndices.Add(me.GetTopologyVertices(i).J);

                        //add length
                        float length = (float)me.EdgeLine(i).Length;
                        initialLengths.Add(length);
                        if (lengthTree.PathExists(path))
                        {
                            float temp = 0.0f;
                            if (lengthTree.get_Branch(path).Count > i)
                            {
                                temp = (float)lengthTree.get_DataItem(path, i).Value;
                            }
                            else
                            {
                                temp = (float)lengthTree.get_DataItem(path, 0).Value;
                            }

                            if (temp < 0.0)
                            {
                                length *= -temp;
                            }
                            else
                            {
                                length = temp;
                            }
                        }
                        targetLengths.Add(length);

                        //add stiffness
                        float stiffness = 1.0f;
                        if (stiffnessTree.PathExists(path))
                        {
                            if (stiffnessTree.get_Branch(path).Count > i)
                            {
                                stiffness = (float)stiffnessTree.get_DataItem(path, i).Value;
                            }
                            else
                            {
                                stiffness = (float)stiffnessTree.get_DataItem(path, 0).Value;
                            }
                        }
                        stiffnesses.Add(stiffness);


                        List <Line> f = new List <Line>();
                        if (sheetStiffeningList.Count > branchIndex && sheetStiffeningList[branchIndex] > 0.0)
                        {
                            isSheetMesh = true;
                            int[] adjFaceInd = me.GetConnectedFaces(i);
                            if (adjFaceInd.Length == 2)
                            {
                                f.Add(me.EdgeLine(i));
                                MeshFace faceA = mesh.Faces[adjFaceInd[0]];
                                MeshFace faceB = mesh.Faces[adjFaceInd[1]];
                                if (faceA.IsTriangle && faceB.IsTriangle)
                                {
                                    List <int> allInds = new List <int> {
                                        faceA.A, faceA.B, faceA.C, faceB.A, faceB.B, faceB.C
                                    };
                                    int[] uniques = new int[6] {
                                        0, 0, 0, 0, 0, 0
                                    };
                                    for (int h = 0; h < 6; h++)
                                    {
                                        for (int g = 0; g < 6; g++)
                                        {
                                            if (allInds[h] == allInds[g])
                                            {
                                                uniques[h]++;
                                            }
                                        }
                                    }
                                    for (int h = 0; h < 6; h++)
                                    {
                                        if (uniques[h] == 1)
                                        {
                                            springPairIndices.Add(mv.TopologyVertexIndex(allInds[h]));
                                            stiffnesses.Add((float)(stiffness * sheetStiffeningList[branchIndex]));
                                        }
                                    }
                                    float le = (float)mv[springPairIndices[springPairIndices.Count - 2]].DistanceTo(mv[springPairIndices[springPairIndices.Count - 1]]);
                                    targetLengths.Add(le);
                                    initialLengths.Add(le);
                                    f.Add(new Line(mesh.Vertices[mv.TopologyVertexIndex(springPairIndices[springPairIndices.Count - 1])], mesh.Vertices[mv.TopologyVertexIndex(springPairIndices[springPairIndices.Count - 2])]));
                                }
                            }
                        }
                    }
                }
                #endregion

                #region isLines
                else if (lines.Count != 0)
                {
                    List <Line> cleanLineList    = new List <Line>();
                    double      ptDuplThrSquared = pointDuplicateThreshold * pointDuplicateThreshold;

                    #region clean up line list
                    List <Line> lHist = new List <Line>();
                    for (int j = 0; j < lines.Count; j++)
                    {
                        //Clean list from duplicate lines
                        Line    lCand             = lines[j];
                        Point3d ptCandA           = lCand.From;
                        Point3d ptCandB           = lCand.To;
                        bool    lineExistsAlready = false;
                        foreach (Line lh in lHist)
                        {
                            Line tempL = new Line(lCand.From, lCand.To);
                            if ((Util.SquareDistance(tempL.From, lh.From) < ptDuplThrSquared && Util.SquareDistance(tempL.To, lh.To) < ptDuplThrSquared) ||
                                (Util.SquareDistance(tempL.From, lh.To) < ptDuplThrSquared && Util.SquareDistance(tempL.To, lh.From) < ptDuplThrSquared))
                            {
                                lineExistsAlready = true;
                            }
                        }

                        //Clean list from too short lines
                        if (!(Util.SquareDistance(ptCandA, ptCandB) < ptDuplThrSquared || lineExistsAlready))
                        {
                            lHist.Add(lCand);
                            cleanLineList.Add(lCand);
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Spring nr. " + j + " in branch " + branchIndex + " is either invalid (too short) or appeared for the second time. It is ignored.");
                        }
                    }
                    #endregion


                    //get velocity and mass for this branch (no mass / velo per particle allowed)
                    List <float> branchDefaultVelocity = new List <float>()
                    {
                        0.0f, 0.0f, 0.0f
                    };
                    if (velTree.PathExists(path))
                    {
                        branchDefaultVelocity = new List <float> {
                            (float)velTree.get_DataItem(path, 0).Value.X, (float)velTree.get_DataItem(path, 0).Value.Y, (float)velTree.get_DataItem(path, 0).Value.Z
                        }
                    }
                    ;

                    float branchDefaultInvMass = 1.0f;
                    if (massTree.PathExists(path))
                    {
                        branchDefaultInvMass = 1.0f / (float)massTree.get_DataItem(path, 0).Value;
                    }

                    //find unique line start indices
                    List <int> springStartIndices = new List <int>();
                    int        advance            = 0;
                    for (int item = 0; item < cleanLineList.Count; item++)
                    {
                        Point3d ptCand          = cleanLineList[item].From;
                        int     alreadyExistsAs = -1;
                        for (int k = 0; k < positions.Count / 3; k++)
                        {
                            //simple squared distance
                            if (Util.SquareDistance(new Point3d(positions[k * 3], positions[k * 3 + 1], positions[k * 3 + 2]), ptCand) < ptDuplThrSquared)
                            {
                                alreadyExistsAs = k;
                                springStartIndices.Add(alreadyExistsAs);
                                break;
                            }
                        }
                        if (alreadyExistsAs == -1)
                        {
                            positions.Add((float)ptCand.X);
                            positions.Add((float)ptCand.Y);
                            positions.Add((float)ptCand.Z);

                            velocities.AddRange(branchDefaultVelocity);
                            invMasses.Add(branchDefaultInvMass);

                            springStartIndices.Add(advance);
                            advance++;
                        }
                    }

                    //find unique line end indices
                    List <int> springEndIndices = new List <int>();
                    for (int item = 0; item < cleanLineList.Count; item++)
                    {
                        Point3d ptCand          = cleanLineList[item].To;
                        int     alreadyExistsAs = -1;
                        for (int k = 0; k < positions.Count / 3; k++)
                        {
                            if (Util.SquareDistance(new Point3d(positions[3 * k], positions[3 * k + 1], positions[3 * k + 2]), ptCand) < ptDuplThrSquared)
                            {
                                alreadyExistsAs = k;
                                springEndIndices.Add(alreadyExistsAs);
                                break;
                            }
                        }
                        if (alreadyExistsAs == -1)
                        {
                            positions.Add((float)ptCand.X);
                            positions.Add((float)ptCand.Y);
                            positions.Add((float)ptCand.Z);

                            velocities.AddRange(branchDefaultVelocity);
                            invMasses.Add(branchDefaultInvMass);

                            springEndIndices.Add(advance);
                            advance++;
                        }
                    }

                    //weave spring start indices and spring end indices together
                    for (int w = 0; w < springStartIndices.Count; w++)
                    {
                        springPairIndices.Add(springStartIndices[w]);
                        springPairIndices.Add(springEndIndices[w]);
                    }

                    //Add everything spring line related...
                    for (int i = 0; i < cleanLineList.Count; i++)
                    {
                        //add length
                        float length = (float)cleanLineList[i].Length;
                        initialLengths.Add(length);
                        if (lengthTree.PathExists(path))
                        {
                            float temp = 0.0f;
                            if (lengthTree.get_Branch(path).Count > i)
                            {
                                temp = (float)lengthTree.get_DataItem(path, i).Value;
                            }
                            else
                            {
                                temp = (float)lengthTree.get_DataItem(path, 0).Value;
                            }

                            if (temp < 0.0)
                            {
                                length *= -temp;
                            }
                            else
                            {
                                length = temp;
                            }
                        }
                        targetLengths.Add(length);

                        //add stiffness
                        float stiffness = 1.0f;
                        if (stiffnessTree.PathExists(path))
                        {
                            if (stiffnessTree.get_Branch(path).Count > i)
                            {
                                stiffness = (float)stiffnessTree.get_DataItem(path, i).Value;
                            }
                            else
                            {
                                stiffness = (float)stiffnessTree.get_DataItem(path, 0).Value;
                            }
                        }
                        stiffnesses.Add(stiffness);
                    }
                }
                #endregion
                else
                {
                    throw new Exception("No valid spring input found in branch " + branchIndex);
                }


                //Add anchors
                if (anchorTree.PathExists(path))
                {
                    foreach (IGH_Goo anchorObj in anchorTree.get_Branch(path))
                    {
                        string  ass = "";
                        int     ai  = 0;
                        Point3d ap  = new Point3d(0.0, 0.0, 0.0);
                        if (anchorObj.CastTo <string>(out ass))
                        {
                            anchorIndices.Add(int.Parse(ass));
                        }
                        else if (anchorObj.CastTo <int>(out ai))
                        {
                            anchorIndices.Add(ai);
                        }
                        else if (anchorObj.CastTo <Point3d>(out ap))
                        {
                            for (int i = 0; i < positions.Count / 3; i++)
                            {
                                if ((anchorThreshold * anchorThreshold) > Math.Pow((positions[3 * i] - ap.X), 2) + Math.Pow((positions[3 * i + 1] - ap.Y), 2) + Math.Pow((positions[3 * i + 2] - ap.Z), 2))
                                {
                                    anchorIndices.Add(i);
                                }
                            }
                        }
                    }
                }

                SpringSystem ss = new SpringSystem(positions.ToArray(), velocities.ToArray(), invMasses.ToArray(), springPairIndices.ToArray(), targetLengths.ToArray(), stiffnesses.ToArray(), selfCollisionList[branchIndex], anchorIndices.ToArray(), groupIndexList[branchIndex]);
                ss.Mesh           = mesh;
                ss.IsSheetMesh    = isSheetMesh;
                ss.InitialLengths = initialLengths.ToArray();
                springSystems.Add(ss);
            }
            DA.SetDataList(0, springSystems);
        }
示例#19
0
        private SpringConfig SPRING_CONFIG;//= SpringConfig.FromOrigamiTensionAndFriction(40, 3);
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it

            EditText tension  = FindViewById <EditText>(Resource.Id.editTextTension);
            EditText friction = FindViewById <EditText>(Resource.Id.editTextFriction);


            //Spring Dynamics
            SpringSystem _springSystem = SpringSystem.Create();

            //Click
            Button button  = FindViewById <Button>(Resource.Id.MyButton);
            Spring _spring = _springSystem.CreateSpring();

            _spring.AddListener(new SimpleSpringListener(button, "click"));
            button.Click += delegate {
                SPRING_CONFIG = SpringConfig.FromOrigamiTensionAndFriction(100, 12);//Best Values: 100,12
                _spring.SetSpringConfig(SPRING_CONFIG);
                _spring.SetCurrentValue(1);
                _spring.SetEndValue(0.2);
                _spring.SetOvershootClampingEnabled(true);
            };


            //Tilt
            Button buttonTilt = FindViewById <Button>(Resource.Id.buttonTilt);
            Spring _spring2   = _springSystem.CreateSpring();

            _spring2.AddListener(new SimpleSpringListener(buttonTilt, "tilt"));
            buttonTilt.Click += delegate
            {
                SPRING_CONFIG = SpringConfig.FromOrigamiTensionAndFriction(100, 12);//Best Values: 100,12
                _spring2.SetSpringConfig(SPRING_CONFIG);
                _spring2.SetCurrentValue(0);
                _spring2.SetEndValue(0.2);
            };


            //BounceIn
            Button buttonBounceIn = FindViewById <Button>(Resource.Id.buttonBounceIn);
            Spring _spring3       = _springSystem.CreateSpring();

            _spring3.AddListener(new SimpleSpringListener(buttonBounceIn, "bouncein"));
            buttonBounceIn.Click += delegate
            {
                SPRING_CONFIG = SpringConfig.FromOrigamiTensionAndFriction(Convert.ToDouble(tension.Text), Convert.ToDouble(friction.Text));//Best Values: 10,2
                _spring3.SetSpringConfig(SPRING_CONFIG);
                _spring3.SetCurrentValue(1);
                _spring3.SetEndValue(0);
            };

            //BounceOut
            Button buttonBounceOut = FindViewById <Button>(Resource.Id.buttonBounceOut);
            Spring _spring4        = _springSystem.CreateSpring();

            _spring4.AddListener(new SimpleSpringListener(buttonBounceOut, "bounceout"));
            buttonBounceOut.Click += delegate
            {
                SPRING_CONFIG = SpringConfig.FromOrigamiTensionAndFriction(Convert.ToDouble(tension.Text), Convert.ToDouble(friction.Text));//Best Values: 10,2
                _spring4.SetSpringConfig(SPRING_CONFIG);
                _spring4.SetCurrentValue(0);
                _spring4.SetEndValue(1);
            };

            //BounceFadeIn
            Button buttonBounceFadeIn = FindViewById <Button>(Resource.Id.buttonBounceFadeIn);

            //Spring _spring5 = _springSystem.CreateSpring();
            //_spring5.AddListener(new SimpleSpringListener(buttonBounceFadeIn, "bouncefadein"));
            buttonBounceFadeIn.Click += delegate
            {
                //SPRING_CONFIG = SpringConfig.FromOrigamiTensionAndFriction(Convert.ToDouble(tension.Text), Convert.ToDouble(friction.Text));//Best Values: 10,2
                //_spring5.SetSpringConfig(SPRING_CONFIG);
                //_spring5.SetCurrentValue(1);
                //_spring5.SetEndValue(0);
                StartActivity(typeof(ChatBubbleActivity));
            };

            Button buttonReset = FindViewById <Button>(Resource.Id.buttonReset);

            //buttonReset.Visibility = ViewStates.Gone;
            buttonReset.Click += (s, e) =>
            {
                _spring4.SetEndValue(0);
                _spring4.SetCurrentValue(0);
                buttonBounceFadeIn.Background.SetAlpha(256);
            };


            //ImageView img = FindViewById<ImageView>(Resource.Id.imageView1);
            // //Spring _spring6 = _springSystem.CreateSpring();
            // // _spring6.AddListener(new SpringListenerViewActivity(this, img));

            //img.SetOnDragListener(new SpringListenerViewActivity(this));
        }