Browse Source

add context menu to watches

pull/59/merge
Siegfried Pammer 13 years ago
parent
commit
d2a7f9891b
  1. 33
      src/AddIns/Debugger/Debugger.AddIn/Pads/CommonResources.xaml
  2. 10
      src/AddIns/Debugger/Debugger.AddIn/Tooltips/DebuggerTooltipControl.xaml
  3. 29
      src/AddIns/Debugger/Debugger.AddIn/TreeModel/Commands.cs
  4. 10
      src/Main/ICSharpCode.Core.Presentation/NotBoolConverter.cs

33
src/AddIns/Debugger/Debugger.AddIn/Pads/CommonResources.xaml

@ -6,6 +6,7 @@
xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:tv="http://icsharpcode.net/sharpdevelop/treeview" xmlns:tv="http://icsharpcode.net/sharpdevelop/treeview"
> >
<core:ContextMenuBuilder x:Key="menuBuilder" />
<Style x:Key="itemContainerStyle" TargetType="{x:Type ListViewItem}"> <Style x:Key="itemContainerStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
@ -39,8 +40,15 @@
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<tv:SharpTreeNodeView/> <tv:SharpTreeNodeView />
<local:AutoCompleteTextBox Margin="-6 0 0 0" MinWidth="100" Text="{Binding Node.Name}" IsEditable="{Binding Node.CanSetName}"/> <local:AutoCompleteTextBox x:Name="name" Margin="-6 0 0 0" MinWidth="100" Text="{Binding Node.Name}" IsEditable="{Binding Node.CanSetName}">
<local:AutoCompleteTextBox.ContextMenu>
<MultiBinding Converter="{StaticResource menuBuilder}">
<Binding Path="Node.ContextMenuAddInTreeEntry" />
<Binding Path="Node" />
</MultiBinding>
</local:AutoCompleteTextBox.ContextMenu>
</local:AutoCompleteTextBox>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
@ -48,14 +56,31 @@
<GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.ValueColumn}" Width="200"> <GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.ValueColumn}" Width="200">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<local:AutoCompleteTextBox MinWidth="100" Text="{Binding Node.Value}" IsEditable="{Binding Node.CanSetValue}"/> <local:AutoCompleteTextBox
MinWidth="100"
Text="{Binding Node.Value}"
IsEditable="{Binding Node.CanSetValue}">
<local:AutoCompleteTextBox.ContextMenu>
<MultiBinding Converter="{StaticResource menuBuilder}">
<Binding Path="Node.ContextMenuAddInTreeEntry" />
<Binding Path="Node" />
</MultiBinding>
</local:AutoCompleteTextBox.ContextMenu>
</local:AutoCompleteTextBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.TypeColumn}" Width="200"> <GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.TypeColumn}" Width="200">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<local:AutoCompleteTextBox MinWidth="100" Text="{Binding Node.Type}" IsEditable="False"/> <local:AutoCompleteTextBox MinWidth="100" Text="{Binding Node.Type}" IsEditable="False">
<local:AutoCompleteTextBox.ContextMenu>
<MultiBinding Converter="{StaticResource menuBuilder}">
<Binding Path="Node.ContextMenuAddInTreeEntry" />
<Binding Path="Node" />
</MultiBinding>
</local:AutoCompleteTextBox.ContextMenu>
</local:AutoCompleteTextBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>

10
src/AddIns/Debugger/Debugger.AddIn/Tooltips/DebuggerTooltipControl.xaml

@ -273,9 +273,15 @@
x:Name="valueText" x:Name="valueText"
Style="{StaticResource TextStyle}" Style="{StaticResource TextStyle}"
IsEnabled="{Binding CanSetValue}" IsEnabled="{Binding CanSetValue}"
ContextMenu="{Binding ContextMenuAddInTreeEntry, Converter={StaticResource menuBuilder}, ConverterParameter={x:Reference dataGrid}}"
ContextMenuService.ShowOnDisabled="True" ContextMenuService.ShowOnDisabled="True"
Text="{Binding Value}" /> Text="{Binding Value}">
<TextBox.ContextMenu>
<MultiBinding Converter="{StaticResource menuBuilder}">
<Binding Path="ContextMenuAddInTreeEntry" />
<Binding />
</MultiBinding>
</TextBox.ContextMenu>
</TextBox>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>

29
src/AddIns/Debugger/Debugger.AddIn/TreeModel/Commands.cs

@ -14,25 +14,9 @@ namespace Debugger.AddIn.TreeModel
{ {
public override void Execute(object parameter) public override void Execute(object parameter)
{ {
var grid = parameter as DataGrid; var node = parameter as ValueNode;
if (grid == null) return; if (node == null) return;
var selection = FormatValue(grid.SelectedItems.OfType<ValueNode>()); SD.Clipboard.SetText(node.FullText);
SD.Clipboard.SetText(selection);
}
string FormatValue(IEnumerable<ValueNode> nodes)
{
StringBuilder b = new StringBuilder();
bool first = true;
foreach (var node in nodes) {
if (first)
first = false;
else
b.AppendLine();
b.Append(node.FullText);
}
return b.ToString();
} }
} }
@ -40,10 +24,9 @@ namespace Debugger.AddIn.TreeModel
{ {
public override void Execute(object parameter) public override void Execute(object parameter)
{ {
var grid = parameter as DataGrid; var node = parameter as ValueNode;
if (grid == null) return; if (node == null) return;
var error = grid.SelectedItems.OfType<ValueNode>().Select(node => node.error).Single(); SD.MessageService.ShowException(node.error, null);
SD.MessageService.ShowException(error, null);
} }
} }
} }

10
src/Main/ICSharpCode.Core.Presentation/NotBoolConverter.cs

@ -31,17 +31,17 @@ namespace ICSharpCode.Core.Presentation
} }
} }
public class ContextMenuBuilder : IValueConverter public class ContextMenuBuilder : IMultiValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{ {
if (value is string) { if (values.Length == 2 && values[0] is string) {
return MenuService.CreateContextMenu(parameter, (string)value); return MenuService.CreateContextMenu(values[1], (string)values[0]);
} }
throw new NotSupportedException(); throw new NotSupportedException();
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }

Loading…
Cancel
Save