Skip to content

Instantly share code, notes, and snippets.

@FriedrichWeinmann
Created January 28, 2018 12:05
Show Gist options
  • Save FriedrichWeinmann/9a95c0cc4745ad041e5f6a2dac71035e to your computer and use it in GitHub Desktop.
Save FriedrichWeinmann/9a95c0cc4745ad041e5f6a2dac71035e to your computer and use it in GitHub Desktop.
Iron Scripter 2018 Prequel 2 classes
using System;
namespace Fred.IronScripter2018
{
/// <summary>
/// Class containing information on a disk
/// </summary>
[Serializable]
public class DiskInfo
{
/// <summary>
/// The name of the computer the disk is installed on
/// </summary>
public string ComputerName;
/// <summary>
/// The ID of the drive
/// </summary>
public string Drive;
/// <summary>
/// What kind of drive is it?
/// </summary>
public string DriveType;
/// <summary>
/// What is the maximum capacity of this drive
/// </summary>
public long Size;
/// <summary>
/// How much free space is still available?
/// </summary>
public long FreeSpace;
/// <summary>
/// How much percent of the space is still in use?
/// </summary>
public double UsedPercent
{
get
{
if (Size == 0)
return 100;
return ((double)Size - (double)FreeSpace) / (double)Size * 100;
}
set
{
// Needs to not throw an exception on set for the type serializer
}
}
/// <summary>
/// Is the disk compressed?
/// </summary>
public bool Compressed;
/// <summary>
/// Creates the default drive display when as a property on another object
/// </summary>
/// <returns>The string representation of the drive</returns>
public override string ToString()
{
return String.Format("{0} : {1}%", Drive, Math.Round(UsedPercent, 2));
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Fred.IronScripter2018
{
/// <summary>
/// Information on a computer
/// </summary>
[Serializable]
public class SystemInformation
{
/// <summary>
/// The name of the computer it is installed on.
/// </summary>
public string ComputerName;
/// <summary>
/// Name of the OS
/// </summary>
public string Name;
/// <summary>
/// Version of the OS
/// </summary>
public Version Version;
/// <summary>
/// Installed Service Pack
/// </summary>
public string ServicePack;
/// <summary>
/// Manufacturer of the OS
/// </summary>
public string Manufacturer;
/// <summary>
/// Path where windows lies.
/// </summary>
public string WindowsDirectory;
/// <summary>
/// What locale the system is running under
/// </summary>
public string Locale;
/// <summary>
/// The amount of physical memory still available
/// </summary>
public long FreePhysicalMemory;
/// <summary>
/// The total virtual memory available
/// </summary>
public long VirtualMemory;
/// <summary>
/// The free amount of virtual memory still available
/// </summary>
public long FreeVirtualMemory;
/// <summary>
/// The disks installed on the system.
/// </summary>
public List<DiskInfo> Disks = new List<DiskInfo>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment