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); }
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); }
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; }
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; } }
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(); } } }
private void DragEventHandler(object sender, DragEventArgs e) { base.ResetState(false); this.state = StreamPagePanel.AnimationState.Drag; this.setCurrentPos(e.LocalPosition.X - this.touchDownLocalPos); }
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; }
private void DragEventHandler(object sender, DragEventArgs e) { base.ResetState (false); this.state = StreamPagePanel.AnimationState.Drag; this.setCurrentPos (e.LocalPosition.X - this.touchDownLocalPos); }
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 (); } } }
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; } }