diff --git a/ILSpy/AssemblyListManager.cs b/ILSpy/AssemblyListManager.cs index 02e041600..0682256ff 100644 --- a/ILSpy/AssemblyListManager.cs +++ b/ILSpy/AssemblyListManager.cs @@ -91,16 +91,18 @@ namespace ICSharpCode.ILSpy }); } - public void CreateList(AssemblyList list) + public bool CreateList(AssemblyList list) { if (!AssemblyLists.Contains(list.ListName)) { AssemblyLists.Add(list.ListName); SaveList(list); + return true; } + return false; } - public void DeleteList(string Name) + public bool DeleteList(string Name) { if (AssemblyLists.Contains(Name)) { @@ -118,7 +120,9 @@ namespace ICSharpCode.ILSpy if (listElement != null) listElement.Remove(); }); + return true; } + return false; } } } diff --git a/ILSpy/CreateListDialog.xaml b/ILSpy/CreateListDialog.xaml new file mode 100644 index 000000000..b0c20d25d --- /dev/null +++ b/ILSpy/CreateListDialog.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/CreateListDialog.xaml.cs b/ILSpy/CreateListDialog.xaml.cs new file mode 100644 index 000000000..a0259828b --- /dev/null +++ b/ILSpy/CreateListDialog.xaml.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ICSharpCode.ILSpy +{ + /// + /// Interaction logic for Create.xaml + /// + public partial class CreateListDialog : Window + { + public CreateListDialog() + { + InitializeComponent(); + } + + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + okButton.IsEnabled = !string.IsNullOrWhiteSpace(ListName.Text); + } + + private void OKButton_Click(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(ListName.Text)) + { + this.DialogResult = true; + } + } + + public string NewListName + { + get + { + return ListName.Text; + } + } + + } +} \ No newline at end of file diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 25f93f1c5..0c958caac 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -108,6 +108,9 @@ + + CreateListDialog.xaml + @@ -268,6 +271,10 @@ SearchBox.cs + + Designer + MSBuild:Compile + diff --git a/ILSpy/OpenListDialog.xaml b/ILSpy/OpenListDialog.xaml index e43394745..7a0626c62 100644 --- a/ILSpy/OpenListDialog.xaml +++ b/ILSpy/OpenListDialog.xaml @@ -5,7 +5,7 @@ WindowStartupLocation="CenterOwner" ResizeMode="CanResizeWithGrip" MinWidth="380" - MinHeight="150" + MinHeight="250" Height="350" Width="380" FocusManager.FocusedElement="{Binding ElementName=listView}"> diff --git a/ILSpy/OpenListDialog.xaml.cs b/ILSpy/OpenListDialog.xaml.cs index e9260bd1c..6a739c2e7 100644 --- a/ILSpy/OpenListDialog.xaml.cs +++ b/ILSpy/OpenListDialog.xaml.cs @@ -55,7 +55,6 @@ namespace ICSharpCode.ILSpy void OKButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = true; - Close(); } public string SelectedListName @@ -152,12 +151,29 @@ namespace ICSharpCode.ILSpy private void CreateButton_Click(object sender, RoutedEventArgs e) { + CreateListDialog dlg = new CreateListDialog(); + dlg.Owner = this; + dlg.Closing += (s, args) => + { + if (dlg.DialogResult == true) + { + if (manager.AssemblyLists.Contains(dlg.NewListName)) + { + args.Cancel = true; + MessageBox.Show("A list with the same name was found.", null, MessageBoxButton.OK); + } + } + }; + if (dlg.ShowDialog() == true) + { + manager.CreateList(new AssemblyList(dlg.NewListName)); + } } private void RemoveButton_Click(object sender, RoutedEventArgs e) { - if(listView.SelectedItem != null) + if (listView.SelectedItem != null) manager.DeleteList(listView.SelectedItem.ToString()); }