Browse Source

Fix for skewed checkbox movement on arrow key press

pull/482/head
tbulle 11 years ago
parent
commit
7e238a9b52
  1. 37
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

37
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

@ -368,8 +368,7 @@ namespace ICSharpCode.WpfDesign.Designer
void DesignPanel_KeyDown(object sender, KeyEventArgs e) void DesignPanel_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down) if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down) {
{
e.Handled = true; e.Handled = true;
if (placementOp == null) { if (placementOp == null) {
@ -379,32 +378,38 @@ namespace ICSharpCode.WpfDesign.Designer
} }
dx += (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0; dx = (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0;
dy += (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0; dy = (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0;
dx += (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : 0; dx = (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : 0;
dy += (e.Key == Key.Down) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : 0; dy = (e.Key == Key.Down) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : 0;
double left, top;
foreach (PlacementInformation info in placementOp.PlacedItems) foreach (PlacementInformation info in placementOp.PlacedItems)
{ {
if (!Keyboard.IsKeyDown(Key.LeftCtrl)) //Let canvas position preceed bounds definition since there can be a discrepancy between them.
{ left = IsPropertySet(info.Item.View,Canvas.LeftProperty)?(double)info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance: info.OriginalBounds.Left;
info.Bounds = new Rect(info.OriginalBounds.Left + dx,
info.OriginalBounds.Top + dy, top = IsPropertySet(info.Item.View, Canvas.TopProperty) ? (double)info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance : info.OriginalBounds.Top;
if (!Keyboard.IsKeyDown(Key.LeftCtrl)) {
info.Bounds = new Rect(left + dx,
top + dy,
info.OriginalBounds.Width, info.OriginalBounds.Width,
info.OriginalBounds.Height); info.OriginalBounds.Height);
} } else {
else info.Bounds = new Rect(left,
{ top,
info.Bounds = new Rect(info.OriginalBounds.Left,
info.OriginalBounds.Top,
info.OriginalBounds.Width + dx, info.OriginalBounds.Width + dx,
info.OriginalBounds.Height + dy); info.OriginalBounds.Height + dy);
} }
placementOp.CurrentContainerBehavior.SetPosition(info); placementOp.CurrentContainerBehavior.SetPosition(info);
} }
} }
} }
static bool IsPropertySet(UIElement element, DependencyProperty d)
{
return element.ReadLocalValue(d) != DependencyProperty.UnsetValue;
}
protected override void OnQueryCursor(QueryCursorEventArgs e) protected override void OnQueryCursor(QueryCursorEventArgs e)
{ {
base.OnQueryCursor(e); base.OnQueryCursor(e);

Loading…
Cancel
Save