This is not one question, but two separate questions.
First of all, pointing device software is designed the way that an application does not make any difference between a touchpad and mouse. Touchpads works the same way, by the software usually have a special feature: you can simulate holding a left mouse button by double click, when on the second click the user should keep a finger in contact, not lift it. In this case, the driver does not dispatch it to the windows system as the second click and simulated the button help down instead. The same functionality is developed for Windows and Linux, and probably other systems. (I don't touch additional multi-touch or drawing tablet features, which is a separate topic.) From the standpoint of a Windows sub-system and applications, there is only button press and the button is help down.
So, from this point, we can forget the difference between a mouse and a touchpad.
Now, dragging of a WPF window without the non-client are is a completely different question unrelated to the above. The short answer is: you should handle your usual client-area mouse events. This is a really easy problem, so, I think you should try to solve it and ask further questions only if you face problems and get stuck.
[EDIT]
On second though, I decided to give you the dragging code: I interested to see if I can write it from the first attempt all from my head using one a little bit unusual feature, the effect of
closure:
static void MakeDragging(Window window) {
bool isDown = false;
Point position = default(Point);
window.MouseDown += (sender, eventArgs) => {
if (eventArgs.LeftButton != MouseButtonState.Pressed) return;
isDown = true;
position = window.PointToScreen(eventArgs.GetPosition(window));
};
window.MouseUp += (sender, eventArgs) => {
if (eventArgs.LeftButton != MouseButtonState.Released) return;
isDown = false;
};
window.MouseMove += (sender, eventArgs) => {
if (!isDown) return;
Point newPosition = window.PointToScreen(eventArgs.GetPosition(window));
window.Left += newPosition.X - position.X;
window.Top += newPosition.Y - position.Y;
position = newPosition;
};
}
Than I tested it, it worked. The closure effect works on the variables
isDown
and
position
. In this approach, local variables behave like static, because they are used in anonymous methods (event handlers). It completely isolate this code from the any properties of any types. Note that it has nothing to do with
static modifier on the method itself, which is done just because no instance is used, for convenience of showing the code sample. Please see:
http://en.wikipedia.org/wiki/Closure_%28computer_science%29[
^].
Note that I use screen coordinates. Not using them would create one difficulty: shifting the window position would itself invoke the
MouseMove
event causing unwanted recursion.
Good luck,
—SA