DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides helpers when working with colors.
|
||||
/// </summary>
|
||||
internal static class ColorHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgbHex">Hexadecimal color representation.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(string rgbHex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(rgbHex))
|
||||
return Color.Empty;
|
||||
|
||||
if (rgbHex.Length == 8)
|
||||
return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(4, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(6, 2), 16));
|
||||
|
||||
return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
|
||||
Convert.ToInt32(rgbHex.Substring(4, 2), 16));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="rgb">Color representation as 32-bit RGB value.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int rgb)
|
||||
{
|
||||
if (rgb == -1)
|
||||
return Color.Empty;
|
||||
|
||||
return Color.FromArgb((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts hex string to Color type.
|
||||
/// </summary>
|
||||
/// <param name="alpha">Alpha component for color.</param>
|
||||
/// <param name="rgb">Color representation as 32-bit RGB value.</param>
|
||||
/// <returns>Reference to Color object.</returns>
|
||||
public static Color GetColor(int alpha, int rgb)
|
||||
{
|
||||
if (rgb == -1)
|
||||
return Color.Empty;
|
||||
|
||||
return Color.FromArgb(alpha, (rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
///<summary>
|
||||
/// ConvertValue
|
||||
///</summary>
|
||||
static public class ConvertValue
|
||||
{
|
||||
///<summary>
|
||||
/// ConvertTo
|
||||
///</summary>
|
||||
///<param name="o"></param>
|
||||
///<param name="type"></param>
|
||||
///<returns></returns>
|
||||
static public object ConvertTo(object o, Type type)
|
||||
{
|
||||
if (o == null || o is DBNull)
|
||||
return (o);
|
||||
|
||||
if (o.GetType() == type)
|
||||
return (o);
|
||||
|
||||
if (type == typeof (decimal))
|
||||
return (Convert.ToDecimal(o));
|
||||
|
||||
if (type == typeof (double))
|
||||
return (Convert.ToDouble(o));
|
||||
|
||||
if (type == typeof (Int16))
|
||||
return (Convert.ToInt16(o));
|
||||
|
||||
if (type == typeof (Int32))
|
||||
return (Convert.ToInt32(o));
|
||||
|
||||
if (type == typeof (Int64))
|
||||
return (Convert.ToInt64(o));
|
||||
|
||||
if (type == typeof (Single))
|
||||
return (Convert.ToSingle(o));
|
||||
|
||||
if (type == typeof (UInt16))
|
||||
return (Convert.ToUInt16(o));
|
||||
|
||||
if (type == typeof (UInt32))
|
||||
return (Convert.ToUInt32(o));
|
||||
|
||||
if (type == typeof (UInt64))
|
||||
return (Convert.ToUInt64(o));
|
||||
|
||||
if (type == typeof(sbyte))
|
||||
return (Convert.ToSByte(o));
|
||||
|
||||
if (type == typeof(byte))
|
||||
return (Convert.ToByte(o));
|
||||
|
||||
if (type == typeof(bool))
|
||||
return (Convert.ToBoolean(o));
|
||||
|
||||
if (type == typeof(char))
|
||||
return (Convert.ToChar(o));
|
||||
|
||||
if (type == typeof(string))
|
||||
return (Convert.ToString(o));
|
||||
|
||||
if (type == typeof(DateTime))
|
||||
return (Convert.ToDateTime(o));
|
||||
|
||||
return (o);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
internal static class DragDrop
|
||||
{
|
||||
public static bool DragStarted(Point pt1, Point pt2)
|
||||
{
|
||||
Rectangle r = new Rectangle(pt1.X, pt1.Y, 0, 0);
|
||||
|
||||
r.Inflate(SystemInformation.DragSize.Width,
|
||||
SystemInformation.DragSize.Height);
|
||||
|
||||
return (r.Contains(pt2.X, pt2.Y) == false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.SuperGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides helpers when working with text.
|
||||
/// </summary>
|
||||
internal static class TextHelper
|
||||
{
|
||||
private static int _textMarkupCultureSpecific = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the text-markup padding for text
|
||||
/// measurement when running on Japanese version of Windows.
|
||||
/// </summary>
|
||||
public static int TextMarkupCultureSpecificPadding
|
||||
{
|
||||
get { return _textMarkupCultureSpecific; }
|
||||
set { _textMarkupCultureSpecific = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MeasureText always adds about 1/2 em width of white space on the right,
|
||||
/// even when NoPadding is specified. It returns zero for an empty string.
|
||||
/// To get the precise string width, measure the width of a string containing a
|
||||
/// single period and subtract that from the width of our original string plus a period.
|
||||
/// </summary>
|
||||
public static Size MeasureText(Graphics g,
|
||||
string s, Font font, Size csize, eTextFormat tf)
|
||||
{
|
||||
return (TextDrawing.MeasureString(g, s, font, csize, tf));
|
||||
|
||||
if (font.Italic == true)
|
||||
return (TextDrawing.MeasureString(g, s, font, csize, tf));
|
||||
|
||||
Size sz1 = TextDrawing.MeasureString(g, ".", font, csize, tf);
|
||||
Size sz2 = TextDrawing.MeasureString(g, s + ".", font, csize, tf);
|
||||
|
||||
return (new Size(sz2.Width - sz1.Width, sz2.Height));
|
||||
}
|
||||
|
||||
public static Size MeasureText(Graphics g, string s, Font font)
|
||||
{
|
||||
return (TextDrawing.MeasureString(g, s, font));
|
||||
|
||||
if (font.Italic == true)
|
||||
return (TextDrawing.MeasureString(g, s, font));
|
||||
|
||||
Size sz1 = TextDrawing.MeasureString(g, ".", font);
|
||||
Size sz2 = TextDrawing.MeasureString(g, s + ".", font);
|
||||
|
||||
return (new Size(sz2.Width - sz1.Width, sz2.Height));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user