Files
Terminal.Gui/UICatalog/Scenarios/ProcessTable.cs
Tig 6851b42a49 Fixes #2921 - MainLoop refactoring (#2922)
* Adds basic MainLoop unit tests

* Remove WinChange action from Curses

* Remove WinChange action from Curses

* Remove ProcessInput action from Windows MainLoop

* Simplified MainLoop/ConsoleDriver by making MainLoop internal and moving impt fns to Application

* Modernized Terminal resize events

* Modernized Terminal resize events

* Removed un used property

* for _isWindowsTerminal devenv->wininit; not sure what changed

* Modernized mouse/keyboard events (Action->EventHandler)

* Updated OnMouseEvent API docs

* Using WT_SESSION to detect WT

* removes hacky GetParentProcess

* Updates to fix #2634 (clear last line)

* removes hacky GetParentProcess2

* Addressed mac resize issue

* Addressed mac resize issue

* Removes ConsoleDriver.PrepareToRun, has Init return MainLoop

* Removes unneeded Attribute methods

* Removed GetProcesssName

* Removed GetProcesssName

* Refactored KeyEvent and KeyEventEventArgs into a single class

* Revert "Refactored KeyEvent and KeyEventEventArgs into a single class"

This reverts commit 88a00658db.

* Fixed key repeat issue; reverted stupidity on 1049/1047 confusion

* Updated CSI API Docs

* merge
2023-10-21 08:06:04 -07:00

63 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using Terminal.Gui;
using System.Linq;
using System.Globalization;
using static Terminal.Gui.TableView;
using System.Diagnostics;
namespace UICatalog.Scenarios {
[ScenarioMetadata (Name: "ProcessTable", Description: "Demonstrates TableView with the currently running processes.")]
[ScenarioCategory ("TableView")]
public class ProcessTable : Scenario {
TableView tableView;
public override void Setup ()
{
Win.Title = this.GetName ();
Win.Y = 1; // menu
Win.Height = Dim.Fill (1); // status bar
Application.Top.LayoutSubviews ();
this.tableView = new TableView () {
X = 0,
Y = 0,
Width = Dim.Fill (),
Height = Dim.Fill (1),
};
// First time
CreateProcessTable ();
// Then every second
Application.AddTimeout (TimeSpan.FromSeconds (1),
() => {
CreateProcessTable ();
return true;
});
Win.Add (tableView);
}
private void CreateProcessTable ()
{
var ro = tableView.RowOffset;
var co = tableView.ColumnOffset;
tableView.Table = new EnumerableTableSource<Process> (Process.GetProcesses (),
new Dictionary<string, Func<Process, object>>() {
{ "ID",(p)=>p.Id},
{ "Name",(p)=>p.ProcessName},
{ "Threads",(p)=>p.Threads.Count},
{ "Virtual Memory",(p)=>p.VirtualMemorySize64},
{ "Working Memory",(p)=>p.WorkingSet64},
});
tableView.RowOffset = ro;
tableView.ColumnOffset = co;
tableView.EnsureValidScrollOffsets ();
}
}
}