I am trying to implement a control that shuffles among a set of images, displaying the current on a Picture edit.
The images are always of the same size. I want the size mode to be Clip.
I want to have the ability to zoom in and out and when I move to the next or the previous image, I want to maintain the zoomed location (zoom percent is maintained).
I shuffle among the images using PageDown and Up. So I use the following code.
C#private void m_ctrlDevXPictureEdit_Properties_KeyDown( object sender, KeyEventArgs e )
{
if( e.KeyData == Keys.PageDown && CurrentImageIndex < m_images.Count - 1 )
{
CurrentImageIndex++;
}
else if( e.KeyData == Keys.PageUp && CurrentImageIndex != 0 )
{
CurrentImageIndex--;
}
else
{
return;
}
var vvalue = m_ctrlDevXPictureEdit.VScrollBar.Value;
var hvalue = m_ctrlDevXPictureEdit.HScrollBar.Value;
m_ctrlDevXPictureEdit.Image = m_images[ CurrentImageIndex ];
m_ctrlDevXPictureEdit.VScrollBar.Value = vvalue;
m_ctrlDevXPictureEdit.HScrollBar.Value = hvalue;
}
If I have visible Scroll bars the above code works but one can see a slight jerking of the scroll bars every time the image changes (probably
because of the double value changing). This can be annoying and I want to avoid it.
If I have invisible scroll bars, the code does not work. Every time the image changes, the scroll bars are reset to the centre of the frame.
Is there another way to achieve what I want to do?
Giorgos
Hello,
I cannot reproduce the issue you described (see the attachment). Nevertheless, I suggest you try wrapping your code with the PictureEdit.Properties.BeginUpdate and EndUpdate methods. If it doesn't help, please modify my sample so that it replicates the problem or send us yours.
We look forward to your reply.
Hello Andrew and thank you for your reply.
I have adapted the project you sent me in a way that reflects my problem.
Since I don't want to have scrollbars I have made then invisible. I have also enabled the per-mouse dragging.
Hi Giorgos,
I've discussed this behavior with our developers and we have come to the conclusion that it is not correct.
The cause of this issue is that we use different mechanisms for scrollbars when they are visible and when they are not. We will add a new property to the PictureEdit control. With this property, changing will work as expected.
While we are working on a hotfix, you can use the following approach as a workaround:
pictureEdit1.Properties.ShowScrollBars = true; pictureEdit1.VScrollBar.Value = vvalue; pictureEdit1.HScrollBar.Value = hvalue; pictureEdit1.Properties.ShowScrollBars = false;
Hello Antonio,
thank you for your reply. The workaround you suggested indeed works.
I was a bit fast do reply.
The workaround DOES work, but the behavior is not smooth. The scrollbars appear and disappear instantly but not so fast that the user does not see it.
Also, if I set the scrollbars to visible there is still this flickering I mentioned on the first post.
I would like to note that I am using images of size 3500x1400, so assume that it takes some time for the control to load the images and relocate the scroll bars.