Merge pull request #829 from matthid/pullVisualStudioDebuggerProblem

Fix for really annoying debugger exception + fixed whitespace
This commit is contained in:
Hylke Bons 2012-07-02 13:31:31 -07:00
commit 2a58657d6e

View file

@ -223,10 +223,15 @@ namespace SparkleShare {
private Rect GetContextMenuRect (ContextMenu menu) private Rect GetContextMenuRect (ContextMenu menu)
{ {
Point start_point = menu.PointToScreen (new Point (0, 0)); var source = PresentationSource.FromVisual (menu);
Point end_point = menu.PointToScreen (new Point (menu.ActualWidth, menu.ActualHeight)); if (source != null) {
Point start_point = menu.PointToScreen(new Point(0, 0));
Point end_point = menu.PointToScreen(new Point(menu.ActualWidth, menu.ActualHeight));
return new Rect (start_point, end_point); return new Rect(start_point, end_point);
}
return new Rect();
} }
@ -244,15 +249,22 @@ namespace SparkleShare {
int left_button_down = 0x201; int left_button_down = 0x201;
int right_button_down = 0x204; int right_button_down = 0x204;
if (button == left_button_down || button == right_button_down) { int ret;
Rect context_menu_rect = GetContextMenuRect (ContextMenu); try {
Point hit_point = GetHitPoint (data_pointer); if (button == left_button_down || button == right_button_down)
{
Rect context_menu_rect = GetContextMenuRect(ContextMenu);
Point hit_point = GetHitPoint(data_pointer);
if (!context_menu_rect.Contains (hit_point)) if (!context_menu_rect.Contains(hit_point))
ContextMenu.IsOpen = false; ContextMenu.IsOpen = false;
} }
}
finally {
ret = CallNextHookEx(this.mouse_hook_handle, code, button, data_pointer);
}
return CallNextHookEx (this.mouse_hook_handle, code, button, data_pointer); return ret;
} }