Page 1 of 1
Force FocusedIndexChanged when scroll
Posted: Wed May 20, 2020 8:20 pm
by guillaume.corneau
Hi,
I want to know if is possible to auto refresh the current focused index when we scroll the ImageViewer by scroll or mouse wheel
Now the focused index will be changed when I click on the visible page
I tried on then PDF Editor Demo shipped with Vintasoft installation
Thank you
Re: Force FocusedIndexChanged when scroll
Posted: Thu May 21, 2020 8:22 am
by Alex
Hi,
If you need to change the focused image in image viewer
asynchronously, you need to use the
ImageViewer.FocusedIndex property.
If you need to change the focused image in image viewer
synchronously, you need to use the
ImageViewer.SetFocusedIndexSync method.
Please try to change the focused image in image viewer and let me know if you will have any question or problem.
Best regards, Alexander
Re: Force FocusedIndexChanged when scroll
Posted: Thu May 21, 2020 3:29 pm
by guillaume.corneau
Hi,
I added this code to ImageViewer Scroll and MouseWheel event and it works well
Code: Select all
private void UpdateFocusIndexWhenScroll()
{
var images = imageViewer1.GetVisibleImages();
if (images.Length > 0 && imageViewer1.FocusedIndex != images[0].SourceInfo.PageIndex)
{
imageViewer1.DisableAutoScrollToFocusedImage();
imageViewer1.FocusedIndex = images[0].SourceInfo.PageIndex;
imageViewer1.EnableAutoScrollToFocusedImage();
}
}
private void imageViewer1_Scroll(object sender, ScrollEventArgs e)
{
UpdateFocusIndexWhenScroll();
}
private void ImageViewer1_MouseWheel(object sender, MouseEventArgs e)
{
UpdateFocusIndexWhenScroll();
}
If you have a better solution let me know
Thanks
Re: Force FocusedIndexChanged when scroll
Posted: Thu May 21, 2020 4:04 pm
by Alex
Hi,
I think your code is optimal.
Best regards, Alexander