Cyotek.Windows.Forms.ImageBox icon indicating copy to clipboard operation
Cyotek.Windows.Forms.ImageBox copied to clipboard

Wrong selection area when maximizing

Open rioka opened this issue 6 years ago • 2 comments

I was playing around with your control, and I faced inconsistent behavior when a region of the image is selected, and the windows is then maximized. If the container window is maximized via a double click in the title bar, the selection area is messed up; everything is correct if the window is maximized using "Maximize" button.

I tried to replicate this behavior in the provided demo, and actually "General Demonstration" shows the same problem

Steps to reproduce

  • Run the demo
  • Click on General Demonstration
  • Set "Selection Mode" to "Rectangle"
  • Select a region in the image
    • look at the values in the lower right corner
  • Maximize the window using "Maximize" button
    • look at the values in the lower right corner: they are still correct
  • Restore the previous size, using the same button
    • look at the values in the lower right corner: they are still correct
  • Maximize the window, this time double-clicking in the title bar
    • look at the values in the lower right corner: they are now wrong
    • selected region is no longer shown in the lower pan

rioka avatar Jun 23 '19 14:06 rioka

Hello,

Thanks for the bug report and the detailed repro. I just tested it with the compiled version of the demo and your steps demonstrated the issue nicely.

I suspect it's likely that because you're double clicking to maximise the window via the title bar, the ImageBox control is intercepting a mouse up event when the window is resized and the control is suddenly underneath the cursor. I tried moving the window near to the top of the screen and then double clicking, so that the mouse never entered the region of the control and the selection remained unchanged. This seems to confirm my hunch, but I'll need to do some testing with the actual source to be sure. Should be straightforward enough to fix if that's the cause. I'll update this ticket once I've had a chance to dig in the source and got a fix prepared.

Thanks again for finding this bug!

Regards; Richard Moss

cyotek avatar Jun 24 '19 20:06 cyotek

I suspect it's likely that because you're double clicking to maximise the window via the title bar...

Yeah, I think so. Actually, I discover that because I was trying to build a simplified/updated version of your control (I wanted to add on option to force selection to have a given aspect ratio), and saw spurious MouseMove event, so I checked if that happened in the original control as well.

rioka avatar Jun 25 '19 07:06 rioka