Browse Source

Copy key/value/names ContextMenu for resource tables

pull/3024/head
miloush 2 years ago
parent
commit
f267c4346a
  1. 10
      ILSpy/Controls/ResourceObjectTable.xaml
  2. 21
      ILSpy/Controls/ResourceObjectTable.xaml.cs
  3. 9
      ILSpy/Controls/ResourceStringTable.xaml
  4. 17
      ILSpy/Controls/ResourceStringTable.xaml.cs

10
ILSpy/Controls/ResourceObjectTable.xaml

@ -22,6 +22,16 @@ @@ -22,6 +22,16 @@
Value="{Binding RelativeSource={RelativeSource Self},
Path=(ItemsControl.AlternationIndex),
Converter={StaticResource BackgroundConverter}}" />
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="_Copy" Command="ApplicationCommands.Copy" />
<MenuItem Header="Copy _name" Command="ApplicationCommands.Copy" CommandParameter="Key" />
<MenuItem Header="Copy _value" Command="ApplicationCommands.Copy" CommandParameter="Value" />
<MenuItem Header="Copy _type" Command="ApplicationCommands.Copy" CommandParameter="Type" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>

21
ILSpy/Controls/ResourceObjectTable.xaml.cs

@ -81,6 +81,27 @@ namespace ICSharpCode.ILSpy.Controls @@ -81,6 +81,27 @@ namespace ICSharpCode.ILSpy.Controls
StringBuilder sb = new StringBuilder();
foreach (var item in resourceListView.SelectedItems)
{
if (item is TreeNodes.ResourcesFileTreeNode.SerializedObjectRepresentation so)
{
switch (args.Parameter)
{
case "Key":
sb.AppendLine(so.Key);
continue;
case "Value":
sb.AppendLine(so.Value);
continue;
case "Type":
sb.AppendLine(so.Type);
continue;
default:
sb.AppendLine($"{so.Key}\t{so.Value}\t{so.Type}");
continue;
}
}
sb.AppendLine(item.ToString());
}
Clipboard.SetText(sb.ToString());

9
ILSpy/Controls/ResourceStringTable.xaml

@ -22,6 +22,15 @@ @@ -22,6 +22,15 @@
Value="{Binding RelativeSource={RelativeSource Self},
Path=(ItemsControl.AlternationIndex),
Converter={StaticResource BackgroundConverter}}" />
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="_Copy" Command="ApplicationCommands.Copy" />
<MenuItem Header="Copy _name" Command="ApplicationCommands.Copy" CommandParameter="Key" />
<MenuItem Header="Copy _value" Command="ApplicationCommands.Copy" CommandParameter="Value" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>

17
ILSpy/Controls/ResourceStringTable.xaml.cs

@ -81,6 +81,23 @@ namespace ICSharpCode.ILSpy.Controls @@ -81,6 +81,23 @@ namespace ICSharpCode.ILSpy.Controls
StringBuilder sb = new StringBuilder();
foreach (var item in resourceListView.SelectedItems)
{
if (item is KeyValuePair<string, string> pair)
{
switch (args.Parameter)
{
case "Key":
sb.AppendLine(pair.Key);
continue;
case "Value":
sb.AppendLine(pair.Value);
continue;
default:
sb.AppendLine($"{pair.Key}\t{pair.Value}");
continue;
}
}
sb.AppendLine(item.ToString());
}
Clipboard.SetText(sb.ToString());

Loading…
Cancel
Save