Browse Source

Updated obsolete API usages.

pull/3501/head
José Pedro 6 years ago
parent
commit
fc9a6d5746
No known key found for this signature in database GPG Key ID: B8247B9301707B83
  1. 32
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  2. 16
      src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs
  3. 15
      src/Avalonia.Controls.DataGrid/Utils/KeyboardHelper.cs
  4. 4
      src/Avalonia.Controls/Calendar/Calendar.cs
  5. 6
      src/Avalonia.Controls/Calendar/CalendarExtensions.cs
  6. 2
      src/Avalonia.Controls/Calendar/CalendarItem.cs
  7. 2
      src/Avalonia.Controls/Calendar/DatePicker.cs
  8. 2
      src/Avalonia.Controls/ComboBox.cs
  9. 2
      src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs
  10. 2
      src/Avalonia.Input/KeyboardNavigationHandler.cs

32
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -2472,25 +2472,25 @@ namespace Avalonia.Controls
internal bool ProcessDownKey(KeyEventArgs e) internal bool ProcessDownKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessDownKeyInternal(shift, ctrl); return ProcessDownKeyInternal(shift, ctrl);
} }
internal bool ProcessEndKey(KeyEventArgs e) internal bool ProcessEndKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessEndKey(shift, ctrl); return ProcessEndKey(shift, ctrl);
} }
internal bool ProcessEnterKey(KeyEventArgs e) internal bool ProcessEnterKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessEnterKey(shift, ctrl); return ProcessEnterKey(shift, ctrl);
} }
internal bool ProcessHomeKey(KeyEventArgs e) internal bool ProcessHomeKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessHomeKey(shift, ctrl); return ProcessHomeKey(shift, ctrl);
} }
@ -2530,25 +2530,25 @@ namespace Avalonia.Controls
internal bool ProcessLeftKey(KeyEventArgs e) internal bool ProcessLeftKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessLeftKey(shift, ctrl); return ProcessLeftKey(shift, ctrl);
} }
internal bool ProcessNextKey(KeyEventArgs e) internal bool ProcessNextKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessNextKey(shift, ctrl); return ProcessNextKey(shift, ctrl);
} }
internal bool ProcessPriorKey(KeyEventArgs e) internal bool ProcessPriorKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessPriorKey(shift, ctrl); return ProcessPriorKey(shift, ctrl);
} }
internal bool ProcessRightKey(KeyEventArgs e) internal bool ProcessRightKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessRightKey(shift, ctrl); return ProcessRightKey(shift, ctrl);
} }
@ -2666,7 +2666,7 @@ namespace Avalonia.Controls
internal bool ProcessUpKey(KeyEventArgs e) internal bool ProcessUpKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessUpKey(shift, ctrl); return ProcessUpKey(shift, ctrl);
} }
@ -2934,7 +2934,7 @@ namespace Avalonia.Controls
//TODO: Ensure left button is checked for //TODO: Ensure left button is checked for
internal bool UpdateStateOnMouseLeftButtonDown(PointerPressedEventArgs pointerPressedEventArgs, int columnIndex, int slot, bool allowEdit) internal bool UpdateStateOnMouseLeftButtonDown(PointerPressedEventArgs pointerPressedEventArgs, int columnIndex, int slot, bool allowEdit)
{ {
KeyboardHelper.GetMetaKeyState(pointerPressedEventArgs.InputModifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(pointerPressedEventArgs.KeyModifiers, out bool ctrl, out bool shift);
return UpdateStateOnMouseLeftButtonDown(pointerPressedEventArgs, columnIndex, slot, allowEdit, shift, ctrl); return UpdateStateOnMouseLeftButtonDown(pointerPressedEventArgs, columnIndex, slot, allowEdit, shift, ctrl);
} }
@ -4376,7 +4376,7 @@ namespace Avalonia.Controls
private bool ProcessAKey(KeyEventArgs e) private bool ProcessAKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift, out bool alt); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift, out bool alt);
if (ctrl && !shift && !alt && SelectionMode == DataGridSelectionMode.Extended) if (ctrl && !shift && !alt && SelectionMode == DataGridSelectionMode.Extended)
{ {
@ -4442,10 +4442,10 @@ namespace Avalonia.Controls
return ProcessAKey(e); return ProcessAKey(e);
case Key.C: case Key.C:
return ProcessCopyKey(e.Modifiers); return ProcessCopyKey(e.KeyModifiers);
case Key.Insert: case Key.Insert:
return ProcessCopyKey(e.Modifiers); return ProcessCopyKey(e.KeyModifiers);
} }
if (focusDataGrid) if (focusDataGrid)
{ {
@ -4644,7 +4644,7 @@ namespace Avalonia.Controls
private bool ProcessF2Key(KeyEventArgs e) private bool ProcessF2Key(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
if (!shift && !ctrl && if (!shift && !ctrl &&
_editingColumnIndex == -1 && CurrentColumnIndex != -1 && GetRowSelection(CurrentSlot) && _editingColumnIndex == -1 && CurrentColumnIndex != -1 && GetRowSelection(CurrentSlot) &&
@ -5001,7 +5001,7 @@ namespace Avalonia.Controls
private bool ProcessTabKey(KeyEventArgs e) private bool ProcessTabKey(KeyEventArgs e)
{ {
KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
return ProcessTabKey(e, shift, ctrl); return ProcessTabKey(e, shift, ctrl);
} }
@ -5787,7 +5787,7 @@ namespace Avalonia.Controls
/// to the Clipboard as text. /// to the Clipboard as text.
/// </summary> /// </summary>
/// <returns>Whether or not the DataGrid handled the key press.</returns> /// <returns>Whether or not the DataGrid handled the key press.</returns>
private bool ProcessCopyKey(InputModifiers modifiers) private bool ProcessCopyKey(KeyModifiers modifiers)
{ {
KeyboardHelper.GetMetaKeyState(modifiers, out bool ctrl, out bool shift, out bool alt); KeyboardHelper.GetMetaKeyState(modifiers, out bool ctrl, out bool shift, out bool alt);

16
src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs

@ -190,28 +190,28 @@ namespace Avalonia.Controls
} }
} }
internal void OnMouseLeftButtonUp_Click(InputModifiers inputModifiers, ref bool handled) internal void OnMouseLeftButtonUp_Click(KeyModifiers keyModifiers, ref bool handled)
{ {
// completed a click without dragging, so we're sorting // completed a click without dragging, so we're sorting
InvokeProcessSort(inputModifiers); InvokeProcessSort(keyModifiers);
handled = true; handled = true;
} }
internal void InvokeProcessSort(InputModifiers inputModifiers) internal void InvokeProcessSort(KeyModifiers keyModifiers)
{ {
Debug.Assert(OwningGrid != null); Debug.Assert(OwningGrid != null);
if (OwningGrid.WaitForLostFocus(() => InvokeProcessSort(inputModifiers))) if (OwningGrid.WaitForLostFocus(() => InvokeProcessSort(keyModifiers)))
{ {
return; return;
} }
if (OwningGrid.CommitEdit(DataGridEditingUnit.Row, exitEditingMode: true)) if (OwningGrid.CommitEdit(DataGridEditingUnit.Row, exitEditingMode: true))
{ {
Avalonia.Threading.Dispatcher.UIThread.Post(() => ProcessSort(inputModifiers)); Avalonia.Threading.Dispatcher.UIThread.Post(() => ProcessSort(keyModifiers));
} }
} }
//TODO GroupSorting //TODO GroupSorting
internal void ProcessSort(InputModifiers inputModifiers) internal void ProcessSort(KeyModifiers keyModifiers)
{ {
// if we can sort: // if we can sort:
// - DataConnection.AllowSort is true, and // - DataConnection.AllowSort is true, and
@ -233,7 +233,7 @@ namespace Avalonia.Controls
DataGridSortDescription newSort; DataGridSortDescription newSort;
KeyboardHelper.GetMetaKeyState(inputModifiers, out bool ctrl, out bool shift); KeyboardHelper.GetMetaKeyState(keyModifiers, out bool ctrl, out bool shift);
DataGridSortDescription sort = OwningColumn.GetSortDescription(); DataGridSortDescription sort = OwningColumn.GetSortDescription();
IDataGridCollectionView collectionView = owningGrid.DataConnection.CollectionView; IDataGridCollectionView collectionView = owningGrid.DataConnection.CollectionView;
@ -371,7 +371,7 @@ namespace Avalonia.Controls
{ {
if (_dragMode == DragMode.MouseDown) if (_dragMode == DragMode.MouseDown)
{ {
OnMouseLeftButtonUp_Click(args.InputModifiers, ref handled); OnMouseLeftButtonUp_Click(args.KeyModifiers, ref handled);
} }
else if (_dragMode == DragMode.Reorder) else if (_dragMode == DragMode.Reorder)
{ {

15
src/Avalonia.Controls.DataGrid/Utils/KeyboardHelper.cs

@ -9,16 +9,17 @@ namespace Avalonia.Controls.Utils
{ {
internal static class KeyboardHelper internal static class KeyboardHelper
{ {
public static void GetMetaKeyState(InputModifiers modifiers, out bool ctrl, out bool shift) public static void GetMetaKeyState(KeyModifiers modifiers, out bool ctrl, out bool shift)
{ {
ctrl = (modifiers & InputModifiers.Control) == InputModifiers.Control; ctrl = (modifiers & KeyModifiers.Control) == KeyModifiers.Control;
shift = (modifiers & InputModifiers.Shift) == InputModifiers.Shift; shift = (modifiers & KeyModifiers.Shift) == KeyModifiers.Shift;
} }
public static void GetMetaKeyState(InputModifiers modifiers, out bool ctrl, out bool shift, out bool alt)
public static void GetMetaKeyState(KeyModifiers modifiers, out bool ctrl, out bool shift, out bool alt)
{ {
ctrl = (modifiers & InputModifiers.Control) == InputModifiers.Control; ctrl = (modifiers & KeyModifiers.Control) == KeyModifiers.Control;
shift = (modifiers & InputModifiers.Shift) == InputModifiers.Shift; shift = (modifiers & KeyModifiers.Shift) == KeyModifiers.Shift;
alt = (modifiers & InputModifiers.Alt) == InputModifiers.Alt; alt = (modifiers & KeyModifiers.Alt) == KeyModifiers.Alt;
} }
} }
} }

4
src/Avalonia.Controls/Calendar/Calendar.cs

@ -1575,7 +1575,7 @@ namespace Avalonia.Controls
base.OnPointerWheelChanged(e); base.OnPointerWheelChanged(e);
if (!e.Handled) if (!e.Handled)
{ {
CalendarExtensions.GetMetaKeyState(e.InputModifiers, out bool ctrl, out bool shift); CalendarExtensions.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
if (!ctrl) if (!ctrl)
{ {
@ -1631,7 +1631,7 @@ namespace Avalonia.Controls
// Some keys (e.g. Left/Right) need to be translated in RightToLeft mode // Some keys (e.g. Left/Right) need to be translated in RightToLeft mode
Key invariantKey = e.Key; //InteractionHelper.GetLogicalKey(FlowDirection, e.Key); Key invariantKey = e.Key; //InteractionHelper.GetLogicalKey(FlowDirection, e.Key);
CalendarExtensions.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); CalendarExtensions.GetMetaKeyState(e.KeyModifiers, out bool ctrl, out bool shift);
switch (invariantKey) switch (invariantKey)
{ {

6
src/Avalonia.Controls/Calendar/CalendarExtensions.cs

@ -9,10 +9,10 @@ namespace Avalonia.Controls.Primitives
{ {
internal static class CalendarExtensions internal static class CalendarExtensions
{ {
public static void GetMetaKeyState(InputModifiers modifiers, out bool ctrl, out bool shift) public static void GetMetaKeyState(KeyModifiers modifiers, out bool ctrl, out bool shift)
{ {
ctrl = (modifiers & InputModifiers.Control) == InputModifiers.Control; ctrl = (modifiers & KeyModifiers.Control) == KeyModifiers.Control;
shift = (modifiers & InputModifiers.Shift) == InputModifiers.Shift; shift = (modifiers & KeyModifiers.Shift) == KeyModifiers.Shift;
} }
} }
} }

2
src/Avalonia.Controls/Calendar/CalendarItem.cs

@ -958,7 +958,7 @@ namespace Avalonia.Controls.Primitives
} }
bool ctrl, shift; bool ctrl, shift;
CalendarExtensions.GetMetaKeyState(e.InputModifiers, out ctrl, out shift); CalendarExtensions.GetMetaKeyState(e.KeyModifiers, out ctrl, out shift);
CalendarDayButton b = sender as CalendarDayButton; CalendarDayButton b = sender as CalendarDayButton;
if (b != null) if (b != null)

2
src/Avalonia.Controls/Calendar/DatePicker.cs

@ -1008,7 +1008,7 @@ namespace Avalonia.Controls
} }
case Key.Down: case Key.Down:
{ {
if ((e.Modifiers & InputModifiers.Control) == InputModifiers.Control) if ((e.KeyModifiers & KeyModifiers.Control) == KeyModifiers.Control)
{ {
HandlePopUp(); HandlePopUp();
return true; return true;

2
src/Avalonia.Controls/ComboBox.cs

@ -130,7 +130,7 @@ namespace Avalonia.Controls
return; return;
if (e.Key == Key.F4 || if (e.Key == Key.F4 ||
((e.Key == Key.Down || e.Key == Key.Up) && ((e.Modifiers & InputModifiers.Alt) != 0))) ((e.Key == Key.Down || e.Key == Key.Up) && ((e.KeyModifiers & KeyModifiers.Alt) != 0)))
{ {
IsDropDownOpen = !IsDropDownOpen; IsDropDownOpen = !IsDropDownOpen;
e.Handled = true; e.Handled = true;

2
src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs

@ -261,7 +261,7 @@ namespace Avalonia.Controls.Utils
break; break;
case Key.Down: case Key.Down:
if ((e.Modifiers & InputModifiers.Alt) == InputModifiers.None) if ((e.KeyModifiers & KeyModifiers.Alt) == KeyModifiers.None)
{ {
SelectedIndexIncrement(); SelectedIndexIncrement();
e.Handled = true; e.Handled = true;

2
src/Avalonia.Input/KeyboardNavigationHandler.cs

@ -124,7 +124,7 @@ namespace Avalonia.Input
if (current != null && e.Key == Key.Tab) if (current != null && e.Key == Key.Tab)
{ {
var direction = (e.Modifiers & InputModifiers.Shift) == 0 ? var direction = (e.KeyModifiers & KeyModifiers.Shift) == 0 ?
NavigationDirection.Next : NavigationDirection.Previous; NavigationDirection.Next : NavigationDirection.Previous;
Move(current, direction, e.Modifiers); Move(current, direction, e.Modifiers);
e.Handled = true; e.Handled = true;

Loading…
Cancel
Save