I am using a scrollviewer having stackpanel with 10 low quality images .When flick once the image moves to the next and load the high resolution image of the viewed image in that view. The problem is when flick 6 times continuously,scroll moves 6 times and the method for add high resolution occurs 6 times and load the image in view. I need an idea to wait for the completed flick for some seconds and execute the high resolution add image method once. Is there any way to do that?
-
How are you defining "last flick"?– Rowland ShawCommented Jul 5, 2012 at 12:03
-
if (e.HorizontalChange < 0) { var helper = DoubleAnimationHelper.Get(scroll, ScrollViewer.HorizontalOffsetProperty); helper.CurrentValue = scroll.HorizontalOffset; helper.TargetValue = y + 480; helper.Duration = TimeSpan.FromMilliseconds(250); scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; helper.Animate(); x = helper.TargetValue; AddhighresImage() }– SENTHIL KUMARCommented Jul 5, 2012 at 12:36
Add a comment
|
1 Answer
You can delay the loading of the high resolution images using a timer.
The code might look something like this:
DispatcherTimer timer = new DispatcherTimer();
public MainPage()
{
InitializeComponent();
timer.Interval = TimeSpan.FromSeconds(1); //You can adjust the delay suitable to your needs
timer.Tick += new EventHandler(timer_Tick);
}
void handle_Flick(object sender, GestureEventArgs args)
{
//If timer is not running, start the timer
//and do everything else other than loading high-resolution image.
if(timer.IsEnabled != true)
{
//start the timer
timer.Start();
}
}
void timer_Tick(object sender, EventArgs e)
{
//Stop the timer
timer.Stop();
//Load the high resolution image
}