Skip to content

Commit

Permalink
support copy content in debug/trace output
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed May 16, 2022
1 parent b080ea7 commit a9eefc2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
13 changes: 13 additions & 0 deletions CadAddinManager/View/Control/LogControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
Text="{Binding Message}" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy"
CanExecute="RightClickCopyCmdCanExecute" Executed="RightClickCopyCmdExecuted" />
</ListBox.CommandBindings>
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Command="Copy">
<MenuItem.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" CanExecute="RightClickCopyCmdCanExecute" Executed="RightClickCopyCmdExecuted" />
</MenuItem.CommandBindings>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
Expand Down
20 changes: 18 additions & 2 deletions CadAddinManager/View/Control/LogControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Windows.Controls;
using System.Text;
using System.Windows.Forms;
using System.Windows.Input;
using CadAddinManager.Model;
using CadAddinManager.ViewModel;
using UserControl = System.Windows.Controls.UserControl;

namespace CadAddinManager.View.Control
{
Expand All @@ -18,6 +22,18 @@ public LogControl()
this.Unloaded += viewModel.UserControl_Unloaded;

}

private void RightClickCopyCmdExecuted(object sender, ExecutedRoutedEventArgs e)
{
StringBuilder sb = new StringBuilder();
foreach (LogMessageString dd in listBox_LogMessages.SelectedItems)
{
sb.AppendLine(dd.Message);
}
Clipboard.SetText(sb.ToString());
}
private void RightClickCopyCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = listBox_LogMessages.SelectedItem != null;
}
}
}

0 comments on commit a9eefc2

Please sign in to comment.