Skip to content

Commit

Permalink
Merge pull request #3024 from miloush/CopyResources
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer authored Jul 2, 2023
2 parents 1758547 + 925de03 commit e70c4ba
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ILSpy/Controls/ResourceObjectTable.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" InputGestureText=" " />
<MenuItem Header="Copy _value" Command="ApplicationCommands.Copy" CommandParameter="Value" InputGestureText=" " />
<MenuItem Header="Copy _type" Command="ApplicationCommands.Copy" CommandParameter="Type" InputGestureText=" " />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
Expand Down
21 changes: 21 additions & 0 deletions ILSpy/Controls/ResourceObjectTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@ void ExecuteCopy(object sender, ExecutedRoutedEventArgs args)
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());
Expand Down
9 changes: 9 additions & 0 deletions ILSpy/Controls/ResourceStringTable.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" InputGestureText=" " />
<MenuItem Header="Copy _value" Command="ApplicationCommands.Copy" CommandParameter="Value" InputGestureText=" " />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
Expand Down
17 changes: 17 additions & 0 deletions ILSpy/Controls/ResourceStringTable.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ void ExecuteCopy(object sender, ExecutedRoutedEventArgs args)
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());
Expand Down

0 comments on commit e70c4ba

Please # to comment.