VintaSoft Imaging .NET SDK and Plug-ins Discussions

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

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Persist "FocusedIndex" in ThumbnailViewer



Persist "FocusedIndex" in ThumbnailViewer

Post by jchristian »

Hello,

I am using a thumbnailviewer and I've been trying to figure out how to keep the next selected thumbnail active after you remove a selected thumbnail.
For example I click to select a thumbnail (my highlight box is colored red), I then have a button event that removes the selected thumbnail from the viewer, but then I have to click again to select the next thumbnail to perform the delete again. Is there a way to keep that selection persistent so that I could keep clicking the delete button without having to click the next thumbnail?

Here is a snippet of C# code I am currently using:
			
			var images = tvRight.GetSelectedImages();
			if (images.Length == 0)
				return;

			for (var count = 0; count < images.Length; count++)
			{
				tvRight.Images.Remove(images[count]);
			}
			
			tvRight.Focus();
			tvRight.FocusedIndex = 0;
			
"tvRight" is the thumbnailviewer control.


Let me know if you need more information.


Thank You.

Jamie C.


Re: Persist "FocusedIndex" in ThumbnailViewer

Post by Alex »

Hello Jamie,

I think you need save the index of focused thumnail before thumbnail removal and restore index after the thumbnail removal:
         var images = tvRight.GetSelectedImages();
         if (images.Length == 0)
            return;

         int focusedIndex = tvRight.FocusedIndex;

         for (var count = 0; count < images.Length; count++)
         {
            tvRight.Images.Remove(images[count]);
         }
         
         tvRight.Focus();
         if (focusedIndex >= 0 && focusedIndex < tvRight.Images.Count)
             tvRight.FocusedIndex = focusedIndex;
         else
             tvRight.FocusedIndex = 0;
Best regards, Alexander


Re: Persist "FocusedIndex" in ThumbnailViewer

Post by jchristian »

Thanks for the reply Alex, unfortunately that didn't work, I did however find a different way of doing it.
         
         var images = tvRight.GetSelectedImages();
         if (images.Length == 0)
            return;

         for (var count = 0; count < images.Length; count++)
         {
            tvRight.Images.Remove(images[count]);
         }
         
         tvRight.Focus();
         
         // Adding this //
	tvRight.SelectedIndices.add(tvRight.FocusedIndex);
	
Manually adding the selected index based off of the focused index, made the selected thumbnail stay on the 0 indexed image.
Which works perfectly for what I need.

Thanks for your help Alex!!


Page 1 from 1: 1