Image/Photo gallery like built-in WP7

后端 未结 2 1184
猫巷女王i
猫巷女王i 2021-01-06 14:27

I\'m looking for a photo gallery for Windows Phone 7. Something that looks and works the same as the built-in photo viewer (slide photo\'s using a flick action, resize using

2条回答
  •  臣服心动
    2021-01-06 15:08

    Actually I've implemented exactly what you are saying in one of my apps,

    You need to use Silverlight Control TOolkit's gesture listener to capture Drag and Pinch from touch.

    define a CompositeTransformation for your image and set it's scale (on pinch) and Offset (in drag).

    Obviously when the image is not zoom, drag can trigger going to next image.

    To make it feel smoother, you may want to define a storyboard on your page resources to use (instead of just settings Offset)

    I hope it can help/


    Drag handlers pseudo code for slider effect:

    
        
            
                
            
        
    
    
        private void GestureListener_DragCompleted(object sender, DragCompletedGestureEventArgs e)
        {
            if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
            {
                var abs = Math.Abs(PANEL_DRAG_HORIZONTAL);
                if (abs > 75)
                {
                    if (PANEL_DRAG_HORIZONTAL > 0) // MovePrevious;
                    else //MoveNext();
    
                    e.Handled = true;
                }
            }
        }
    
    
        double PANEL_DRAG_HORIZONTAL = 0;
        private void GestureListener_DragDelta(object sender, DragDeltaGestureEventArgs e)
        {
                if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
                {
                    PANEL_DRAG_HORIZONTAL += e.HorizontalChange;
    
                    var baseLeft = -imgImage.Width / 2;
                    if (PANEL_DRAG_HORIZONTAL > 75) imgImageTranslate.OffsetX = baseLeft + PANEL_DRAG_HORIZONTAL;
                    else if (PANEL_DRAG_HORIZONTAL < -75) imgImageTranslate.OffsetX = baseLeft + PANEL_DRAG_HORIZONTAL;
                    else imgImageTranslate.OffsetX = baseLeft;
                }
            }
        }
    
        private void GestureListener_DragStarted(object sender, DragStartedGestureEventArgs e)
        {
            PANEL_DRAG_HORIZONTAL = 0;
        }
    

提交回复
热议问题