Esempio n. 1
0
        public StreamPagePanel()
        {
            this.panelContainer          = new StreamContainerWidget();
            this.panelContainer.BaseClip = false;
            base.AddChildLast(this.panelContainer);
            this.sprtContainer          = new StreamContainerWidget();
            this.sprtContainer.BaseClip = false;
            base.AddChildLast(this.sprtContainer);
            this.panelList           = new List <Panel> ();
            this.sprtList            = new List <UISprite> ();
            this.pageCount           = 0;
            this.pageIndex           = -1;
            base.Clip                = true;
            base.HookChildTouchEvent = true;
            this.state               = StreamPagePanel.AnimationState.None;
            this.activeImage         = new ImageAsset(SystemImageAsset.PagePanelActive);
            this.normalImage         = new ImageAsset(SystemImageAsset.PagePanelNormal);
            DragGestureDetector dragGestureDetector = new DragGestureDetector();

            dragGestureDetector.DragDetected += new EventHandler <DragEventArgs> (this.DragEventHandler);
            base.AddGestureDetector(dragGestureDetector);
            FlickGestureDetector flickGestureDetector = new FlickGestureDetector();

            flickGestureDetector.Direction      = FlickDirection.Horizontal;
            flickGestureDetector.FlickDetected += new EventHandler <FlickEventArgs> (this.FlickEventHandler);
            base.AddGestureDetector(flickGestureDetector);
        }
Esempio n. 2
0
 public StreamPagePanel()
 {
     this.panelContainer = new StreamContainerWidget ();
     this.panelContainer.BaseClip = false;
     base.AddChildLast (this.panelContainer);
     this.sprtContainer = new StreamContainerWidget ();
     this.sprtContainer.BaseClip = false;
     base.AddChildLast (this.sprtContainer);
     this.panelList = new List<Panel> ();
     this.sprtList = new List<UISprite> ();
     this.pageCount = 0;
     this.pageIndex = -1;
     base.Clip = true;
     base.HookChildTouchEvent = true;
     this.state = StreamPagePanel.AnimationState.None;
     this.activeImage = new ImageAsset (SystemImageAsset.PagePanelActive);
     this.normalImage = new ImageAsset (SystemImageAsset.PagePanelNormal);
     DragGestureDetector dragGestureDetector = new DragGestureDetector ();
     dragGestureDetector.DragDetected += new EventHandler<DragEventArgs> (this.DragEventHandler);
     base.AddGestureDetector (dragGestureDetector);
     FlickGestureDetector flickGestureDetector = new FlickGestureDetector ();
     flickGestureDetector.Direction = FlickDirection.Horizontal;
     flickGestureDetector.FlickDetected += new EventHandler<FlickEventArgs> (this.FlickEventHandler);
     base.AddGestureDetector (flickGestureDetector);
 }
Esempio n. 3
0
        private void FlickEventHandler(object sender, FlickEventArgs e)
        {
            base.ResetState(false);
            this.state = StreamPagePanel.AnimationState.Flick;
            int num = -(int)(this.panelContainer.X / this.Width);

            if (e.Speed.X < 0f)
            {
                this.ScrollTo(num + 1, true);
            }
            else
            {
                this.ScrollTo(num, true);
            }
            this.animation = true;
        }
Esempio n. 4
0
        protected override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            if (primaryTouchEvent.Type == TouchEventType.Down)
            {
                this.animation         = false;
                this.startPos          = this.panelContainer.X;
                this.touchDownLocalPos = primaryTouchEvent.LocalPosition.X;
                this.state             = StreamPagePanel.AnimationState.None;
            }
            if (primaryTouchEvent.Type == TouchEventType.Up && this.state != StreamPagePanel.AnimationState.Flick)
            {
                this.ScrollTo(this.pageIndex, true);
            }
            if (this.state != StreamPagePanel.AnimationState.Drag && this.state != StreamPagePanel.AnimationState.Flick)
            {
                touchEvents.Forward = true;
            }
        }
