@@ -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
@@ -161,6 +161,9 @@ public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurfa
161161 DesignContext _context ;
162162 readonly EatAllHitTestRequests _eatAllHitTestRequests ;
163163 readonly AdornerLayer _adornerLayer ;
164+ PlacementOperation _currentOperation ;
165+ bool _moving = false ;
166+ int _movingDistance ;
164167
165168 public DesignPanel ( )
166169 {
@@ -328,6 +331,10 @@ private void DesignPanel_KeyUp(object sender, KeyEventArgs e)
328331 {
329332 if ( e . Key == Key . Left || e . Key == Key . Right || e . Key == Key . Up || e . Key == Key . Down )
330333 {
334+ if ( _currentOperation != null )
335+ _currentOperation . Commit ( ) ;
336+ _currentOperation = null ;
337+ _moving = false ;
331338 e . Handled = true ;
332339 }
333340 }
@@ -338,14 +345,19 @@ void DesignPanel_KeyDown(object sender, KeyEventArgs e)
338345 {
339346 e . Handled = true ;
340347
341- var placementOp = PlacementOperation . Start ( Context . Services . Selection . SelectedItems , PlacementType . Move ) ;
342-
343-
344- var dx1 = ( e . Key == Key . Left ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? - 10 : - 1 : 0 ;
345- var dy1 = ( e . Key == Key . Up ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? - 10 : - 1 : 0 ;
346- var dx2 = ( e . Key == Key . Right ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? 10 : 1 : 0 ;
347- var dy2 = ( e . Key == Key . Down ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? 10 : 1 : 0 ;
348- foreach ( PlacementInformation info in placementOp . PlacedItems )
348+ if ( ! _moving )
349+ {
350+ _currentOperation = PlacementOperation . Start ( Context . Services . Selection . SelectedItems , PlacementType . Move ) ;
351+ _moving = true ;
352+ _movingDistance = 0 ;
353+ }
354+
355+ var dx1 = ( e . Key == Key . Left ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance - 10 : _movingDistance - 1 : 0 ;
356+ var dy1 = ( e . Key == Key . Up ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance - 10 : _movingDistance - 1 : 0 ;
357+ var dx2 = ( e . Key == Key . Right ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance + 10 : _movingDistance + 1 : 0 ;
358+ var dy2 = ( e . Key == Key . Down ) ? Keyboard . IsKeyDown ( Key . LeftShift ) ? _movingDistance + 10 : _movingDistance + 1 : 0 ;
359+
360+ foreach ( PlacementInformation info in _currentOperation . PlacedItems )
349361 {
350362 if ( ! Keyboard . IsKeyDown ( Key . LeftCtrl ) )
351363 {
@@ -361,9 +373,11 @@ void DesignPanel_KeyDown(object sender, KeyEventArgs e)
361373 info . OriginalBounds . Width + dx1 + dx2 ,
362374 info . OriginalBounds . Height + dy1 + dy2 ) ;
363375 }
364-
365- placementOp . CurrentContainerBehavior . SetPosition ( info ) ;
376+
377+ _currentOperation . CurrentContainerBehavior . SetPosition ( info ) ;
366378 }
379+
380+ _movingDistance = ( dx1 + dx2 + dy1 + dy2 ) ;
367381 }
368382 }
369383
0 commit comments