Browse Source

Added the possibility to create lists.

pull/254/head
Dick van den Brink 14 years ago
parent
commit
dcc834a27d
  1. 8
      ILSpy/AssemblyListManager.cs
  2. 24
      ILSpy/CreateListDialog.xaml
  3. 49
      ILSpy/CreateListDialog.xaml.cs
  4. 7
      ILSpy/ILSpy.csproj
  5. 2
      ILSpy/OpenListDialog.xaml
  6. 18
      ILSpy/OpenListDialog.xaml.cs

8
ILSpy/AssemblyListManager.cs

@ -91,16 +91,18 @@ namespace ICSharpCode.ILSpy @@ -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 @@ -118,7 +120,9 @@ namespace ICSharpCode.ILSpy
if (listElement != null)
listElement.Remove();
});
return true;
}
return false;
}
}
}

24
ILSpy/CreateListDialog.xaml

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
<Window
x:Class="ICSharpCode.ILSpy.CreateListDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
Title="New list"
Style="{DynamicResource DialogWindow}"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Width="300"
Height="150"
FocusManager.FocusedElement="{Binding ElementName=listView}">
<Grid Margin="12,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Label>Enter a list name:</Label>
<TextBox Margin="8,8" Name="ListName" TextChanged="TextBox_TextChanged"></TextBox>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="8,0">
<Button IsDefault="True" Margin="2,0" IsEnabled="False" Name="okButton" Click="OKButton_Click">Create</Button>
<Button IsCancel="True" Margin="2,0">Cancel</Button>
</StackPanel>
</Grid>
</Window>

49
ILSpy/CreateListDialog.xaml.cs

@ -0,0 +1,49 @@ @@ -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
{
/// <summary>
/// Interaction logic for Create.xaml
/// </summary>
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;
}
}
}
}

7
ILSpy/ILSpy.csproj

@ -108,6 +108,9 @@ @@ -108,6 +108,9 @@
<Compile Include="Commands\ExportCommandAttribute.cs" />
<Compile Include="Controls\SearchBox.cs" />
<Compile Include="Controls\SortableGridViewColumn.cs" />
<Compile Include="CreateListDialog.xaml.cs">
<DependentUpon>CreateListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Languages\CSharpLanguage.cs" />
<Compile Include="DecompilationOptions.cs" />
<Compile Include="ExtensionMethods.cs" />
@ -268,6 +271,10 @@ @@ -268,6 +271,10 @@
<Page Include="Controls\SearchBoxStyle.xaml">
<DependentUpon>SearchBox.cs</DependentUpon>
</Page>
<Page Include="CreateListDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml" />
<Page Include="OpenFromGacDialog.xaml" />
<Page Include="OpenListDialog.xaml" />

2
ILSpy/OpenListDialog.xaml

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
WindowStartupLocation="CenterOwner"
ResizeMode="CanResizeWithGrip"
MinWidth="380"
MinHeight="150"
MinHeight="250"
Height="350"
Width="380"
FocusManager.FocusedElement="{Binding ElementName=listView}">

18
ILSpy/OpenListDialog.xaml.cs

@ -55,7 +55,6 @@ namespace ICSharpCode.ILSpy @@ -55,7 +55,6 @@ namespace ICSharpCode.ILSpy
void OKButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
Close();
}
public string SelectedListName
@ -152,6 +151,23 @@ namespace ICSharpCode.ILSpy @@ -152,6 +151,23 @@ 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));
}
}

Loading…
Cancel
Save