DotNet 4.8.1 build of DotNetBar

This commit is contained in:
2025-02-07 10:35:23 -05:00
parent 33439b63a0
commit 6b0a5d60f4
2609 changed files with 989814 additions and 7 deletions

View File

@@ -0,0 +1,206 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace DevComponents.DotNetBar.Metro.Helpers
{
internal static class ColorHelpers
{
public static HSVColor ColorToHSV(Color color)
{
double var_R = ((double)color.R / 255); //RGB from 0 to 255
double var_G = ((double)color.G / 255);
double var_B = ((double)color.B / 255);
double var_Min = Min(var_R, var_G, var_B); //Min. value of RGB
double var_Max = Max(var_R, var_G, var_B); //Max. value of RGB
double del_Max = var_Max - var_Min; //Delta RGB value
HSVColor hsv = new HSVColor();
hsv.Value = var_Max;
if (del_Max == 0) //This is a gray, no chroma...
{
hsv.Hue = 0; //HSV results from 0 to 1
hsv.Saturation = 0;
}
else //Chromatic data...
{
hsv.Saturation = del_Max / var_Max;
double del_R = (((var_Max - var_R) / 6) + (del_Max / 2)) / del_Max;
double del_G = (((var_Max - var_G) / 6) + (del_Max / 2)) / del_Max;
double del_B = (((var_Max - var_B) / 6) + (del_Max / 2)) / del_Max;
if (var_R == var_Max)
hsv.Hue = del_B - del_G;
else if (var_G == var_Max)
hsv.Hue = (1d / 3d) + del_R - del_B;
else if (var_B == var_Max)
hsv.Hue = (2d / 3d) + del_G - del_R;
if (hsv.Hue < 0) hsv.Hue += 1;
if (hsv.Hue > 1) hsv.Hue -= 1;
}
return hsv;
}
public static Color HSVToColor(double h, double s, double v)
{
return HSVToColor(new HSVColor(h, s, v));
}
public static Color HSVToColor(HSVColor hsv)
{
Color color;
if (hsv.Value < 0)
hsv.Value = 0;
else if (hsv.Value > 1)
hsv.Value = 1;
if (hsv.Saturation > 1)
hsv.Saturation = 1;
else if (hsv.Saturation < 0)
hsv.Saturation = 0;
if (hsv.Saturation == 0) //HSV from 0 to 1
{
color = Color.FromArgb((int)(hsv.Value * 255), (int)(hsv.Value * 255), (int)(hsv.Value * 255));
}
else
{
double var_h = hsv.Hue * 6;
if (var_h == 6) var_h = 0; //H must be < 1
int var_i = (int)var_h; //Or ... var_i = floor( var_h )
double var_1 = hsv.Value * (1 - hsv.Saturation);
double var_2 = hsv.Value * (1 - hsv.Saturation * (var_h - var_i));
double var_3 = hsv.Value * (1 - hsv.Saturation * (1 - (var_h - var_i)));
double var_r, var_g, var_b;
if (var_i == 0)
{
var_r = hsv.Value;
var_g = var_3;
var_b = var_1;
}
else if (var_i == 1)
{
var_r = var_2;
var_g = hsv.Value;
var_b = var_1;
}
else if (var_i == 2)
{
var_r = var_1;
var_g = hsv.Value;
var_b = var_3;
}
else if (var_i == 3)
{
var_r = var_1;
var_g = var_2;
var_b = hsv.Value;
}
else if (var_i == 4)
{
var_r = var_3;
var_g = var_1;
var_b = hsv.Value;
}
else
{
var_r = hsv.Value;
var_g = var_1;
var_b = var_2;
}
color = Color.FromArgb((int)(var_r * 255), (int)(var_g * 255), (int)(var_b * 255));
}
return color;
}
private static double Max(double rR, double rG, double rB)
{
double ret = 0;
if (rR > rG)
{
if (rR > rB)
ret = rR;
else
ret = rB;
}
else
{
if (rB > rG)
ret = rB;
else
ret = rG;
}
return ret;
}
private static double Min(double rR, double rG, double rB)
{
double ret = 0;
if (rR < rG)
{
if (rR < rB)
ret = rR;
else
ret = rB;
}
else
{
if (rB < rG)
ret = rB;
else
ret = rG;
}
return ret;
}
public static Color GetShadeColor(Color c)
{
if (c.IsEmpty) return Color.Black;
HSVColor hsv = ColorToHSV(c);
hsv.Value += hsv.Value > .5 ? -.2 : .2;
return HSVToColor(hsv);
}
}
internal struct HSVColor
{
/// <summary>
/// Gets or sets color hue. Hue is value from 0-1 which determines the degree on color wheel color is on, i.e. 0.5 = 180 degrees
/// </summary>
public double Hue;
/// <summary>
/// Gets or sets the color saturation from 0-1, i.e. 0-100%.
/// </summary>
public double Saturation;
/// <summary>
/// Gets or sets the amount of white and black in color.
/// </summary>
public double Value;
/// <summary>
/// Initializes a new instance of the HSVColor structure.
/// </summary>
/// <param name="hue"></param>
/// <param name="saturation"></param>
/// <param name="value"></param>
public HSVColor(double hue, double saturation, double value)
{
Hue = hue;
Saturation = saturation;
Value = value;
}
public override string ToString()
{
return string.Format("Hue={0}, Saturation={1}, Value={2}", Hue, Saturation, Value);
}
}
}

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace DevComponents.DotNetBar.Metro.Helpers
{
internal static class DoubleHelpers
{
/// <summary>
/// Gets whether values are close.
/// </summary>
/// <param name="value1">First value.</param>
/// <param name="value2">Second value</param>
/// <returns>true if values are close enough</returns>
public static bool AreClose(double value1, double value2)
{
if (value1 == value2)
{
return true;
}
double num2 = ((Math.Abs(value1) + Math.Abs(value2)) + 10.0) * 2.2204460492503131E-16;
double num = value1 - value2;
return ((-num2 < num) && (num2 > num));
}
/// <summary>
/// Gets whether value is zero
/// </summary>
/// <param name="value">value to check</param>
/// <returns>true if value is considered zero</returns>
public static bool IsZero(double value)
{
return (Math.Abs(value) < 2.2204460492503131E-15);
}
/// <summary>
/// Gets whether value is not an number.
/// </summary>
/// <param name="value">value to test</param>
/// <returns>true if value is not an number</returns>
public static bool IsNaN(double value)
{
NanUnion union = new NanUnion();
union.DoubleValue = value;
ulong num = union.UintValue & 18442240474082181120L;
ulong num2 = union.UintValue & ((ulong)0xfffffffffffffL);
if ((num != 0x7ff0000000000000L) && (num != 18442240474082181120L))
{
return false;
}
return (num2 != 0L);
}
[StructLayout(LayoutKind.Explicit)]
private struct NanUnion
{
// Fields
[FieldOffset(0)]
internal double DoubleValue;
[FieldOffset(0)]
internal ulong UintValue;
}
}
}