Issue #3: quick region drawing now enabled by click dragging while holding the CTRL key.

This commit is contained in:
Lorenz Cuno Klopfenstein 2014-01-09 01:19:03 +01:00
parent 1c253bdcb1
commit 6256dba0bd
2 changed files with 38 additions and 1 deletions

View file

@ -29,6 +29,7 @@ namespace OnTopReplica {
_startupOptions = startupOptions;
FullscreenManager = new FullscreenFormManager(this);
_quickRegionDrawingHandler = new ThumbnailPanel.RegionDrawnHandler(HandleQuickRegionDrawn);
//WinForms init pass
InitializeComponent();
@ -163,6 +164,8 @@ namespace OnTopReplica {
}
}
private ThumbnailPanel.RegionDrawnHandler _quickRegionDrawingHandler;
protected override void WndProc(ref Message m) {
if (_msgPumpManager != null) {
if (_msgPumpManager.PumpMessage(ref m)) {
@ -181,6 +184,19 @@ namespace OnTopReplica {
}
break;
case WM.NCLBUTTONDOWN:
if ((ModifierKeys & Keys.Control) == Keys.Control &&
ThumbnailPanel.IsShowingThumbnail &&
!ThumbnailPanel.DrawMouseRegions) {
ThumbnailPanel.EnableMouseRegionsDrawingWithMouseDown();
ThumbnailPanel.RegionDrawn += _quickRegionDrawingHandler;
m.Result = IntPtr.Zero;
return;
}
break;
case WM.NCLBUTTONDBLCLK:
//Toggle fullscreen mode if double click on caption (whole glass area)
if (m.WParam.ToInt32() == HT.CAPTION) {
@ -205,6 +221,14 @@ namespace OnTopReplica {
base.WndProc(ref m);
}
private void HandleQuickRegionDrawn(object sender, ThumbnailRegion region) {
//Reset region drawing state
ThumbnailPanel.DrawMouseRegions = false;
ThumbnailPanel.RegionDrawn -= _quickRegionDrawingHandler;
SelectedThumbnailRegion = region;
}
#endregion
#region Keyboard event handling

View file

@ -74,6 +74,19 @@ namespace OnTopReplica {
}
}
/// <summary>
/// Enables mouse regions drawing, simulating one first click on the panel at the current cursor's position.
/// </summary>
public void EnableMouseRegionsDrawingWithMouseDown() {
if (DrawMouseRegions)
return;
var localCursor = this.PointToClient(Cursor.Position);
DrawMouseRegions = true;
OnMouseDown(new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, localCursor.X, localCursor.Y, 0));
}
bool _drawMouseRegions = false;
/// <summary>
@ -178,7 +191,7 @@ namespace OnTopReplica {
//Check whether this is a hit-test on "client" surface
if (m.Msg == WM.NCHITTEST && m.Result.ToInt32() == HT.CLIENT) {
//Check whether clicks must be reported
if(!DrawMouseRegions && !ReportThumbnailClicks /*&& !InputMethods.IsKeyPressed(VirtualKeyState.VK_SHIFT)*/){
if(!DrawMouseRegions && !ReportThumbnailClicks){
m.Result = new IntPtr(HT.TRANSPARENT);
}
}