DotNet 4.8.1 build of DotNetBar
This commit is contained in:
40
PROMS/DotNetBar Source Code/AdvTree/Drawing/Border.cs
Normal file
40
PROMS/DotNetBar Source Code/AdvTree/Drawing/Border.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public abstract class Border : Component
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates the pen for the border.
|
||||
/// </summary>
|
||||
/// <returns>Returns pen or null if pen cannot be created.</returns>
|
||||
public abstract Pen CreatePen();
|
||||
|
||||
internal int _Width = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the border width. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0), Description("Indicates border width.")]
|
||||
public int Width
|
||||
{
|
||||
get { return _Width; }
|
||||
set
|
||||
{
|
||||
_Width = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Rectangle Deflate(Rectangle bounds, Border border)
|
||||
{
|
||||
if (border == null) return bounds;
|
||||
bounds.Inflate(-border.Width, -border.Width);
|
||||
return bounds;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Collection for the ColorStop objects.
|
||||
/// </summary>
|
||||
public class ColorBlendCollection : CollectionBase
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>Creates new instance of the class.</summary>
|
||||
public ColorBlendCollection() { }
|
||||
|
||||
/// <summary>
|
||||
/// Adds new object to the collection.
|
||||
/// </summary>
|
||||
/// <param name="item">Object to add.</param>
|
||||
/// <returns>Index of newly added object.</returns>
|
||||
public int Add(ColorStop item)
|
||||
{
|
||||
return List.Add(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds array of new objects to the collection.
|
||||
/// </summary>
|
||||
/// <param name="items">Array of object to add.</param>
|
||||
public void AddRange(ColorStop[] items)
|
||||
{
|
||||
foreach (ColorStop item in items)
|
||||
this.Add(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns reference to the object in collection based on it's index.
|
||||
/// </summary>
|
||||
public ColorStop this[int index]
|
||||
{
|
||||
get { return (ColorStop)(List[index]); }
|
||||
set { List[index] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts new object into the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">Position of the object.</param>
|
||||
/// <param name="value">Object to insert.</param>
|
||||
public void Insert(int index, ColorStop value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns index of the object inside of the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Reference to the object.</param>
|
||||
/// <returns>Index of the object.</returns>
|
||||
public int IndexOf(ColorStop value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether collection contains specified object.
|
||||
/// </summary>
|
||||
/// <param name="value">Object to look for.</param>
|
||||
/// <returns>true if object is part of the collection, otherwise false.</returns>
|
||||
public bool Contains(ColorStop value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes specified object from the collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void Remove(ColorStop value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
//protected override void OnRemoveComplete(int index,object value)
|
||||
//{
|
||||
// base.OnRemoveComplete(index,value);
|
||||
// ColorStop me=value as ColorStop;
|
||||
//}
|
||||
//protected override void OnInsertComplete(int index,object value)
|
||||
//{
|
||||
// base.OnInsertComplete(index,value);
|
||||
// ColorStop me=value as ColorStop;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Copies collection into the specified array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy collection to.</param>
|
||||
/// <param name="index">Starting index.</param>
|
||||
public void CopyTo(ColorStop[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies contained items to the ColorStop array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy to.</param>
|
||||
internal void CopyTo(ColorStop[] array)
|
||||
{
|
||||
List.CopyTo(array, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates ColorBlend object based on the members of the collection. ColorBlend object will be valid only if all members of the collection
|
||||
/// represents relative/percentage based color blends.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ColorBlend GetColorBlend()
|
||||
{
|
||||
ColorBlend blend = new ColorBlend();
|
||||
Color[] colors = new Color[this.Count];
|
||||
float[] positions = new float[this.Count];
|
||||
|
||||
for (int i = 0; i < this.Count; i++)
|
||||
{
|
||||
ColorStop b = this[i];
|
||||
colors[i] = b.Color;
|
||||
positions[i] = b.Position;
|
||||
}
|
||||
|
||||
blend.Colors = colors;
|
||||
blend.Positions = positions;
|
||||
|
||||
return blend;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the ColorStop objects from the collection.
|
||||
/// </summary>
|
||||
/// <param name="col">Collection to copy objects from</param>
|
||||
public void CopyFrom(ColorBlendCollection col)
|
||||
{
|
||||
foreach (ColorStop b in col)
|
||||
this.Add(b);
|
||||
}
|
||||
|
||||
internal eColorStopType GetBlendType()
|
||||
{
|
||||
ColorBlendCollection c = this;
|
||||
if (c.Count <= 1)
|
||||
return eColorStopType.Invalid;
|
||||
|
||||
eColorStopType t = eColorStopType.Invalid;
|
||||
|
||||
foreach (ColorStop b in c)
|
||||
{
|
||||
if (b.Position == 0 || b.Position == 1f)
|
||||
continue;
|
||||
if (b.Position <= 1f)
|
||||
{
|
||||
if (t == eColorStopType.Invalid)
|
||||
t = eColorStopType.Relative;
|
||||
else if (t == eColorStopType.Absolute)
|
||||
{
|
||||
t = eColorStopType.Invalid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (t == eColorStopType.Invalid)
|
||||
t = eColorStopType.Absolute;
|
||||
else if (t == eColorStopType.Relative)
|
||||
{
|
||||
t = eColorStopType.Invalid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c.Count == 2 && c[0].Position == 0f && c[1].Position == 1f)
|
||||
return eColorStopType.Relative;
|
||||
|
||||
if (t == eColorStopType.Invalid)
|
||||
return t;
|
||||
|
||||
if (t == eColorStopType.Relative && c[0].Position != 0f && c[c.Count - 1].Position != 1f)
|
||||
return eColorStopType.Invalid;
|
||||
else if (t == eColorStopType.Absolute && ((c.Count / 2) * 2 != c.Count))
|
||||
return eColorStopType.Invalid;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Initializes the collection with the two color blend.
|
||||
///// </summary>
|
||||
///// <param name="collection">Collection to initialize.</param>
|
||||
///// <param name="backColor1">Start color.</param>
|
||||
///// <param name="backColor2">End color.</param>
|
||||
//public static void InitializeCollection(ColorBlendCollection collection, int backColor1, int backColor2)
|
||||
//{
|
||||
// InitializeCollection(collection, ColorScheme.GetColor(backColor1), ColorScheme.GetColor(backColor2));
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the collection with the two color blend.
|
||||
/// </summary>
|
||||
/// <param name="collection">Collection to initialize.</param>
|
||||
/// <param name="backColor1">Start color.</param>
|
||||
/// <param name="backColor2">End color.</param>
|
||||
public static void InitializeCollection(ColorBlendCollection collection, Color backColor1, Color backColor2)
|
||||
{
|
||||
collection.Clear();
|
||||
collection.Add(new ColorStop(backColor1, 0f));
|
||||
collection.Add(new ColorStop(backColor2, 1f));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal enum eColorStopType
|
||||
{
|
||||
Invalid,
|
||||
Relative,
|
||||
Absolute
|
||||
}
|
||||
}
|
83
PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStop.cs
Normal file
83
PROMS/DotNetBar Source Code/AdvTree/Drawing/ColorStop.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines single color blend point for the multicolor gradient fills.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false), TypeConverter(typeof(ColorStopConverter))]
|
||||
public class ColorStop
|
||||
{
|
||||
#region Private Variables
|
||||
private Color _Color = Color.Empty;
|
||||
private float _Position = 0;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates new instance of the class. When defining multicolor gradient blends and using the percentage positions the positions created
|
||||
/// must start with 0f and end with 1f.
|
||||
/// </summary>
|
||||
public ColorStop() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initialize it with default values.
|
||||
/// </summary>
|
||||
public ColorStop(Color color, float position)
|
||||
{
|
||||
_Color = color;
|
||||
_Position = position;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Creates new instance of the class and initialize it with default values.
|
||||
///// </summary>
|
||||
//public ColorStop(int color, float position)
|
||||
//{
|
||||
// _Color = ColorScheme.GetColor(color);
|
||||
// _Position = position;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets Color to use in multicolor gradient blend at specified position.
|
||||
/// </summary>
|
||||
[Browsable(true), Description("Indicates the Color to use in multicolor gradient blend at specified position.")]
|
||||
public Color Color
|
||||
{
|
||||
get { return _Color; }
|
||||
set
|
||||
{
|
||||
_Color = value;
|
||||
OnColorBlendChanged();
|
||||
}
|
||||
}
|
||||
private bool ShouldSerializeColor()
|
||||
{
|
||||
return !_Color.IsEmpty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color position in multicolor gradient blend. Values less or equal to 1 are used as percentage specifing percentages of distance along the gradient line.
|
||||
/// Values greater than 1 are used as absolute pixel values of distance along the gradient line.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(0f), Description("")]
|
||||
public float Position
|
||||
{
|
||||
get { return _Position; }
|
||||
set
|
||||
{
|
||||
_Position = value;
|
||||
OnColorBlendChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnColorBlendChanged()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents BackgroundColorBlend object converter.
|
||||
/// </summary>
|
||||
public class ColorStopConverter : TypeConverter
|
||||
{
|
||||
public ColorStopConverter() { }
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(InstanceDescriptor))
|
||||
return true;
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
throw new ArgumentNullException("destinationType");
|
||||
|
||||
if ((destinationType == typeof(InstanceDescriptor)) && (value is ColorStop))
|
||||
{
|
||||
ColorStop doc = (ColorStop)value;
|
||||
Type[] constructorParams = null;
|
||||
MemberInfo constructorMemberInfo = null;
|
||||
object[] constructorValues = null;
|
||||
|
||||
constructorParams = new Type[2] { typeof(Color), typeof(float) };
|
||||
constructorMemberInfo = typeof(ColorStop).GetConstructor(constructorParams);
|
||||
constructorValues = new object[2] { doc.Color, doc.Position };
|
||||
|
||||
if (constructorMemberInfo != null)
|
||||
{
|
||||
return new InstanceDescriptor(constructorMemberInfo, constructorValues);
|
||||
}
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
258
PROMS/DotNetBar Source Code/AdvTree/Drawing/CornerRadius.cs
Normal file
258
PROMS/DotNetBar Source Code/AdvTree/Drawing/CornerRadius.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential), TypeConverter(typeof(CornerRadiusConverter))]
|
||||
public struct CornerRadius
|
||||
#if FRAMEWORK20
|
||||
: IEquatable<CornerRadius>
|
||||
#endif
|
||||
{
|
||||
#region Private Variables
|
||||
private int _TopLeft;
|
||||
private int _topRight;
|
||||
private int _bottomLeft;
|
||||
private int _bottomRight;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public CornerRadius(int uniformRadius)
|
||||
{
|
||||
this._TopLeft = this._topRight = this._bottomLeft = this._bottomRight = uniformRadius;
|
||||
}
|
||||
|
||||
public CornerRadius(int topLeft, int topRight, int bottomRight, int bottomLeft)
|
||||
{
|
||||
this._TopLeft = topLeft;
|
||||
this._topRight = topRight;
|
||||
this._bottomRight = bottomRight;
|
||||
this._bottomLeft = bottomLeft;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is CornerRadius)
|
||||
{
|
||||
CornerRadius radius = (CornerRadius)obj;
|
||||
return (this == radius);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Equals(CornerRadius cornerRadius)
|
||||
{
|
||||
return (this == cornerRadius);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((this._TopLeft.GetHashCode() ^ this._topRight.GetHashCode()) ^ this._bottomLeft.GetHashCode()) ^ this._bottomRight.GetHashCode());
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return CornerRadiusConverter.ToString(this, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static bool operator ==(CornerRadius cr1, CornerRadius cr2)
|
||||
{
|
||||
return ((cr1._TopLeft == cr2._TopLeft) && (cr1._topRight == cr2._topRight) && (cr1._bottomRight == cr2._bottomRight) && (cr1._bottomLeft == cr2._bottomLeft));
|
||||
}
|
||||
|
||||
public static bool operator !=(CornerRadius cr1, CornerRadius cr2)
|
||||
{
|
||||
return !(cr1 == cr2);
|
||||
}
|
||||
|
||||
public int TopLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._TopLeft;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._TopLeft = value;
|
||||
}
|
||||
}
|
||||
public int TopRight
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._topRight;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._topRight = value;
|
||||
}
|
||||
}
|
||||
public int BottomRight
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._bottomRight;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._bottomRight = value;
|
||||
}
|
||||
}
|
||||
public int BottomLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._bottomLeft;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._bottomLeft = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsValid(bool allowNegative)
|
||||
{
|
||||
if (!allowNegative && (((this._TopLeft < 0.0) || (this._topRight < 0.0)) || ((this._bottomLeft < 0.0) || (this._bottomRight < 0.0))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
internal bool IsZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_TopLeft == 0 && _topRight == 0 && _bottomRight == 0 && _bottomLeft == 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region CornerRadiusConverter
|
||||
public class CornerRadiusConverter : TypeConverter
|
||||
{
|
||||
// Methods
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext typeDescriptorContext, Type sourceType)
|
||||
{
|
||||
switch (Type.GetTypeCode(sourceType))
|
||||
{
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Single:
|
||||
case TypeCode.Double:
|
||||
case TypeCode.Decimal:
|
||||
case TypeCode.String:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext typeDescriptorContext, Type destinationType)
|
||||
{
|
||||
if ((destinationType != typeof(InstanceDescriptor)) && (destinationType != typeof(string)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object source)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
throw base.GetConvertFromException(source);
|
||||
}
|
||||
if (source is string)
|
||||
{
|
||||
return FromString((string)source, cultureInfo);
|
||||
}
|
||||
return new CornerRadius(Convert.ToInt32(source, cultureInfo));
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (!(value is CornerRadius))
|
||||
{
|
||||
throw new ArgumentException("Unexpected parameter type", "value");
|
||||
}
|
||||
CornerRadius cr = (CornerRadius)value;
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
return ToString(cr, cultureInfo);
|
||||
}
|
||||
if (destinationType != typeof(InstanceDescriptor))
|
||||
{
|
||||
throw new ArgumentException("Cannot convert to type " + destinationType.FullName);
|
||||
}
|
||||
return new InstanceDescriptor(typeof(CornerRadius).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) }), new object[] { cr.TopLeft, cr.TopRight, cr.BottomRight, cr.BottomLeft });
|
||||
}
|
||||
|
||||
internal static CornerRadius FromString(string s, CultureInfo cultureInfo)
|
||||
{
|
||||
string[] parsed = s.Split(GetNumericListSeparator(cultureInfo));
|
||||
int[] numArray = new int[4];
|
||||
for (int i = 0; i < parsed.Length; i++)
|
||||
{
|
||||
numArray[i] = int.Parse(parsed[i], cultureInfo);
|
||||
}
|
||||
|
||||
int index = Math.Min(5, parsed.Length);
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
return new CornerRadius(numArray[0]);
|
||||
|
||||
case 4:
|
||||
return new CornerRadius(numArray[0], numArray[1], numArray[2], numArray[3]);
|
||||
}
|
||||
throw new FormatException("Invalid string corner radius");
|
||||
}
|
||||
|
||||
internal static string ToString(CornerRadius cr, CultureInfo cultureInfo)
|
||||
{
|
||||
char numericListSeparator = GetNumericListSeparator(cultureInfo);
|
||||
StringBuilder builder = new StringBuilder(0x40);
|
||||
builder.Append(cr.TopLeft.ToString(cultureInfo));
|
||||
builder.Append(numericListSeparator);
|
||||
builder.Append(cr.TopRight.ToString(cultureInfo));
|
||||
builder.Append(numericListSeparator);
|
||||
builder.Append(cr.BottomRight.ToString(cultureInfo));
|
||||
builder.Append(numericListSeparator);
|
||||
builder.Append(cr.BottomLeft.ToString(cultureInfo));
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
internal static char GetNumericListSeparator(IFormatProvider provider)
|
||||
{
|
||||
char ch = ',';
|
||||
NumberFormatInfo instance = NumberFormatInfo.GetInstance(provider);
|
||||
if ((instance.NumberDecimalSeparator.Length > 0) && (ch == instance.NumberDecimalSeparator[0]))
|
||||
{
|
||||
ch = ';';
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
27
PROMS/DotNetBar Source Code/AdvTree/Drawing/Fill.cs
Normal file
27
PROMS/DotNetBar Source Code/AdvTree/Drawing/Fill.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public abstract class Fill : Component
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates the brush for fill.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Bounds for the brush</param>
|
||||
/// <returns>Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.</returns>
|
||||
public abstract Brush CreateBrush(Rectangle bounds);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a pen based on fill parameters.
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the pen to create</param>
|
||||
/// <returns>new instance of pen or null if pen cannot be created.</returns>
|
||||
public abstract Pen CreatePen(int width);
|
||||
#endregion
|
||||
}
|
||||
}
|
179
PROMS/DotNetBar Source Code/AdvTree/Drawing/GradientFill.cs
Normal file
179
PROMS/DotNetBar Source Code/AdvTree/Drawing/GradientFill.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
public class GradientFill : Fill
|
||||
{
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GradientFill class.
|
||||
/// </summary>
|
||||
public GradientFill()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GradientFill class.
|
||||
/// </summary>
|
||||
/// <param name="color1"></param>
|
||||
/// <param name="color2"></param>
|
||||
public GradientFill(Color color1, Color color2)
|
||||
{
|
||||
_Color1 = color1;
|
||||
_Color2 = color2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GradientFill class.
|
||||
/// </summary>
|
||||
/// <param name="color1"></param>
|
||||
/// <param name="color2"></param>
|
||||
/// <param name="angle"></param>
|
||||
public GradientFill(Color color1, Color color2, float angle)
|
||||
{
|
||||
_Color1 = color1;
|
||||
_Color2 = color2;
|
||||
_Angle = angle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GradientFill class.
|
||||
/// </summary>
|
||||
/// <param name="interpolationColors"></param>
|
||||
public GradientFill(ColorStop[] interpolationColors)
|
||||
{
|
||||
_InterpolationColors.AddRange(interpolationColors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GradientFill class.
|
||||
/// </summary>
|
||||
/// <param name="interpolationColors"></param>
|
||||
public GradientFill(ColorStop[] interpolationColors, int angle)
|
||||
{
|
||||
_InterpolationColors.AddRange(interpolationColors);
|
||||
_Angle = angle;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates the brush for fill.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Bounds for the brush</param>
|
||||
/// <returns>Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.</returns>
|
||||
public override Brush CreateBrush(Rectangle bounds)
|
||||
{
|
||||
if (_Color1.IsEmpty && _Color2.IsEmpty && _InterpolationColors.Count == 0 || bounds.Width < 1 || bounds.Height < 1) return null;
|
||||
|
||||
LinearGradientBrush brush=new LinearGradientBrush(bounds, _Color1, _Color2, _Angle);
|
||||
if (_InterpolationColors.Count == 0)
|
||||
return brush;
|
||||
brush.InterpolationColors = _InterpolationColors.GetColorBlend();
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
private Color _Color1 = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the starting gradient fill color.
|
||||
/// </summary>
|
||||
[Description("Indicates the fill color.")]
|
||||
public Color Color1
|
||||
{
|
||||
get { return _Color1; }
|
||||
set { _Color1 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
/// <returns>true if property should be serialized</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeColor1()
|
||||
{
|
||||
return !_Color1.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetColor1()
|
||||
{
|
||||
Color1 = Color.Empty;
|
||||
}
|
||||
|
||||
private Color _Color2 = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the end gradient fill color.
|
||||
/// </summary>
|
||||
[Description("Indicates the fill color.")]
|
||||
public Color Color2
|
||||
{
|
||||
get { return _Color2; }
|
||||
set { _Color2 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
/// <returns>true if property should be serialized</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeColor2()
|
||||
{
|
||||
return !_Color2.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetColor2()
|
||||
{
|
||||
Color2 = Color.Empty;
|
||||
}
|
||||
|
||||
private ColorBlendCollection _InterpolationColors = new ColorBlendCollection();
|
||||
/// <summary>
|
||||
/// Gets the collection that defines the multicolor gradient background.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Setting this property creates a multicolor gradient with one color at each position along the gradient line. Setting this property nullifies all previous color, position, and falloff settings for this gradient fill.
|
||||
/// </remarks>
|
||||
[Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Description("Collection that defines the multicolor gradient background.")]
|
||||
public ColorBlendCollection InterpolationColors
|
||||
{
|
||||
get { return _InterpolationColors; }
|
||||
}
|
||||
|
||||
private float _Angle = 90;
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient fill angle. Default value is 90.
|
||||
/// </summary>
|
||||
[DefaultValue(90), Description("Indicates gradient fill angle.")]
|
||||
public float Angle
|
||||
{
|
||||
get { return _Angle; }
|
||||
set
|
||||
{
|
||||
_Angle = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a pen based on fill parameters.
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the pen to create</param>
|
||||
/// <returns>new instance of pen or null if pen cannot be created.</returns>
|
||||
public override Pen CreatePen(int width)
|
||||
{
|
||||
if (!_Color1.IsEmpty)
|
||||
return new Pen(_Color1, width);
|
||||
if (!_Color2.IsEmpty)
|
||||
return new Pen(_Color2, width);
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
128
PROMS/DotNetBar Source Code/AdvTree/Drawing/RectangleShape.cs
Normal file
128
PROMS/DotNetBar Source Code/AdvTree/Drawing/RectangleShape.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.AdvTree;
|
||||
using System.Drawing.Drawing2D;
|
||||
using DevComponents.DotNetBar;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
internal class RectangleShape : Shape
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Renders rectangle on canvas.
|
||||
/// </summary>
|
||||
/// <param name="g">Target graphics to render shape on.</param>
|
||||
/// <param name="bounds">Shape bounds.</param>
|
||||
public override void Paint(Graphics g, Rectangle bounds)
|
||||
{
|
||||
if (bounds.Width < 2 || bounds.Height < 2 || g == null || _Fill == null && _Border == null) return;
|
||||
|
||||
GraphicsPath path = null;
|
||||
|
||||
if (!_CornerRadius.IsZero)
|
||||
{
|
||||
path = DisplayHelp.GetRoundedRectanglePath(bounds, _CornerRadius.TopLeft, _CornerRadius.TopRight,
|
||||
_CornerRadius.BottomRight, _CornerRadius.BottomLeft);
|
||||
}
|
||||
|
||||
if (_Fill != null)
|
||||
{
|
||||
Brush brush = _Fill.CreateBrush(bounds);
|
||||
if (brush != null)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
if (brush is SolidBrush && path==null)
|
||||
g.SmoothingMode = SmoothingMode.None;
|
||||
if (path == null)
|
||||
g.FillRectangle(brush, bounds);
|
||||
else
|
||||
g.FillPath(brush, path);
|
||||
g.SmoothingMode = sm;
|
||||
brush.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (_Border != null)
|
||||
{
|
||||
Pen pen = _Border.CreatePen();
|
||||
if (pen != null)
|
||||
{
|
||||
if (path == null)
|
||||
g.DrawRectangle(pen, bounds);
|
||||
else
|
||||
g.DrawPath(pen, path);
|
||||
|
||||
pen.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Shape content = this.Content;
|
||||
if (content != null)
|
||||
{
|
||||
Rectangle contentBounds = Border.Deflate(bounds, _Border);
|
||||
Region oldClip = null;
|
||||
if (path != null && ClipToBounds)
|
||||
{
|
||||
oldClip = g.Clip;
|
||||
g.SetClip(path, CombineMode.Intersect);
|
||||
}
|
||||
content.Paint(g, contentBounds);
|
||||
if (oldClip != null) g.Clip = oldClip;
|
||||
}
|
||||
|
||||
if (path != null) path.Dispose();
|
||||
}
|
||||
|
||||
private Border _Border;
|
||||
/// <summary>
|
||||
/// Gets or sets shape border.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Description("Indicates shape border.")]
|
||||
public Border Border
|
||||
{
|
||||
get { return _Border; }
|
||||
set { _Border = value; }
|
||||
}
|
||||
|
||||
private Fill _Fill = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the shape fill.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Description("Indicates shape fill")]
|
||||
public Fill Fill
|
||||
{
|
||||
get { return _Fill; }
|
||||
set { _Fill = value; }
|
||||
}
|
||||
|
||||
private CornerRadius _CornerRadius;
|
||||
/// <summary>
|
||||
/// Gets or sets the CornerRadius.
|
||||
/// </summary>
|
||||
public CornerRadius CornerRadius
|
||||
{
|
||||
get { return _CornerRadius; }
|
||||
set { _CornerRadius = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeCornerRadius()
|
||||
{
|
||||
return !_CornerRadius.IsZero;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetCornerRadius()
|
||||
{
|
||||
CornerRadius = new CornerRadius();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
48
PROMS/DotNetBar Source Code/AdvTree/Drawing/Shape.cs
Normal file
48
PROMS/DotNetBar Source Code/AdvTree/Drawing/Shape.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a visual shape.
|
||||
/// </summary>
|
||||
internal abstract class Shape
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Renders shape on canvas.
|
||||
/// </summary>
|
||||
/// <param name="g">Target graphics to render shape on.</param>
|
||||
/// <param name="bounds">Shape bounds.</param>
|
||||
public abstract void Paint(Graphics g, Rectangle bounds);
|
||||
|
||||
private Shape _Content = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the single piece of content inside of the shape.
|
||||
/// </summary>
|
||||
[DefaultValue(null)]
|
||||
public Shape Content
|
||||
{
|
||||
get { return _Content; }
|
||||
set { _Content = value; }
|
||||
}
|
||||
|
||||
private bool _ClipToBounds = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether to clip the Content of this shape. Default value is false.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
public bool ClipToBounds
|
||||
{
|
||||
get { return _ClipToBounds; }
|
||||
set
|
||||
{
|
||||
_ClipToBounds = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
86
PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidBorder.cs
Normal file
86
PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidBorder.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
public class SolidBorder : Border
|
||||
{
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the SolidBorder class.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
/// <param name="width"></param>
|
||||
public SolidBorder(Color color, int width)
|
||||
{
|
||||
_Color = color;
|
||||
_Width = width;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the SolidBorder class.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public SolidBorder(Color color)
|
||||
{
|
||||
_Color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the SolidBorder class.
|
||||
/// </summary>
|
||||
public SolidBorder()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates the pen for the border.
|
||||
/// </summary>
|
||||
/// <returns>Returns pen or null if pen cannot be created.</returns>
|
||||
public override Pen CreatePen()
|
||||
{
|
||||
if (!CanCreatePen()) return null;
|
||||
|
||||
return new Pen(_Color, _Width);
|
||||
}
|
||||
|
||||
private bool CanCreatePen()
|
||||
{
|
||||
return !_Color.IsEmpty && _Width > 0;
|
||||
}
|
||||
|
||||
private Color _Color = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the fill color.
|
||||
/// </summary>
|
||||
[Description("Indicates the fill color.")]
|
||||
public Color Color
|
||||
{
|
||||
get { return _Color; }
|
||||
set { _Color = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
/// <returns>true if property should be serialized</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeColor()
|
||||
{
|
||||
return !_Color.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetColor()
|
||||
{
|
||||
Color = Color.Empty;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
76
PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidFill.cs
Normal file
76
PROMS/DotNetBar Source Code/AdvTree/Drawing/SolidFill.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.WinForms.Drawing
|
||||
{
|
||||
public class SolidFill : Fill
|
||||
{
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the SolidFill class.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public SolidFill(Color color)
|
||||
{
|
||||
_Color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the SolidFill class.
|
||||
/// </summary>
|
||||
public SolidFill()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates the brush for fill.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Bounds for the brush</param>
|
||||
/// <returns>Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.</returns>
|
||||
public override Brush CreateBrush(Rectangle bounds)
|
||||
{
|
||||
if (_Color.IsEmpty) return null;
|
||||
return new SolidBrush(_Color);
|
||||
}
|
||||
|
||||
private Color _Color = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the fill color.
|
||||
/// </summary>
|
||||
[Description("Indicates the fill color.")]
|
||||
public Color Color
|
||||
{
|
||||
get { return _Color; }
|
||||
set { _Color = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
/// <returns>true if property should be serialized</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeColor()
|
||||
{
|
||||
return !_Color.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetColor()
|
||||
{
|
||||
Color = Color.Empty;
|
||||
}
|
||||
|
||||
public override Pen CreatePen(int width)
|
||||
{
|
||||
if (!_Color.IsEmpty)
|
||||
return new Pen(_Color, width);
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user