Force FocusedIndexChanged when scroll

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Moderator: Alex

Post Reply
guillaume.corneau
Posts: 7
Joined: Wed May 20, 2020 8:11 pm

Force FocusedIndexChanged when scroll

Post 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
Alex
Site Admin
Posts: 2048
Joined: Thu Jul 10, 2008 2:21 pm

Re: Force FocusedIndexChanged when scroll

Post 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
guillaume.corneau
Posts: 7
Joined: Wed May 20, 2020 8:11 pm

Re: Force FocusedIndexChanged when scroll

Post 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
Alex
Site Admin
Posts: 2048
Joined: Thu Jul 10, 2008 2:21 pm

Re: Force FocusedIndexChanged when scroll

Post by Alex »

Hi,

I think your code is optimal.

Best regards, Alexander
Post Reply