Skip to content

Instantly share code, notes, and snippets.

@mjs3339
mjs3339 / DriveInformation.cs
Created February 25, 2018 14:31
C# Get Detailed Information on Installed Drives/Volumes
public class DriveInfoStruct
{
public string Access;
public string Caption;
public string Compressed;
public string Description;
public string DevicePath;
public List<DiskInfoStruct> DiskInformations = new List<DiskInfoStruct>();
public string DiskNumbers;
public string Drive;
@mjs3339
mjs3339 / SmartData.cs
Created February 25, 2018 14:39
C# S.M.A.R.T. (Self Monitoring, Analysis and Reporting Technology) Detection Class
public struct SData
{
public string Attribute;
public int RAWValue;
public string RAWValueS;
public int Value;
}
public static class SmartInformation
{
@mjs3339
mjs3339 / FindFile.cs
Created February 25, 2018 16:27
C# FindFile FindFirstFile FindNextFile IEnumerable
/// <summary>
/// var ff = new FindFile(); ff.Path = @"c:\"; (var _fd in ff) {var filepath = _fd.cFileName;}
/// </summary>
public class FindFile : IEnumerable<WIN32_FIND_DATA>
{
public string Path { get; set; }
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(Path);
@mjs3339
mjs3339 / CircularProgressBar.cs
Created March 14, 2018 22:35
C# Circular Progress Bar with Percentage
/// <summary>
/// Circular Progress bar with percentage
/// </summary>
public class CircularProgressBar : Control
{
public enum graphtypes
{
Standard,
Spin
}
@mjs3339
mjs3339 / Ellipse.cs
Created March 16, 2018 01:21
C# Shaded Ellipse Control Class
public class Ellipse : Control
{
private readonly IContainer components = null;
private Color _centerreflectioncolor = Color.FromArgb(180, 135, 206, 250);
private Color _color = Color.DodgerBlue;
private Color _lightColor, _darkColor, _darkDarkColor;
private bool _on = true;
private bool _reflectionon = true;
private readonly Color[] _surroundcolors = {Color.FromArgb(0, 135, 206, 250)};
public Ellipse()
@mjs3339
mjs3339 / ShadowBox.cs
Created March 16, 2018 23:47
C# ShadowBox Custom Control Class
public class ShadowBox : UserPanel
{
private Color _backColor = Color.White;
private Color _frameColor = Color.Silver;
private float _frameWidth = 12;
private Bitmap _offScreenBitmap;
private IContainer components;
public ShadowBox()
{
InitializeComponent();
@mjs3339
mjs3339 / TicksToTime.cs
Last active March 20, 2018 19:54
C# Tick Time Date Constants and Conversion
[Serializable]
public class TicksToTime
{
////--------------Constants---------------
public const double TicksPerMicrosecond = 10;
private const double MicrosecondsPerTick = 1.0 / TicksPerMicrosecond;
public const long TicksPerMillisecond = 10000;
private const double MillisecondsPerTick = 1.0 / TicksPerMillisecond;
public const long TicksPerSecond = TicksPerMillisecond * 1000;
private const double SecondsPerTick = 1.0 / TicksPerSecond;
@mjs3339
mjs3339 / StopwatchMs.cs
Created March 20, 2018 22:24
C# Stopwatch Class with Microseconds
public class StopwatchMs
{
private const long TicksPerMillisecond = 10000;
private const long TicksPerSecond = TicksPerMillisecond * 1000;
private const double TicksPerMicrosecond = 10;
public static readonly long Frequency;
public static readonly bool IsHighResolution;
private static readonly double tickFrequency;
private long elapsed;
private long startTimeStamp;
@mjs3339
mjs3339 / TextFontGraphics.cs
Created March 23, 2018 06:13
C# TextFontGraphics Class
public static class TextFontGraphics
{
public static int GetNumberOfLines(this string text)
{
return text.Split('\n').Length;
}
public static int GetTextCharacterCount(this string text)
{
return text.Count(c => c != '\r' && c != '\n');
}
@mjs3339
mjs3339 / CustomToolTip.cs
Last active March 23, 2018 14:54
C# Custom ToolTip with Adjustable Font, Background Image, and Border
public class CustomToolTip : ToolTip
{
private readonly float[] _GradientPositions;
private readonly ColorBlend gradientBlender;
private Color _gradientEndColor = Color.DeepSkyBlue;
private Color _gradientMiddleColor = Color.LightSkyBlue;
private Color _gradientStartColor = Color.LightSkyBlue;
public CustomToolTip()
{
Font = new Font("Arial Narrow", 9.75F, FontStyle.Bold, GraphicsUnit.Point, 0);