Esempio n. 5
0
 protected override void OnUpdate(float elapsedTime)
 {
     base.OnUpdate(elapsedTime);
     if (this.animation)
     {
         this.animationElapsedTime += elapsedTime;
         this.panelContainer.X      = (this.animationStartPos - this.nextPos) * (float)Math.Exp((double)(-(double)this.animationElapsedTime * 0.011997601f)) + this.nextPos;
         int num = -(int)(this.panelContainer.X / this.Width);
         for (int i = 0; i < this.pageCount; i++)
         {
             this.panelList [i].Visible = (i == num || i == num + 1);
         }
         float num2 = this.nextPos - this.panelContainer.X;
         this.pageIndex = (int)(0.5f - this.panelContainer.X / this.Width);
         this.UpdateSprite();
         if (num2 < 1f && num2 > -1f)
         {
             this.panelContainer.X = this.nextPos;
             this.animation        = false;
             this.state            = StreamPagePanel.AnimationState.None;
             this.SetupPageVisible();
         }
     }
 }
Esempio n. 6
0
 private void DragEventHandler(object sender, DragEventArgs e)
 {
     base.ResetState(false);
     this.state = StreamPagePanel.AnimationState.Drag;
     this.setCurrentPos(e.LocalPosition.X - this.touchDownLocalPos);
 }
Esempio n. 7
0
 private void FlickEventHandler(object sender, FlickEventArgs e)
 {
     base.ResetState (false);
     this.state = StreamPagePanel.AnimationState.Flick;
     int num = -(int)(this.panelContainer.X / this.Width);
     if (e.Speed.X < 0f)
     {
         this.ScrollTo (num + 1, true);
     }
     else
     {
         this.ScrollTo (num, true);
     }
     this.animation = true;
 }
Esempio n. 8
0
 private void DragEventHandler(object sender, DragEventArgs e)
 {
     base.ResetState (false);
     this.state = StreamPagePanel.AnimationState.Drag;
     this.setCurrentPos (e.LocalPosition.X - this.touchDownLocalPos);
 }
Esempio n. 9
0
 protected override void OnUpdate(float elapsedTime)
 {
     base.OnUpdate (elapsedTime);
     if (this.animation)
     {
         this.animationElapsedTime += elapsedTime;
         this.panelContainer.X = (this.animationStartPos - this.nextPos) * (float)Math.Exp ((double)(-(double)this.animationElapsedTime * 0.011997601f)) + this.nextPos;
         int num = -(int)(this.panelContainer.X / this.Width);
         for (int i = 0; i < this.pageCount; i++)
         {
             this.panelList [i].Visible = (i == num || i == num + 1);
         }
         float num2 = this.nextPos - this.panelContainer.X;
         this.pageIndex = (int)(0.5f - this.panelContainer.X / this.Width);
         this.UpdateSprite ();
         if (num2 < 1f && num2 > -1f)
         {
             this.panelContainer.X = this.nextPos;
             this.animation = false;
             this.state = StreamPagePanel.AnimationState.None;
             this.SetupPageVisible ();
         }
     }
 }
Esempio n. 10
0
 protected override void OnTouchEvent(TouchEventCollection touchEvents)
 {
     base.OnTouchEvent (touchEvents);
     TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;
     if (primaryTouchEvent.Type == TouchEventType.Down)
     {
         this.animation = false;
         this.startPos = this.panelContainer.X;
         this.touchDownLocalPos = primaryTouchEvent.LocalPosition.X;
         this.state = StreamPagePanel.AnimationState.None;
     }
     if (primaryTouchEvent.Type == TouchEventType.Up && this.state != StreamPagePanel.AnimationState.Flick)
     {
         this.ScrollTo (this.pageIndex, true);
     }
     if (this.state != StreamPagePanel.AnimationState.Drag && this.state != StreamPagePanel.AnimationState.Flick)
     {
         touchEvents.Forward = true;
     }
 }