mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* touching publish.yml * Moved Examples into ./Examples * Moved Benchmarks into ./Tests * Moved Benchmarks into ./Tests * Moved UICatalog into ./Examples * Moved UICatalog into ./Examples 2 * Moved tests into ./Tests * Updated nuget
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using Terminal.Gui;
|
|
|
|
namespace UICatalog.Scenarios;
|
|
|
|
[ScenarioMetadata ("ProcessTable", "Demonstrates TableView with the currently running processes.")]
|
|
[ScenarioCategory ("TableView")]
|
|
public class ProcessTable : Scenario
|
|
{
|
|
private TableView tableView;
|
|
|
|
public override void Main ()
|
|
{
|
|
Application.Init ();
|
|
var win = new Window
|
|
{
|
|
Title = GetName (),
|
|
Y = 1, // menu
|
|
Height = Dim.Fill (1) // status bar
|
|
};
|
|
|
|
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);
|
|
|
|
Application.Run (win);
|
|
win.Dispose ();
|
|
Application.Shutdown ();
|
|
}
|
|
|
|
private void CreateProcessTable ()
|
|
{
|
|
int ro = tableView.RowOffset;
|
|
int 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 ();
|
|
}
|
|
}
|