private void posImage(Viewport3DControl image, int index) { double diffFactor = index - _current; double left = _xCenter + diffFactor * SpaceWidth - _touch_move_distance; double top = 1.0; double Zindex = -Math.Abs(diffFactor) * 100; image.SetValue(Canvas.ZIndexProperty, (int)Zindex); if (index == _target) { left += 30; image.AnimationRotateTo(1, 1, 1, 0); } else if (index > _target) { left += 55; image.AnimationRotateTo(0.9, 0.9, 1, -45); } else if (index < _target) { image.AnimationRotateTo(0.9, 0.9, 1, 45); } image.Opacity = 1 - Math.Abs(diffFactor) * OPACITY_DOWN_FACTOR; image.SetValue(Canvas.LeftProperty, left); image.SetValue(Canvas.TopProperty, top); }
private void posImage(Viewport3DControl image, int index) { // LayoutRoot.Children.Add(image); double diffFactor = index - _current; double left = _xCenter + diffFactor * SpaceWidth - _touch_move_distance; double top = 0.0; double Zindex = -Math.Abs(diffFactor) * 100; image.SetValue(Canvas.ZIndexProperty, (int)Zindex); double scalez = 1 - Math.Abs(diffFactor) * 0.07; // image.Width = ChildViewWidth; // image.Height = ChildViewHeight; if (index == _target) { double angle = (left - _xCenter) * 0.05; image.AnimationTransformTo(scalez, scalez, 1, angle); left += 30; } else if (index > _target) { image.AnimationTransformTo(scalez, scalez, 1, 8); left += 60; } else if (index < _target) { image.AnimationTransformTo(scalez, scalez, 1, -8); //-10 } image.Opacity = 1 - Math.Abs(diffFactor) * OPACITY_DOWN_FACTOR; image.SetValue(Canvas.LeftProperty, left); image.SetValue(Canvas.TopProperty, top); }
void image_MouseUp(object sender, MouseButtonEventArgs e) { if (Math.Abs(e.GetPosition(LayoutRoot).X - mouseHaseMove) < 3) { Viewport3DControl view = (Viewport3DControl)sender; if (OnTouchDownEvent == null) { return; } OnTouchDownEvent(view, view.Index); } }
public void AddImage(ImageSource bitmapImage) { Viewport3DControl image = new Viewport3DControl(); image.SetImageSource(ref bitmapImage); image.Index = _images.Count; image.Width = ChildViewWidth; image.Height = ChildViewHeight; image.MouseDown += new MouseButtonEventHandler(image_MouseDown); LayoutRoot.Children.Add(image); posImage(image, _images.Count); _images.Add(image); }
public void AddImages(string[] imagesUri) { for (int i = 0; i < imagesUri.Length; i++) { string url = imagesUri[i]; Viewport3DControl image = new Viewport3DControl(); image.SetImageSource(url); image.Index = i; image.Width = ChildViewWidth; image.Height = ChildViewHeight; image.MouseDown += new MouseButtonEventHandler(image_MouseDown); LayoutRoot.Children.Add(image); posImage(image, i); _images.Add(image); } }
void _timer_Tick(object sender, EventArgs e) { //还原位置 if (IsPressed == false && _touch_move_distance != 0) { //回弹 _touch_move_distance += (-_touch_move_distance) * SPRINESS; } for (int i = 0; i < _images.Count; i++) { Viewport3DControl image = _images[i]; posImage(image, i); } if (Math.Abs(_target - _current) < CRITICAL_POINT && IsPressed == false) { return; } _current += (_target - _current) * SPRINESS; }
void image_MouseDown(object sender, MouseButtonEventArgs e) { Viewport3DControl view = (Viewport3DControl)sender; OnTouchDownEvent(view, view.Index); }