From 31093d66b711d8f541c3be15b03331bb3db2a2dc Mon Sep 17 00:00:00 2001
From: Abraham <69463303+abummoja@users.noreply.github.com>
Date: Thu, 21 Dec 2023 15:11:55 +0300
Subject: [PATCH] Added more options in details dialog
Minor improvements and details added in the details dialog
---
App.config | 6 +
Form1.Designer.cs | 198 ++++++++++++++++++++++++++
Form1.cs | 258 ++++++++++++++++++++++++++++++++++
Form1.resx | 120 ++++++++++++++++
Program.cs | 22 +++
Task Manager Lite.csproj | 124 ++++++++++++++++
Task Manager Lite.csproj.user | 16 +++
7 files changed, 744 insertions(+)
create mode 100644 App.config
create mode 100644 Form1.Designer.cs
create mode 100644 Form1.cs
create mode 100644 Form1.resx
create mode 100644 Program.cs
create mode 100644 Task Manager Lite.csproj
create mode 100644 Task Manager Lite.csproj.user
diff --git a/App.config b/App.config
new file mode 100644
index 0000000..5754728
--- /dev/null
+++ b/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Form1.Designer.cs b/Form1.Designer.cs
new file mode 100644
index 0000000..0c9efd2
--- /dev/null
+++ b/Form1.Designer.cs
@@ -0,0 +1,198 @@
+
+namespace Task_Manager_Lite
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.listBox1 = new System.Windows.Forms.ListBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.button2 = new System.Windows.Forms.Button();
+ this.tabControl1 = new System.Windows.Forms.TabControl();
+ this.tabPage1 = new System.Windows.Forms.TabPage();
+ this.tabPage2 = new System.Windows.Forms.TabPage();
+ this.listBox2 = new System.Windows.Forms.ListBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.button3 = new System.Windows.Forms.Button();
+ this.button4 = new System.Windows.Forms.Button();
+ this.button5 = new System.Windows.Forms.Button();
+ this.tabControl1.SuspendLayout();
+ this.tabPage1.SuspendLayout();
+ this.tabPage2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // listBox1
+ //
+ this.listBox1.FormattingEnabled = true;
+ this.listBox1.Location = new System.Drawing.Point(0, 0);
+ this.listBox1.Name = "listBox1";
+ this.listBox1.Size = new System.Drawing.Size(791, 485);
+ this.listBox1.TabIndex = 0;
+ this.listBox1.Click += new System.EventHandler(this.listItemClicked);
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(695, 515);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(101, 25);
+ this.button1.TabIndex = 1;
+ this.button1.Text = "Force Close";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.endOneProcess);
+ //
+ // button2
+ //
+ this.button2.Location = new System.Drawing.Point(525, 515);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(79, 25);
+ this.button2.TabIndex = 2;
+ this.button2.Text = "End All";
+ this.button2.UseVisualStyleBackColor = true;
+ this.button2.Click += new System.EventHandler(this.endAllProcesses);
+ //
+ // tabControl1
+ //
+ this.tabControl1.Controls.Add(this.tabPage1);
+ this.tabControl1.Controls.Add(this.tabPage2);
+ this.tabControl1.Location = new System.Drawing.Point(1, 0);
+ this.tabControl1.Name = "tabControl1";
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new System.Drawing.Size(799, 509);
+ this.tabControl1.TabIndex = 4;
+ //
+ // tabPage1
+ //
+ this.tabPage1.Controls.Add(this.listBox1);
+ this.tabPage1.Location = new System.Drawing.Point(4, 22);
+ this.tabPage1.Name = "tabPage1";
+ this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage1.Size = new System.Drawing.Size(791, 483);
+ this.tabPage1.TabIndex = 0;
+ this.tabPage1.Text = "Running Apps";
+ this.tabPage1.UseVisualStyleBackColor = true;
+ //
+ // tabPage2
+ //
+ this.tabPage2.Controls.Add(this.listBox2);
+ this.tabPage2.Location = new System.Drawing.Point(4, 22);
+ this.tabPage2.Name = "tabPage2";
+ this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage2.Size = new System.Drawing.Size(791, 483);
+ this.tabPage2.TabIndex = 1;
+ this.tabPage2.Text = "Background Processes";
+ this.tabPage2.UseVisualStyleBackColor = true;
+ //
+ // listBox2
+ //
+ this.listBox2.FormattingEnabled = true;
+ this.listBox2.Location = new System.Drawing.Point(0, 0);
+ this.listBox2.Name = "listBox2";
+ this.listBox2.Size = new System.Drawing.Size(795, 485);
+ this.listBox2.TabIndex = 0;
+ this.listBox2.Click += new System.EventHandler(this.listBgProcClicked);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(79, 521);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(104, 13);
+ this.label1.TabIndex = 5;
+ this.label1.Text = "No process selected";
+ //
+ // button3
+ //
+ this.button3.Location = new System.Drawing.Point(440, 515);
+ this.button3.Name = "button3";
+ this.button3.Size = new System.Drawing.Size(79, 25);
+ this.button3.TabIndex = 6;
+ this.button3.Text = "Details";
+ this.button3.UseVisualStyleBackColor = true;
+ this.button3.Click += new System.EventHandler(this.showDetails);
+ //
+ // button4
+ //
+ this.button4.Location = new System.Drawing.Point(347, 516);
+ this.button4.Name = "button4";
+ this.button4.Size = new System.Drawing.Size(87, 24);
+ this.button4.TabIndex = 7;
+ this.button4.Text = "Refresh";
+ this.button4.UseVisualStyleBackColor = true;
+ this.button4.Click += new System.EventHandler(this.RfClicked);
+ //
+ // button5
+ //
+ this.button5.Location = new System.Drawing.Point(610, 515);
+ this.button5.Name = "button5";
+ this.button5.Size = new System.Drawing.Size(79, 25);
+ this.button5.TabIndex = 8;
+ this.button5.Text = "Close";
+ this.button5.UseVisualStyleBackColor = true;
+ this.button5.Click += new System.EventHandler(this.closeGraceFully);
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 543);
+ this.Controls.Add(this.button5);
+ this.Controls.Add(this.button4);
+ this.Controls.Add(this.button3);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.tabControl1);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.button1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.MaximizeBox = false;
+ this.Name = "Form1";
+ this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.Text = "Task Manager Lite";
+ this.tabControl1.ResumeLayout(false);
+ this.tabPage1.ResumeLayout(false);
+ this.tabPage2.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.TabControl tabControl1;
+ private System.Windows.Forms.TabPage tabPage1;
+ private System.Windows.Forms.TabPage tabPage2;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ListBox listBox2;
+ private System.Windows.Forms.Button button3;
+ private System.Windows.Forms.Button button4;
+ private System.Windows.Forms.Button button5;
+ }
+}
+
diff --git a/Form1.cs b/Form1.cs
new file mode 100644
index 0000000..a6d1919
--- /dev/null
+++ b/Form1.cs
@@ -0,0 +1,258 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Task_Manager_Lite
+{
+ public partial class Form1 : Form
+ {
+ int CURRENT = 1;
+ public Form1()
+ {
+ InitializeComponent();
+ ListProcesses();
+ tabPage1.GotFocus += TabPage1_GotFocus;
+ tabPage2.GotFocus += TabPage2_GotFocus;
+ try
+ {
+ getUsers();
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("Error");
+ }
+ }
+
+ private void TabPage2_GotFocus(object sender, EventArgs e)
+ {
+ CURRENT = 2;
+ Form1.ActiveForm.Text = Form1.ActiveForm.Text + ":Background Apps";
+ //button3.Enabled = false;
+ if(button3.Enabled == true)
+ {
+ button3.Enabled = false;
+ }
+ }
+
+ private void TabPage1_GotFocus(object sender, EventArgs e)
+ {
+ CURRENT = 1;
+ Form1.ActiveForm.Text = Form1.ActiveForm.Text + ":Foreground Apps";
+ if(button3.Enabled == false)
+ {
+ button3.Enabled = true;
+ }
+ }
+
+ private void ListProcesses()
+ {
+ listBox1.Items.Clear();
+ listBox2.Items.Clear();
+ Process[] processes = Process.GetProcesses();
+ foreach(Process p in processes)
+ {
+ if (!string.IsNullOrEmpty(p.MainWindowTitle))
+ {
+ //Console.WriteLine(p.ProcessName);
+ listBox1.Items.Add(p.ProcessName);
+ listBox1.Sorted = true;
+ }
+ else
+ {
+ listBox2.Items.Add(p.ProcessName);
+ listBox2.Sorted = true;
+ }
+
+ }
+ }
+
+ private void endOneProcess(object sender, EventArgs e)
+ {
+ Process[] p = Process.GetProcessesByName(label1.Text);
+ foreach(var proc in p)
+ {
+ try
+ {
+ proc.Kill();
+ }catch (Exception)
+ {
+ try
+ {
+ proc.Close();
+ }catch(Exception Ve)
+ {
+ MessageBox.Show("Could not end the task.");
+ }
+ }
+ }
+ ListProcesses();
+ }
+
+
+ private void endAllProcesses(object sender, EventArgs e)
+ {
+ Process[] processes = Process.GetProcesses();
+ foreach (Process p in processes)
+ {
+ p.Kill();
+ }
+ }
+
+ private void listItemClicked(object sender, EventArgs e)
+ {
+ getProcess(listBox1);
+ }
+
+ private void getProcess(ListBox listBox)
+ {
+ string selectedItem = listBox.SelectedItem.ToString();
+ label1.Text = selectedItem;
+ }
+
+ private void listBgProcClicked(object sender, EventArgs e)
+ {
+ getProcess(listBox2);
+ }
+
+ private void showDetails(object sender, EventArgs e)
+ {
+ Process[] p = Process.GetProcessesByName(label1.Text);
+ foreach(var pr in p)
+ {
+ string name = pr.ProcessName.ToString();
+ if(name.Equals("Task Manager Lite"))
+ {
+ name = "This Application (Task Manager Lite)";
+ }
+ var id = pr.Id;
+ var path = "SysWin";
+ try
+ {
+ path = pr.MainModule.FileName;
+ }
+ catch (Exception)
+ {
+ path = "System32";
+ }
+
+ var mwinTitle = pr.MainWindowTitle;
+ string w64 = pr.WorkingSet64.ToString();
+ // string ws = pr.WorkingSet.ToString();
+ string bp = pr.BasePriority.ToString();
+ string pc;
+ try
+ {
+ pc = pr.PriorityClass.ToString();
+
+ }
+ catch (Exception)
+ {
+ pc = "Background Process";
+ }
+ string uproc;
+ try
+ {
+ uproc = pr.UserProcessorTime.ToString();
+ }
+ catch (Exception)
+ {
+ uproc = "Unavailable";
+ }
+ string pproc;
+ try
+ {
+ pproc = pr.PrivilegedProcessorTime.ToString();
+ }
+ catch (Exception)
+ {
+ pproc = "Unavailable";
+ }
+ string tproc;
+ try
+ {
+ tproc = pr.TotalProcessorTime.ToString();
+ }
+ catch (Exception)
+ {
+ tproc = "Unhandled";
+ }
+ string psysmem = pr.PagedSystemMemorySize64.ToString();
+ string pmem = pr.PagedMemorySize64.ToString();
+ string resp = pr.Responding.ToString();
+ String details = "Name: "+name+"\nId: "+id+"\nPath: "+path+"\nMain Window Title: "+mwinTitle+"\nWorking set: " + w64+"\nBase priority: "+bp+"\nPriorityClass: "
+ +pc+"\nProcessor Time: "+uproc+"\nPrivileged Time: "+pproc+"\nTotal Processor Time: "+tproc+"\nPaged System Memory: "+psysmem
+ +"\nPaged Memory: "+pmem+"\nIs Responsive: "+resp;
+ MessageBox.Show(details);
+
+
+
+ }
+ }
+
+ void refreshProcess()
+ {
+ Process[] p = Process.GetProcessesByName(label1.Text);
+ foreach (var proc in p)
+ {
+ try
+ {
+ proc.Refresh();
+ }
+ catch (Exception)
+ {
+ MessageBox.Show("Unable to refresh");
+ }
+
+ }
+ }
+
+ private void RfClicked(object sender, EventArgs e)
+ {
+ refreshProcess();
+ }
+
+ private void closeGraceFully(object sender, EventArgs e)
+ {
+ Process[] p = Process.GetProcessesByName(label1.Text);
+ foreach (var proc in p)
+ {
+ try
+ {
+ proc.CloseMainWindow();
+ }
+ catch (Exception)
+ {
+ try
+ {
+ proc.Close();
+ }
+ catch (Exception)
+ {
+ MessageBox.Show("Could not end the task.");
+ }
+ }
+ }
+ ListProcesses();
+ }
+
+ void getUsers()
+ {
+ //TODO: get users and their CPU Usage to allow us to force log them out#
+ string path = @"C:\Users\";
+ string[] usrs = System.IO.Directory.GetDirectories(path);
+
+ foreach(string usr in usrs)
+ {
+ Console.WriteLine(usr.LastIndexOf("/"));
+ //ERROR: The code above returns -1
+ }
+ }
+ }
+}
diff --git a/Form1.resx b/Form1.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..e2ce9dc
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Task_Manager_Lite
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/Task Manager Lite.csproj b/Task Manager Lite.csproj
new file mode 100644
index 0000000..6055aa6
--- /dev/null
+++ b/Task Manager Lite.csproj
@@ -0,0 +1,124 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {D427BC85-D3FC-4701-BE27-2AD94A16C9A0}
+ WinExe
+ Task_Manager_Lite
+ Task Manager Lite
+ v4.7.2
+ 512
+ true
+ true
+ false
+ C:\Users\Admin\Downloads\Task Mgr Lite\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 2
+ 1.0.0.%2a
+ false
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ D4AB154EE6C64D9010CACB3B7AD3C0C457F18466
+
+
+ Task Manager Lite_TemporaryKey.pfx
+
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.7.2 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
\ No newline at end of file
diff --git a/Task Manager Lite.csproj.user b/Task Manager Lite.csproj.user
new file mode 100644
index 0000000..46b9239
--- /dev/null
+++ b/Task Manager Lite.csproj.user
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+ en-US
+ false
+
+
+ false
+
+
\ No newline at end of file