private void SelectFrame(uint threadId, ParallelStackFrameModel selectedItem) { if (selectedItem == null) { return; } var thread = Process.Threads.Find(t => t.ID == threadId); if (thread == null) { return; } if (StackSelected != null) { StackSelected(this, EventArgs.Empty); } this.IsSelected = true; foreach (var frame in thread.Callstack) { if (frame.GetMethodName() == selectedItem.MethodName) { if (!selectedItem.IsRunningStackFrame) { selectedItem.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source; } SourcecodeSegment nextStatement = frame.NextStatement; if (nextStatement != null) { var location = new Location(nextStatement.StartColumn, nextStatement.StartLine); FileService.JumpToFilePosition( nextStatement.Filename, location.Line, location.Column); if (FrameSelected != null) { FrameSelected(this, new FrameSelectedEventArgs(frame, location)); } } break; } } }
private void Datagrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { if (Process.IsRunning) { return; } ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; if (selectedItem == null) { return; } datagrid.ContextMenu = CreateContextMenu(selectedItem); datagrid.ContextMenu.IsOpen = true; }
ContextMenu CreateContextMenu(ParallelStackFrameModel item) { var menu = new ContextMenu(); foreach (var id in ThreadIds) { MenuItem m = new MenuItem(); m.IsCheckable = true; m.IsChecked = id == Process.SelectedThread.ID; m.Click += delegate(object sender, RoutedEventArgs e) { var menuItem = e.OriginalSource as MenuItem; SelectFrame((uint)menuItem.Tag, item); }; m.Tag = id; m.Header = id.ToString() + ":" + item.MethodName; menu.Items.Add(m); } return(menu); }
private void Datagrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (Process.IsRunning) { return; } ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; if (selectedItem != null) { if (ThreadIds.Count > 1) { datagrid.ContextMenu = CreateContextMenu(selectedItem); datagrid.ContextMenu.IsOpen = true; } else { SelectFrame(ThreadIds[0], selectedItem); } } }
private void OnToolTipOpening(object sender, ToolTipEventArgs e) { if (Process.IsRunning) { return; } StackPanel panel = new StackPanel(); ParallelStackFrameModel selectedItem = datagrid.SelectedItem as ParallelStackFrameModel; if (selectedItem == null) { panel.Children.Add(new TextBlock { Text = "No item selected" }); this.toolTip.Content = panel; return; } foreach (var thread in Process.Threads) { if (ThreadIds.Contains(thread.ID)) { foreach (var frame in thread.Callstack) { if (selectedItem.MethodName == frame.GetMethodName()) { TextBlock tb = new TextBlock(); tb.Text = thread.ID + ": " + CallStackPadContent.GetFullName(frame); panel.Children.Add(tb); } } } } this.toolTip.Content = panel; }