示例#1
0
        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;
                }
            }
        }
示例#2
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
                }
            }
        }
示例#5
0
        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;
        }