locked
Processing ManipulationModes::TranslateY isn't fluency like ManipulationModes::System.

    Question

  • I have a ScrollViewer, and it has an Image.Like this:

    <Grid x:Name="RootGrid">
        <ScrollViewer x:Name="scrollViewer" ZoomMode="Enabled" Background="Gray" VerticalScrollMode="Enabled" IsVerticalRailEnabled="True" Margin="192,0,0,0" >
            <Image x:Name="Image_1" HorizontalAlignment="Center" VerticalAlignment="Top"
               Source="{Binding Content}"
                Width="{Binding ContentWidth}"
                Height="{Binding ContentHeight}" />
        </ScrollViewer>
        <Button Content="Button" HorizontalAlignment="Left" Margin="10,366,0,0" VerticalAlignment="Top" Height="62" Width="110" Click="Button_Click_1"/>
    </Grid>

    // In MainPage.xaml.cpp
    Image_1->ManipulationMode = ManipulationModes::Scale | ManipulationModes::TranslateY | ManipulationModes::TranslateInertia | ManipulationModes::TranslateRailsY;
    m_transformGroup = ref new TransformGroup();
    m_previousTransform = ref new MatrixTransform();
    m_previousTransform->Matrix = Windows::UI::Xaml::Media::Matrix::Identity;
    m_compositeTransform = ref new CompositeTransform();
    
    m_transformGroup->Children->Append(m_previousTransform);
    m_transformGroup->Children->Append(m_compositeTransform);
    Image_1>RenderTransform = m_transformGroup;

    But I want to process ManipulationDelta myself. So I implement it according to
    SDK Sample(http://code.msdn.microsoft.com/windowsapps/Input-3dff271b#content).

    As a result I dit it. But it's not fluency when comparing to Manipulation::System.

    And Next is My processing code:

    void MainPage::OnImage_ManipulationDelta(Platform::Object^ sender, Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs^ e) { //LogPrint(TEXT("OnImage_ManipulationDelta\n")); m_previousTransform->Matrix = m_transformGroup->Value; Point center = m_previousTransform->TransformPoint(Point(e->Position.X, e->Position.Y)); //m_compositeTransform->CenterX = center.X; //m_compositeTransform->CenterY = center.Y; //m_compositeTransform->Rotation = e->Delta.Rotation; //m_compositeTransform->ScaleX = e->Delta.Scale; //m_compositeTransform->ScaleY = e->Delta.Scale; //m_compositeTransform->TranslateX = e->Delta.Translation.X; //m_compositeTransform->TranslateY = e->Delta.Translation.Y; m_yOffset -= e->Delta.Translation.Y;

    double fMaxHeight = scrollViewer->ScrollableHeight; if (m_yOffset < 0) { m_yOffset = 0; } else if (m_yOffset > fMaxHeight) { m_yOffset = fMaxHeight; } scrollViewer->ScrollToVerticalOffset(m_yOffset); //LogPrint(TEXT("Center.y: %.0f, Delta.y: %.0f, Trans.y: %.0f\n"), center.Y, e->Delta.Translation.Y, m_compositeTransform->TranslateY); e->Handled = true; }

    Who knows the differnce between myself processing ManipulationModes::TranslateY with system ManipulationModes::System.


    • Changed type Jumping fish Wednesday, October 24, 2012 12:41 AM Want to change
    • Edited by Jumping fish Thursday, October 25, 2012 12:40 AM Missing a word
    Tuesday, October 23, 2012 10:24 AM

All replies

  • I'm not sure what you mean. Can you please explain the difference between the results you want and the results you get more clearly?

    --Rob

    Thursday, October 25, 2012 12:22 AM
    Owner
  • We know that if an image-control's ManipulationModes::System is System. Then system will process rolling triggered by Touch.
    But I want to process rolling by myself. So I change image-control's ManipulationModes to ManipulationModes::TranslateY.
    It works, but it has some latency when rolling by Touch.

    Besides, I want to know the principle of how ManipulationModes::System works when processing rolling.

     

    Thursday, October 25, 2012 12:52 AM
  • Rob, Are you here?

    Tuesday, October 30, 2012 12:54 AM
  • Sorry. I took the weekend off and am now at //build/

    You cannot mimic the direct manipulation engine which handles the default scrolling. That is a lower level engine which will run asynchronously from your event handling. By passing your manipulations off to ScrollViewer.ScrollToVerticalOffset you are much less direct. You may be able to get better results by changing your heuristics a bit and building in some artificial inertia.

    --Rob

    Tuesday, October 30, 2012 6:06 AM
    Owner
  • By passing your manipulations off to ScrollViewer.ScrollToVerticalOffset you are much less direct.

    What I use next code:

    scrollViewer->ScrollToVerticalOffset(m_yOffset);
    

    instead of

    m_compositeTransform->TranslateX = e->Delta.Translation.X;
    m_compositeTransform->TranslateY = e->Delta.Translation.Y;
    

    Because I want to show the ScrollBar in the right of ScrollViewer.

    OK, With you wors "You may be able to get better results by changing your heuristics a bit and building in some artificial inertia.", I will try it again.

     

    Tuesday, October 30, 2012 6:42 AM