@@ -60,20 +60,20 @@ void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallb
6060 HitTestFilterBehavior FilterHitTestInvisibleElements ( DependencyObject potentialHitTestTarget )
6161 {
6262 UIElement element = potentialHitTestTarget as UIElement ;
63-
63+
6464 if ( element != null ) {
6565 if ( ! ( element . IsHitTestVisible && element . Visibility == Visibility . Visible ) ) {
6666 return HitTestFilterBehavior . ContinueSkipSelfAndChildren ;
6767 }
6868
6969 var designItem = Context . Services . Component . GetDesignItem ( element ) as XamlDesignItem ;
70-
70+
7171 if ( designItem != null && designItem . IsDesignTimeLocked ) {
7272 return HitTestFilterBehavior . ContinueSkipSelfAndChildren ;
73+ }
74+
7375 }
7476
75- }
76-
7777 return HitTestFilterBehavior . Continue ;
7878 }
7979
@@ -158,6 +158,9 @@ public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurfa
158158 DesignContext _context ;
159159 readonly EatAllHitTestRequests _eatAllHitTestRequests ;
160160 readonly AdornerLayer _adornerLayer ;
161+ PlacementOperation _currentOperation ;
162+ bool _moving = false ;
163+ int _movingDistance ;
161164
162165 public DesignPanel ( )
163166 {
@@ -323,6 +326,10 @@ private void DesignPanel_KeyUp(object sender, KeyEventArgs e)
323326 {
324327 if ( e . Key == Key . Left || e . Key == Key . Right || e . Key == Key . Up || e . Key == Key . Down )
325328 {
329+ if ( _currentOperation != null )
330+ _currentOperation . Commit ( ) ;
331+ _currentOperation = null ;
332+ _moving = false ;
326333 e . Handled = true ;
327334 }
328335 }
@@ -333,14 +340,19 @@ void DesignPanel_KeyDown(object sender, KeyEventArgs e)
333340 {
334341 e . Handled = true ;
335342
336- var placementOp = PlacementOperation . Start ( Context . Services . Selection . SelectedItems , PlacementType . Move ) ;
337-
338-
339- var dx1 = ( e . Key == Key . Left ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? - 10 : - 1 : 0 ;
340- var dy1 = ( e . Key == Key . Up ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? - 10 : - 1 : 0 ;
341- var dx2 = ( e . Key == Key . Right ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? 10 : 1 : 0 ;
342- var dy2 = ( e . Key == Key . Down ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? 10 : 1 : 0 ;
343- foreach ( PlacementInformation info in placementOp . PlacedItems )
343+ if ( ! _moving )
344+ {
345+ _currentOperation = PlacementOperation . Start ( Context . Services . Selection . SelectedItems , PlacementType . Move ) ;
346+ _moving = true ;
347+ _movingDistance = 0 ;
348+ }
349+
350+ var dx1 = ( e . Key == Key . Left ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance - 10 : _movingDistance - 1 : 0 ;
351+ var dy1 = ( e . Key == Key . Up ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance - 10 : _movingDistance - 1 : 0 ;
352+ var dx2 = ( e . Key == Key . Right ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance + 10 : _movingDistance + 1 : 0 ;
353+ var dy2 = ( e . Key == Key . Down ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance + 10 : _movingDistance + 1 : 0 ;
354+
355+ foreach ( PlacementInformation info in _currentOperation . PlacedItems )
344356 {
345357 if ( ! Keyboard . IsKeyDown ( Key . LeftCtrl ) )
346358 {
@@ -356,9 +368,11 @@ void DesignPanel_KeyDown(object sender, KeyEventArgs e)
356368 info . OriginalBounds . Width + dx1 + dx2 ,
357369 info . OriginalBounds . Height + dy1 + dy2 ) ;
358370 }
359-
360- placementOp . CurrentContainerBehavior . SetPosition ( info ) ;
371+
372+ _currentOperation . CurrentContainerBehavior . SetPosition ( info ) ;
361373 }
374+
375+ _movingDistance = ( dx1 + dx2 + dy1 + dy2 ) ;
362376 }
363377 }
364378
0 commit comments