コード例 #1
0
        private void SetupPage()
        {
            if (_visiblePageIndex != SelectedIndex && ItemsSource != null)
            {
                _currentView = (MycoView)ItemTemplate.CreateContent();
                _currentView.BindingContext = ItemsSource[SelectedIndex];
                _currentView.Parent         = this;
                _currentView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height));
                _currentView.TranslationX = 0;

                if (_nextView != null)
                {
                    _nextView.Parent = null;
                    _nextView        = null;
                }

                _visiblePageIndex = SelectedIndex;

                Invalidate();
            }
            else if (ItemsSource == null)
            {
                _currentView = null;
                _nextView    = null;

                Invalidate();
            }
        }
コード例 #2
0
        public static Task <bool> FadeTo(this MycoView view, double opacity, uint length = 250, Easing easing = null)
        {
            if (view == null)
            {
                throw new ArgumentNullException("mycoview");
            }
            if (easing == null)
            {
                easing = Easing.Linear;
            }

            var             tcs      = new TaskCompletionSource <bool>();
            var             weakView = new WeakReference <MycoView>(view);
            Action <double> fade     = f =>
            {
                MycoView v;
                if (weakView.TryGetTarget(out v))
                {
                    v.Opacity = f;
                }
            };

            new Animation(fade, view.Opacity, opacity, easing).Commit(view, "FadeTo", 16, length, finished: (f, a) => tcs.SetResult(a));

            return(tcs.Task);
        }
コード例 #3
0
 protected virtual void OnTouchUp(MycoView view, double x, double y, bool canceled)
 {
     if (TouchUp != null)
     {
         TouchUp(view, new TouchUpEventArgs(x, y, canceled));
     }
 }
コード例 #4
0
 void IMycoPanGestureRecognizerController.SendPanCompleted(MycoView view)
 {
     if (PanCompleted != null)
     {
         PanCompleted(this, new EventArgs());
     }
 }
コード例 #5
0
        public static Task <bool> TranslateTo(this MycoView view, double x, double y, uint length = 250, Easing easing = null)
        {
            if (view == null)
            {
                throw new ArgumentNullException("mycoview");
            }
            easing = easing ?? Easing.Linear;

            var             tcs        = new TaskCompletionSource <bool>();
            var             weakView   = new WeakReference <MycoView>(view);
            Action <double> translateX = f =>
            {
                MycoView v;
                if (weakView.TryGetTarget(out v))
                {
                    v.TranslationX = f;
                }
            };
            Action <double> translateY = f =>
            {
                MycoView v;
                if (weakView.TryGetTarget(out v))
                {
                    v.TranslationY = f;
                }
            };

            new Animation {
                { 0, 1, new Animation(translateX, view.TranslationX, x) }, { 0, 1, new Animation(translateY, view.TranslationY, y) }
            }.Commit(view, "TranslateTo", 16, length, easing,
                     (f, a) => tcs.SetResult(a));

            return(tcs.Task);
        }
コード例 #6
0
 void IMycoPanGestureRecognizerController.SendPanUpdatedWithUpdate(MycoView view, double updateX, double updateY)
 {
     if (PanUpdated != null)
     {
         PanUpdated(this, new PanEventArgs(updateX, updateY));
     }
 }
コード例 #7
0
 protected virtual void OnTouchDown(MycoView view, double x, double y)
 {
     if (TouchDown != null)
     {
         TouchDown(view, new TouchDownEventArgs(x, y));
     }
 }
コード例 #8
0
        void IMycoPanGestureRecognizerController.SendPanStarted(MycoView view)
        {
            _lastOffsetX = 0;
            _lastOffsetY = 0;

            if (PanStarted != null)
            {
                PanStarted(this, new EventArgs());
            }
        }
コード例 #9
0
        void IMycoPanGestureRecognizerController.SendPanUpdatedWithOffset(MycoView view, double offsetX, double offsetY)
        {
            if (PanUpdated != null)
            {
                PanUpdated(this, new PanEventArgs(offsetX - _lastOffsetX, offsetY - _lastOffsetY));
            }

            _lastOffsetX = offsetX;
            _lastOffsetY = offsetY;
        }
コード例 #10
0
        void IMycoSwipeGestureRecognizerController.SendSwipeRight(MycoView view)
        {
            if (SwipeRightCommand != null)
            {
                SwipeRightCommand.Execute(SwipeRightCommandParameter);
            }

            if (SwipeRight != null)
            {
                SwipeRight(view, new EventArgs());
            }
        }
コード例 #11
0
        public async Task AnimateToPage(int index)
        {
            // really animate to new page ?
            if (_visiblePageIndex != index && _nextView == null && ItemsSource != null)
            {
                // get animation direction
                var translation = _visiblePageIndex < index ? Width : -Width;

                // indicate this is the one that is visible
                _visiblePageIndex = index;

                // save selected
                SelectedIndex = index;

                // get view to move to
                _nextView = (MycoView)ItemTemplate.CreateContent();
                _nextView.BindingContext = ItemsSource[index];
                _nextView.Parent         = this;
                _nextView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height));

                // setup the next view offscreen
                _nextView.TranslationX = translation;

                // view to set to once complete
                var targetView = _nextView;
                var oldView    = _currentView;

                // animate new in, ol dout
                await Task.WhenAll(_nextView.TranslateTo(0, 0, 250, Easing.CubicInOut), _currentView.TranslateTo(-translation, 0, 250, Easing.CubicInOut));

                // setup the current view
                _currentView = targetView;

                // null out old view
                oldView.Parent = null;
                oldView        = null;

                // allow next animation
                _nextView = null;
            }
        }
コード例 #12
0
ファイル: MycoPagingLayout.cs プロジェクト: roceh/MycoLayout
        private void SetupPage()
        {
            if (_visiblePageIndex != SelectedIndex && SelectedIndex >= 0 && SelectedIndex < Children.Count)
            {
                // only show the current view
                _currentView           = Children[SelectedIndex];
                _currentView.IsVisible = true;
                _currentView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height));
                _currentView.TranslationX = 0;

                if (_nextView != null)
                {
                    _nextView.IsVisible = false;
                    _nextView           = null;
                }

                _visiblePageIndex = SelectedIndex;

                Invalidate();
            }
        }
コード例 #13
0
        protected override void OnTouchUp(MycoView view, double x, double y, bool canceled)
        {
            base.OnTouchUp(view, x, y, canceled);

            var point = new Point(x, y);

            var totalTapTime = (DateTime.Now - _downTime).TotalMilliseconds;

            if (totalTapTime > TapMinimum && totalTapTime < TapMaximum && point.Distance(_downTapLocation) < TapMaxMovement && !canceled)
            {
                if (Command != null)
                {
                    Command.Execute(CommandParameter);
                }

                if (Tapped != null)
                {
                    Tapped(view, new TapEventArgs(x, y));
                }
            }
        }
コード例 #14
0
ファイル: MycoPagingLayout.cs プロジェクト: roceh/MycoLayout
        public async Task AnimateToPage(int index)
        {
            // really animate to new page ?
            if (index >= 0 && index < Children.Count && _visiblePageIndex != index && _nextView == null)
            {
                // get animation direction
                var translation = _visiblePageIndex < index ? Width : -Width;

                // indicate this is the one that is visible
                _visiblePageIndex = index;

                // save selected
                SelectedIndex = index;

                // get view to move to
                _nextView           = Children[index];
                _nextView.IsVisible = true;
                _nextView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height));

                // setup the next view offscreen
                _nextView.TranslationX = translation;

                // view to set to once complete
                var targetView = _nextView;
                var oldView    = _currentView;

                // animate new in, ol dout
                await Task.WhenAll(_nextView.TranslateTo(0, 0, 250, Easing.CubicInOut), _currentView.TranslateTo(-translation, 0, 250, Easing.CubicInOut));

                // setup the current view
                _currentView = targetView;

                // null out old view
                oldView.IsVisible = false;

                // allow next animation
                _nextView = null;
            }
        }
コード例 #15
0
 void IMycoGestureRecognizerController.SendTouchDown(MycoView view, double x, double y)
 {
     OnTouchDown(view, x, y);
 }
コード例 #16
0
 void IMycoGestureRecognizerController.SendTouchUp(MycoView view, double x, double y, bool canceled)
 {
     OnTouchUp(view, x, y, canceled);
 }
コード例 #17
0
 protected override void OnTouchDown(MycoView view, double x, double y)
 {
     base.OnTouchDown(view, x, y);
     _downTime        = DateTime.Now;
     _downTapLocation = new Point(x, y);
 }