Skip to content

Commit

Permalink
Merge pull request #72 from jogibear9988/master
Browse files Browse the repository at this point in the history
Better experience draging documents arround - yes this looks much better, thank you for re-working this :-)
  • Loading branch information
Dirkster99 authored Sep 26, 2019
2 parents b9da31c + f763aa9 commit abf4df3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*]
end_of_line = lf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class LayoutDocumentTabItem : Control
private DocumentPaneTabPanel _parentDocumentTabPanel;
private bool _isMouseDown = false;
private Point _mouseDownPoint;
private bool _allowDrag = false;

#endregion

Expand Down Expand Up @@ -141,6 +142,7 @@ protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonE
{
base.OnMouseLeftButtonDown( e );

_allowDrag = false;
Model.IsActive = true;

var layoutDocument = Model as LayoutDocument;
Expand All @@ -157,21 +159,22 @@ protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonE
protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseMove( e );

if( _isMouseDown )
{
Point ptMouseMove = e.GetPosition( this );

this.CaptureMouse();
if( Math.Abs( ptMouseMove.X - _mouseDownPoint.X ) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs( ptMouseMove.Y - _mouseDownPoint.Y ) > SystemParameters.MinimumVerticalDragDistance )
{
this.UpdateDragDetails();
this.CaptureMouse();

_isMouseDown = false;
_allowDrag = true;
}
}

if( this.IsMouseCaptured )
if( this.IsMouseCaptured && _allowDrag)
{
var mousePosInScreenCoord = this.PointToScreenDPI( e.GetPosition( this ) );
if( !_parentDocumentTabPanelScreenArea.Contains( mousePosInScreenCoord ) )
Expand Down Expand Up @@ -204,10 +207,10 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )

protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
if( IsMouseCaptured )
ReleaseMouseCapture();
_isMouseDown = false;

_allowDrag = false;
if ( IsMouseCaptured )
ReleaseMouseCapture();
base.OnMouseLeftButtonUp( e );
}

Expand Down

0 comments on commit abf4df3

Please sign in to comment.