未验证 提交 2a1b75e8 编写于 作者: A Allison Chou 提交者: GitHub

Merge pull request #44974 from allisonchou/ChangeSignatureAccessibility

Fix change signature accessibility bugs
...@@ -48,20 +48,24 @@ ...@@ -48,20 +48,24 @@
<Thickness x:Key="textboxPadding">2</Thickness> <Thickness x:Key="textboxPadding">2</Thickness>
<vs:NegateBooleanConverter x:Key="NegateBooleanConverter"/> <vs:NegateBooleanConverter x:Key="NegateBooleanConverter"/>
<RoutedUICommand x:Key="MoveUp" /> <RoutedUICommand x:Key="MoveUp" />
<RoutedUICommand x:Key="MoveUpFocus" />
<RoutedUICommand x:Key="MoveDown" /> <RoutedUICommand x:Key="MoveDown" />
<RoutedUICommand x:Key="MoveDownFocus" />
<RoutedUICommand x:Key="MoveSelectionUp" /> <RoutedUICommand x:Key="MoveSelectionUp" />
<RoutedUICommand x:Key="MoveSelectionDown" /> <RoutedUICommand x:Key="MoveSelectionDown" />
<RoutedUICommand x:Key="ClickOK" /> <RoutedUICommand x:Key="ClickOK" />
<RoutedUICommand x:Key="ToggleRemovedState" /> <RoutedUICommand x:Key="ToggleRemovedState" />
</Window.Resources> </Window.Resources>
<Window.CommandBindings> <Window.CommandBindings>
<CommandBinding Command="{StaticResource MoveUpFocus}" Executed="MoveUp_Click_FocusRow" />
<CommandBinding Command="{StaticResource MoveUp}" Executed="MoveUp_Click" /> <CommandBinding Command="{StaticResource MoveUp}" Executed="MoveUp_Click" />
<CommandBinding Command="{StaticResource MoveDownFocus}" Executed="MoveDown_Click_FocusRow" />
<CommandBinding Command="{StaticResource MoveDown}" Executed="MoveDown_Click" /> <CommandBinding Command="{StaticResource MoveDown}" Executed="MoveDown_Click" />
<CommandBinding Command="{StaticResource ToggleRemovedState}" Executed="ToggleRemovedState" /> <CommandBinding Command="{StaticResource ToggleRemovedState}" Executed="ToggleRemovedState" />
</Window.CommandBindings> </Window.CommandBindings>
<Window.InputBindings> <Window.InputBindings>
<KeyBinding Key="Up" Modifiers="Alt" Command="{StaticResource MoveUp}" /> <KeyBinding Key="Up" Modifiers="Alt" Command="{StaticResource MoveUpFocus}" />
<KeyBinding Key="Down" Modifiers="Alt" Command="{StaticResource MoveDown}" /> <KeyBinding Key="Down" Modifiers="Alt" Command="{StaticResource MoveDownFocus}" />
<KeyBinding Key="Delete" Command="{StaticResource ToggleRemovedState}" /> <KeyBinding Key="Delete" Command="{StaticResource ToggleRemovedState}" />
<KeyBinding Key="Return" Command="{StaticResource ClickOK}" /> <KeyBinding Key="Return" Command="{StaticResource ClickOK}" />
</Window.InputBindings> </Window.InputBindings>
...@@ -308,7 +312,7 @@ ...@@ -308,7 +312,7 @@
<ScrollViewer Name="Scroller" <ScrollViewer Name="Scroller"
AutomationProperties.Name="{Binding SignaturePreviewAutomationText}" AutomationProperties.Name="{Binding SignaturePreviewAutomationText}"
AutomationProperties.LabeledBy="{Binding ElementName=PreviewMethodSignatureLabel}" AutomationProperties.LabeledBy="{Binding ElementName=PreviewMethodSignatureLabel}"
IsTabStop="True" IsTabStop="False"
Padding="8, 4, 4, 4" Padding="8, 4, 4, 4"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"
Content="{Binding SignatureDisplay}" Content="{Binding SignatureDisplay}"
...@@ -318,6 +322,7 @@ ...@@ -318,6 +322,7 @@
<StackPanel Name="ControlButtonsPanel" Grid.Column="1" Grid.Row="0" Height="Auto" Width="Auto" Margin="0, 3, 0, 0" > <StackPanel Name="ControlButtonsPanel" Grid.Column="1" Grid.Row="0" Height="Auto" Width="Auto" Margin="0, 3, 0, 0" >
<vs:DialogButton Name="UpButton" <vs:DialogButton Name="UpButton"
AutomationProperties.Name="{Binding MoveUpAutomationText}" AutomationProperties.Name="{Binding MoveUpAutomationText}"
ToolTip="{Binding MoveUpAutomationText}"
Margin="9 0 0 0" Margin="9 0 0 0"
IsEnabled="{Binding CanMoveUp, Mode=OneWay}" IsEnabled="{Binding CanMoveUp, Mode=OneWay}"
AutomationProperties.AutomationId="UpButton" AutomationProperties.AutomationId="UpButton"
...@@ -331,6 +336,7 @@ ...@@ -331,6 +336,7 @@
</vs:DialogButton> </vs:DialogButton>
<vs:DialogButton Name="DownButton" <vs:DialogButton Name="DownButton"
AutomationProperties.Name="{Binding MoveDownAutomationText}" AutomationProperties.Name="{Binding MoveDownAutomationText}"
ToolTip="{Binding MoveDownAutomationText}"
Margin="9 9 0 0" Margin="9 9 0 0"
IsEnabled="{Binding CanMoveDown, Mode=OneWay}" IsEnabled="{Binding CanMoveDown, Mode=OneWay}"
AutomationProperties.AutomationId="DownButton" AutomationProperties.AutomationId="DownButton"
......
...@@ -8,10 +8,8 @@ ...@@ -8,10 +8,8 @@
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ChangeSignature; using Microsoft.CodeAnalysis.ChangeSignature;
using Microsoft.VisualStudio.PlatformUI; using Microsoft.VisualStudio.PlatformUI;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature namespace Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature
{ {
...@@ -85,6 +83,18 @@ private void Cancel_Click(object sender, RoutedEventArgs e) ...@@ -85,6 +83,18 @@ private void Cancel_Click(object sender, RoutedEventArgs e)
=> DialogResult = false; => DialogResult = false;
private void MoveUp_Click(object sender, EventArgs e) private void MoveUp_Click(object sender, EventArgs e)
{
MoveUp_UpdateSelectedIndex();
SetFocusToSelectedRow(false);
}
private void MoveUp_Click_FocusRow(object sender, EventArgs e)
{
MoveUp_UpdateSelectedIndex();
SetFocusToSelectedRow(true);
}
private void MoveUp_UpdateSelectedIndex()
{ {
var oldSelectedIndex = Members.SelectedIndex; var oldSelectedIndex = Members.SelectedIndex;
if (_viewModel.CanMoveUp && oldSelectedIndex >= 0) if (_viewModel.CanMoveUp && oldSelectedIndex >= 0)
...@@ -93,11 +103,21 @@ private void MoveUp_Click(object sender, EventArgs e) ...@@ -93,11 +103,21 @@ private void MoveUp_Click(object sender, EventArgs e)
Members.Items.Refresh(); Members.Items.Refresh();
Members.SelectedIndex = oldSelectedIndex - 1; Members.SelectedIndex = oldSelectedIndex - 1;
} }
SetFocusToSelectedRow();
} }
private void MoveDown_Click(object sender, EventArgs e) private void MoveDown_Click(object sender, EventArgs e)
{
MoveDown_UpdateSelectedIndex();
SetFocusToSelectedRow(false);
}
private void MoveDown_Click_FocusRow(object sender, EventArgs e)
{
MoveDown_UpdateSelectedIndex();
SetFocusToSelectedRow(true);
}
private void MoveDown_UpdateSelectedIndex()
{ {
var oldSelectedIndex = Members.SelectedIndex; var oldSelectedIndex = Members.SelectedIndex;
if (_viewModel.CanMoveDown && oldSelectedIndex >= 0) if (_viewModel.CanMoveDown && oldSelectedIndex >= 0)
...@@ -106,8 +126,6 @@ private void MoveDown_Click(object sender, EventArgs e) ...@@ -106,8 +126,6 @@ private void MoveDown_Click(object sender, EventArgs e)
Members.Items.Refresh(); Members.Items.Refresh();
Members.SelectedIndex = oldSelectedIndex + 1; Members.SelectedIndex = oldSelectedIndex + 1;
} }
SetFocusToSelectedRow();
} }
private void Remove_Click(object sender, RoutedEventArgs e) private void Remove_Click(object sender, RoutedEventArgs e)
...@@ -118,7 +136,7 @@ private void Remove_Click(object sender, RoutedEventArgs e) ...@@ -118,7 +136,7 @@ private void Remove_Click(object sender, RoutedEventArgs e)
Members.Items.Refresh(); Members.Items.Refresh();
} }
SetFocusToSelectedRow(); SetFocusToSelectedRow(true);
} }
private void Restore_Click(object sender, RoutedEventArgs e) private void Restore_Click(object sender, RoutedEventArgs e)
...@@ -129,7 +147,7 @@ private void Restore_Click(object sender, RoutedEventArgs e) ...@@ -129,7 +147,7 @@ private void Restore_Click(object sender, RoutedEventArgs e)
Members.Items.Refresh(); Members.Items.Refresh();
} }
SetFocusToSelectedRow(); SetFocusToSelectedRow(true);
} }
private void Add_Click(object sender, RoutedEventArgs e) private void Add_Click(object sender, RoutedEventArgs e)
...@@ -157,7 +175,7 @@ private void Add_Click(object sender, RoutedEventArgs e) ...@@ -157,7 +175,7 @@ private void Add_Click(object sender, RoutedEventArgs e)
_viewModel.AddParameter(addedParameter); _viewModel.AddParameter(addedParameter);
} }
SetFocusToSelectedRow(); SetFocusToSelectedRow(false);
} }
private CallSiteKind GetCallSiteKind(AddParameterDialogViewModel addParameterViewModel) private CallSiteKind GetCallSiteKind(AddParameterDialogViewModel addParameterViewModel)
...@@ -178,7 +196,7 @@ private CallSiteKind GetCallSiteKind(AddParameterDialogViewModel addParameterVie ...@@ -178,7 +196,7 @@ private CallSiteKind GetCallSiteKind(AddParameterDialogViewModel addParameterVie
: CallSiteKind.Value; : CallSiteKind.Value;
} }
private void SetFocusToSelectedRow() private void SetFocusToSelectedRow(bool focusRow)
{ {
if (Members.SelectedIndex >= 0) if (Members.SelectedIndex >= 0)
{ {
...@@ -188,7 +206,7 @@ private void SetFocusToSelectedRow() ...@@ -188,7 +206,7 @@ private void SetFocusToSelectedRow()
row = Members.ItemContainerGenerator.ContainerFromIndex(Members.SelectedIndex) as DataGridRow; row = Members.ItemContainerGenerator.ContainerFromIndex(Members.SelectedIndex) as DataGridRow;
} }
if (row != null) if (row != null && focusRow)
{ {
FocusRow(row); FocusRow(row);
} }
...@@ -216,7 +234,7 @@ private void MoveSelectionUp_Click(object sender, EventArgs e) ...@@ -216,7 +234,7 @@ private void MoveSelectionUp_Click(object sender, EventArgs e)
} }
} }
SetFocusToSelectedRow(); SetFocusToSelectedRow(true);
} }
private void MoveSelectionDown_Click(object sender, EventArgs e) private void MoveSelectionDown_Click(object sender, EventArgs e)
...@@ -227,7 +245,7 @@ private void MoveSelectionDown_Click(object sender, EventArgs e) ...@@ -227,7 +245,7 @@ private void MoveSelectionDown_Click(object sender, EventArgs e)
Members.SelectedIndex = oldSelectedIndex + 1; Members.SelectedIndex = oldSelectedIndex + 1;
} }
SetFocusToSelectedRow(); SetFocusToSelectedRow(true);
} }
private void Members_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) private void Members_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
...@@ -238,7 +256,7 @@ private void Members_GotKeyboardFocus(object sender, KeyboardFocusChangedEventAr ...@@ -238,7 +256,7 @@ private void Members_GotKeyboardFocus(object sender, KeyboardFocusChangedEventAr
Members.SelectedIndex = _viewModel.GetStartingSelectionIndex(); Members.SelectedIndex = _viewModel.GetStartingSelectionIndex();
} }
SetFocusToSelectedRow(); SetFocusToSelectedRow(true);
} }
private void ToggleRemovedState(object sender, ExecutedRoutedEventArgs e) private void ToggleRemovedState(object sender, ExecutedRoutedEventArgs e)
...@@ -253,7 +271,7 @@ private void ToggleRemovedState(object sender, ExecutedRoutedEventArgs e) ...@@ -253,7 +271,7 @@ private void ToggleRemovedState(object sender, ExecutedRoutedEventArgs e)
} }
Members.Items.Refresh(); Members.Items.Refresh();
SetFocusToSelectedRow(); SetFocusToSelectedRow(true);
} }
internal TestAccessor GetTestAccessor() internal TestAccessor GetTestAccessor()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册