示例#1
0
 public override void OnSpringUpdate(Spring spring)
 {
     mProperty.Set(mTarget,
                   (float)SpringUtil.MapValueFromRangeToRange(spring.CurrentValue,
                                                              initialStart, initialEnd, start, end)
                   );
 }
 static TranslatorFactory()
 {
     try
     {
         TranslatorFactory.translator = (ITranslator)SpringUtil.getContext().GetObject("Translator");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
        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;
                    }
                }
            }
        }
示例#4
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);
        }
示例#5
0
 static PropUtilFactory()
 {
     PropUtilFactory.propUtil = (PropertyUtilInterface)SpringUtil.getContext().GetObject("PropUtil");
 }