Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better experience draging documents arround #72

Merged
merged 4 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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