Files
Terminal.Gui/UICatalog/Scenarios/ProcessTable.cs
Tig bc41d9bc09 Fixes #2465 - Simplify/Enforce LayoutStyle.Absolute when X, Y, Width, and/or Height are null or Absolute() (#2467)
* Merged v2_develop; updated API docs

* Code cleanup

* Fixed code that was using Dim/Pos before IsInit

* Fixed ComboBox using Bounds before IsInitalized and grabbing focus when it shouldn't

* Fixed ComboBox tests. Fixed FileDialog

* Fixed all !IsInitalized warnings

* Fixed AllviewsTester

* Fixed CharMap scenario

* Fixed ColorPicker (hack)

* Fixed CoputedLayout and Csv Editor

* Imrpoved warning

* Fixed more warnings

* Fixed GetTextFormatterSizeNeededForTextAndHotKey

* Fixed AllViewsTester

* AllViewsTester code cleanup

* AllViewsTester code cleanup

* AllViewsTester fixed for realz

* Decided Fill was better than Percent for default
2024-01-04 10:40:47 -07:00

62 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
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 ();
}
}
}