コード例 #1
0
        private List <int> SortGraphs(List <PlottedGraph> graphs, PreviewSortMethod order)
        {
            List <int> result = new List <int>();

            switch (order)
            {
            case PreviewSortMethod.InstructionCount:
                result = graphs.ToList().OrderByDescending(x => x.InternalProtoGraph.TotalInstructions).Select(x => graphs.IndexOf(x)).ToList();
                break;

            case PreviewSortMethod.LastUpdated:
                result = graphs.ToList().OrderByDescending(x => x.InternalProtoGraph.LastUpdated).Select(x => graphs.IndexOf(x)).ToList();
                break;

            case PreviewSortMethod.ThreadID:
                result = graphs.ToList().OrderBy(x => x.TID).Select(x => graphs.IndexOf(x)).ToList();
                break;

            case PreviewSortMethod.StartOrder:
                result = Enumerable.Range(0, DrawnPreviewGraphs.Count).ToList();
                break;

            default:
                Logging.RecordLogEvent($"Bad preview sort order: {order}");
                break;
            }

            return(result);
        }
コード例 #2
0
        private bool HandlePreviewGraphContextMenu()
        {
            if (ActiveTrace is null)
            {
                return(false);
            }

            if (ImGui.BeginPopupContextItem("GraphWidgetCtxMenu", ImGuiPopupFlags.MouseButtonRight))
            {
                _lastCtxMenu = DateTime.Now;
                ImGui.Text($"Sort ({_activeSortMethod})");
                ImGui.Separator();
                if (ImGui.MenuItem("Start Order", "S", _activeSortMethod == PreviewSortMethod.StartOrder, true))
                {
                    _cachedSorts.Remove(ActiveTrace);
                    _activeSortMethod = PreviewSortMethod.StartOrder;
                }
                if (ImGui.MenuItem("Instruction Count", "I", _activeSortMethod == PreviewSortMethod.InstructionCount, true))
                {
                    _cachedSorts.Remove(ActiveTrace);
                    _activeSortMethod = PreviewSortMethod.InstructionCount;
                }
                if (ImGui.MenuItem("Recent Activity", "A", _activeSortMethod == PreviewSortMethod.LastUpdated, true))
                {
                    _cachedSorts.Remove(ActiveTrace);
                    _activeSortMethod = PreviewSortMethod.LastUpdated;
                }
                if (ImGui.MenuItem("Thread ID", "T", _activeSortMethod == PreviewSortMethod.ThreadID, true))
                {
                    _cachedSorts.Remove(ActiveTrace);
                    _activeSortMethod = PreviewSortMethod.ThreadID;
                }


                PlottedGraph?hoverGraph = HoveredGraph;
                if (hoverGraph != null || PreviewPopupGraph != null)
                {
                    if (hoverGraph != null)
                    {
                        PreviewPopupGraph = hoverGraph;
                    }

                    ImGui.Separator();
                    ImGui.Text($"Graph {PreviewPopupGraph!.TID}");
                    if (!PreviewPopupGraph.InternalProtoGraph.Terminated && ImGui.MenuItem("Terminate"))
                    {
                        PreviewPopupGraph.InternalProtoGraph.TraceData.SendDebugCommand(PreviewPopupGraph.TID, "KILL");
                    }
                    if (!PreviewPopupGraph.InternalProtoGraph.Terminated && ImGui.MenuItem("Force Terminate"))
                    {
                        //todo - rgat doesn't detect this because pin threads still run, keeping pipes open
                        IntPtr handle = OpenThread(1, false, PreviewPopupGraph.TID);
                        if (handle != (IntPtr)0)
                        {
                            TerminateThread(handle, 0);
                            CloseHandle(handle);
                        }
                    }
                }

                ImGui.EndPopup();
                return(true);
            }
            PreviewPopupGraph = null;

            return(false);
        }