Browse Source

AssemblyListManager: add keyboard input actions to dialog and fix bugs in rename/delete handler.

pull/2069/head
Siegfried Pammer 6 years ago
parent
commit
6062cdd26d
  1. 4
      ILSpy/AssemblyListManager.cs
  2. 2
      ILSpy/SessionSettings.cs
  3. 28
      ILSpy/ViewModels/ManageAssemblyListsViewModel.cs
  4. 6
      ILSpy/Views/ManageAssemblyListsDialog.xaml

4
ILSpy/AssemblyListManager.cs

@ -119,10 +119,8 @@ namespace ICSharpCode.ILSpy
public bool DeleteList(string Name) public bool DeleteList(string Name)
{ {
if (AssemblyLists.Contains(Name)) if (AssemblyLists.Remove(Name))
{ {
AssemblyLists.Remove(Name);
ILSpySettings.Update( ILSpySettings.Update(
delegate(XElement root) delegate(XElement root)
{ {

2
ILSpy/SessionSettings.cs

@ -78,7 +78,7 @@ namespace ICSharpCode.ILSpy
public string ActiveAssemblyList { public string ActiveAssemblyList {
get => activeAssemblyList; get => activeAssemblyList;
set { set {
if (value != activeAssemblyList) { if (value != null && value != activeAssemblyList) {
activeAssemblyList = value; activeAssemblyList = value;
OnPropertyChanged(); OnPropertyChanged();
} }

28
ILSpy/ViewModels/ManageAssemblyListsViewModel.cs

@ -126,7 +126,7 @@ namespace ICSharpCode.ILSpy.ViewModels
if (dlg.DialogResult == true) { if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.ListName)) { if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true; args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK); MessageBox.Show(Resources.ListExistsAlready, null, MessageBoxButton.OK);
} }
} }
}; };
@ -148,7 +148,7 @@ namespace ICSharpCode.ILSpy.ViewModels
if (dlg.DialogResult == true) { if (dlg.DialogResult == true) {
if (manager.AssemblyLists.Contains(dlg.ListName)) { if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true; args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK); MessageBox.Show(Resources.ListExistsAlready, null, MessageBoxButton.OK);
} }
} }
}; };
@ -159,7 +159,7 @@ namespace ICSharpCode.ILSpy.ViewModels
private void ExecuteReset() private void ExecuteReset()
{ {
if (MessageBox.Show(parent, Properties.Resources.ListsResetConfirmation, if (MessageBox.Show(parent, Resources.ListsResetConfirmation,
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes) "ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return; return;
manager.ClearAll(); manager.ClearAll();
@ -169,10 +169,19 @@ namespace ICSharpCode.ILSpy.ViewModels
private void ExecuteDelete() private void ExecuteDelete()
{ {
if (MessageBox.Show(parent, Properties.Resources.ListDeleteConfirmation, if (MessageBox.Show(parent, Resources.ListDeleteConfirmation,
"ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes) "ILSpy", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) != MessageBoxResult.Yes)
return; return;
manager.DeleteList(SelectedAssemblyList); string assemblyList = SelectedAssemblyList;
SelectedAssemblyList = null;
int index = manager.AssemblyLists.IndexOf(assemblyList);
manager.DeleteList(assemblyList);
if (manager.AssemblyLists.Count > 0) {
SelectedAssemblyList = manager.AssemblyLists[Math.Max(0, index - 1)];
if (MainWindow.Instance.sessionSettings.ActiveAssemblyList == assemblyList) {
MainWindow.Instance.sessionSettings.ActiveAssemblyList = SelectedAssemblyList;
}
}
} }
private bool CanExecuteDelete() private bool CanExecuteDelete()
@ -199,12 +208,17 @@ namespace ICSharpCode.ILSpy.ViewModels
} }
if (manager.AssemblyLists.Contains(dlg.ListName)) { if (manager.AssemblyLists.Contains(dlg.ListName)) {
args.Cancel = true; args.Cancel = true;
MessageBox.Show(Properties.Resources.ListExistsAlready, null, MessageBoxButton.OK); MessageBox.Show(Resources.ListExistsAlready, null, MessageBoxButton.OK);
} }
} }
}; };
if (dlg.ShowDialog() == true) { if (dlg.ShowDialog() == true) {
manager.RenameList(selectedAssemblyList, dlg.ListName); string assemblyList = SelectedAssemblyList;
SelectedAssemblyList = dlg.ListName;
manager.RenameList(assemblyList, dlg.ListName);
if (MainWindow.Instance.sessionSettings.ActiveAssemblyList == assemblyList) {
MainWindow.Instance.sessionSettings.ActiveAssemblyList = manager.AssemblyLists[manager.AssemblyLists.Count - 1];
}
} }
} }

6
ILSpy/Views/ManageAssemblyListsDialog.xaml

@ -41,6 +41,12 @@
<b:EventTrigger EventName="MouseDoubleClick"> <b:EventTrigger EventName="MouseDoubleClick">
<b:InvokeCommandAction Command="{Binding SelectAssemblyListCommand}" /> <b:InvokeCommandAction Command="{Binding SelectAssemblyListCommand}" />
</b:EventTrigger> </b:EventTrigger>
<b:KeyTrigger Key="Return" FiredOn="KeyDown">
<b:InvokeCommandAction Command="{Binding SelectAssemblyListCommand}" />
</b:KeyTrigger>
<b:KeyTrigger Key="Delete" FiredOn="KeyDown">
<b:InvokeCommandAction Command="{Binding DeleteCommand}" CommandParameter="{Binding ., RelativeSource={RelativeSource AncestorType=Window}}" />
</b:KeyTrigger>
</b:Interaction.Triggers> </b:Interaction.Triggers>
</ListBox> </ListBox>

Loading…
Cancel
Save