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

Drag Adorner Gets Clipped #69

Closed
osicka opened this issue Aug 7, 2013 · 1 comment
Closed

Drag Adorner Gets Clipped #69

osicka opened this issue Aug 7, 2013 · 1 comment

Comments

@osicka
Copy link

osicka commented Aug 7, 2013

If you drag the adorner to the left or right of the screen the adorner gets clipped, which is bad if you need to look at the information in the adorner. (I have changing information based on what element you are over).

To fix this I make the adorner position relative to the position on the adorned element, in the middle it is in the centre, as you move left or right the adorner slowly shifts away from centre so that it is always fully visible.

To achieve this I modified DragDrog.cs.

In DropTarget_PreviewDragOver when setting the DragAdorner position

if (DontClipAdorner == true)
{
    _adornerPos.Offset((_adornerSize.Width * (tempAdornerPos.X / DragAdorner.AdornedElement.DesiredSize.Width * -1)), (_adornerSize.Height * -0.9));
}
else
{
    // When there is a custom adorner move to above the cursor and center it
    if (m_DragInfo != null && GetDragAdornerTemplate(m_DragInfo.VisualSource) != null)
        _adornerPos.Offset((_adornerSize.Width * -0.5), (_adornerSize.Height * -0.9));
    else
        _adornerPos.Offset(0, (_adornerSize.Height * -0.5));
}

and lower down when setting the EffectAdorner position

if (DontClipAdorner == true)                
{
    // Fixed the flickering adorner - Size changes to zero 'randomly'...?
    if (EffectAdorner.RenderSize.Width > 0 && EffectAdorner.RenderSize.Height > 0)
        _effectAdornerSize = EffectAdorner.RenderSize;

    adornerPos.Offset((_effectAdornerSize.Width * (adornerPos.X / EffectAdorner.AdornedElement.DesiredSize.Width * -1)), 25);
}
else
{
    adornerPos.Offset(20, 20);
}
@punker76
Copy link
Owner

punker76 commented Aug 9, 2013

this will be fixed in 0.1.3.9 but with this solution at DropTarget_PreviewDragOver

if (m_DragInfo != null) {
  // move the adorner
  var offsetX = _adornerSize.Width * -GetDragMouseAnchorPoint(m_DragInfo.VisualSource).X;
  var offsetY = _adornerSize.Height * -GetDragMouseAnchorPoint(m_DragInfo.VisualSource).Y;
  _adornerPos.Offset(offsetX, offsetY);
  var maxAdornerPosX = DragAdorner.AdornedElement.RenderSize.Width;
  var adornerPosRightX = (_adornerPos.X + _adornerSize.Width);
  if (adornerPosRightX > maxAdornerPosX) {
    _adornerPos.Offset(-adornerPosRightX + maxAdornerPosX, 0);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants