MouseDown, MouseUp, Timing and Threading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeremy Robertson

    MouseDown, MouseUp, Timing and Threading

    I'm working on an application that manages large image files (mulit-page
    ..Tiff's to be exact some 1000+ pages).

    I've written an user control that displays a number of the images as
    thumbnails in a scrollable window. The user can select and modify Images
    from my thumbnail control. I need to let the user re-arrange the images if
    they are out of order. I need the user to be able to click on a thumbnail or
    multiple and DRAG them to the correct position, BUT I don't just want
    erroneous clicking and barley moving the mouse to do the re-order. On Event
    MouseDown I capture the selected image(s) in a array, then pop off a new
    thread that waits 1 second before it sets a Bool that allows re-ordering,
    and displays a blinky thing to show where the re-order is going to go. On
    Event MouseMove I just change the position of the blinkything (if needed) to
    reflect the position of where it's going to go. On Event MouseUp if the
    timer has gone long enough (one second) and it's in a new position then I
    re-order...

    Here's my problem. When a user MousesDown, in another part of the app, a
    full size-image gets loaded and displayed(only one page); now if I'm loading
    a big 300dpi grayscale image, it takes over a second. So on these large
    images, when a user MouseDowns, moves the mouse, and then MouseUps in under
    the time it takes the large image to load, the MouseUp event doesn't happen
    until it loads (which is over a second) so it assumes the user meant to move
    no matter what, which really messes things up.

    I'm writing this control to be used by others, and telling them to work
    around this is unacceptable. Is there a way to have the MouseUp event
    handled in separate Thread so that the large processing time doesn't break
    my control? or some other ingenious way to do this? :) I understand that the
    built-in Drag-Drop events also happen in the same thread so I'm pretty sure
    that wouldn't help me, and I don't need to worry about stuff being dragged
    into/out of my control.


  • Fergus Cooney

    #2
    Re: MouseDown, MouseUp, Timing and Threading

    Hi Jeremy,

    I'm not sure I fully understand what you are saying - the 'in another part
    of the app, a
    full size-image gets loaded' part - but I wonder whether it might be easier to
    do the image loading in a different thread rather than trying to MouseUp in a
    different thread?

    Another curiousity - is this large-image loadingh part of your drag-n-drop
    rearranging? If not, perhaps you could simply not allow a drag to be initiated
    until the load has finshed?

    Regards,
    Fergus


    Comment

    Working...