-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
561 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
|
||
namespace ResourceMonitor | ||
{ | ||
static class Battery | ||
{ | ||
private static readonly PowerStatus status = SystemInformation.PowerStatus; | ||
|
||
//Returns (hours, minutes, seconds) | ||
public static (int, int, int) BatteryRemains | ||
{ | ||
get | ||
{ | ||
int remainsInSeconds = status.BatteryLifeRemaining; | ||
int remainsInHour = remainsInSeconds / 60 / 60; | ||
int remainsMinute = (remainsInSeconds - remainsInHour * 3600) / 60; | ||
int remainsSecond = remainsInSeconds - remainsInHour * 3600 - remainsMinute * 60; | ||
return (remainsInHour, remainsMinute, remainsInSeconds); | ||
} | ||
} | ||
|
||
public static float BatteryPercent => status.BatteryLifePercent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ResourceMonitor | ||
{ | ||
static class CPU | ||
{ | ||
private static readonly PerformanceCounter counter = new PerformanceCounter("Processor", "% Processor Time", "_Total", Environment.MachineName); | ||
|
||
public static int Usage => (int)counter.NextValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.IO; | ||
|
||
namespace ResourceMonitor | ||
{ | ||
class Disk | ||
{ | ||
private static DirectoryInfo directoryInfo; | ||
|
||
public Disk(string path) | ||
{ | ||
directoryInfo = new DirectoryInfo(path); | ||
} | ||
|
||
private static float ToKB(long value) => value / 1024.0f; | ||
private static float ToMB(long value) => value / 1024.0f / 1024.0f; | ||
private static float ToGB(long value) => value / 1024.0f / 1024.0f / 1024.0f; | ||
|
||
private static float ConvertUnit(long value, SizeUnit unit) | ||
{ | ||
switch (unit) | ||
{ | ||
case SizeUnit.KB: | ||
return ToKB(value); | ||
case SizeUnit.MB: | ||
return ToMB(value); | ||
case SizeUnit.GB: | ||
return ToGB(value); | ||
} | ||
return 0.0f; | ||
} | ||
|
||
public float SolutionSize(SizeUnit unit) | ||
{ | ||
long size = 0; | ||
foreach (var fileInfo in directoryInfo.EnumerateFiles("*", SearchOption.AllDirectories)) | ||
{ | ||
Console.WriteLine($"{fileInfo.FullName} -> {fileInfo.Length}"); | ||
size += fileInfo.Length; | ||
} | ||
return ConvertUnit(size, unit); | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.