DotNet 4.8.1 build of DotNetBar
This commit is contained in:
331
PROMS/DotNetBar Source Code/Metro/BorderColors.cs
Normal file
331
PROMS/DotNetBar Source Code/Metro/BorderColors.cs
Normal file
@@ -0,0 +1,331 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Defines BorderColors structure used to define border colors.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential), TypeConverter(typeof(BorderColorsConverter))]
|
||||
public struct BorderColors : IEquatable<BorderColors>
|
||||
{
|
||||
#region Constructor
|
||||
private Color _Left;
|
||||
private Color _Top;
|
||||
private Color _Right;
|
||||
private Color _Bottom;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="uniformLength">Uniform BorderColors</param>
|
||||
public BorderColors(Color uniformBorderColors)
|
||||
{
|
||||
_Left = _Top = _Right = _Bottom = uniformBorderColors;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="left">Left BorderColors</param>
|
||||
/// <param name="top">Top BorderColors</param>
|
||||
/// <param name="right">Right BorderColors</param>
|
||||
/// <param name="bottom">Bottom BorderColors</param>
|
||||
public BorderColors(Color left, Color top, Color right, Color bottom)
|
||||
{
|
||||
_Left = left;
|
||||
_Top = top;
|
||||
_Right = right;
|
||||
_Bottom = bottom;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Gets whether object equals to this instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">object to test.</param>
|
||||
/// <returns>returns whether objects are Equals</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is BorderColors)
|
||||
{
|
||||
BorderColors BorderColors = (BorderColors)obj;
|
||||
return (this == BorderColors);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether object equals to this instance.
|
||||
/// </summary>
|
||||
/// <param name="BorderColors">object to test.</param>
|
||||
/// <returns>returns whether objects are Equals</returns>
|
||||
public bool Equals(BorderColors BorderColors)
|
||||
{
|
||||
return (this == BorderColors);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns hash code for object.
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((_Left.GetHashCode() ^ _Top.GetHashCode()) ^ _Right.GetHashCode()) ^ _Bottom.GetHashCode());
|
||||
}
|
||||
|
||||
const string StringValueSeparator = ",";
|
||||
/// <summary>
|
||||
/// Returns string representation of object.
|
||||
/// </summary>
|
||||
/// <returns>string representing BorderColors</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Convert.ToString(_Left) + StringValueSeparator + Convert.ToString(_Top) + StringValueSeparator + Convert.ToString(_Right) + StringValueSeparator + Convert.ToString(_Bottom);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets string representation of object.
|
||||
/// </summary>
|
||||
/// <param name="cultureInfo">Culture info.</param>
|
||||
/// <returns>string representing BorderColors</returns>
|
||||
internal string ToString(CultureInfo cultureInfo)
|
||||
{
|
||||
return Convert.ToString(_Left, cultureInfo) + StringValueSeparator + Convert.ToString(_Top, cultureInfo) + StringValueSeparator + Convert.ToString(_Right, cultureInfo) + StringValueSeparator + Convert.ToString(_Bottom, cultureInfo);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether all values are empty.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.Left.IsEmpty && this.Top.IsEmpty && this.Right.IsEmpty && this.Bottom.IsEmpty);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether all values are the same.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsUniform
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.Left == this.Top && this.Top == this.Right && this.Right == this.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(BorderColors t1, BorderColors t2)
|
||||
{
|
||||
return (t1._Left == t2._Left && t1._Top == t2._Top && t1._Right == t2._Right && t1._Bottom == t2._Bottom);
|
||||
}
|
||||
|
||||
public static bool operator !=(BorderColors t1, BorderColors t2)
|
||||
{
|
||||
return !(t1 == t2);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the left BorderColors.
|
||||
/// </summary>
|
||||
public Color Left
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Left;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Left = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the top BorderColors.
|
||||
/// </summary>
|
||||
public Color Top
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Top;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Top = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the Right BorderColors.
|
||||
/// </summary>
|
||||
public Color Right
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Right;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Right = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the Bottom BorderColors.
|
||||
/// </summary>
|
||||
public Color Bottom
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Bottom;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Bottom = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
#region BorderColorsConverter
|
||||
/// <summary>
|
||||
/// Provides BorderColors TypeConverter.
|
||||
/// </summary>
|
||||
public class BorderColorsConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return ((destinationType == typeof(InstanceDescriptor)) || base.CanConvertTo(context, destinationType));
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
string str = value as string;
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
return new BorderColors();
|
||||
}
|
||||
string str2 = str.Trim();
|
||||
if (str2.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
char ch = culture.TextInfo.ListSeparator[0];
|
||||
string[] strArray = str2.Split(new char[] { ch });
|
||||
Color[] numArray = new Color[strArray.Length];
|
||||
//TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color));
|
||||
for (int i = 0; i < numArray.Length; i++)
|
||||
{
|
||||
numArray[i] = ColorScheme.GetColor(strArray[i]);// (Color)converter.ConvertFromString(context, culture, strArray[i]);
|
||||
}
|
||||
|
||||
if (numArray.Length == 1)
|
||||
{
|
||||
return new BorderColors(numArray[0]);
|
||||
}
|
||||
|
||||
if (numArray.Length != 4)
|
||||
{
|
||||
throw new ArgumentException("Text Parsing Failed");
|
||||
}
|
||||
return new BorderColors(numArray[0], numArray[1], numArray[2], numArray[3]);
|
||||
}
|
||||
|
||||
private string ToArgbString(Color color)
|
||||
{
|
||||
if (color.IsEmpty) return "";
|
||||
if (color.A == 255)
|
||||
return color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
|
||||
return color.A.ToString("X2") + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
|
||||
}
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (value is BorderColors)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
BorderColors colors = (BorderColors)value;
|
||||
if (colors.IsEmpty) return "";
|
||||
if (colors.IsUniform) return ToArgbString(colors.Left);
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
string separator = culture.TextInfo.ListSeparator + " ";
|
||||
//TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color));
|
||||
string[] strArray = new string[4];
|
||||
int num = 0;
|
||||
//strArray[num++] = converter.ConvertToString(context, culture, BorderColors.Left);
|
||||
//strArray[num++] = converter.ConvertToString(context, culture, BorderColors.Top);
|
||||
//strArray[num++] = converter.ConvertToString(context, culture, BorderColors.Right);
|
||||
//strArray[num++] = converter.ConvertToString(context, culture, BorderColors.Bottom);
|
||||
strArray[num++] = ToArgbString(colors.Left);
|
||||
strArray[num++] = ToArgbString(colors.Top);
|
||||
strArray[num++] = ToArgbString(colors.Right);
|
||||
strArray[num++] = ToArgbString(colors.Bottom);
|
||||
return string.Join(separator, strArray);
|
||||
}
|
||||
if (destinationType == typeof(InstanceDescriptor))
|
||||
{
|
||||
BorderColors BorderColors2 = (BorderColors)value;
|
||||
ConstructorInfo constructor = typeof(BorderColors).GetConstructor(new Type[] { typeof(Color), typeof(Color), typeof(Color), typeof(Color) });
|
||||
if (constructor != null)
|
||||
{
|
||||
return new InstanceDescriptor(constructor, new object[] { BorderColors2.Left, BorderColors2.Top, BorderColors2.Right, BorderColors2.Bottom });
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
|
||||
{
|
||||
if (propertyValues == null)
|
||||
{
|
||||
throw new ArgumentNullException("propertyValues");
|
||||
}
|
||||
object left = propertyValues["Left"];
|
||||
object top = propertyValues["Top"];
|
||||
object right = propertyValues["Right"];
|
||||
object bottom = propertyValues["Bottom"];
|
||||
if ((((left == null) || (top == null)) || ((right == null) || (bottom == null))) || ((!(left is Color) || !(top is Color)) || (!(right is Color) || !(bottom is Color))))
|
||||
{
|
||||
throw new ArgumentException(string.Format("Property Value Invalid: left={0}, top={1}, right={2}, bottom={3}", left, top, right, bottom));
|
||||
}
|
||||
return new BorderColors((Color)left, (Color)top, (Color)right, (Color)bottom);
|
||||
}
|
||||
|
||||
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
return TypeDescriptor.GetProperties(typeof(BorderColors), attributes).Sort(new string[] { "Left", "Top", "Right", "Bottom" });
|
||||
}
|
||||
|
||||
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
402
PROMS/DotNetBar Source Code/Metro/ColorTables/MetroColorTable.cs
Normal file
402
PROMS/DotNetBar Source Code/Metro/ColorTables/MetroColorTable.cs
Normal file
@@ -0,0 +1,402 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
public class MetroColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the background color.
|
||||
/// </summary>
|
||||
public Color CanvasColor = Color.White;
|
||||
/// <summary>
|
||||
/// Gets or sets the canvas light shade color. This property is not directly used but it is provided for reference.
|
||||
/// </summary>
|
||||
public Color CanvasColorShadeLight = Color.White;
|
||||
/// <summary>
|
||||
/// Gets or sets the canvas lighter shade color. This property is not directly used but it is provided for reference.
|
||||
/// </summary>
|
||||
public Color CanvasColorShadeLighter = Color.White;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the foreground color.
|
||||
/// </summary>
|
||||
public Color ForeColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the base metro color.
|
||||
/// </summary>
|
||||
public Color BaseColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets background color of edit controls.
|
||||
/// </summary>
|
||||
public Color EditControlBackColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color table for MetroAppForm.
|
||||
/// </summary>
|
||||
public MetroAppFormColorTable MetroAppForm = new MetroAppFormColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color table for MetroForm.
|
||||
/// </summary>
|
||||
public MetroFormColorTable MetroForm = new MetroFormColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color table for MetroTab.
|
||||
/// </summary>
|
||||
public MetroTabColorTable MetroTab = new MetroTabColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets color table for MetroStatusBar.
|
||||
/// </summary>
|
||||
public MetroStatusBarColorTable MetroStatusBar = new MetroStatusBarColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets color table for MetroToolbar.
|
||||
/// </summary>
|
||||
public MetroToolbarColorTable MetroToolbar = new MetroToolbarColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color table used by MetroTile items.
|
||||
/// </summary>
|
||||
public MetroTileColorTable MetroTile = new MetroTileColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the metro-part colors that define the metro UI color scheme. These colors are provided for you reference and reuse in your app.
|
||||
/// </summary>
|
||||
public MetroPartColors MetroPartColors = new MetroPartColors();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents class that defines parameters for Metro style color scheme.
|
||||
/// </summary>
|
||||
[TypeConverterAttribute(typeof(MetroColorGeneratorParametersConverter))]
|
||||
public struct MetroColorGeneratorParameters
|
||||
{
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroStyleParameters class.
|
||||
/// </summary>
|
||||
/// <param name="canvasColor">Canvas color.</param>
|
||||
/// <param name="baseColor">Base color.</param>
|
||||
public MetroColorGeneratorParameters(Color canvasColor, Color baseColor)
|
||||
{
|
||||
if (canvasColor.IsEmpty) canvasColor = DefaultCanvasColor;
|
||||
if (baseColor.IsEmpty) baseColor = DefaultBaseColor;
|
||||
_CanvasColor = canvasColor;
|
||||
_BaseColor = baseColor;
|
||||
_ThemeName = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroColorGeneratorParameters structure.
|
||||
/// </summary>
|
||||
/// <param name="canvasColor">Canvas color.</param>
|
||||
/// <param name="baseColor">Base color.</param>
|
||||
/// <param name="themeName">User friendly theme name.</param>
|
||||
public MetroColorGeneratorParameters(Color canvasColor, Color baseColor, string themeName)
|
||||
{
|
||||
_CanvasColor = canvasColor;
|
||||
_BaseColor = baseColor;
|
||||
_ThemeName = themeName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns array of all predefined Metro color themes.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static MetroColorGeneratorParameters[] GetAllPredefinedThemes()
|
||||
{
|
||||
Type t = typeof(MetroColorGeneratorParameters);
|
||||
PropertyInfo[] members = t.GetProperties(BindingFlags.Public | BindingFlags.Static);
|
||||
List<MetroColorGeneratorParameters> themes = new List<MetroColorGeneratorParameters>();
|
||||
foreach (PropertyInfo mem in members)
|
||||
{
|
||||
if (mem.PropertyType == t)
|
||||
{
|
||||
themes.Add((MetroColorGeneratorParameters)mem.GetValue(null, null));
|
||||
}
|
||||
}
|
||||
return themes.ToArray();
|
||||
}
|
||||
|
||||
private static readonly Color DefaultCanvasColor = Color.White;
|
||||
private Color _CanvasColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the Metro canvas.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of the metro Canvas.")]
|
||||
public Color CanvasColor
|
||||
{
|
||||
get { return _CanvasColor; }
|
||||
set { _CanvasColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeCanvasColor()
|
||||
{
|
||||
return _CanvasColor != DefaultCanvasColor;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetCanvasColor()
|
||||
{
|
||||
this.CanvasColor = DefaultCanvasColor;
|
||||
}
|
||||
|
||||
private static readonly Color DefaultBaseColor = ColorScheme.GetColor("FFA31A");
|
||||
private Color _BaseColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the base color for the Metro style.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates base color of the Metro style.")]
|
||||
public Color BaseColor
|
||||
{
|
||||
get { return _BaseColor; }
|
||||
set { _BaseColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeBaseColor()
|
||||
{
|
||||
return _BaseColor != DefaultBaseColor;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetBaseColor()
|
||||
{
|
||||
this.BaseColor = DefaultBaseColor;
|
||||
}
|
||||
|
||||
private string _ThemeName;
|
||||
/// <summary>
|
||||
/// Gets or sets the user friendly theme name.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public string ThemeName
|
||||
{
|
||||
get { return _ThemeName; }
|
||||
set { _ThemeName = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static Color Schemes
|
||||
public static MetroColorGeneratorParameters Default { get { return new MetroColorGeneratorParameters(Color.White, ColorScheme.GetColor("2B579A"), "Default"); } }
|
||||
public static MetroColorGeneratorParameters Purple { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("6A3889"), "Purple"); } }
|
||||
public static MetroColorGeneratorParameters Red { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("CF4926"), "Red"); } }
|
||||
public static MetroColorGeneratorParameters Green { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("217346"), "Green"); } }
|
||||
public static MetroColorGeneratorParameters Blue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("0072C6"), "Blue"); } }
|
||||
public static MetroColorGeneratorParameters DarkPurple { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("80397B"), "DarkPurple"); } }
|
||||
public static MetroColorGeneratorParameters RedAmplified { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("D24726"), "RedAmplified"); } }
|
||||
public static MetroColorGeneratorParameters ForestGreen { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("077568"), "ForestGreen"); } }
|
||||
|
||||
public static MetroColorGeneratorParameters Brown { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor(0xE7DEC0), ColorScheme.GetColor("6D4320"), "Brown");}}
|
||||
public static MetroColorGeneratorParameters DarkRed { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("F2F2F2"), ColorScheme.GetColor("A4373A"), "Dark Red"); } }
|
||||
public static MetroColorGeneratorParameters Orange { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("ED8E00"), "Orange"); } }
|
||||
public static MetroColorGeneratorParameters BlackMaroon { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("1C190F"), ColorScheme.GetColor("8A2F25"), "Black Maroon");}}
|
||||
public static MetroColorGeneratorParameters BlackSky { get { return new MetroColorGeneratorParameters(Color.Black, ColorScheme.GetColor("00A7FF"), "Black Sky");}}
|
||||
public static MetroColorGeneratorParameters BlackClouds { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("000000"), ColorScheme.GetColor("9B96A3"), "Black Clouds");}}
|
||||
public static MetroColorGeneratorParameters BlackLilac { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("191919"), ColorScheme.GetColor("D8CAFF"), "Black Lilac");}}
|
||||
public static MetroColorGeneratorParameters Bordeaux { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("F2EBDC"), ColorScheme.GetColor("960E00"), "Bordeaux");}}
|
||||
public static MetroColorGeneratorParameters Rust { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("B4B48D"), ColorScheme.GetColor("A94D2D"), "Rust");}}
|
||||
public static MetroColorGeneratorParameters Espresso { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("AB9667"), ColorScheme.GetColor("383025"), "Espresso");}}
|
||||
public static MetroColorGeneratorParameters PowderRed { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("D0D9D6"), ColorScheme.GetColor("BF0404"), "Powder Red");}}
|
||||
public static MetroColorGeneratorParameters BlueishBrown { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("D5D5E0"), ColorScheme.GetColor("3D1429"), "Blueish Brown");}}
|
||||
public static MetroColorGeneratorParameters SilverGreen { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("F2F2F2"), ColorScheme.GetColor("588C3F"), "Silver Green");}}
|
||||
public static MetroColorGeneratorParameters MaroonSilver { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("260B01"), ColorScheme.GetColor("F2F2F2"), "Maroon Silver");}}
|
||||
public static MetroColorGeneratorParameters SkyGreen { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("BDD5D0"), ColorScheme.GetColor("04ADBF"), "Sky Green");}}
|
||||
public static MetroColorGeneratorParameters DarkBrown { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("D9B573"), ColorScheme.GetColor("261105"), "Dark Brown");}}
|
||||
public static MetroColorGeneratorParameters Latte { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("B18D5A"), ColorScheme.GetColor("851A1D"), "Latte");}}
|
||||
public static MetroColorGeneratorParameters Cherry { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("DECDAE"), ColorScheme.GetColor("5A0D12"), "Cherry");}}
|
||||
public static MetroColorGeneratorParameters GrayOrange { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("E8E8DC"), ColorScheme.GetColor("FF8600"), "Gray Orange");}}
|
||||
public static MetroColorGeneratorParameters EarlyRed { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FCFCF0"), ColorScheme.GetColor("C93C00"), "Early Red");}}
|
||||
public static MetroColorGeneratorParameters EarlyMaroon { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FCFCF0"), ColorScheme.GetColor("730046"), "Early Maroon");}}
|
||||
public static MetroColorGeneratorParameters EarlyOrange { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FCFCF0"), ColorScheme.GetColor("E88801"), "Early Orange");}}
|
||||
public static MetroColorGeneratorParameters SilverBlues { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("dcdcdc"), ColorScheme.GetColor("002395"), "Silver Blues");}}
|
||||
public static MetroColorGeneratorParameters RetroBlue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FEFEFE"), ColorScheme.GetColor("3E788F"), "Retro Blue");}}
|
||||
public static MetroColorGeneratorParameters LatteRed { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("A77A51"), ColorScheme.GetColor("8C170D"), "Latte Red");}}
|
||||
public static MetroColorGeneratorParameters LatteDarkSteel { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("A77A51"), ColorScheme.GetColor("2C2D40"), "Latte Dark Steel");}}
|
||||
public static MetroColorGeneratorParameters SimplyBlue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("E2E2E2"), ColorScheme.GetColor("215BA6"), "Simply Blue");}}
|
||||
public static MetroColorGeneratorParameters WashedBlue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("B8CDD1"), ColorScheme.GetColor("B4090A"), "Washed Blue");}}
|
||||
public static MetroColorGeneratorParameters WashedWhite { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FEFFF8"), ColorScheme.GetColor("92AAB1"), "Washed White");}}
|
||||
public static MetroColorGeneratorParameters NapaRed { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("F2F2F2"), ColorScheme.GetColor("A64B29"), "Napa Red");}}
|
||||
public static MetroColorGeneratorParameters Magenta { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("7F3B78"), "Magenta"); } }
|
||||
public static MetroColorGeneratorParameters DarkBlue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("2B569A"), "Dark Blue"); } }
|
||||
public static MetroColorGeneratorParameters VisualStudio2012Light { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("EFEFF2"), ColorScheme.GetColor("007ACC"), "Visual Studio 2012 Light"); } }
|
||||
public static MetroColorGeneratorParameters VisualStudio2012Dark { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("2D2D30"), ColorScheme.GetColor("007ACC"), "Visual Studio 2012 Dark"); } }
|
||||
public static MetroColorGeneratorParameters Office2016Blue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("0173C7"), "Office 2016 Blue"); } }
|
||||
public static MetroColorGeneratorParameters Office2016DarkBlue { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("2A579A"), "Office 2016 Dark Blue"); } }
|
||||
public static MetroColorGeneratorParameters Office2016Green { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("227447"), "Office 2016 Green"); } }
|
||||
public static MetroColorGeneratorParameters Office2016Orange { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("B7472A"), "Office 2016 Orange"); } }
|
||||
public static MetroColorGeneratorParameters Office2016Red { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("A4373A"), "Office 2016 Red"); } }
|
||||
public static MetroColorGeneratorParameters Office2016Purple { get { return new MetroColorGeneratorParameters(ColorScheme.GetColor("FFFFFF"), ColorScheme.GetColor("80397B"), "Office 2016 Purple"); } }
|
||||
|
||||
#endregion
|
||||
}
|
||||
#region MetroColorGeneratorParameters
|
||||
public class MetroColorGeneratorParametersConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return ((destinationType == typeof(InstanceDescriptor)) || base.CanConvertTo(context, destinationType));
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
string str = value as string;
|
||||
if (str == null)
|
||||
{
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
string str2 = str.Trim();
|
||||
if (str2.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
char ch = culture.TextInfo.ListSeparator[0];
|
||||
string[] strArray = str2.Split(new char[] { ch });
|
||||
if (strArray.Length != 2)
|
||||
{
|
||||
throw new ArgumentException("String parsing failed due to incorrect format.");
|
||||
}
|
||||
|
||||
MetroColorGeneratorParameters colorParams = new MetroColorGeneratorParameters();
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color));
|
||||
|
||||
colorParams.CanvasColor = (Color)converter.ConvertFromString(context, culture, strArray[0]);
|
||||
colorParams.BaseColor = (Color)converter.ConvertFromString(context, culture, strArray[1]);
|
||||
|
||||
return colorParams;
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (value is MetroColorGeneratorParameters)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
MetroColorGeneratorParameters colorParams = (MetroColorGeneratorParameters)value;
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
string separator = culture.TextInfo.ListSeparator + " ";
|
||||
//TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color));
|
||||
string[] strArray = new string[2];
|
||||
int num = 0;
|
||||
strArray[num++] = ColorToString(culture, colorParams.CanvasColor); // converter.ConvertToString(context, culture, colorParams.CanvasColor);
|
||||
strArray[num++] = ColorToString(culture, colorParams.BaseColor); // converter.ConvertToString(context, culture, colorParams.BaseColor);
|
||||
return string.Join(separator, strArray);
|
||||
}
|
||||
if (destinationType == typeof(InstanceDescriptor))
|
||||
{
|
||||
MetroColorGeneratorParameters colorParams = (MetroColorGeneratorParameters)value;
|
||||
ConstructorInfo constructor = typeof(MetroColorGeneratorParameters).GetConstructor(new Type[] { typeof(Color), typeof(Color) });
|
||||
if (constructor != null)
|
||||
{
|
||||
return new InstanceDescriptor(constructor, new object[] { colorParams.CanvasColor, colorParams.BaseColor });
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
private static string ColorToString(CultureInfo culture, Color color)
|
||||
{
|
||||
string[] strArray;
|
||||
if (color == Color.Empty)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (color.IsKnownColor)
|
||||
{
|
||||
return color.Name;
|
||||
}
|
||||
if (color.IsNamedColor)
|
||||
{
|
||||
return ("'" + color.Name + "'");
|
||||
}
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
string separator = "";
|
||||
int num = 0;
|
||||
if (color.A < 0xff)
|
||||
{
|
||||
strArray = new string[4];
|
||||
strArray[num++] = color.A.ToString("X2");
|
||||
}
|
||||
else
|
||||
{
|
||||
strArray = new string[3];
|
||||
}
|
||||
strArray[num++] = color.R.ToString("X2");
|
||||
strArray[num++] = color.G.ToString("X2");
|
||||
strArray[num++] = color.B.ToString("X2");
|
||||
return "#" + string.Join(separator, strArray);
|
||||
|
||||
}
|
||||
|
||||
public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
|
||||
{
|
||||
if (propertyValues == null)
|
||||
{
|
||||
throw new ArgumentNullException("propertyValues");
|
||||
}
|
||||
object canvasColor = propertyValues["CanvasColor"];
|
||||
object baseColor = propertyValues["BaseColor"];
|
||||
if (canvasColor == null || !(canvasColor is Color) || baseColor==null || !(baseColor is Color))
|
||||
{
|
||||
throw new ArgumentException("Invalid property value entry");
|
||||
}
|
||||
return new MetroColorGeneratorParameters((Color)canvasColor, (Color)baseColor);
|
||||
}
|
||||
|
||||
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
return TypeDescriptor.GetProperties(typeof(MetroColorGeneratorParameters), attributes).Sort(new string[] { "CanvasColor", "BaseColor" });
|
||||
}
|
||||
|
||||
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,318 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using DevComponents.DotNetBar.Metro.Helpers;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the Metro UI color table based on colors specified.
|
||||
/// </summary>
|
||||
internal class MetroColorTableInitializer
|
||||
{
|
||||
public static MetroColorTable CreateColorTable(MetroColorGeneratorParameters colorParams)
|
||||
{
|
||||
return CreateColorTable(colorParams.CanvasColor, colorParams.BaseColor);
|
||||
}
|
||||
public static MetroColorTable CreateColorTable(Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroColorTable metroTable = new MetroColorTable();
|
||||
Office2007ColorTable officeMetroColorTable = new Office2007ColorTable();
|
||||
CreateColors(metroTable, officeMetroColorTable, canvasColor, baseColor);
|
||||
if (StyleManager.IsMetro(StyleManager.Style))
|
||||
((Office2007Renderer)GlobalManager.Renderer).ColorTable = officeMetroColorTable;
|
||||
return metroTable;
|
||||
}
|
||||
|
||||
private const double DEGREE = 1d / 360;
|
||||
private static double GetHue(double hue, int addDegrees)
|
||||
{
|
||||
hue += addDegrees * DEGREE;
|
||||
if (hue > 1)
|
||||
hue -= 1;
|
||||
else if (hue < 0)
|
||||
hue += 1;
|
||||
return hue;
|
||||
}
|
||||
private static double GetComplementSaturation(double saturation)
|
||||
{
|
||||
if (saturation == 1) return 1;
|
||||
|
||||
if (saturation < .81d)
|
||||
return saturation + .1d;
|
||||
if (saturation < .91d)
|
||||
return saturation + .05d;
|
||||
return saturation + (.99d - saturation);
|
||||
}
|
||||
public static MetroPartColors CreateMetroPartColors(Color canvasColor, Color baseColor)
|
||||
{
|
||||
ColorFunctions.HLSColor canvasHsl = ColorFunctions.RGBToHSL(canvasColor);
|
||||
ColorFunctions.HLSColor baseHsl = ColorFunctions.RGBToHSL(baseColor);
|
||||
HSVColor baseHsv = ColorHelpers.ColorToHSV(baseColor);
|
||||
HSVColor canvasHsv = ColorHelpers.ColorToHSV(canvasColor);
|
||||
|
||||
// Create metro colors
|
||||
MetroPartColors partColors = new MetroPartColors();
|
||||
partColors.CanvasColor = canvasColor;
|
||||
partColors.BaseColor = baseColor;
|
||||
partColors.TextColor = (canvasHsl.Lightness < .4) ? Color.White : Color.Black;
|
||||
//HSVColor textHsv = ColorHelpers.ColorToHSV(partColors.TextColor);
|
||||
partColors.TextInactiveColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .53 : canvasHsv.Value - .47));
|
||||
partColors.TextDisabledColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .67));
|
||||
partColors.TextLightColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .6 : canvasHsv.Value + .4));
|
||||
partColors.CanvasColorDarkShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .67));
|
||||
partColors.CanvasColorLightShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .17 : canvasHsv.Value - .17));
|
||||
partColors.CanvasColorLighterShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .05 : canvasHsv.Value - .05));
|
||||
if(partColors.IsSolidCanvas)
|
||||
partColors.CanvasColorLight = (partColors.TextColor == Color.Black)?ColorHelpers.HSVToColor(0, 0, .99):ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, canvasHsv.Value+.05);
|
||||
else
|
||||
partColors.CanvasColorLight = (partColors.TextColor == Color.Black) ? ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, canvasHsv.Value + (canvasHsv.Value>=.96?.020:.058)) : ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, canvasHsv.Value - .05);
|
||||
//Console.WriteLine(string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", partColors.CanvasColorLight.A, partColors.CanvasColorLight.R, partColors.CanvasColorLight.G, partColors.CanvasColorLight.B));
|
||||
partColors.BaseTextColor = GetTextColor(baseColor);
|
||||
|
||||
partColors.BaseColorLight = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .41), baseHsv.Value + .3);
|
||||
partColors.BaseColorLight1 = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .12), baseHsv.Value + .12);
|
||||
partColors.BaseColorLightText = GetTextColor(partColors.BaseColorLight);
|
||||
|
||||
partColors.BaseColorLightest = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .6), baseHsv.Value + .35);
|
||||
partColors.BaseColorLighter = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .4), baseHsv.Value + .39);
|
||||
partColors.BaseColorDark = ColorHelpers.HSVToColor(baseHsv.Hue, baseHsv.Saturation + .1, baseHsv.Value - .06);
|
||||
partColors.BaseColorDarker = ColorFunctions.HLSToRGB(baseHsl.Hue, baseHsl.Lightness - .2, baseHsl.Saturation);
|
||||
|
||||
partColors.ComplementColor = ColorHelpers.HSVToColor(GetComplementHue(baseHsv.Hue), baseHsv.Saturation, baseHsv.Value + (baseHsv.Value > .5d ? -.35 : 0d));
|
||||
ColorFunctions.HLSColor compHsl = ColorFunctions.RGBToHSL(partColors.ComplementColor);
|
||||
HSVColor compHsv = ColorHelpers.ColorToHSV(partColors.ComplementColor);
|
||||
partColors.ComplementColorLight = ColorHelpers.HSVToColor(compHsv.Hue, compHsv.Saturation, compHsv.Value + .2d);
|
||||
partColors.ComplementColorDark = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .10, compHsl.Saturation);
|
||||
partColors.ComplementColorDarker = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .2, compHsl.Saturation);
|
||||
partColors.ComplementColorText = GetTextColor(partColors.ComplementColor);
|
||||
partColors.ComplementColorLightText = GetTextColor(partColors.ComplementColorLight);
|
||||
|
||||
partColors.BaseButtonGradientStart = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .01 : canvasHsv.Value + .08));
|
||||
partColors.BaseButtonGradientEnd = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .08 : canvasHsv.Value + .20));
|
||||
|
||||
if (partColors.TextColor == Color.Black)
|
||||
partColors.EditControlBackColor = Color.White;
|
||||
else
|
||||
partColors.EditControlBackColor = Color.Black;
|
||||
|
||||
return partColors;
|
||||
}
|
||||
public static void CreateColors(MetroColorTable metroTable, Office2007ColorTable officeMetroColorTable, Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroPartColors partColors = CreateMetroPartColors(canvasColor, baseColor);
|
||||
|
||||
metroTable.CanvasColor = partColors.CanvasColor;
|
||||
metroTable.CanvasColorShadeLight = partColors.CanvasColorLightShade;
|
||||
metroTable.CanvasColorShadeLighter = partColors.CanvasColorLighterShade;
|
||||
metroTable.ForeColor = partColors.TextColor;
|
||||
metroTable.BaseColor = baseColor;
|
||||
metroTable.EditControlBackColor = partColors.EditControlBackColor;
|
||||
metroTable.MetroPartColors = partColors;
|
||||
|
||||
metroTable.MetroAppForm.BorderThickness = new Thickness(0, 0, 1, 1);
|
||||
metroTable.MetroAppForm.BorderColors = new BorderColors(partColors.BaseColor);
|
||||
metroTable.MetroAppForm.BorderColorsInactive = new BorderColors(partColors.BaseColorLight);
|
||||
|
||||
metroTable.MetroForm.BorderThickness = new Thickness(3, 3, 3, 3);
|
||||
metroTable.MetroForm.BorderColors = new BorderColors[3] { new BorderColors(partColors.BaseColorDark), new BorderColors(partColors.BaseColor), new BorderColors(partColors.BaseColor) };
|
||||
metroTable.MetroForm.BorderColorsInactive = new BorderColors[4] { new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight) };
|
||||
|
||||
metroTable.MetroTab.ActiveCaptionText = partColors.TextInactiveColor;
|
||||
metroTable.MetroTab.InactiveCaptionText = partColors.TextDisabledColor;
|
||||
|
||||
metroTable.MetroTab.MetroTabItem.Default = GetMetroTabItemStateTable(partColors.TextInactiveColor);
|
||||
metroTable.MetroTab.MetroTabItem.Selected = GetMetroTabItemStateTable(partColors.BaseColor);
|
||||
metroTable.MetroTab.MetroTabItem.Disabled = GetMetroTabItemStateTable(partColors.TextDisabledColor);
|
||||
metroTable.MetroTab.MetroTabItem.MouseOver = GetMetroTabItemStateTable(partColors.TextInactiveColor, partColors.BaseColor);
|
||||
metroTable.MetroTab.MetroTabItem.Pressed = null;
|
||||
|
||||
metroTable.MetroTab.TabPanelBackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColor);
|
||||
|
||||
// Toolbar
|
||||
metroTable.MetroToolbar.BackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColor);
|
||||
|
||||
// Status Bar
|
||||
metroTable.MetroStatusBar.BackgroundStyle = new ElementStyle(partColors.TextColor, partColors.BaseColor);
|
||||
metroTable.MetroStatusBar.TopBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.BottomBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.ResizeMarkerLightColor = Color.FromArgb(196, Color.White);
|
||||
metroTable.MetroStatusBar.ResizeMarkerColor = partColors.BaseColorDarker;
|
||||
|
||||
MetroOfficeColorTableInitializer.InitializeColorTable(officeMetroColorTable, ColorFactory.Empty, partColors);
|
||||
}
|
||||
private static double GetColorMin(double minValue, double value)
|
||||
{
|
||||
if (value < 0)
|
||||
return minValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Color GetTextColor(Color color)
|
||||
{
|
||||
ColorFunctions.HLSColor hslColor = ColorFunctions.RGBToHSL(color);
|
||||
return hslColor.Lightness < .65 ? Color.White : Color.Black;
|
||||
//HSVColor hsvColor = ColorHelpers.ColorToHSV(backColor);
|
||||
//return hsvColor.Value < .65 ? Color.White : Color.Black;
|
||||
}
|
||||
|
||||
private static double GetComplementHue(double hue)
|
||||
{
|
||||
if (hue <= .37777d)
|
||||
{
|
||||
return Math.Min(1, hue + (137 * DEGREE + (86 * DEGREE * (hue / .37777d))));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.Max(0, hue - (137 * DEGREE + (86 * DEGREE * (hue / .6222222d))));// ((137 + 86 * DEGREE * (hue / .6222222) * DEGREE)));
|
||||
}
|
||||
}
|
||||
|
||||
private static MetroTabItemStateColorTable GetMetroTabItemStateTable(Color textColor)
|
||||
{
|
||||
return GetMetroTabItemStateTable(textColor, Color.Empty);
|
||||
}
|
||||
private static MetroTabItemStateColorTable GetMetroTabItemStateTable(Color textColor, Color bottomBorderColor)
|
||||
{
|
||||
ElementStyle style = new ElementStyle(textColor);
|
||||
style.TextAlignment = eStyleTextAlignment.Center;
|
||||
style.TextLineAlignment = eStyleTextAlignment.Center;
|
||||
style.HideMnemonic = true;
|
||||
if (!bottomBorderColor.IsEmpty)
|
||||
{
|
||||
style.BorderBottom = eStyleBorderType.Solid;
|
||||
style.BorderBottomWidth = 2;
|
||||
style.BorderBottomColor = bottomBorderColor;
|
||||
}
|
||||
return new MetroTabItemStateColorTable(style);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Defines base set of Metro UI color scheme.
|
||||
/// </summary>
|
||||
public class MetroPartColors
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the base canvas color, like form background.
|
||||
/// </summary>
|
||||
public Color CanvasColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the chrome base color, used for window border, selection marking etc.
|
||||
/// </summary>
|
||||
public Color BaseColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the text color for text displayed over the BaseColor.
|
||||
/// </summary>
|
||||
public Color BaseTextColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the text color displayed over the canvas color.
|
||||
/// </summary>
|
||||
public Color TextColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the lighter text color used for example for inactive non selected tab text etc.
|
||||
/// </summary>
|
||||
public Color TextInactiveColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the text color used for disabled text.
|
||||
/// </summary>
|
||||
public Color TextDisabledColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the text light color.
|
||||
/// </summary>
|
||||
public Color TextLightColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the color that lighter than canvas color unless canvas is white in which case this will be white as well.
|
||||
/// </summary>
|
||||
public Color CanvasColorLight;
|
||||
/// <summary>
|
||||
/// Gets or sets the color that is in dark shade off of the canvas color.
|
||||
/// </summary>
|
||||
public Color CanvasColorDarkShade;
|
||||
/// <summary>
|
||||
/// Gets or sets the color that is in darker shade off of the canvas color.
|
||||
/// </summary>
|
||||
public Color CanvasColorDarkerShade;
|
||||
/// <summary>
|
||||
/// Gets or sets the color that is in light shade off of the canvas color.
|
||||
/// </summary>
|
||||
public Color CanvasColorLightShade;
|
||||
/// <summary>
|
||||
/// Gets or sets the color that is in lighter shade off of the canvas color.
|
||||
/// </summary>
|
||||
public Color CanvasColorLighterShade;
|
||||
/// <summary>
|
||||
/// Gets or sets the light base color shade.
|
||||
/// </summary>
|
||||
public Color BaseColorLight;
|
||||
/// <summary>
|
||||
/// Gets or sets the just a tad lighter base color.
|
||||
/// </summary>
|
||||
public Color BaseColorLight1;
|
||||
/// <summary>
|
||||
/// Gets or sets the text color for light base color.
|
||||
/// </summary>
|
||||
public Color BaseColorLightText;
|
||||
/// <summary>
|
||||
/// Gets or sets the lighter base color shade.
|
||||
/// </summary>
|
||||
public Color BaseColorLighter;
|
||||
/// <summary>
|
||||
/// Gets or sets the lightest base color shade.
|
||||
/// </summary>
|
||||
public Color BaseColorLightest;
|
||||
/// <summary>
|
||||
/// Gets or sets the dark base color shade.
|
||||
/// </summary>
|
||||
public Color BaseColorDark;
|
||||
/// <summary>
|
||||
/// Gets or sets the darker base color shade.
|
||||
/// </summary>
|
||||
public Color BaseColorDarker;
|
||||
/// <summary>
|
||||
/// Gets or sets the base color analogous color 1
|
||||
/// </summary>
|
||||
public Color ComplementColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the Analogous color light variant.
|
||||
/// </summary>
|
||||
public Color ComplementColorLight;
|
||||
/// <summary>
|
||||
/// Gets or sets the text color for Analogous color light variant.
|
||||
/// </summary>
|
||||
public Color ComplementColorLightText;
|
||||
/// <summary>
|
||||
/// Gets or sets the Analogous color dark variant.
|
||||
/// </summary>
|
||||
public Color ComplementColorDark;
|
||||
/// <summary>
|
||||
/// Gets or sets the Analogous color darker variant.
|
||||
/// </summary>
|
||||
public Color ComplementColorDarker;
|
||||
/// <summary>
|
||||
/// Gets or sets the Analogous color text color.
|
||||
/// </summary>
|
||||
public Color ComplementColorText;
|
||||
/// <summary>
|
||||
/// Gets or sets the off base color button gradient start.
|
||||
/// </summary>
|
||||
public Color BaseButtonGradientStart;
|
||||
/// <summary>
|
||||
/// Gets or sets the off base color button gradient start.
|
||||
/// </summary>
|
||||
public Color BaseButtonGradientEnd;
|
||||
/// <summary>
|
||||
/// Gets or sets background color of edit controls.
|
||||
/// </summary>
|
||||
public Color EditControlBackColor;
|
||||
|
||||
internal bool IsSolidCanvas
|
||||
{
|
||||
get
|
||||
{
|
||||
return CanvasColor == Color.White || CanvasColor == Color.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the MetroAppForm color table.
|
||||
/// </summary>
|
||||
public class MetroAppFormColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the border thickness.
|
||||
/// </summary>
|
||||
public Thickness BorderThickness = new Thickness(0, 0, 1, 1);
|
||||
/// <summary>
|
||||
/// Gets or sets the border thickness for form when it is running on Windows without Glass effect enabled.
|
||||
/// </summary>
|
||||
public Thickness BorderPlainThickness = new Thickness(1);
|
||||
/// <summary>
|
||||
/// Gets or sets the border colors.
|
||||
/// </summary>
|
||||
public BorderColors BorderColors = new BorderColors(ColorScheme.GetColor("FF6B10"));
|
||||
/// <summary>
|
||||
/// Gets or sets the inactive form border colors.
|
||||
/// </summary>
|
||||
public BorderColors BorderColorsInactive = new BorderColors();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the MetroForm color table.
|
||||
/// </summary>
|
||||
public class MetroFormColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the border thickness.
|
||||
/// </summary>
|
||||
public Thickness BorderThickness = new Thickness(0, 0, 1, 1);
|
||||
/// <summary>
|
||||
/// Gets or sets the border thickness for form when it is running on Windows without Glass effect enabled.
|
||||
/// </summary>
|
||||
public Thickness BorderPlainThickness = new Thickness(1);
|
||||
/// <summary>
|
||||
/// Gets or sets the border colors.
|
||||
/// </summary>
|
||||
public BorderColors[] BorderColors = new BorderColors[1] { new BorderColors(ColorScheme.GetColor("FF6B10")) };
|
||||
/// <summary>
|
||||
/// Gets or sets the inactive form border colors.
|
||||
/// </summary>
|
||||
public BorderColors[] BorderColorsInactive = null;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
public class MetroStatusBarColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the color array for the top-border lines.
|
||||
/// </summary>
|
||||
public Color[] TopBorders;
|
||||
/// <summary>
|
||||
/// Gets or sets the color array for the bottom-border lines.
|
||||
/// </summary>
|
||||
public Color[] BottomBorders;
|
||||
/// <summary>
|
||||
/// Gets or sets status bar background style.
|
||||
/// </summary>
|
||||
public ElementStyle BackgroundStyle = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the resize handle marker light color.
|
||||
/// </summary>
|
||||
public Color ResizeMarkerLightColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the resize handle marker color.
|
||||
/// </summary>
|
||||
public Color ResizeMarkerColor;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
public class MetroTabColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the color table for MetroTabStrip.
|
||||
/// </summary>
|
||||
public MetroTabStripColorTable TabStrip = new MetroTabStripColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets tab panel background style.
|
||||
/// </summary>
|
||||
public ElementStyle TabPanelBackgroundStyle = new ElementStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color table for MetroTabItem.
|
||||
/// </summary>
|
||||
public MetroTabItemColorTable MetroTabItem = new MetroTabItemColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the active form caption text displayed on metro strip.
|
||||
/// </summary>
|
||||
public Color ActiveCaptionText;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the inactive form caption text displayed on metro strip.
|
||||
/// </summary>
|
||||
public Color InactiveCaptionText;
|
||||
/// <summary>
|
||||
/// Gets or sets the text formatting for caption text.
|
||||
/// </summary>
|
||||
public eTextFormat CaptionTextFormat = eTextFormat.VerticalCenter | eTextFormat.Left | eTextFormat.EndEllipsis | eTextFormat.NoPrefix;
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents MetroTabItem color table.
|
||||
/// </summary>
|
||||
public class MetroTabItemColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the default state tab colors.
|
||||
/// </summary>
|
||||
public MetroTabItemStateColorTable Default;
|
||||
/// <summary>
|
||||
/// Gets or sets the mouse over state tab colors.
|
||||
/// </summary>
|
||||
public MetroTabItemStateColorTable MouseOver;
|
||||
/// <summary>
|
||||
/// Gets or sets the selected state tab colors.
|
||||
/// </summary>
|
||||
public MetroTabItemStateColorTable Selected;
|
||||
/// <summary>
|
||||
/// Gets or sets the pressed state tab colors.
|
||||
/// </summary>
|
||||
public MetroTabItemStateColorTable Pressed;
|
||||
/// <summary>
|
||||
/// Gets or sets the disabled state tab colors.
|
||||
/// </summary>
|
||||
public MetroTabItemStateColorTable Disabled;
|
||||
}
|
||||
|
||||
public class MetroTabItemStateColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroTabItemStateColorTable class.
|
||||
/// </summary>
|
||||
/// <param name="textColor"></param>
|
||||
/// <param name="background"></param>
|
||||
public MetroTabItemStateColorTable(ElementStyle background)
|
||||
{
|
||||
Background = background;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background style.
|
||||
/// </summary>
|
||||
public ElementStyle Background = null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
public class MetroTabStripColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets tabstrip background style.
|
||||
/// </summary>
|
||||
public ElementStyle BackgroundStyle = new ElementStyle();
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
public class MetroTileColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the tile check-mark background overlay color.
|
||||
/// </summary>
|
||||
public Color CheckBackground = Color.FromArgb(76, Color.Black);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tile check-mark foreground overlay color.
|
||||
/// </summary>
|
||||
public Color CheckForeground = Color.FromArgb(204, Color.White);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
public class MetroToolbarColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets toolbar background style.
|
||||
/// </summary>
|
||||
public ElementStyle BackgroundStyle = null;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using DevComponents.DotNetBar.Metro.Helpers;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
internal class Office2016MetroInitializer
|
||||
{
|
||||
public static MetroColorTable CreateColorTable(MetroColorGeneratorParameters colorParams)
|
||||
{
|
||||
return CreateColorTable(colorParams.CanvasColor, colorParams.BaseColor);
|
||||
}
|
||||
public static MetroColorTable CreateColorTable(Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroColorTable metroTable = new MetroColorTable();
|
||||
Office2007ColorTable officeMetroColorTable = new Office2007ColorTable();
|
||||
CreateColors(metroTable, officeMetroColorTable, canvasColor, baseColor);
|
||||
if (StyleManager.IsMetro(StyleManager.Style))
|
||||
((Office2007Renderer)GlobalManager.Renderer).ColorTable = officeMetroColorTable;
|
||||
return metroTable;
|
||||
}
|
||||
|
||||
private const double DEGREE = 1d / 360;
|
||||
public static MetroPartColors CreateMetroPartColors(Color canvasColor, Color baseColor)
|
||||
{
|
||||
ColorFunctions.HLSColor canvasHsl = ColorFunctions.RGBToHSL(canvasColor);
|
||||
ColorFunctions.HLSColor baseHsl = ColorFunctions.RGBToHSL(baseColor);
|
||||
HSVColor baseHsv = ColorHelpers.ColorToHSV(baseColor);
|
||||
HSVColor canvasHsv = ColorHelpers.ColorToHSV(canvasColor);
|
||||
|
||||
// Create metro colors
|
||||
MetroPartColors partColors = new MetroPartColors();
|
||||
partColors.CanvasColor = canvasColor;
|
||||
partColors.BaseColor = baseColor;
|
||||
partColors.TextColor = (canvasHsl.Lightness < .4) ? Color.White : Color.Black;
|
||||
//HSVColor textHsv = ColorHelpers.ColorToHSV(partColors.TextColor);
|
||||
partColors.TextInactiveColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .53 : canvasHsv.Value - .47));
|
||||
partColors.TextDisabledColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .67));
|
||||
partColors.TextLightColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .6 : canvasHsv.Value + .4));
|
||||
partColors.CanvasColorDarkShade = partColors.TextColor == Color.Black ? ColorScheme.GetColor(0xC8C8C8) : ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .33));
|
||||
partColors.CanvasColorDarkerShade = ColorScheme.GetColor(0xB4B4B4);
|
||||
partColors.CanvasColorLightShade = ColorScheme.GetColor(0xCCCCCC);
|
||||
partColors.CanvasColorLighterShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .08 : canvasHsv.Value - .08));
|
||||
partColors.CanvasColorLight = (partColors.TextColor == Color.Black) ? ColorScheme.GetColor(0xF1F1F1) : ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, canvasHsv.Value + .06);
|
||||
partColors.BaseTextColor = GetTextColor(baseColor);
|
||||
|
||||
partColors.BaseColorLight = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .41), baseHsv.Value + .3);
|
||||
partColors.BaseColorLight1 = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .12), baseHsv.Value + .12);
|
||||
partColors.BaseColorLightText = GetTextColor(partColors.BaseColorLight);
|
||||
|
||||
partColors.BaseColorLightest = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .6), baseHsv.Value + .5);
|
||||
partColors.BaseColorLighter = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .46), baseHsv.Value + .39);
|
||||
partColors.BaseColorDark = ColorHelpers.HSVToColor(baseHsv.Hue, baseHsv.Saturation + .1, baseHsv.Value - .06);
|
||||
partColors.BaseColorDarker = ColorFunctions.HLSToRGB(baseHsl.Hue, baseHsl.Lightness - .2, baseHsl.Saturation);
|
||||
|
||||
partColors.ComplementColor = ColorHelpers.HSVToColor(GetComplementHue(baseHsv.Hue), baseHsv.Saturation, baseHsv.Value + (baseHsv.Value > .5d ? -.35 : 0d));
|
||||
ColorFunctions.HLSColor compHsl = ColorFunctions.RGBToHSL(partColors.ComplementColor);
|
||||
HSVColor compHsv = ColorHelpers.ColorToHSV(partColors.ComplementColor);
|
||||
partColors.ComplementColorLight = ColorHelpers.HSVToColor(compHsv.Hue, compHsv.Saturation, compHsv.Value + .2d);
|
||||
partColors.ComplementColorDark = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .10, compHsl.Saturation);
|
||||
partColors.ComplementColorDarker = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .2, compHsl.Saturation);
|
||||
partColors.ComplementColorText = GetTextColor(partColors.ComplementColor);
|
||||
partColors.ComplementColorLightText = GetTextColor(partColors.ComplementColorLight);
|
||||
|
||||
partColors.BaseButtonGradientStart = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .01 : canvasHsv.Value + .08));
|
||||
partColors.BaseButtonGradientEnd = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .08 : canvasHsv.Value + .20));
|
||||
|
||||
if (partColors.TextColor == Color.Black)
|
||||
partColors.EditControlBackColor = Color.White;
|
||||
else
|
||||
partColors.EditControlBackColor = Color.Black;
|
||||
|
||||
return partColors;
|
||||
}
|
||||
public static void CreateColors(MetroColorTable metroTable, Office2007ColorTable officeMetroColorTable, Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroPartColors partColors = CreateMetroPartColors(canvasColor, baseColor);
|
||||
|
||||
metroTable.CanvasColor = partColors.CanvasColor;
|
||||
metroTable.CanvasColorShadeLight = partColors.CanvasColorLightShade;
|
||||
metroTable.CanvasColorShadeLighter = partColors.CanvasColorLighterShade;
|
||||
metroTable.ForeColor = partColors.TextColor;
|
||||
metroTable.BaseColor = baseColor;
|
||||
metroTable.EditControlBackColor = partColors.EditControlBackColor;
|
||||
metroTable.MetroPartColors = partColors;
|
||||
|
||||
metroTable.MetroAppForm.BorderThickness = new Thickness(1, 1, 1, 1);
|
||||
metroTable.MetroAppForm.BorderColors = new BorderColors(partColors.BaseColor);
|
||||
metroTable.MetroAppForm.BorderColorsInactive = new BorderColors(partColors.BaseColorLight);
|
||||
|
||||
metroTable.MetroForm.BorderThickness = new Thickness(1, 1, 1, 1);
|
||||
metroTable.MetroForm.BorderColors = new BorderColors[1] { new BorderColors(partColors.BaseColor) };
|
||||
metroTable.MetroForm.BorderColorsInactive = new BorderColors[4] { new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight) };
|
||||
|
||||
metroTable.MetroTab.ActiveCaptionText = partColors.BaseTextColor;
|
||||
metroTable.MetroTab.InactiveCaptionText = partColors.BaseTextColor;
|
||||
|
||||
metroTable.MetroTab.MetroTabItem.Default = GetMetroTabItemStateTable(partColors.BaseTextColor, Color.Empty);
|
||||
metroTable.MetroTab.MetroTabItem.Selected = GetMetroTabItemStateTable(partColors.BaseColor, partColors.CanvasColorLight);
|
||||
metroTable.MetroTab.MetroTabItem.Disabled = GetMetroTabItemStateTable(partColors.TextDisabledColor, Color.Empty);
|
||||
metroTable.MetroTab.MetroTabItem.MouseOver = null;
|
||||
metroTable.MetroTab.MetroTabItem.Pressed = null;
|
||||
metroTable.MetroTab.TabStrip.BackgroundStyle = new ElementStyle(partColors.BaseTextColor, partColors.BaseColor);
|
||||
metroTable.MetroTab.CaptionTextFormat = eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter | eTextFormat.EndEllipsis | eTextFormat.NoPrefix;
|
||||
|
||||
metroTable.MetroTab.TabPanelBackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColorLight);
|
||||
|
||||
// Toolbar
|
||||
metroTable.MetroToolbar.BackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColorLight);
|
||||
|
||||
// Status Bar
|
||||
metroTable.MetroStatusBar.BackgroundStyle = new ElementStyle(partColors.BaseTextColor, partColors.BaseColor);
|
||||
metroTable.MetroStatusBar.TopBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.BottomBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.ResizeMarkerLightColor = Color.FromArgb(196, Color.White);
|
||||
metroTable.MetroStatusBar.ResizeMarkerColor = partColors.BaseColorDarker;
|
||||
|
||||
Office2016ColorTableInitializer.InitializeColorTable(officeMetroColorTable, ColorFactory.Empty, partColors);
|
||||
}
|
||||
private static double GetColorMin(double minValue, double value)
|
||||
{
|
||||
if (value < 0)
|
||||
return minValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Color GetTextColor(Color color)
|
||||
{
|
||||
ColorFunctions.HLSColor hslColor = ColorFunctions.RGBToHSL(color);
|
||||
return hslColor.Lightness < .65 ? Color.White : Color.Black;
|
||||
//HSVColor hsvColor = ColorHelpers.ColorToHSV(backColor);
|
||||
//return hsvColor.Value < .65 ? Color.White : Color.Black;
|
||||
}
|
||||
|
||||
private static double GetComplementHue(double hue)
|
||||
{
|
||||
if (hue <= .37777d)
|
||||
{
|
||||
return Math.Min(1, hue + (137 * DEGREE + (86 * DEGREE * (hue / .37777d))));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.Max(0, hue - (137 * DEGREE + (86 * DEGREE * (hue / .6222222d))));// ((137 + 86 * DEGREE * (hue / .6222222) * DEGREE)));
|
||||
}
|
||||
}
|
||||
|
||||
private static MetroTabItemStateColorTable GetMetroTabItemStateTable(Color textColor, Color backColor)
|
||||
{
|
||||
ElementStyle style = new ElementStyle(textColor);
|
||||
style.TextAlignment = eStyleTextAlignment.Center;
|
||||
style.TextLineAlignment = eStyleTextAlignment.Center;
|
||||
style.HideMnemonic = true;
|
||||
if (!backColor.IsEmpty)
|
||||
{
|
||||
style.CornerTypeTopRight = eCornerType.Rounded;
|
||||
style.CornerTypeTopLeft = eCornerType.Rounded;
|
||||
style.CornerDiameter = 2;
|
||||
style.BorderLeft = eStyleBorderType.Solid;
|
||||
style.BorderTop = eStyleBorderType.Solid;
|
||||
style.BorderRight = eStyleBorderType.Solid;
|
||||
style.BorderLeftWidth = 1;
|
||||
style.BorderTopWidth = 1;
|
||||
style.BorderRightWidth = 1;
|
||||
style.BorderColor = backColor;
|
||||
style.BackColor = backColor;
|
||||
}
|
||||
style.TextColor = textColor;
|
||||
return new MetroTabItemStateColorTable(style);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using DevComponents.DotNetBar.Metro.Helpers;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes Office Mobile 2014 color scheme Metro color table based on colors specified.
|
||||
/// </summary>
|
||||
internal class OfficeMobile2014MetroInitializer
|
||||
{
|
||||
public static MetroColorTable CreateColorTable(MetroColorGeneratorParameters colorParams)
|
||||
{
|
||||
return CreateColorTable(colorParams.CanvasColor, colorParams.BaseColor);
|
||||
}
|
||||
public static MetroColorTable CreateColorTable(Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroColorTable metroTable = new MetroColorTable();
|
||||
Office2007ColorTable officeMetroColorTable = new Office2007ColorTable();
|
||||
CreateColors(metroTable, officeMetroColorTable, canvasColor, baseColor);
|
||||
if (StyleManager.IsMetro(StyleManager.Style))
|
||||
((Office2007Renderer)GlobalManager.Renderer).ColorTable = officeMetroColorTable;
|
||||
return metroTable;
|
||||
}
|
||||
|
||||
private const double DEGREE = 1d / 360;
|
||||
public static MetroPartColors CreateMetroPartColors(Color canvasColor, Color baseColor)
|
||||
{
|
||||
ColorFunctions.HLSColor canvasHsl = ColorFunctions.RGBToHSL(canvasColor);
|
||||
ColorFunctions.HLSColor baseHsl = ColorFunctions.RGBToHSL(baseColor);
|
||||
HSVColor baseHsv = ColorHelpers.ColorToHSV(baseColor);
|
||||
HSVColor canvasHsv = ColorHelpers.ColorToHSV(canvasColor);
|
||||
|
||||
// Create metro colors
|
||||
MetroPartColors partColors = new MetroPartColors();
|
||||
partColors.CanvasColor = canvasColor;
|
||||
partColors.BaseColor = baseColor;
|
||||
partColors.TextColor = (canvasHsl.Lightness < .4) ? Color.White : Color.Black;
|
||||
//HSVColor textHsv = ColorHelpers.ColorToHSV(partColors.TextColor);
|
||||
partColors.TextInactiveColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .53 : canvasHsv.Value - .47));
|
||||
partColors.TextDisabledColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .67));
|
||||
partColors.TextLightColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .6 : canvasHsv.Value + .4));
|
||||
partColors.CanvasColorDarkShade = partColors.TextColor == Color.Black ? ColorScheme.GetColor(0xC8C8C8) : ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .33));
|
||||
partColors.CanvasColorDarkerShade = ColorScheme.GetColor(0xB4B4B4);
|
||||
partColors.CanvasColorLightShade = ColorScheme.GetColor(0xCCCCCC);
|
||||
partColors.CanvasColorLighterShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .05 : canvasHsv.Value - .05));
|
||||
partColors.CanvasColorLight = (partColors.TextColor == Color.Black) ? ColorScheme.GetColor(0xFAFAFA) : ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, canvasHsv.Value + .06);
|
||||
partColors.BaseTextColor = GetTextColor(baseColor);
|
||||
|
||||
partColors.BaseColorLight = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .41), baseHsv.Value + .3);
|
||||
partColors.BaseColorLight1 = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .12), baseHsv.Value + .12);
|
||||
partColors.BaseColorLightText = GetTextColor(partColors.BaseColorLight);
|
||||
|
||||
partColors.BaseColorLightest = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .6), baseHsv.Value + .5);
|
||||
partColors.BaseColorLighter = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .46), baseHsv.Value + .39);
|
||||
partColors.BaseColorDark = ColorHelpers.HSVToColor(baseHsv.Hue, baseHsv.Saturation + .1, baseHsv.Value - .06);
|
||||
partColors.BaseColorDarker = ColorFunctions.HLSToRGB(baseHsl.Hue, baseHsl.Lightness - .2, baseHsl.Saturation);
|
||||
|
||||
partColors.ComplementColor = ColorHelpers.HSVToColor(GetComplementHue(baseHsv.Hue), baseHsv.Saturation, baseHsv.Value + (baseHsv.Value > .5d ? -.35 : 0d));
|
||||
ColorFunctions.HLSColor compHsl = ColorFunctions.RGBToHSL(partColors.ComplementColor);
|
||||
HSVColor compHsv = ColorHelpers.ColorToHSV(partColors.ComplementColor);
|
||||
partColors.ComplementColorLight = ColorHelpers.HSVToColor(compHsv.Hue, compHsv.Saturation, compHsv.Value + .2d);
|
||||
partColors.ComplementColorDark = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .10, compHsl.Saturation);
|
||||
partColors.ComplementColorDarker = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .2, compHsl.Saturation);
|
||||
partColors.ComplementColorText = GetTextColor(partColors.ComplementColor);
|
||||
partColors.ComplementColorLightText = GetTextColor(partColors.ComplementColorLight);
|
||||
|
||||
partColors.BaseButtonGradientStart = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .01 : canvasHsv.Value + .08));
|
||||
partColors.BaseButtonGradientEnd = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .08 : canvasHsv.Value + .20));
|
||||
|
||||
if (partColors.TextColor == Color.Black)
|
||||
partColors.EditControlBackColor = Color.White;
|
||||
else
|
||||
partColors.EditControlBackColor = Color.Black;
|
||||
|
||||
return partColors;
|
||||
}
|
||||
public static void CreateColors(MetroColorTable metroTable, Office2007ColorTable officeMetroColorTable, Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroPartColors partColors = CreateMetroPartColors(canvasColor, baseColor);
|
||||
|
||||
metroTable.CanvasColor = partColors.CanvasColor;
|
||||
metroTable.CanvasColorShadeLight = partColors.CanvasColorLightShade;
|
||||
metroTable.CanvasColorShadeLighter = partColors.CanvasColorLighterShade;
|
||||
metroTable.ForeColor = partColors.TextColor;
|
||||
metroTable.BaseColor = baseColor;
|
||||
metroTable.EditControlBackColor = partColors.EditControlBackColor;
|
||||
metroTable.MetroPartColors = partColors;
|
||||
|
||||
metroTable.MetroAppForm.BorderThickness = new Thickness(1, 1, 1, 1);
|
||||
metroTable.MetroAppForm.BorderColors = new BorderColors(partColors.BaseColor);
|
||||
metroTable.MetroAppForm.BorderColorsInactive = new BorderColors(partColors.BaseColorLight);
|
||||
|
||||
metroTable.MetroForm.BorderThickness = new Thickness(1, 1, 1, 1);
|
||||
metroTable.MetroForm.BorderColors = new BorderColors[1] { new BorderColors(partColors.BaseColor) };
|
||||
metroTable.MetroForm.BorderColorsInactive = new BorderColors[4] { new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight) };
|
||||
|
||||
metroTable.MetroTab.ActiveCaptionText = partColors.BaseTextColor;
|
||||
metroTable.MetroTab.InactiveCaptionText = partColors.BaseTextColor;
|
||||
|
||||
metroTable.MetroTab.MetroTabItem.Default = GetMetroTabItemStateTable(partColors.BaseTextColor, Color.Empty);
|
||||
metroTable.MetroTab.MetroTabItem.Selected = GetMetroTabItemStateTable(partColors.BaseColor, partColors.CanvasColorLight);
|
||||
metroTable.MetroTab.MetroTabItem.Disabled = GetMetroTabItemStateTable(partColors.TextDisabledColor, Color.Empty);
|
||||
metroTable.MetroTab.MetroTabItem.MouseOver = null;
|
||||
metroTable.MetroTab.MetroTabItem.Pressed = null;
|
||||
metroTable.MetroTab.TabStrip.BackgroundStyle = new ElementStyle(partColors.BaseTextColor, partColors.BaseColor);
|
||||
metroTable.MetroTab.CaptionTextFormat = eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter | eTextFormat.EndEllipsis | eTextFormat.NoPrefix;
|
||||
|
||||
metroTable.MetroTab.TabPanelBackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColorLight);
|
||||
|
||||
// Toolbar
|
||||
metroTable.MetroToolbar.BackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColorLight);
|
||||
|
||||
// Status Bar
|
||||
metroTable.MetroStatusBar.BackgroundStyle = new ElementStyle(partColors.BaseTextColor, partColors.BaseColor);
|
||||
metroTable.MetroStatusBar.TopBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.BottomBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.ResizeMarkerLightColor = Color.FromArgb(196, Color.White);
|
||||
metroTable.MetroStatusBar.ResizeMarkerColor = partColors.BaseColorDarker;
|
||||
|
||||
OfficeMobile2014ColorTableInitializer.InitializeColorTable(officeMetroColorTable, ColorFactory.Empty, partColors);
|
||||
}
|
||||
private static double GetColorMin(double minValue, double value)
|
||||
{
|
||||
if (value < 0)
|
||||
return minValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Color GetTextColor(Color color)
|
||||
{
|
||||
ColorFunctions.HLSColor hslColor = ColorFunctions.RGBToHSL(color);
|
||||
return hslColor.Lightness < .65 ? Color.White : Color.Black;
|
||||
//HSVColor hsvColor = ColorHelpers.ColorToHSV(backColor);
|
||||
//return hsvColor.Value < .65 ? Color.White : Color.Black;
|
||||
}
|
||||
|
||||
private static double GetComplementHue(double hue)
|
||||
{
|
||||
if (hue <= .37777d)
|
||||
{
|
||||
return Math.Min(1, hue + (137 * DEGREE + (86 * DEGREE * (hue / .37777d))));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.Max(0, hue - (137 * DEGREE + (86 * DEGREE * (hue / .6222222d))));// ((137 + 86 * DEGREE * (hue / .6222222) * DEGREE)));
|
||||
}
|
||||
}
|
||||
|
||||
private static MetroTabItemStateColorTable GetMetroTabItemStateTable(Color textColor, Color backColor)
|
||||
{
|
||||
ElementStyle style = new ElementStyle(textColor);
|
||||
style.TextAlignment = eStyleTextAlignment.Center;
|
||||
style.TextLineAlignment = eStyleTextAlignment.Center;
|
||||
style.HideMnemonic = true;
|
||||
if (!backColor.IsEmpty)
|
||||
{
|
||||
style.CornerTypeTopRight = eCornerType.Rounded;
|
||||
style.CornerTypeTopLeft = eCornerType.Rounded;
|
||||
style.CornerDiameter = 2;
|
||||
style.BorderLeft = eStyleBorderType.Solid;
|
||||
style.BorderTop = eStyleBorderType.Solid;
|
||||
style.BorderRight = eStyleBorderType.Solid;
|
||||
style.BorderLeftWidth = 1;
|
||||
style.BorderTopWidth = 1;
|
||||
style.BorderRightWidth = 1;
|
||||
style.BorderColor = backColor;
|
||||
style.BackColor = backColor;
|
||||
}
|
||||
style.TextColor = textColor;
|
||||
return new MetroTabItemStateColorTable(style);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using DevComponents.DotNetBar.Metro.Helpers;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.ColorTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the Visual Studio 2012 color scheme Metro color table based on colors specified.
|
||||
/// </summary>
|
||||
internal class VisualStudio2012ColorTableInitializer
|
||||
{
|
||||
public static MetroColorTable CreateColorTable(MetroColorGeneratorParameters colorParams)
|
||||
{
|
||||
return CreateColorTable(colorParams.CanvasColor, colorParams.BaseColor);
|
||||
}
|
||||
public static MetroColorTable CreateColorTable(Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroColorTable metroTable = new MetroColorTable();
|
||||
Office2007ColorTable officeMetroColorTable = new Office2007ColorTable();
|
||||
CreateColors(metroTable, officeMetroColorTable, canvasColor, baseColor);
|
||||
if (StyleManager.IsMetro(StyleManager.Style))
|
||||
((Office2007Renderer)GlobalManager.Renderer).ColorTable = officeMetroColorTable;
|
||||
return metroTable;
|
||||
}
|
||||
|
||||
private const double DEGREE = 1d / 360;
|
||||
public static MetroPartColors CreateMetroPartColors(Color canvasColor, Color baseColor)
|
||||
{
|
||||
ColorFunctions.HLSColor canvasHsl = ColorFunctions.RGBToHSL(canvasColor);
|
||||
ColorFunctions.HLSColor baseHsl = ColorFunctions.RGBToHSL(baseColor);
|
||||
HSVColor baseHsv = ColorHelpers.ColorToHSV(baseColor);
|
||||
HSVColor canvasHsv = ColorHelpers.ColorToHSV(canvasColor);
|
||||
|
||||
// Create metro colors
|
||||
MetroPartColors partColors = new MetroPartColors();
|
||||
partColors.CanvasColor = canvasColor;
|
||||
partColors.BaseColor = baseColor;
|
||||
partColors.TextColor = (canvasHsl.Lightness < .4) ? Color.White : Color.Black;
|
||||
//HSVColor textHsv = ColorHelpers.ColorToHSV(partColors.TextColor);
|
||||
partColors.TextInactiveColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .53 : canvasHsv.Value - .47));
|
||||
partColors.TextDisabledColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .67));
|
||||
partColors.TextLightColor = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .6 : canvasHsv.Value + .4));
|
||||
partColors.CanvasColorDarkShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.Black ? canvasHsv.Value - .33 : canvasHsv.Value + .33));
|
||||
partColors.CanvasColorLightShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .17 : canvasHsv.Value - .17));
|
||||
partColors.CanvasColorLighterShade = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (partColors.TextColor == Color.White ? canvasHsv.Value + .05 : canvasHsv.Value - .05));
|
||||
partColors.CanvasColorLight = (partColors.TextColor == Color.Black) ? ColorHelpers.HSVToColor(0, 0, .999) : ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, canvasHsv.Value + .06);
|
||||
partColors.BaseTextColor = GetTextColor(baseColor);
|
||||
|
||||
partColors.BaseColorLight = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .41), baseHsv.Value + .3);
|
||||
partColors.BaseColorLight1 = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .12), baseHsv.Value + .12);
|
||||
partColors.BaseColorLightText = GetTextColor(partColors.BaseColorLight);
|
||||
|
||||
partColors.BaseColorLightest = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.05, baseHsv.Saturation - .6), baseHsv.Value + .5);
|
||||
partColors.BaseColorLighter = ColorHelpers.HSVToColor(baseHsv.Hue, GetColorMin(0.08, baseHsv.Saturation - .46), baseHsv.Value + .39);
|
||||
partColors.BaseColorDark = ColorHelpers.HSVToColor(baseHsv.Hue, baseHsv.Saturation + .1, baseHsv.Value - .06);
|
||||
partColors.BaseColorDarker = ColorFunctions.HLSToRGB(baseHsl.Hue, baseHsl.Lightness - .2, baseHsl.Saturation);
|
||||
|
||||
partColors.ComplementColor = ColorHelpers.HSVToColor(GetComplementHue(baseHsv.Hue), baseHsv.Saturation, baseHsv.Value + (baseHsv.Value > .5d ? -.35 : 0d));
|
||||
ColorFunctions.HLSColor compHsl = ColorFunctions.RGBToHSL(partColors.ComplementColor);
|
||||
HSVColor compHsv = ColorHelpers.ColorToHSV(partColors.ComplementColor);
|
||||
partColors.ComplementColorLight = ColorHelpers.HSVToColor(compHsv.Hue, compHsv.Saturation, compHsv.Value + .2d);
|
||||
partColors.ComplementColorDark = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .10, compHsl.Saturation);
|
||||
partColors.ComplementColorDarker = ColorFunctions.HLSToRGB(compHsl.Hue, compHsl.Lightness - .2, compHsl.Saturation);
|
||||
partColors.ComplementColorText = GetTextColor(partColors.ComplementColor);
|
||||
partColors.ComplementColorLightText = GetTextColor(partColors.ComplementColorLight);
|
||||
|
||||
partColors.BaseButtonGradientStart = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .01 : canvasHsv.Value + .08));
|
||||
partColors.BaseButtonGradientEnd = ColorHelpers.HSVToColor(canvasHsv.Hue, canvasHsv.Saturation, (canvasHsv.Value > 0 ? canvasHsv.Value - .08 : canvasHsv.Value + .20));
|
||||
|
||||
if (partColors.TextColor == Color.Black)
|
||||
partColors.EditControlBackColor = Color.White;
|
||||
else
|
||||
partColors.EditControlBackColor = Color.Black;
|
||||
|
||||
return partColors;
|
||||
}
|
||||
public static void CreateColors(MetroColorTable metroTable, Office2007ColorTable officeMetroColorTable, Color canvasColor, Color baseColor)
|
||||
{
|
||||
MetroPartColors partColors = CreateMetroPartColors(canvasColor, baseColor);
|
||||
|
||||
metroTable.CanvasColor = partColors.CanvasColor;
|
||||
metroTable.CanvasColorShadeLight = partColors.CanvasColorLightShade;
|
||||
metroTable.CanvasColorShadeLighter = partColors.CanvasColorLighterShade;
|
||||
metroTable.ForeColor = partColors.TextColor;
|
||||
metroTable.BaseColor = baseColor;
|
||||
metroTable.EditControlBackColor = partColors.EditControlBackColor;
|
||||
metroTable.MetroPartColors = partColors;
|
||||
|
||||
metroTable.MetroAppForm.BorderThickness = new Thickness(0, 0, 1, 1);
|
||||
metroTable.MetroAppForm.BorderColors = new BorderColors(partColors.BaseColor);
|
||||
metroTable.MetroAppForm.BorderColorsInactive = new BorderColors(partColors.BaseColorLight);
|
||||
|
||||
metroTable.MetroForm.BorderThickness = new Thickness(1, 1, 1, 1);
|
||||
metroTable.MetroForm.BorderColors = new BorderColors[1] { new BorderColors(partColors.BaseColor) };
|
||||
metroTable.MetroForm.BorderColorsInactive = new BorderColors[4] { new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight), new BorderColors(partColors.BaseColorLight) };
|
||||
|
||||
metroTable.MetroTab.ActiveCaptionText = partColors.TextInactiveColor;
|
||||
metroTable.MetroTab.InactiveCaptionText = partColors.TextDisabledColor;
|
||||
|
||||
metroTable.MetroTab.MetroTabItem.Default = GetMetroTabItemStateTable(partColors.TextInactiveColor);
|
||||
metroTable.MetroTab.MetroTabItem.Selected = GetMetroTabItemStateTable(partColors.BaseColor);
|
||||
metroTable.MetroTab.MetroTabItem.Disabled = GetMetroTabItemStateTable(partColors.TextDisabledColor);
|
||||
metroTable.MetroTab.MetroTabItem.MouseOver = GetMetroTabItemStateTable(partColors.TextInactiveColor, partColors.BaseColor);
|
||||
metroTable.MetroTab.MetroTabItem.Pressed = null;
|
||||
|
||||
metroTable.MetroTab.TabPanelBackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColor);
|
||||
|
||||
// Toolbar
|
||||
metroTable.MetroToolbar.BackgroundStyle = new ElementStyle(partColors.TextColor, partColors.CanvasColor);
|
||||
|
||||
// Status Bar
|
||||
metroTable.MetroStatusBar.BackgroundStyle = new ElementStyle(partColors.TextColor, partColors.BaseColor);
|
||||
metroTable.MetroStatusBar.TopBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.BottomBorders = new Color[0];
|
||||
metroTable.MetroStatusBar.ResizeMarkerLightColor = Color.FromArgb(196, Color.White);
|
||||
metroTable.MetroStatusBar.ResizeMarkerColor = partColors.BaseColorDarker;
|
||||
|
||||
VisualStudio2012OfficeColorTableInitializer.InitializeColorTable(officeMetroColorTable, ColorFactory.Empty, partColors);
|
||||
}
|
||||
private static double GetColorMin(double minValue, double value)
|
||||
{
|
||||
if (value < 0)
|
||||
return minValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Color GetTextColor(Color color)
|
||||
{
|
||||
ColorFunctions.HLSColor hslColor = ColorFunctions.RGBToHSL(color);
|
||||
return hslColor.Lightness < .65 ? Color.White : Color.Black;
|
||||
//HSVColor hsvColor = ColorHelpers.ColorToHSV(backColor);
|
||||
//return hsvColor.Value < .65 ? Color.White : Color.Black;
|
||||
}
|
||||
|
||||
private static double GetComplementHue(double hue)
|
||||
{
|
||||
if (hue <= .37777d)
|
||||
{
|
||||
return Math.Min(1, hue + (137 * DEGREE + (86 * DEGREE * (hue / .37777d))));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.Max(0, hue - (137 * DEGREE + (86 * DEGREE * (hue / .6222222d))));// ((137 + 86 * DEGREE * (hue / .6222222) * DEGREE)));
|
||||
}
|
||||
}
|
||||
|
||||
private static MetroTabItemStateColorTable GetMetroTabItemStateTable(Color textColor)
|
||||
{
|
||||
return GetMetroTabItemStateTable(textColor, Color.Empty);
|
||||
}
|
||||
private static MetroTabItemStateColorTable GetMetroTabItemStateTable(Color textColor, Color bottomBorderColor)
|
||||
{
|
||||
ElementStyle style = new ElementStyle(textColor);
|
||||
style.TextAlignment = eStyleTextAlignment.Center;
|
||||
style.TextLineAlignment = eStyleTextAlignment.Center;
|
||||
style.HideMnemonic = true;
|
||||
if (!bottomBorderColor.IsEmpty)
|
||||
{
|
||||
style.BorderBottom = eStyleBorderType.Solid;
|
||||
style.BorderBottomWidth = 2;
|
||||
style.BorderBottomColor = bottomBorderColor;
|
||||
}
|
||||
return new MetroTabItemStateColorTable(style);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
206
PROMS/DotNetBar Source Code/Metro/Helpers/ColorHelpers.cs
Normal file
206
PROMS/DotNetBar Source Code/Metro/Helpers/ColorHelpers.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
64
PROMS/DotNetBar Source Code/Metro/Helpers/DoubleHelpers.cs
Normal file
64
PROMS/DotNetBar Source Code/Metro/Helpers/DoubleHelpers.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
368
PROMS/DotNetBar Source Code/Metro/MetroAppButton.cs
Normal file
368
PROMS/DotNetBar Source Code/Metro/MetroAppButton.cs
Normal file
@@ -0,0 +1,368 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Metro application button used on MetroTab control.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false), DefaultEvent("Click"), Designer("DevComponents.DotNetBar.Design.MetroAppButtonDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public class MetroAppButton : ButtonItem
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroAppButton class.
|
||||
/// </summary>
|
||||
public MetroAppButton()
|
||||
{
|
||||
this.VerifyPopupScreenPosition = false;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_BackstageTab != null)
|
||||
_BackstageTab.Leave -= BackstageTabLeave;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
public override void RecalcSize()
|
||||
{
|
||||
ButtonItemLayout.LayoutButton(this, true);
|
||||
m_NeedRecalcSize = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the item is expanded or not. For Popup items this would indicate whether the item is popped up or not.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Expanded
|
||||
{
|
||||
get { return base.Expanded; }
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Expanded != value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
MetroTabStrip container = this.ContainerControl as MetroTabStrip;
|
||||
if (container != null && container.MouseDownOnCaption)
|
||||
return;
|
||||
}
|
||||
base.Expanded = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _ThumbTucked = false;
|
||||
protected internal override void OnExpandChange()
|
||||
{
|
||||
_ThumbTucked = false;
|
||||
if (!this.DesignMode && this.Expanded && this.PopupLocation.IsEmpty && this.PopupSide == ePopupSide.Default &&
|
||||
(this.Parent is CaptionItemContainer ||
|
||||
this.Parent is MetroTabItemContainer))
|
||||
{
|
||||
if (this.SubItems.Count > 0 && this.SubItems[0] is ItemContainer &&
|
||||
((ItemContainer)this.SubItems[0]).BackgroundStyle.Class == ElementStyleClassKeys.RibbonFileMenuContainerKey)
|
||||
{
|
||||
MetroTabStrip rs = this.ContainerControl as MetroTabStrip;
|
||||
if (rs != null)
|
||||
{
|
||||
if (this.Parent is MetroTabItemContainer)
|
||||
{
|
||||
if (this.EffectiveStyle == eDotNetBarStyle.Windows7)
|
||||
this.PopupLocation = new Point(this.IsRightToLeft ? this.Bounds.Right : this.LeftInternal, this.TopInternal - 1);
|
||||
else
|
||||
this.PopupLocation = new Point(this.IsRightToLeft ? this.Bounds.Right : this.LeftInternal, this.TopInternal);
|
||||
}
|
||||
else
|
||||
this.PopupLocation = new Point(this.IsRightToLeft ? this.Bounds.Right : this.LeftInternal, rs.GetItemContainerBounds().Y - 1);
|
||||
_ThumbTucked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_BackstageTab != null && _BackstageTabEnabled)
|
||||
{
|
||||
if (this.Expanded)
|
||||
{
|
||||
PopupOpenEventArgs args = new PopupOpenEventArgs();
|
||||
OnPopupOpen(args);
|
||||
if (args.Cancel)
|
||||
{
|
||||
this.Expanded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateBackstageTabSize();
|
||||
if (this.ContainerControl is IKeyTipsControl)
|
||||
{
|
||||
IKeyTipsControl kc = this.ContainerControl as IKeyTipsControl;
|
||||
_BackstageTab.TabStrip.ShowKeyTips = kc.ShowKeyTips;
|
||||
kc.ShowKeyTips = false;
|
||||
}
|
||||
OnPopupShowing(EventArgs.Empty);
|
||||
_BackstageTab.Visible = true;
|
||||
_BackstageTab.BringToFront();
|
||||
_BackstageTab.Focus();
|
||||
MetroTabStrip strip = this.MetroTabStrip;
|
||||
if (strip != null && strip.SelectedTab != null)
|
||||
{
|
||||
_LastSelectedTabItem = strip.SelectedTab;
|
||||
if (this.DesignMode)
|
||||
_LastSelectedTabItem.RenderTabState = false;
|
||||
else
|
||||
_LastSelectedTabItem.Checked = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
OnPopupClose(EventArgs.Empty);
|
||||
if (_LastSelectedTabItem != null)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
_LastSelectedTabItem.RenderTabState = true;
|
||||
else
|
||||
_LastSelectedTabItem.Checked = true;
|
||||
_LastSelectedTabItem = null;
|
||||
}
|
||||
if (this.ContainerControl is IKeyTipsControl)
|
||||
{
|
||||
IKeyTipsControl kc = this.ContainerControl as IKeyTipsControl;
|
||||
kc.ShowKeyTips = _BackstageTab.TabStrip.ShowKeyTips;
|
||||
_BackstageTab.TabStrip.ShowKeyTips = false;
|
||||
}
|
||||
_BackstageTab.Visible = false;
|
||||
MetroTabStrip strip = this.ContainerControl as MetroTabStrip;
|
||||
if (strip != null)
|
||||
strip.BackstageTabClosed(_BackstageTab);
|
||||
OnPopupFinalized(EventArgs.Empty);
|
||||
}
|
||||
|
||||
HideToolTip();
|
||||
// Fire events
|
||||
RaiseExpandChange(EventArgs.Empty);
|
||||
return;
|
||||
}
|
||||
|
||||
base.OnExpandChange();
|
||||
}
|
||||
|
||||
public override void ContainerLostFocus(bool appLostFocus)
|
||||
{
|
||||
if (_BackstageTabEnabled && _BackstageTab != null && this.DesignMode && this.Expanded && appLostFocus) return;
|
||||
|
||||
base.ContainerLostFocus(appLostFocus);
|
||||
|
||||
}
|
||||
|
||||
internal override bool PopupPositionAdjusted
|
||||
{
|
||||
get { return base.PopupPositionAdjusted; }
|
||||
set
|
||||
{
|
||||
base.PopupPositionAdjusted = value;
|
||||
if (base.PopupPositionAdjusted && _ThumbTucked)
|
||||
_ThumbTucked = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnMenuPaint(ItemPaintArgs pa)
|
||||
{
|
||||
if (!_ThumbTucked) return;
|
||||
|
||||
Graphics g = pa.Graphics;
|
||||
MetroTabStrip rs = this.ContainerControl as MetroTabStrip;
|
||||
if (rs != null)
|
||||
{
|
||||
if (this.Parent is MetroTabItemContainer)
|
||||
{
|
||||
if (pa.RightToLeft)
|
||||
g.TranslateTransform(-(this.LeftInternal - pa.ContainerControl.Width + this.WidthInternal), -(this.TopInternal));
|
||||
else
|
||||
{
|
||||
if (this.EffectiveStyle == eDotNetBarStyle.Windows7)
|
||||
g.TranslateTransform(-this.LeftInternal, -(this.TopInternal - 1));
|
||||
else
|
||||
g.TranslateTransform(-this.LeftInternal, -(this.TopInternal));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pa.RightToLeft)
|
||||
g.TranslateTransform(-(this.LeftInternal - pa.ContainerControl.Width + this.WidthInternal), -(rs.GetItemContainerBounds().Y - 1));
|
||||
else
|
||||
g.TranslateTransform(-this.LeftInternal, -(rs.GetItemContainerBounds().Y - 1));
|
||||
}
|
||||
|
||||
g.ResetClip();
|
||||
Control c = pa.ContainerControl;
|
||||
pa.ContainerControl = rs;
|
||||
pa.IsOnMenu = false;
|
||||
this.IgnoreAlpha = true;
|
||||
bool oldGlassEnabled = pa.GlassEnabled;
|
||||
pa.GlassEnabled = rs.IsGlassEnabled;
|
||||
this.Paint(pa);
|
||||
pa.GlassEnabled = oldGlassEnabled;
|
||||
this.IgnoreAlpha = false;
|
||||
pa.ContainerControl = c;
|
||||
pa.IsOnMenu = true;
|
||||
g.ResetTransform();
|
||||
}
|
||||
}
|
||||
protected override void OnCommandChanged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool IsRightHanded
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnStyleChanged()
|
||||
{
|
||||
this.ImagePaddingHorizontal = 0;
|
||||
this.ImagePaddingVertical = 0;
|
||||
|
||||
base.OnStyleChanged();
|
||||
}
|
||||
|
||||
protected override bool IsPulseEnabed
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((this.EffectiveStyle == eDotNetBarStyle.Office2010 || StyleManager.IsMetro(this.EffectiveStyle)) && WinApi.IsGlassEnabled) return false;
|
||||
return base.IsPulseEnabed;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBackstageTabSize()
|
||||
{
|
||||
if (_BackstageTab == null) return;
|
||||
Control parentForm = _BackstageTab.Parent;
|
||||
if (parentForm == null) throw new InvalidOperationException("BackstageTab control does not have a parent");
|
||||
|
||||
Rectangle tabBounds = parentForm.ClientRectangle;
|
||||
MetroTabStrip strip = this.MetroTabStrip;
|
||||
if (strip != null)
|
||||
{
|
||||
Point p = parentForm.PointToClient(strip.PointToScreen(this.Bounds.Location));
|
||||
p.Y += this.Bounds.Height;// +1;
|
||||
tabBounds = new Rectangle(p.X, p.Y, parentForm.ClientRectangle.Width, parentForm.ClientRectangle.Height - p.Y);
|
||||
MetroAppForm metroForm = parentForm as MetroAppForm;
|
||||
if (metroForm != null)
|
||||
{
|
||||
Thickness borderThickness = metroForm.GetBorderThickness();
|
||||
tabBounds.Width -= (int)borderThickness.Horizontal;
|
||||
tabBounds.Height -= (int)borderThickness.Bottom;
|
||||
}
|
||||
}
|
||||
|
||||
_BackstageTab.Bounds = tabBounds;
|
||||
_BackstageTab.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top;
|
||||
}
|
||||
|
||||
private MetroTabItem _LastSelectedTabItem = null;
|
||||
private MetroTabStrip MetroTabStrip
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ContainerControl as MetroTabStrip;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _BackstageTabEnabled = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control set on BackstageTab property is used on application menu popup.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Indicates whether control set on BackstageTab property is used on application menu popup.")]
|
||||
public bool BackstageTabEnabled
|
||||
{
|
||||
get { return _BackstageTabEnabled; }
|
||||
set
|
||||
{
|
||||
this.Expanded = false;
|
||||
_BackstageTabEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private SuperTabControl _BackstageTab = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the backstage tab that is displayed instead of popup menu.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Behavior"), Description("Indicates backstage tab that is displayed instead of popup menu.")]
|
||||
public SuperTabControl BackstageTab
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BackstageTab;
|
||||
}
|
||||
set
|
||||
{
|
||||
SuperTabControl oldValue = _BackstageTab;
|
||||
_BackstageTab = value;
|
||||
OnBackstageTabChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBackstageTabChanged(SuperTabControl oldValue, SuperTabControl newValue)
|
||||
{
|
||||
if (oldValue != null)
|
||||
{
|
||||
oldValue.Leave -= BackstageTabLeave;
|
||||
if (oldValue.TabStrip != null) oldValue.TabStrip.ApplicationButton = null;
|
||||
}
|
||||
|
||||
if (this.Expanded) this.Expanded = false;
|
||||
if (newValue != null)
|
||||
{
|
||||
newValue.Visible = false;
|
||||
newValue.Leave += BackstageTabLeave;
|
||||
if (newValue.TabStrip != null) newValue.TabStrip.ApplicationButton = this;
|
||||
}
|
||||
}
|
||||
|
||||
private void BackstageTabLeave(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Expanded)
|
||||
this.Expanded = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the Escape key when Application Button is hosting the backstage tab and uses it to close the tab if open.
|
||||
/// This method is called from ProcessDialogKey method of MetroForm.
|
||||
/// </summary>
|
||||
/// <param name="keyData">Key data</param>
|
||||
/// <returns>true if key was used to close backstage tab</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ProcessEscapeKey(Keys keyData)
|
||||
{
|
||||
if (keyData == Keys.Escape && this.Expanded)
|
||||
{
|
||||
this.Expanded = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
internal void BackstageMnemonicProcessed(char charCode)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CanShowPopup
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.ShowSubItems || ShouldAutoExpandOnClick) && (this.SubItems.Count > 0 || this.PopupType == ePopupType.Container || BackstageTab != null && BackstageTabEnabled);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
1429
PROMS/DotNetBar Source Code/Metro/MetroAppForm.cs
Normal file
1429
PROMS/DotNetBar Source Code/Metro/MetroAppForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
331
PROMS/DotNetBar Source Code/Metro/MetroForm.cs
Normal file
331
PROMS/DotNetBar Source Code/Metro/MetroForm.cs
Normal file
@@ -0,0 +1,331 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro.Rendering;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
public class MetroForm : OfficeForm
|
||||
{
|
||||
#region Private Vars
|
||||
private const string DefaultSettingsButtonText = "<font size=\"7\">SETTINGS</font>";
|
||||
private const string DefaultHelpButtonText = "<font size=\"7\">HELP</font>";
|
||||
private ButtonItem _Settings = null;
|
||||
private ButtonItem _Help = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroForm class.
|
||||
/// </summary>
|
||||
public MetroForm()
|
||||
{
|
||||
if (!StyleManager.IsMetro(StyleManager.Style))
|
||||
StyleManager.Style = eStyle.Metro;
|
||||
|
||||
StyleManager.Register(this);
|
||||
base.EnableGlass = false;
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing) StyleManager.Unregister(this);
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
UpdateColorScheme();
|
||||
base.OnHandleCreated(e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the array of LinearGradientColorTable objects that describe the border colors. The colors with index 0 is used as the outer most
|
||||
/// border.
|
||||
/// </summary>
|
||||
/// <returns>Array of LinearGradientColorTable</returns>
|
||||
protected override Color[] GetBorderColors(int borderSize)
|
||||
{
|
||||
DevComponents.DotNetBar.Metro.ColorTables.MetroColorTable metroColorTable = MetroRender.GetColorTable();
|
||||
DevComponents.DotNetBar.Metro.ColorTables.MetroFormColorTable ct = metroColorTable.MetroForm;
|
||||
Color canvas = this.BackColor; //metroColorTable.CanvasColor;
|
||||
BorderColors[] borderColors = _BorderColors ?? ct.BorderColors;
|
||||
Color[] colors = new Color[((FormBorderStyle == FormBorderStyle.FixedSingle) ? 1 : borderColors.Length + (borderSize > borderColors.Length ? 1 : 0))];
|
||||
if (FormBorderStyle == System.Windows.Forms.FormBorderStyle.FixedSingle && borderSize > 1)
|
||||
{
|
||||
colors = new Color[4];
|
||||
colors[0] = borderColors[0].Left;
|
||||
colors[1] = colors[0];
|
||||
colors[2] = colors[0];
|
||||
colors[3] = canvas;
|
||||
return colors;
|
||||
}
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
if (i > borderColors.Length - 1)
|
||||
colors[i] = canvas;
|
||||
else
|
||||
colors[i] = borderColors[i].Left;
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
/// <summary>
|
||||
/// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
|
||||
/// its style is controlled by StyleManager.
|
||||
/// </summary>
|
||||
/// <param name="newStyle">New active style.</param>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
|
||||
{
|
||||
base.StyleManagerStyleChanged(newStyle);
|
||||
if (BarFunctions.IsHandleValid(this))
|
||||
UpdateColorScheme();
|
||||
}
|
||||
|
||||
private void UpdateColorScheme()
|
||||
{
|
||||
StyleManager.UpdateMetroAmbientColors(this);
|
||||
}
|
||||
|
||||
private BorderColors[] _BorderColors = null;
|
||||
/// <summary>
|
||||
/// Gets or sets custom border colors for the form. When set it overrides settings from global Metro color table.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public BorderColors[] BorderColors
|
||||
{
|
||||
get { return _BorderColors; }
|
||||
set { _BorderColors = value; Invalidate(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This property is not applicable for MetroForm.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool EnableGlass
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.EnableGlass;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.EnableGlass = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the form path for the given input bounds.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Represent the form bounds.</param>
|
||||
/// <returns></returns>
|
||||
protected override GraphicsPath GetFormPath(Rectangle bounds)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddRectangle(bounds);
|
||||
return path;
|
||||
}
|
||||
|
||||
protected override bool UseCornerSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// protected override Rectangle GetInnerFormBounds()
|
||||
// {
|
||||
// Rectangle r = new Rectangle(3, 3, this.Width - 7, this.Height - 2);
|
||||
|
||||
//#if FRAMEWORK20
|
||||
// if (this.RightToLeftLayout) r = new Rectangle(3, 3, this.Width - 6, this.Height - 2);
|
||||
//#endif
|
||||
|
||||
// return r;
|
||||
// }
|
||||
|
||||
protected override LabelItem CreateTitleLabel()
|
||||
{
|
||||
LabelItem label = new LabelItem();
|
||||
label.GlobalItem = false;
|
||||
try
|
||||
{
|
||||
label.Font = new Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
label.Font = SystemFonts.MenuFont; // SystemInformation.MenuFont;
|
||||
}
|
||||
label.Stretch = true;
|
||||
label.TextLineAlignment = StringAlignment.Center;
|
||||
label.TextAlignment = StringAlignment.Center;
|
||||
label.Text = this.Text;
|
||||
label.PaddingLeft = 3;
|
||||
label.PaddingRight = 1;
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
protected override void CreateAdditionalCaptionItems(GenericItemContainer captionContainer)
|
||||
{
|
||||
// Add Settings and Help buttons
|
||||
_Settings = new ButtonItem("sysSettingsButton");
|
||||
_Settings.Text = DefaultSettingsButtonText;
|
||||
//_Settings.ItemAlignment = eItemAlignment.Far;
|
||||
_Settings.Click += InternalSettingsButtonClick;
|
||||
_Settings.SetSystemItem(true);
|
||||
_Settings.CanCustomize = false;
|
||||
_Settings.Visible = false;
|
||||
captionContainer.SubItems.Add(_Settings);
|
||||
|
||||
_Help = new ButtonItem("sysHelpButton");
|
||||
_Help.Text = DefaultHelpButtonText;
|
||||
_Help.SetSystemItem(true);
|
||||
_Help.CanCustomize = false;
|
||||
_Help.Visible = false;
|
||||
//_Help.ItemAlignment = eItemAlignment.Far;
|
||||
_Help.Click += InternalHelpButtonClick;
|
||||
captionContainer.SubItems.Add(_Help);
|
||||
|
||||
base.CreateAdditionalCaptionItems(captionContainer);
|
||||
}
|
||||
|
||||
/// Gets or sets whether SETTINGS button is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance"), Description("Indicates whether SETTINGS button is visible.")]
|
||||
public bool SettingsButtonVisible
|
||||
{
|
||||
get { return _Settings.Visible; }
|
||||
set
|
||||
{
|
||||
if (value != _Settings.Visible)
|
||||
{
|
||||
_Settings.Visible = value;
|
||||
if (this.IsHandleCreated)
|
||||
this.RecalcSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets or sets whether HELP button is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Category("Appearance"), Description("Indicates whether HELP button is visible.")]
|
||||
public bool HelpButtonVisible
|
||||
{
|
||||
get { return _Help.Visible; }
|
||||
set
|
||||
{
|
||||
if (value != _Help.Visible)
|
||||
{
|
||||
_Help.Visible = value;
|
||||
this.RecalcSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _HelpButtonText = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the HELP button text.
|
||||
/// </summary>
|
||||
[DefaultValue(""), Category("Appearance"), Description("Indicates HELP button text")]
|
||||
public string HelpButtonText
|
||||
{
|
||||
get { return _HelpButtonText; }
|
||||
set
|
||||
{
|
||||
if (value != _HelpButtonText)
|
||||
{
|
||||
string oldValue = _HelpButtonText;
|
||||
_HelpButtonText = value;
|
||||
OnHelpButtonTextChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when HelpButtonText property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnHelpButtonTextChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newValue))
|
||||
_Help.Text = DefaultHelpButtonText;
|
||||
else
|
||||
_Help.Text = "<font size=\"7\">" + newValue + "</font>";
|
||||
this.RecalcSize();
|
||||
}
|
||||
private string _SettingsButtonText = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the SETTINGS button text.
|
||||
/// </summary>
|
||||
[DefaultValue(""), Category("Appearance"), Description("Indicates SETTINGS button text")]
|
||||
public string SettingsButtonText
|
||||
{
|
||||
get { return _SettingsButtonText; }
|
||||
set
|
||||
{
|
||||
if (value != _SettingsButtonText)
|
||||
{
|
||||
string oldValue = _SettingsButtonText;
|
||||
_SettingsButtonText = value;
|
||||
OnSettingsButtonTextChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when SettingsButtonText property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnSettingsButtonTextChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newValue))
|
||||
_Settings.Text = DefaultSettingsButtonText;
|
||||
else
|
||||
_Settings.Text = "<font size=\"7\">" + newValue + "</font>";
|
||||
this.RecalcSize();
|
||||
}
|
||||
private void InternalSettingsButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
OnSettingsButtonClick(e);
|
||||
}
|
||||
private void InternalHelpButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
OnHelpButtonClick(e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when SETTINGS button, if displayed, is clicked.
|
||||
/// </summary>
|
||||
[Description("Occurs when SETTINGS button, if displayed, is clicked.")]
|
||||
public event EventHandler SettingsButtonClick;
|
||||
/// <summary>
|
||||
/// Raises SettingsButtonClick event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnSettingsButtonClick(EventArgs e)
|
||||
{
|
||||
EventHandler handler = SettingsButtonClick;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when HELP button, if displayed, is clicked.
|
||||
/// </summary>
|
||||
[Description("Occurs when HELP button, if displayed, is clicked.")]
|
||||
public event EventHandler HelpButtonClick;
|
||||
/// <summary>
|
||||
/// Raises HelpButtonClick event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnHelpButtonClick(EventArgs e)
|
||||
{
|
||||
EventHandler handler = HelpButtonClick;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
707
PROMS/DotNetBar Source Code/Metro/MetroMessageBoxDialog.cs
Normal file
707
PROMS/DotNetBar Source Code/Metro/MetroMessageBoxDialog.cs
Normal file
@@ -0,0 +1,707 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
internal class MetroMessageBoxDialog : MetroForm
|
||||
{
|
||||
private ButtonX Button1;
|
||||
private ButtonX Button2;
|
||||
private ButtonX Button3;
|
||||
private PictureBox PictureBox1;
|
||||
private PanelEx TextPanel;
|
||||
private PanelEx ButtonBackgroundPanel;
|
||||
private eDotNetBarStyle m_Style = eDotNetBarStyle.Metro;
|
||||
private bool m_Button1Visible = true;
|
||||
private bool m_Button2Visible = true;
|
||||
private bool m_Button3Visible = true;
|
||||
private MessageBoxButtons m_Buttons = MessageBoxButtons.OK;
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
public MetroMessageBoxDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
TextPanel.DisableSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
this.Button1.Click -= new System.EventHandler(this.Button1_Click);
|
||||
this.Button2.Click -= new System.EventHandler(this.Button2_Click);
|
||||
this.Button3.Click -= new System.EventHandler(this.Button3_Click);
|
||||
this.TextPanel.MarkupLinkClick -= new MarkupLinkClickEventHandler(TextPanelMarkupLinkClick);
|
||||
}
|
||||
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Button1 = new DevComponents.DotNetBar.ButtonX();
|
||||
this.Button2 = new DevComponents.DotNetBar.ButtonX();
|
||||
this.Button3 = new DevComponents.DotNetBar.ButtonX();
|
||||
this.PictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.TextPanel = new DevComponents.DotNetBar.PanelEx();
|
||||
this.ButtonBackgroundPanel = new DevComponents.DotNetBar.PanelEx();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Button1
|
||||
//
|
||||
this.Button1.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.Button1.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.Button1.Location = new System.Drawing.Point(26, 85);
|
||||
this.Button1.Name = "Button1";
|
||||
this.Button1.Size = new System.Drawing.Size(77, 24);
|
||||
this.Button1.TabIndex = 0;
|
||||
this.Button1.Text = "&OK";
|
||||
this.Button1.Click += new System.EventHandler(this.Button1_Click);
|
||||
this.Button1.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// Button2
|
||||
//
|
||||
this.Button2.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.Button2.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.Button2.Location = new System.Drawing.Point(109, 85);
|
||||
this.Button2.Name = "Button2";
|
||||
this.Button2.Size = new System.Drawing.Size(77, 24);
|
||||
this.Button2.TabIndex = 1;
|
||||
this.Button2.Text = "&Cancel";
|
||||
this.Button2.Click += new System.EventHandler(this.Button2_Click);
|
||||
this.Button2.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// Button3
|
||||
//
|
||||
this.Button3.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.Button3.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.Button3.Location = new System.Drawing.Point(192, 85);
|
||||
this.Button3.Name = "Button3";
|
||||
this.Button3.Size = new System.Drawing.Size(77, 24);
|
||||
this.Button3.TabIndex = 2;
|
||||
this.Button3.Text = "&Ignore";
|
||||
this.Button3.Click += new System.EventHandler(this.Button3_Click);
|
||||
this.Button3.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
//
|
||||
// PictureBox1
|
||||
//
|
||||
this.PictureBox1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.PictureBox1.Location = new System.Drawing.Point(10, 10);
|
||||
this.PictureBox1.Name = "PictureBox1";
|
||||
this.PictureBox1.Size = new System.Drawing.Size(34, 34);
|
||||
this.PictureBox1.TabIndex = 3;
|
||||
this.PictureBox1.TabStop = false;
|
||||
//
|
||||
// TextPanel
|
||||
//
|
||||
this.TextPanel.AntiAlias = false;
|
||||
this.TextPanel.CanvasColor = System.Drawing.SystemColors.Control;
|
||||
this.TextPanel.Location = new System.Drawing.Point(53, 10);
|
||||
this.TextPanel.Name = "TextPanel";
|
||||
this.TextPanel.Size = new System.Drawing.Size(225, 53);
|
||||
this.TextPanel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
|
||||
this.TextPanel.Style.BorderWidth = 0;
|
||||
this.TextPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText;
|
||||
this.TextPanel.Style.GradientAngle = 90;
|
||||
this.TextPanel.Style.LineAlignment = System.Drawing.StringAlignment.Near;
|
||||
this.TextPanel.TabIndex = 4;
|
||||
this.TextPanel.TabStop = false;
|
||||
this.TextPanel.Style.WordWrap = true;
|
||||
this.TextPanel.MarkupLinkClick += new MarkupLinkClickEventHandler(TextPanelMarkupLinkClick);
|
||||
|
||||
//
|
||||
// ButtonBackgroundPanel
|
||||
//
|
||||
this.ButtonBackgroundPanel.AntiAlias = false;
|
||||
this.ButtonBackgroundPanel.CanvasColor = System.Drawing.SystemColors.Control;
|
||||
this.ButtonBackgroundPanel.Location = new System.Drawing.Point(53, 10);
|
||||
this.ButtonBackgroundPanel.Name = "ButtonBackgroundPanel";
|
||||
this.ButtonBackgroundPanel.Size = new System.Drawing.Size(225, 42);
|
||||
this.ButtonBackgroundPanel.Dock = DockStyle.Bottom;
|
||||
this.ButtonBackgroundPanel.ColorSchemeStyle = eDotNetBarStyle.StyleManagerControlled;
|
||||
this.ButtonBackgroundPanel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
|
||||
this.ButtonBackgroundPanel.Style.BorderWidth = 1;
|
||||
this.ButtonBackgroundPanel.Style.BorderSide = eBorderSide.Top;
|
||||
this.ButtonBackgroundPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText;
|
||||
this.ButtonBackgroundPanel.Style.BackColor1.ColorSchemePart = eColorSchemePart.BarBackground;
|
||||
this.ButtonBackgroundPanel.Style.BorderColor.ColorSchemePart = eColorSchemePart.BarDockedBorder;
|
||||
this.ButtonBackgroundPanel.Style.GradientAngle = 90;
|
||||
this.ButtonBackgroundPanel.Style.LineAlignment = System.Drawing.StringAlignment.Near;
|
||||
this.ButtonBackgroundPanel.TabIndex = 4;
|
||||
this.ButtonBackgroundPanel.TabStop = false;
|
||||
//
|
||||
// MessageBoxDialog
|
||||
//
|
||||
#if FRAMEWORK20
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); // for design in 96 DPI
|
||||
#endif
|
||||
this.ClientSize = new System.Drawing.Size(290, 121);
|
||||
this.ShowInTaskbar = false;
|
||||
this.Controls.Add(this.TextPanel);
|
||||
this.Controls.Add(this.PictureBox1);
|
||||
this.Controls.Add(this.Button3);
|
||||
this.Controls.Add(this.Button2);
|
||||
this.Controls.Add(this.Button1);
|
||||
this.Controls.Add(this.ButtonBackgroundPanel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MessageBoxDialog";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private void TextPanelMarkupLinkClick(object sender, MarkupLinkClickEventArgs e)
|
||||
{
|
||||
MessageBoxEx.InvokeMarkupLinkClick(sender, e);
|
||||
}
|
||||
|
||||
public DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool topMost)
|
||||
{
|
||||
m_Buttons = buttons;
|
||||
this.Text = caption;
|
||||
TextPanel.Style.UseMnemonic = false;
|
||||
TextPanel.Text = text;
|
||||
if (icon != MessageBoxIcon.None)
|
||||
{
|
||||
Image iconImage= GetSystemImage(icon);
|
||||
if (iconImage != null && iconImage.Width > PictureBox1.Width) PictureBox1.Width = iconImage.Width;
|
||||
if (iconImage!=null && iconImage.Height > PictureBox1.Height) PictureBox1.Height = iconImage.Height;
|
||||
PictureBox1.Image = iconImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
PictureBox1.Image = null;
|
||||
PictureBox1.Visible = false;
|
||||
}
|
||||
|
||||
if (buttons == MessageBoxButtons.OKCancel || buttons == MessageBoxButtons.RetryCancel || buttons == MessageBoxButtons.YesNo)
|
||||
{
|
||||
Button3.Visible = false;
|
||||
m_Button3Visible = false;
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.OK)
|
||||
{
|
||||
Button2.Visible = false;
|
||||
Button3.Visible = false;
|
||||
m_Button2Visible = false;
|
||||
m_Button3Visible = false;
|
||||
}
|
||||
|
||||
// Set Cancel and Accept buttons
|
||||
if (buttons == MessageBoxButtons.OK)
|
||||
{
|
||||
this.AcceptButton = Button1;
|
||||
this.CancelButton = Button1;
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.OKCancel || buttons == MessageBoxButtons.RetryCancel || buttons == MessageBoxButtons.YesNo)
|
||||
{
|
||||
this.AcceptButton = Button1;
|
||||
this.CancelButton = Button2;
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.YesNoCancel)
|
||||
{
|
||||
this.AcceptButton = Button1;
|
||||
this.CancelButton = Button3;
|
||||
}
|
||||
|
||||
SetButtonText(buttons);
|
||||
|
||||
if (defaultButton == MessageBoxDefaultButton.Button1 && m_Button1Visible)
|
||||
{
|
||||
Button1.Select();
|
||||
this.AcceptButton = Button1;
|
||||
}
|
||||
else if (defaultButton == MessageBoxDefaultButton.Button2 && m_Button2Visible)
|
||||
{
|
||||
this.AcceptButton = Button2;
|
||||
Button2.Select();
|
||||
}
|
||||
else if (defaultButton == MessageBoxDefaultButton.Button3 && m_Button3Visible)
|
||||
{
|
||||
this.AcceptButton = Button3;
|
||||
Button3.Select();
|
||||
}
|
||||
|
||||
ResizeDialog();
|
||||
|
||||
SetupColors();
|
||||
|
||||
#if FRAMEWORK20
|
||||
if (icon == MessageBoxIcon.Question)
|
||||
System.Media.SystemSounds.Question.Play(); // NativeFunctions.sndPlaySound("SystemQuestion", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
|
||||
else if (icon == MessageBoxIcon.Asterisk)
|
||||
System.Media.SystemSounds.Asterisk.Play(); // NativeFunctions.sndPlaySound("SystemAsterisk", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
|
||||
else
|
||||
System.Media.SystemSounds.Exclamation.Play(); // NativeFunctions.sndPlaySound("SystemExclamation", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
|
||||
#else
|
||||
if(icon == MessageBoxIcon.Question)
|
||||
NativeFunctions.sndPlaySound("SystemQuestion", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
|
||||
else if(icon == MessageBoxIcon.Asterisk)
|
||||
NativeFunctions.sndPlaySound("SystemAsterisk", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
|
||||
else
|
||||
NativeFunctions.sndPlaySound("SystemExclamation", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT);
|
||||
#endif
|
||||
if (buttons == MessageBoxButtons.AbortRetryIgnore || buttons == MessageBoxButtons.YesNo)
|
||||
{
|
||||
this.CloseEnabled = false;
|
||||
}
|
||||
|
||||
if(this.TopMost!=topMost)
|
||||
this.TopMost = topMost;
|
||||
return this.ShowDialog(owner);
|
||||
}
|
||||
|
||||
public eDotNetBarStyle Style
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Style;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Style = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupColors()
|
||||
{
|
||||
if (!_MessageTextColor.IsEmpty)
|
||||
{
|
||||
this.TextPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.Custom;
|
||||
this.TextPanel.Style.ForeColor.Color = _MessageTextColor;
|
||||
}
|
||||
else if (DevComponents.DotNetBar.Rendering.GlobalManager.Renderer is DevComponents.DotNetBar.Rendering.Office2007Renderer)
|
||||
{
|
||||
DevComponents.DotNetBar.Rendering.Office2007ColorTable ct = ((DevComponents.DotNetBar.Rendering.Office2007Renderer)DevComponents.DotNetBar.Rendering.GlobalManager.Renderer).ColorTable;
|
||||
this.TextPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.Custom;
|
||||
this.TextPanel.Style.ForeColor.Color = ct.Form.TextColor;
|
||||
this.TextPanel.Style.BackColor1.Color = ct.Form.BackColor;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _ButtonsDividerVisible = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether divider panel that divides message box buttons and text content is visible. Default value is true.
|
||||
/// </summary>
|
||||
public bool ButtonsDividerVisible
|
||||
{
|
||||
get { return _ButtonsDividerVisible; }
|
||||
set
|
||||
{
|
||||
if (_ButtonsDividerVisible != value)
|
||||
{
|
||||
_ButtonsDividerVisible = value;
|
||||
this.ButtonBackgroundPanel.Visible = _ButtonsDividerVisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Color _MessageTextColor = Color.Empty;
|
||||
public Color MessageTextColor
|
||||
{
|
||||
get { return _MessageTextColor; }
|
||||
set { _MessageTextColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Text supports and renders text markup. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Gets or sets whether Text supports and renders text markup.")]
|
||||
public bool TextMarkupEnabled
|
||||
{
|
||||
get { return TextPanel.TextMarkupEnabled; }
|
||||
set
|
||||
{
|
||||
TextPanel.TextMarkupEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetButtonText(MessageBoxButtons buttons)
|
||||
{
|
||||
if (buttons == MessageBoxButtons.AbortRetryIgnore)
|
||||
{
|
||||
Button1.Text = GetString(SystemStrings.Abort);
|
||||
Button2.Text = GetString(SystemStrings.Retry);
|
||||
Button3.Text = GetString(SystemStrings.Ignore);
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.OK)
|
||||
{
|
||||
Button1.Text = GetString(SystemStrings.OK);
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.OKCancel)
|
||||
{
|
||||
Button1.Text = GetString(SystemStrings.OK);
|
||||
Button2.Text = GetString(SystemStrings.Cancel);
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.RetryCancel)
|
||||
{
|
||||
Button1.Text = GetString(SystemStrings.Retry);
|
||||
Button2.Text = GetString(SystemStrings.Cancel);
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.YesNo)
|
||||
{
|
||||
Button1.Text = GetString(SystemStrings.Yes);
|
||||
Button2.Text = GetString(SystemStrings.No);
|
||||
}
|
||||
else if (buttons == MessageBoxButtons.YesNoCancel)
|
||||
{
|
||||
Button1.Text = GetString(SystemStrings.Yes);
|
||||
Button2.Text = GetString(SystemStrings.No);
|
||||
Button3.Text = GetString(SystemStrings.Cancel);
|
||||
}
|
||||
}
|
||||
|
||||
internal static Image GetSystemImage(MessageBoxIcon icon)
|
||||
{
|
||||
Icon ico = null;
|
||||
if (icon == MessageBoxIcon.Asterisk)
|
||||
ico = SystemIcons.Asterisk;
|
||||
else if (icon == MessageBoxIcon.Error || icon == MessageBoxIcon.Stop)
|
||||
ico = SystemIcons.Error;
|
||||
else if (icon == MessageBoxIcon.Exclamation)
|
||||
ico = SystemIcons.Exclamation;
|
||||
else if (icon == MessageBoxIcon.Hand)
|
||||
ico = SystemIcons.Hand;
|
||||
else if (icon == MessageBoxIcon.Information)
|
||||
ico = SystemIcons.Information;
|
||||
else if (icon == MessageBoxIcon.Question)
|
||||
ico = SystemIcons.Question;
|
||||
else if (icon == MessageBoxIcon.Warning)
|
||||
ico = SystemIcons.Warning;
|
||||
|
||||
Bitmap bmp = new Bitmap(ico.Width, ico.Height);
|
||||
bmp.MakeTransparent();
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
if (System.Environment.Version.Build <= 3705 && System.Environment.Version.Revision == 288 && System.Environment.Version.Major == 1 && System.Environment.Version.Minor == 0)
|
||||
{
|
||||
IntPtr hdc = g.GetHdc();
|
||||
try
|
||||
{
|
||||
NativeFunctions.DrawIconEx(hdc, 0, 0, ico.Handle, ico.Width, ico.Height, 0, IntPtr.Zero, 3);
|
||||
}
|
||||
finally
|
||||
{
|
||||
g.ReleaseHdc(hdc);
|
||||
}
|
||||
}
|
||||
else if (ico.Handle != IntPtr.Zero)
|
||||
{
|
||||
try
|
||||
{
|
||||
g.DrawIcon(ico, 0,0);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private void ResizeDialog()
|
||||
{
|
||||
Size size = Size.Empty;
|
||||
int buttonSpacing = 6;
|
||||
int buttonMargin = Dpi.Width(40);
|
||||
int textMargin = Dpi.Width10;
|
||||
int minTextSize = Dpi.Width(110);
|
||||
|
||||
if (PictureBox1.Image!=null)
|
||||
{
|
||||
TextPanel.Left = PictureBox1.Bounds.Right + Dpi.Width16;
|
||||
}
|
||||
else
|
||||
TextPanel.Left = PictureBox1.Left;
|
||||
|
||||
Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
|
||||
TextPanel.Size = TextPanel.GetAutoSize(workingArea.Width);
|
||||
|
||||
if (TextPanel.Size.Width > (double)workingArea.Width * .75d)
|
||||
TextPanel.Size = TextPanel.GetAutoSize((int)((double)workingArea.Width * .75d));
|
||||
else if (TextPanel.Size.Width < minTextSize)
|
||||
TextPanel.Width = minTextSize;
|
||||
|
||||
// Measure the caption size
|
||||
if (this.Text.Length > 0)
|
||||
{
|
||||
Size captionSize = Size.Empty;
|
||||
Font font = this.Font;
|
||||
using (Graphics g = BarFunctions.CreateGraphics(this))
|
||||
{
|
||||
size = TextDrawing.MeasureString(g, this.Text, font);
|
||||
}
|
||||
size.Width += 2;
|
||||
size.Height += 2;
|
||||
if (size.Width > TextPanel.Width)
|
||||
TextPanel.Width = size.Width;
|
||||
}
|
||||
|
||||
int y = Math.Max(TextPanel.Bounds.Bottom, PictureBox1.Bounds.Bottom);
|
||||
y += (int)(19 / Dpi.Factor.Height);
|
||||
|
||||
Button1.Top = y;
|
||||
Button2.Top = y;
|
||||
Button3.Top = y;
|
||||
|
||||
int buttonWidth = Button1.Width +
|
||||
(m_Button2Visible ? Button2.Width + buttonSpacing : 0) +
|
||||
(m_Button3Visible ? Button3.Width + buttonSpacing : 0);
|
||||
|
||||
int buttonArea = buttonWidth + buttonMargin * 2;
|
||||
if (buttonWidth < TextPanel.Bounds.Right + textMargin)
|
||||
buttonArea = TextPanel.Bounds.Right + textMargin;
|
||||
else
|
||||
{
|
||||
TextPanel.Width += buttonArea - TextPanel.Bounds.Right - textMargin;
|
||||
}
|
||||
|
||||
// Arrange buttons inside of the available area
|
||||
int x = (buttonArea - buttonWidth) / 2;
|
||||
Button1.Left = x;
|
||||
x += Button1.Width + buttonSpacing;
|
||||
|
||||
if (m_Button2Visible)
|
||||
{
|
||||
Button2.Left = x;
|
||||
x += Button2.Width + buttonSpacing;
|
||||
}
|
||||
|
||||
if (m_Button3Visible)
|
||||
{
|
||||
Button3.Left = x;
|
||||
x += Button3.Width + buttonSpacing;
|
||||
}
|
||||
|
||||
size = new Size(TextPanel.Bounds.Right + textMargin,
|
||||
Button1.Bounds.Bottom + textMargin);
|
||||
|
||||
this.ClientSize = size;
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult r = DialogResult.OK;
|
||||
if (m_Buttons == MessageBoxButtons.OK || m_Buttons == MessageBoxButtons.OKCancel)
|
||||
r = DialogResult.OK;
|
||||
else if (m_Buttons == MessageBoxButtons.YesNo || m_Buttons == MessageBoxButtons.YesNoCancel)
|
||||
r = DialogResult.Yes;
|
||||
else if (m_Buttons == MessageBoxButtons.AbortRetryIgnore)
|
||||
r = DialogResult.Abort;
|
||||
else if (m_Buttons == MessageBoxButtons.RetryCancel)
|
||||
r = DialogResult.Retry;
|
||||
|
||||
this.DialogResult = r;
|
||||
}
|
||||
|
||||
private void Button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult r = DialogResult.Cancel;
|
||||
if (m_Buttons == MessageBoxButtons.OKCancel)
|
||||
r = DialogResult.Cancel;
|
||||
else if (m_Buttons == MessageBoxButtons.YesNo || m_Buttons == MessageBoxButtons.YesNoCancel)
|
||||
r = DialogResult.No;
|
||||
else if (m_Buttons == MessageBoxButtons.AbortRetryIgnore)
|
||||
r = DialogResult.Retry;
|
||||
else if (m_Buttons == MessageBoxButtons.RetryCancel)
|
||||
r = DialogResult.Cancel;
|
||||
|
||||
this.DialogResult = r;
|
||||
}
|
||||
|
||||
private void Button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult r = DialogResult.Cancel;
|
||||
if (m_Buttons == MessageBoxButtons.AbortRetryIgnore)
|
||||
r = DialogResult.Ignore;
|
||||
else if (m_Buttons == MessageBoxButtons.YesNoCancel)
|
||||
r = DialogResult.Cancel;
|
||||
|
||||
this.DialogResult = r;
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
int wParamInt = WinApi.ToInt(m.WParam);
|
||||
if (m.Msg == NativeFunctions.WM_SYSCOMMAND && (wParamInt == NativeFunctions.SC_MAXIMIZE || wParamInt == NativeFunctions.SC_MINIMIZE))
|
||||
return;
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if ((keyData & Keys.C) == Keys.C && (keyData & Keys.Control) == Keys.Control)
|
||||
{
|
||||
string s = "------------------------------" + "\r\n" + this.Text + "\r\n" + "------------------------------" +
|
||||
"\r\n" + TextPanel.Text +
|
||||
"\r\n" + "------------------------------" + "\r\n";
|
||||
if (Button1.Visible)
|
||||
s += "[" + Button1.Text.Replace("&", "") + "] ";
|
||||
if (Button2.Visible)
|
||||
s += "[" + Button2.Text.Replace("&", "") + "] ";
|
||||
if (Button3.Visible)
|
||||
s += "[" + Button3.Text.Replace("&", "") + "]";
|
||||
s += "\r\n------------------------------";
|
||||
#if (FRAMEWORK20)
|
||||
Clipboard.SetText(s);
|
||||
#else
|
||||
Clipboard.SetDataObject(s);
|
||||
#endif
|
||||
}
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the anti-alias setting for text-pane.
|
||||
/// </summary>
|
||||
public bool AntiAlias
|
||||
{
|
||||
get { return TextPanel.AntiAlias; }
|
||||
set
|
||||
{
|
||||
TextPanel.AntiAlias = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region System Strings
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
private static extern string MB_GetString(int i);
|
||||
|
||||
private static string GetLocalizedText(SystemStrings sysString)
|
||||
{
|
||||
string key = "";
|
||||
string result = null;
|
||||
if (sysString == SystemStrings.Abort)
|
||||
{
|
||||
result = "&Abort";
|
||||
key = LocalizationKeys.MessageBoxAbortButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Cancel)
|
||||
{
|
||||
result = "&Cancel";
|
||||
key = LocalizationKeys.MessageBoxCancelButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Close)
|
||||
{
|
||||
result = "C&lose";
|
||||
key = LocalizationKeys.MessageBoxCloseButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Continue)
|
||||
{
|
||||
result = "Co&ntinue";
|
||||
key = LocalizationKeys.MessageBoxContinueButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Help)
|
||||
{
|
||||
result = "&Help";
|
||||
key = LocalizationKeys.MessageBoxHelpButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Ignore)
|
||||
{
|
||||
result = "&Ignore";
|
||||
key = LocalizationKeys.MessageBoxIgnoreButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.No)
|
||||
{
|
||||
result = "&No";
|
||||
key = LocalizationKeys.MessageBoxNoButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.OK)
|
||||
{
|
||||
result = "&OK";
|
||||
key = LocalizationKeys.MessageBoxOkButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Retry)
|
||||
{
|
||||
result = "&Retry";
|
||||
key = LocalizationKeys.MessageBoxRetryButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.TryAgain)
|
||||
{
|
||||
result = "&Try Again";
|
||||
key = LocalizationKeys.MessageBoxTryAgainButton;
|
||||
}
|
||||
else if (sysString == SystemStrings.Yes)
|
||||
{
|
||||
result = "&Yes";
|
||||
key = LocalizationKeys.MessageBoxYesButton;
|
||||
}
|
||||
|
||||
if (key != null)
|
||||
{
|
||||
result = LocalizationManager.GetLocalizedString(key, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private static string GetString(SystemStrings sysString)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
if (CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.ToLower() != "en" && MessageBoxEx.UseSystemLocalizedString)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = MB_GetString((int)sysString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (result == "")
|
||||
{
|
||||
result = GetLocalizedText(sysString);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration of available common system strings.
|
||||
/// </summary>
|
||||
private enum SystemStrings
|
||||
{
|
||||
OK = 0,
|
||||
Cancel = 1,
|
||||
Abort = 2,
|
||||
Retry = 3,
|
||||
Ignore = 4,
|
||||
Yes = 5,
|
||||
No = 6,
|
||||
Close = 7,
|
||||
Help = 8,
|
||||
TryAgain = 9,
|
||||
Continue = 10
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
113
PROMS/DotNetBar Source Code/Metro/MetroQatCustomizeDialog.cs
Normal file
113
PROMS/DotNetBar Source Code/Metro/MetroQatCustomizeDialog.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Ribbon;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
internal class MetroQatCustomizeDialog : MetroForm
|
||||
{
|
||||
private QatCustomizePanel qatCustomizePanel1;
|
||||
internal ButtonX buttonOK;
|
||||
internal ButtonX buttonCancel;
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.qatCustomizePanel1 = new DevComponents.DotNetBar.Ribbon.QatCustomizePanel();
|
||||
this.buttonOK = new DevComponents.DotNetBar.ButtonX();
|
||||
this.buttonCancel = new DevComponents.DotNetBar.ButtonX();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// qatCustomizePanel1
|
||||
//
|
||||
this.qatCustomizePanel1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.qatCustomizePanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.qatCustomizePanel1.Name = "qatCustomizePanel1";
|
||||
this.qatCustomizePanel1.Size = new System.Drawing.Size(444, 298);
|
||||
this.qatCustomizePanel1.TabIndex = 0;
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonOK.Location = new System.Drawing.Point(285, 297);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(73, 21);
|
||||
this.buttonOK.TabIndex = 1;
|
||||
this.buttonOK.Text = "OK";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(364, 297);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(73, 21);
|
||||
this.buttonCancel.TabIndex = 2;
|
||||
this.buttonCancel.Text = "Cancel";
|
||||
//
|
||||
// QatCustomizeDialog
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(445, 324);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.Controls.Add(this.qatCustomizePanel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Name = "QatCustomizeDialog";
|
||||
this.Text = "Customize";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public MetroQatCustomizeDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the items for the customization from MetroTab control. Registered MetroToolbar controls are enumerated and items
|
||||
/// are added if they have CanCustomize=true.
|
||||
/// </summary>
|
||||
/// <param name="tab">MetroTab control that holds references to known MetroToolbars.</param>
|
||||
public void LoadItems(MetroShell tab)
|
||||
{
|
||||
qatCustomizePanel1.LoadItems(tab);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to the internal Quick Access Toolbar Customization panel.
|
||||
/// </summary>
|
||||
public QatCustomizePanel QatCustomizePanel
|
||||
{
|
||||
get { return qatCustomizePanel1; }
|
||||
}
|
||||
}
|
||||
}
|
1604
PROMS/DotNetBar Source Code/Metro/MetroShell.cs
Normal file
1604
PROMS/DotNetBar Source Code/Metro/MetroShell.cs
Normal file
File diff suppressed because it is too large
Load Diff
BIN
PROMS/DotNetBar Source Code/Metro/MetroShell.ico
Normal file
BIN
PROMS/DotNetBar Source Code/Metro/MetroShell.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
212
PROMS/DotNetBar Source Code/Metro/MetroStatusBar.cs
Normal file
212
PROMS/DotNetBar Source Code/Metro/MetroStatusBar.cs
Normal file
@@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro.Rendering;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Metro-UI Status Bar control.
|
||||
/// </summary>
|
||||
[ToolboxBitmap(typeof(MetroShell), "MetroStatusBar.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.MetroStatusBarDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
|
||||
public class MetroStatusBar : ItemControl
|
||||
{
|
||||
#region Constructor
|
||||
private GenericItemContainer _ItemContainer = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroStatusBar class.
|
||||
/// </summary>
|
||||
public MetroStatusBar()
|
||||
{
|
||||
_ItemContainer = new GenericItemContainer();
|
||||
_ItemContainer.GlobalItem = false;
|
||||
_ItemContainer.ContainerControl = this;
|
||||
_ItemContainer.Stretch = true;
|
||||
_ItemContainer.Displayed = true;
|
||||
_ItemContainer.WrapItems = false;
|
||||
_ItemContainer.ItemSpacing = 2;
|
||||
_ItemContainer.PaddingTop = 1;
|
||||
_ItemContainer.PaddingBottom = 4;
|
||||
_ItemContainer.PaddingLeft = 4;
|
||||
_ItemContainer.PaddingRight = 1;
|
||||
_ItemContainer.ToolbarItemsAlign = eContainerVerticalAlignment.Middle;
|
||||
_ItemContainer.EventHeight = false;
|
||||
_ItemContainer.FillsContainerControl = true;
|
||||
_ItemContainer.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
this.ColorScheme.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
_ItemContainer.SetOwner(this);
|
||||
_ItemContainer.LayoutType = eLayoutType.Toolbar;
|
||||
|
||||
this.SetBaseItemContainer(_ItemContainer);
|
||||
this.DragDropSupport = true;
|
||||
this.ItemAdded += new EventHandler(ChildItemAdded);
|
||||
this.ItemRemoved += new ItemRemovedEventHandler(ChildItemRemoved);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
this.ItemAdded -= new EventHandler(ChildItemAdded);
|
||||
this.ItemRemoved -= new ItemRemovedEventHandler(ChildItemRemoved);
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Indicates whether items that cannot fit are displayed on popup.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Indicates whether items that cannot fit are displayed on popup.")]
|
||||
public bool OverflowEnabled
|
||||
{
|
||||
get { return _ItemContainer.OverflowEnabled; }
|
||||
set
|
||||
{
|
||||
_ItemContainer.OverflowEnabled = value;
|
||||
if (this.IsHandleCreated)
|
||||
RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ChildItemAdded(object sender, EventArgs e)
|
||||
{
|
||||
this.RecalcLayout();
|
||||
}
|
||||
private void ChildItemRemoved(object sender, ItemRemovedEventArgs e)
|
||||
{
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override void PaintControlBackground(ItemPaintArgs pa)
|
||||
{
|
||||
MetroRender.Paint(this, pa);
|
||||
base.PaintControlBackground(pa);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns collection of items on a bar.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Browsable(false)]
|
||||
public SubItemsCollection Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ItemContainer.SubItems;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly int ResizeHandleWidth = 10;
|
||||
protected override Rectangle GetItemContainerRectangle()
|
||||
{
|
||||
Rectangle ic = base.GetItemContainerRectangle();
|
||||
if (_ResizeHandleVisible)
|
||||
{
|
||||
ic.Width -= ResizeHandleWidth;
|
||||
if (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes)
|
||||
ic.X += ResizeHandleWidth;
|
||||
}
|
||||
return ic;
|
||||
}
|
||||
|
||||
private bool _ResizeHandleVisible = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether resize handle used to resize the parent form is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance"), Description("Indicates whether resize handle used to resize the parent form is visible.")]
|
||||
public bool ResizeHandleVisible
|
||||
{
|
||||
get { return _ResizeHandleVisible; }
|
||||
set
|
||||
{
|
||||
if (value != _ResizeHandleVisible)
|
||||
{
|
||||
bool oldValue = _ResizeHandleVisible;
|
||||
_ResizeHandleVisible = value;
|
||||
OnResizeHandleVisibleChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when ResizeHandleVisible property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnResizeHandleVisibleChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("ResizeHandleVisible"));
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref System.Windows.Forms.Message m)
|
||||
{
|
||||
if (_ResizeHandleVisible && m.Msg == (int)WinApi.WindowsMessages.WM_NCHITTEST)
|
||||
{
|
||||
// Get position being tested...
|
||||
int x = WinApi.LOWORD(m.LParam);
|
||||
int y = WinApi.HIWORD(m.LParam);
|
||||
Point p = PointToClient(new Point(x, y));
|
||||
int resizeHandleWidth = Dpi.Width(ResizeHandleWidth);
|
||||
Rectangle resizeBounds = (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes) ?
|
||||
new Rectangle(0, this.Height - resizeHandleWidth, resizeHandleWidth, resizeHandleWidth) :
|
||||
new Rectangle(this.Width - resizeHandleWidth, this.Height - resizeHandleWidth, resizeHandleWidth, resizeHandleWidth);
|
||||
if (resizeBounds.Contains(p))
|
||||
{
|
||||
m.Result = new IntPtr((int)WinApi.WindowHitTestRegions.TransparentOrCovered);
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets spacing between items, default value is 2.
|
||||
/// </summary>
|
||||
[DefaultValue(2), Category("Appearance"), Description("Gets or sets spacing between items.")]
|
||||
public int ItemSpacing
|
||||
{
|
||||
get { return _ItemContainer.ItemSpacing; }
|
||||
set
|
||||
{
|
||||
_ItemContainer.ItemSpacing = value;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size DefaultSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Size(200, 22);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Licensing
|
||||
#if !TRIAL
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (NativeFunctions.keyValidated2 != 266)
|
||||
TextDrawing.DrawString(e.Graphics, "Invalid License", this.Font, Color.FromArgb(180, Color.Red), this.ClientRectangle, eTextFormat.Bottom | eTextFormat.HorizontalCenter);
|
||||
}
|
||||
|
||||
private string _LicenseKey = "";
|
||||
[Browsable(false), DefaultValue("")]
|
||||
public string LicenseKey
|
||||
{
|
||||
get { return _LicenseKey; }
|
||||
set
|
||||
{
|
||||
if (NativeFunctions.ValidateLicenseKey(value))
|
||||
return;
|
||||
_LicenseKey = (!NativeFunctions.CheckLicenseKey(value) ? "9dsjkhds7" : value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/Metro/MetroStatusBar.ico
Normal file
BIN
PROMS/DotNetBar Source Code/Metro/MetroStatusBar.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
679
PROMS/DotNetBar Source Code/Metro/MetroStripContainerItem.cs
Normal file
679
PROMS/DotNetBar Source Code/Metro/MetroStripContainerItem.cs
Normal file
@@ -0,0 +1,679 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the internal container item for the ribbon strip control.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false)]
|
||||
internal class MetroStripContainerItem : ImageItem, IDesignTimeProvider
|
||||
{
|
||||
#region Private Variables
|
||||
private const string DefaultSettingsButtonText = "<font size=\"7\">SETTINGS</font>";
|
||||
private const string DefaultHelpButtonText = "<font size=\"7\">HELP</font>";
|
||||
|
||||
private MetroTabItemContainer _ItemContainer = null;
|
||||
private CaptionItemContainer _CaptionContainer = null;
|
||||
private SystemCaptionItem _SystemCaptionItem = null;
|
||||
private MetroTabStrip _TabStrip = null;
|
||||
private SystemCaptionItem _WindowIcon = null;
|
||||
private Separator _IconSeparator = null;
|
||||
private ButtonItem _Settings = null;
|
||||
private ButtonItem _Help = null;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initializes it with the parent RibbonStrip control.
|
||||
/// </summary>
|
||||
/// <param name="parent">Reference to parent RibbonStrip control</param>
|
||||
public MetroStripContainerItem(MetroTabStrip parent)
|
||||
{
|
||||
_TabStrip = parent;
|
||||
|
||||
// We contain other controls
|
||||
m_IsContainer = true;
|
||||
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
|
||||
_ItemContainer = new MetroTabItemContainer();
|
||||
_ItemContainer.ContainerControl = parent;
|
||||
_ItemContainer.GlobalItem = false;
|
||||
//_ItemContainer.WrapItems = false;
|
||||
//_ItemContainer.EventHeight = false;
|
||||
//_ItemContainer.UseMoreItemsButton = false;
|
||||
_ItemContainer.Stretch = true;
|
||||
_ItemContainer.Displayed = true;
|
||||
//_ItemContainer.SystemContainer = true;
|
||||
//_ItemContainer.PaddingTop = 0;
|
||||
//_ItemContainer.PaddingBottom = 0;
|
||||
//_ItemContainer.PaddingLeft = 0;
|
||||
//_ItemContainer.ItemSpacing = 1;
|
||||
|
||||
_CaptionContainer = new CaptionItemContainer();
|
||||
_CaptionContainer.ContainerControl = parent;
|
||||
_CaptionContainer.GlobalItem = false;
|
||||
_CaptionContainer.WrapItems = false;
|
||||
_CaptionContainer.EventHeight = false;
|
||||
_CaptionContainer.EqualButtonSize = false;
|
||||
_CaptionContainer.ToolbarItemsAlign = eContainerVerticalAlignment.Top;
|
||||
_CaptionContainer.UseMoreItemsButton = false;
|
||||
_CaptionContainer.Stretch = true;
|
||||
_CaptionContainer.Displayed = true;
|
||||
_CaptionContainer.SystemContainer = true;
|
||||
_CaptionContainer.PaddingBottom = 0;
|
||||
_CaptionContainer.PaddingTop = 0;
|
||||
_CaptionContainer.PaddingLeft = 6;
|
||||
_CaptionContainer.ItemSpacing = 1;
|
||||
_CaptionContainer.TrackSubItemsImageSize = false;
|
||||
_CaptionContainer.ItemAdded += new EventHandler(this.CaptionContainerNewItemAdded);
|
||||
this.SubItems.Add(_CaptionContainer);
|
||||
this.SubItems.Add(_ItemContainer);
|
||||
|
||||
_Settings = new ButtonItem("sysSettingsButton");
|
||||
_Settings.Text=DefaultSettingsButtonText;
|
||||
//_Settings.HotTrackingStyle = eHotTrackingStyle.None;
|
||||
_Settings.ItemAlignment = eItemAlignment.Far;
|
||||
_Settings.Click += new EventHandler(SettingsButtonClick);
|
||||
_Settings.SetSystemItem(true);
|
||||
_Settings.CanCustomize = false;
|
||||
_CaptionContainer.SubItems.Add(_Settings);
|
||||
|
||||
_Help = new ButtonItem("sysHelpButton");
|
||||
_Help.Text = DefaultHelpButtonText;
|
||||
_Help.SetSystemItem(true);
|
||||
_Help.CanCustomize = false;
|
||||
//_Help.HotTrackingStyle = eHotTrackingStyle.None;
|
||||
_Help.ItemAlignment = eItemAlignment.Far;
|
||||
_Help.Click += new EventHandler(HelpButtonClick);
|
||||
_CaptionContainer.SubItems.Add(_Help);
|
||||
|
||||
SystemCaptionItem sc = new SystemCaptionItem();
|
||||
sc.RestoreEnabled = false;
|
||||
sc.IsSystemIcon = false;
|
||||
sc.ItemAlignment = eItemAlignment.Far;
|
||||
_CaptionContainer.SubItems.Add(sc);
|
||||
_SystemCaptionItem = sc;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
private void CaptionContainerNewItemAdded(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is BaseItem)
|
||||
{
|
||||
BaseItem item = sender as BaseItem;
|
||||
if (!(item is SystemCaptionItem))
|
||||
{
|
||||
if (_CaptionContainer.SubItems.Contains(_Settings))
|
||||
{
|
||||
_CaptionContainer.SubItems._Remove(_Settings);
|
||||
_CaptionContainer.SubItems._Add(_Settings);
|
||||
}
|
||||
if (_CaptionContainer.SubItems.Contains(_Help))
|
||||
{
|
||||
_CaptionContainer.SubItems._Remove(_Help);
|
||||
_CaptionContainer.SubItems._Add(_Help);
|
||||
}
|
||||
if (_CaptionContainer.SubItems.Contains(_SystemCaptionItem))
|
||||
{
|
||||
_CaptionContainer.SubItems._Remove(_SystemCaptionItem);
|
||||
_CaptionContainer.SubItems._Add(_SystemCaptionItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SettingsButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
MetroTabStrip mts = this.ContainerControl as MetroTabStrip;
|
||||
if (mts == null) return;
|
||||
|
||||
MetroShell tab = mts.Parent as MetroShell;
|
||||
if (tab == null) return;
|
||||
|
||||
tab.InvokeSettingsButtonClick(e);
|
||||
}
|
||||
private void HelpButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
MetroTabStrip mts = this.ContainerControl as MetroTabStrip;
|
||||
if (mts == null) return;
|
||||
|
||||
MetroShell tab = mts.Parent as MetroShell;
|
||||
if (tab == null) return;
|
||||
|
||||
tab.InvokeHelpButtonClick(e);
|
||||
}
|
||||
|
||||
internal void ReleaseSystemFocus()
|
||||
{
|
||||
_ItemContainer.ReleaseSystemFocus();
|
||||
if (_TabStrip.CaptionVisible)
|
||||
_CaptionContainer.ReleaseSystemFocus();
|
||||
}
|
||||
|
||||
public override void ContainerLostFocus(bool appLostFocus)
|
||||
{
|
||||
base.ContainerLostFocus(appLostFocus);
|
||||
_ItemContainer.ContainerLostFocus(appLostFocus);
|
||||
if (_TabStrip.CaptionVisible)
|
||||
_CaptionContainer.ContainerLostFocus(appLostFocus);
|
||||
}
|
||||
|
||||
internal void SetSystemFocus()
|
||||
{
|
||||
if (_TabStrip.CaptionVisible && _ItemContainer.ExpandedItem()==null)
|
||||
_CaptionContainer.SetSystemFocus();
|
||||
else
|
||||
_ItemContainer.SetSystemFocus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints this base container
|
||||
/// </summary>
|
||||
public override void Paint(ItemPaintArgs pa)
|
||||
{
|
||||
if (this.SuspendLayout)
|
||||
return;
|
||||
|
||||
_ItemContainer.Paint(pa);
|
||||
if (_TabStrip.CaptionVisible)
|
||||
_CaptionContainer.Paint(pa);
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
if (this.SuspendLayout)
|
||||
return;
|
||||
_ItemContainer.Bounds = GetItemContainerBounds();
|
||||
_ItemContainer.RecalcSize();
|
||||
if (_ItemContainer.HeightInternal < 0) _ItemContainer.HeightInternal = 0;
|
||||
bool isMaximized = false;
|
||||
if (_TabStrip.CaptionVisible)
|
||||
{
|
||||
_CaptionContainer.Bounds = GetCaptionContainerBounds();
|
||||
_CaptionContainer.RecalcSize();
|
||||
Size frameBorderSize = SystemInformation.FrameBorderSize;
|
||||
Control container = this.ContainerControl as Control;
|
||||
if (container != null)
|
||||
{
|
||||
Form form = container.FindForm();
|
||||
if (form != null)
|
||||
{
|
||||
if (_WindowIcon != null)
|
||||
_WindowIcon.SetVisibleDirect(form.ShowIcon && _TabStrip.ShowIcon);
|
||||
if (_IconSeparator != null)
|
||||
_IconSeparator.SetVisibleDirect(form.ShowIcon && _TabStrip.ShowIcon);
|
||||
}
|
||||
MetroAppForm appForm = form as MetroAppForm;
|
||||
if (appForm != null)
|
||||
{
|
||||
NonClientInfo nci = appForm.GetNonClientInfo();
|
||||
frameBorderSize.Width = nci.LeftBorder;
|
||||
frameBorderSize.Height = nci.BottomBorder;
|
||||
}
|
||||
}
|
||||
if (_TabStrip.CaptionHeight == 0 && _SystemCaptionItem.TopInternal < (frameBorderSize.Height - 1))
|
||||
{
|
||||
Control c = this.ContainerControl as Control;
|
||||
Form form = null;
|
||||
if (c != null) form = c.FindForm();
|
||||
if (form != null && form.WindowState == FormWindowState.Maximized)
|
||||
isMaximized = true;
|
||||
|
||||
if (isMaximized)
|
||||
{
|
||||
_SystemCaptionItem.TopInternal = 1;
|
||||
if (_WindowIcon != null) _WindowIcon.TopInternal = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_SystemCaptionItem.TopInternal = Math.Max(1,frameBorderSize.Height - 6);
|
||||
if (_WindowIcon != null) _WindowIcon.TopInternal = frameBorderSize.Height - 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the Y position of the items inside of the caption container since they are top aligned and
|
||||
// quick access toolbar items should be aligned with the bottom of the system caption item.
|
||||
if (System.Environment.OSVersion.Version.Major >= 6)
|
||||
{
|
||||
int topOffset = 3;
|
||||
if (isMaximized)
|
||||
topOffset += 1;
|
||||
int maxBottom = 0;
|
||||
foreach (BaseItem item in _CaptionContainer.SubItems)
|
||||
{
|
||||
if (!(item is ApplicationButton || item is DevComponents.DotNetBar.Metro.MetroAppButton) && item != _SystemCaptionItem && item != _IconSeparator)
|
||||
item.TopInternal += topOffset;
|
||||
else if (item == _IconSeparator)
|
||||
item.TopInternal += (isMaximized ? 2 : 1);
|
||||
maxBottom = Math.Max(item.Bounds.Bottom, maxBottom);
|
||||
}
|
||||
if (_CaptionContainer.MoreItems != null)
|
||||
_CaptionContainer.MoreItems.TopInternal += topOffset;
|
||||
if (maxBottom > _CaptionContainer.HeightInternal) _CaptionContainer.SetDisplayRectangle(new Rectangle(_CaptionContainer.Bounds.X, _CaptionContainer.Bounds.Y, _CaptionContainer.Bounds.Width, maxBottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
int maxBottom = 0;
|
||||
foreach (BaseItem item in _CaptionContainer.SubItems)
|
||||
{
|
||||
if (item.HeightInternal < _SystemCaptionItem.HeightInternal && (item != _IconSeparator && item!= _WindowIcon))
|
||||
{
|
||||
//item.TopInternal += (m_SystemCaptionItem.HeightInternal - item.HeightInternal);
|
||||
item.TopInternal = (_SystemCaptionItem.Bounds.Bottom - (item.HeightInternal + ((item is LabelItem) ? 2 : 0)));
|
||||
maxBottom = Math.Max(item.Bounds.Bottom, maxBottom);
|
||||
}
|
||||
}
|
||||
if (_CaptionContainer.MoreItems != null)
|
||||
_CaptionContainer.MoreItems.TopInternal += (_SystemCaptionItem.HeightInternal - _CaptionContainer.MoreItems.HeightInternal);
|
||||
if (maxBottom > _CaptionContainer.HeightInternal) _CaptionContainer.SetDisplayRectangle(new Rectangle(_CaptionContainer.Bounds.X, _CaptionContainer.Bounds.Y, _CaptionContainer.Bounds.Width, maxBottom));
|
||||
}
|
||||
|
||||
if (_ItemContainer.HeightInternal == 0)
|
||||
this.HeightInternal = _CaptionContainer.HeightInternal;
|
||||
else
|
||||
this.HeightInternal = _ItemContainer.Bounds.Bottom;// -m_CaptionContainer.Bounds.Top;
|
||||
}
|
||||
else
|
||||
{
|
||||
int h = _ItemContainer.HeightInternal;
|
||||
this.HeightInternal = h;
|
||||
}
|
||||
|
||||
base.RecalcSize();
|
||||
}
|
||||
|
||||
private Rectangle GetItemContainerBounds()
|
||||
{
|
||||
return _TabStrip.GetItemContainerBounds();
|
||||
}
|
||||
|
||||
private Rectangle GetCaptionContainerBounds()
|
||||
{
|
||||
return _TabStrip.GetCaptionContainerBounds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to internal ribbon strip container that contains tabs and/or other items.
|
||||
/// </summary>
|
||||
public SimpleItemContainer RibbonStripContainer
|
||||
{
|
||||
get { return _ItemContainer; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to internal caption container item that contains the quick toolbar, start button and system caption item.
|
||||
/// </summary>
|
||||
public GenericItemContainer CaptionContainer
|
||||
{
|
||||
get { return _CaptionContainer; }
|
||||
}
|
||||
|
||||
public SystemCaptionItem SystemCaptionItem
|
||||
{
|
||||
get { return _SystemCaptionItem; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of GenericItemContainer item
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
MetroStripContainerItem objCopy = new MetroStripContainerItem(_TabStrip);
|
||||
this.CopyToItem(objCopy);
|
||||
|
||||
return objCopy;
|
||||
}
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
MetroStripContainerItem objCopy = copy as MetroStripContainerItem;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
|
||||
public override void InternalClick(MouseButtons mb, Point mpos)
|
||||
{
|
||||
_ItemContainer.InternalClick(mb, mpos);
|
||||
if (_TabStrip.CaptionVisible) _CaptionContainer.InternalClick(mb, mpos);
|
||||
}
|
||||
|
||||
public override void InternalDoubleClick(MouseButtons mb, Point mpos)
|
||||
{
|
||||
_ItemContainer.InternalDoubleClick(mb, mpos);
|
||||
if (_TabStrip.CaptionVisible) _CaptionContainer.InternalDoubleClick(mb, mpos);
|
||||
}
|
||||
|
||||
public override void InternalMouseDown(MouseEventArgs objArg)
|
||||
{
|
||||
_ItemContainer.InternalMouseDown(objArg);
|
||||
if (_TabStrip.CaptionVisible)
|
||||
{
|
||||
if(this.DesignMode && _CaptionContainer.ItemAtLocation(objArg.X, objArg.Y)!=null || !this.DesignMode)
|
||||
_CaptionContainer.InternalMouseDown(objArg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void InternalMouseHover()
|
||||
{
|
||||
_ItemContainer.InternalMouseHover();
|
||||
if (_TabStrip.CaptionVisible) _CaptionContainer.InternalMouseHover();
|
||||
}
|
||||
|
||||
public override void InternalMouseLeave()
|
||||
{
|
||||
_ItemContainer.InternalMouseLeave();
|
||||
if (_TabStrip.CaptionVisible) _CaptionContainer.InternalMouseLeave();
|
||||
}
|
||||
|
||||
public override void InternalMouseMove(MouseEventArgs objArg)
|
||||
{
|
||||
_ItemContainer.InternalMouseMove(objArg);
|
||||
if (_TabStrip.CaptionVisible) _CaptionContainer.InternalMouseMove(objArg);
|
||||
}
|
||||
|
||||
public override void InternalMouseUp(MouseEventArgs objArg)
|
||||
{
|
||||
_ItemContainer.InternalMouseUp(objArg);
|
||||
if (_TabStrip.CaptionVisible) _CaptionContainer.InternalMouseUp(objArg);
|
||||
}
|
||||
|
||||
public override void InternalKeyDown(KeyEventArgs objArg)
|
||||
{
|
||||
BaseItem expanded = this.ExpandedItem();
|
||||
if (expanded == null)
|
||||
expanded = _CaptionContainer.ExpandedItem();
|
||||
if (expanded == null)
|
||||
expanded = _ItemContainer.ExpandedItem();
|
||||
|
||||
if (expanded == null || !_TabStrip.CaptionVisible)
|
||||
{
|
||||
_ItemContainer.InternalKeyDown(objArg);
|
||||
if (!objArg.Handled && _TabStrip.CaptionVisible)
|
||||
_CaptionContainer.InternalKeyDown(objArg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (expanded.Parent == _ItemContainer)
|
||||
{
|
||||
_ItemContainer.InternalKeyDown(objArg);
|
||||
}
|
||||
else
|
||||
{
|
||||
_CaptionContainer.InternalKeyDown(objArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return Sub Item at specified location
|
||||
/// </summary>
|
||||
public override BaseItem ItemAtLocation(int x, int y)
|
||||
{
|
||||
if (_ItemContainer.DisplayRectangle.Contains(x, y))
|
||||
return _ItemContainer.ItemAtLocation(x, y);
|
||||
|
||||
if (_CaptionContainer.DisplayRectangle.Contains(x, y))
|
||||
return _CaptionContainer.ItemAtLocation(x, y);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnStyleChanged()
|
||||
{
|
||||
eDotNetBarStyle effectiveStyle = this.EffectiveStyle;
|
||||
if (effectiveStyle == eDotNetBarStyle.Office2010)
|
||||
{
|
||||
if (_WindowIcon == null)
|
||||
{
|
||||
_IconSeparator = new Separator("sys_caption_separator");
|
||||
_IconSeparator.SetSystemItem(true);
|
||||
_IconSeparator.DesignTimeVisible = false;
|
||||
_IconSeparator.CanCustomize = false;
|
||||
_CaptionContainer.SubItems._Add(_IconSeparator, 0);
|
||||
_WindowIcon = new SystemCaptionItem();
|
||||
_WindowIcon.Name = "sys_caption_icon";
|
||||
_WindowIcon.Enabled = false;
|
||||
_WindowIcon.Style = this.Style;
|
||||
_WindowIcon.IsSystemIcon = true;
|
||||
_WindowIcon.DesignTimeVisible = false;
|
||||
_WindowIcon.CanCustomize = false;
|
||||
_WindowIcon.QueryIconOnPaint = true;
|
||||
_WindowIcon.MouseDown += WindowIconMouseDown;
|
||||
_WindowIcon.DoubleClick += WindowIconDoubleClick;
|
||||
_CaptionContainer.SubItems._Add(_WindowIcon, 0);
|
||||
}
|
||||
}
|
||||
else if (effectiveStyle == eDotNetBarStyle.Windows7)
|
||||
{
|
||||
if (_WindowIcon == null)
|
||||
{
|
||||
_IconSeparator = new Separator("sys_caption_separator");
|
||||
_IconSeparator.FixedSize = new Size(3, 12);
|
||||
_IconSeparator.SetSystemItem(true);
|
||||
_IconSeparator.DesignTimeVisible = false;
|
||||
_IconSeparator.CanCustomize = false;
|
||||
_CaptionContainer.SubItems._Add(_IconSeparator, 0);
|
||||
_WindowIcon = new SystemCaptionItem();
|
||||
_WindowIcon.Name = "sys_caption_icon";
|
||||
_WindowIcon.Enabled = false;
|
||||
_WindowIcon.Style = this.Style;
|
||||
_WindowIcon.IsSystemIcon = true;
|
||||
_WindowIcon.QueryIconOnPaint = true;
|
||||
_WindowIcon.DesignTimeVisible = false;
|
||||
_WindowIcon.CanCustomize = false;
|
||||
_WindowIcon.MouseDown += WindowIconMouseDown;
|
||||
_CaptionContainer.SubItems._Add(_WindowIcon, 0);
|
||||
}
|
||||
}
|
||||
else if (StyleManager.IsMetro(effectiveStyle))
|
||||
{
|
||||
if (_WindowIcon == null)
|
||||
{
|
||||
_IconSeparator = new Separator("sys_caption_separator");
|
||||
_IconSeparator.FixedSize = new Size(3, 14);
|
||||
_IconSeparator.SetSystemItem(true);
|
||||
_IconSeparator.DesignTimeVisible = false;
|
||||
_IconSeparator.CanCustomize = false;
|
||||
_CaptionContainer.SubItems._Add(_IconSeparator, 0);
|
||||
_WindowIcon = new SystemCaptionItem();
|
||||
_WindowIcon.Name = "sys_caption_icon";
|
||||
_WindowIcon.Enabled = false;
|
||||
_WindowIcon.Style = this.Style;
|
||||
_WindowIcon.IsSystemIcon = true;
|
||||
_WindowIcon.DesignTimeVisible = false;
|
||||
_WindowIcon.CanCustomize = false;
|
||||
_WindowIcon.QueryIconOnPaint = true;
|
||||
_WindowIcon.MouseDown += WindowIconMouseDown;
|
||||
_WindowIcon.DoubleClick += WindowIconDoubleClick;
|
||||
_CaptionContainer.SubItems._Add(_WindowIcon, 0);
|
||||
}
|
||||
}
|
||||
else if (_WindowIcon != null)
|
||||
{
|
||||
if (_CaptionContainer.SubItems.Contains(_WindowIcon))
|
||||
_CaptionContainer.SubItems._Remove(_WindowIcon);
|
||||
_WindowIcon.MouseDown -= WindowIconMouseDown;
|
||||
_WindowIcon.DoubleClick -= WindowIconDoubleClick;
|
||||
_WindowIcon.Dispose();
|
||||
_WindowIcon = null;
|
||||
if (_CaptionContainer.SubItems.Contains(_IconSeparator))
|
||||
_CaptionContainer.SubItems._Remove(_IconSeparator);
|
||||
_IconSeparator.Dispose();
|
||||
_IconSeparator = null;
|
||||
}
|
||||
base.OnStyleChanged();
|
||||
}
|
||||
|
||||
void WindowIconDoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (_TabStrip != null)
|
||||
{
|
||||
_TabStrip.CloseParentForm();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowIconMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
MetroTabStrip mts = this.ContainerControl as MetroTabStrip;
|
||||
if (mts != null)
|
||||
{
|
||||
Point p = new Point(_WindowIcon.LeftInternal, _WindowIcon.Bounds.Bottom + 1);
|
||||
p = mts.PointToScreen(p);
|
||||
mts.ShowSystemMenu(p);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDesignTimeProvider Members
|
||||
|
||||
public InsertPosition GetInsertPosition(Point pScreen, BaseItem DragItem)
|
||||
{
|
||||
InsertPosition pos = _ItemContainer.GetInsertPosition(pScreen, DragItem);
|
||||
if(pos==null && _TabStrip.CaptionVisible)
|
||||
pos = _CaptionContainer.GetInsertPosition(pScreen, DragItem);
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void DrawReversibleMarker(int iPos, bool Before)
|
||||
{
|
||||
//DesignTimeProviderContainer.DrawReversibleMarker(this, iPos, Before);
|
||||
}
|
||||
|
||||
public void InsertItemAt(BaseItem objItem, int iPos, bool Before)
|
||||
{
|
||||
//DesignTimeProviderContainer.InsertItemAt(this, objItem, iPos, Before);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the item is expanded or not. For Popup items this would indicate whether the item is popped up or not.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Expanded
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Expanded;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Expanded = value;
|
||||
if (!value)
|
||||
{
|
||||
foreach (BaseItem item in this.SubItems)
|
||||
item.Expanded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When parent items does recalc size for its sub-items it should query
|
||||
/// image size and store biggest image size into this property.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public override System.Drawing.Size SubItemsImageSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.SubItemsImageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
//m_SubItemsImageSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Settings button is visible.
|
||||
/// </summary>
|
||||
public bool SettingsButtonVisible
|
||||
{
|
||||
get { return _Settings.Visible; }
|
||||
set
|
||||
{
|
||||
if (value != _Settings.Visible)
|
||||
{
|
||||
_Settings.Visible = value;
|
||||
this.RecalcSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Help button is visible.
|
||||
/// </summary>
|
||||
public bool HelpButtonVisible
|
||||
{
|
||||
get { return _Help.Visible; }
|
||||
set
|
||||
{
|
||||
if (value != _Help.Visible)
|
||||
{
|
||||
_Help.Visible = value;
|
||||
this.RecalcSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _SettingsButtonText = "";
|
||||
/// <summary>
|
||||
/// Gets or sets the Settings button text.
|
||||
/// </summary>
|
||||
public string SettingsButtonText
|
||||
{
|
||||
get { return _SettingsButtonText; }
|
||||
set
|
||||
{
|
||||
if (value != _SettingsButtonText)
|
||||
{
|
||||
string oldValue = _SettingsButtonText;
|
||||
_SettingsButtonText = value;
|
||||
OnSettingsButtonTextChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when SettingsButtonText property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnSettingsButtonTextChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newValue))
|
||||
_Settings.Text = DefaultSettingsButtonText;
|
||||
else
|
||||
_Settings.Text = "<font size=\"7\">" + newValue + "</font>";
|
||||
}
|
||||
|
||||
private string _HelpButtonText;
|
||||
public string HelpButtonText
|
||||
{
|
||||
get { return _HelpButtonText; }
|
||||
set
|
||||
{
|
||||
if (value != _HelpButtonText)
|
||||
{
|
||||
string oldValue = _HelpButtonText;
|
||||
_HelpButtonText = value;
|
||||
OnHelpButtonTextChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when HelpButtonText property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnHelpButtonTextChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newValue))
|
||||
_Help.Text = DefaultHelpButtonText;
|
||||
else
|
||||
_Help.Text = "<font size=\"7\">" + newValue + "</font>";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
742
PROMS/DotNetBar Source Code/Metro/MetroTabItem.cs
Normal file
742
PROMS/DotNetBar Source Code/Metro/MetroTabItem.cs
Normal file
@@ -0,0 +1,742 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro.Rendering;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Rendering Tab used on Metro Tab Control.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DesignTimeVisible(false), Designer("DevComponents.DotNetBar.Design.MetroTabItemDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public class MetroTabItem:ButtonItem
|
||||
{
|
||||
#region Private Variables & Constructor
|
||||
private MetroTabPanel _Panel=null;
|
||||
private eMetroTabColor _ColorTable = eMetroTabColor.Default; private string _CashedColorTableName = "Default";
|
||||
private bool _ReducedSize = false;
|
||||
private int _PaddingHorizontal = 0;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroTabItem class.
|
||||
/// </summary>
|
||||
public MetroTabItem()
|
||||
{
|
||||
this.ButtonStyle = eButtonStyle.ImageAndText;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Paint(ItemPaintArgs p)
|
||||
{
|
||||
MetroRender.Paint(this, p);
|
||||
|
||||
if (!string.IsNullOrEmpty(NotificationMarkText))
|
||||
DevComponents.DotNetBar.Rendering.NotificationMarkPainter.Paint(p.Graphics, this.Bounds, NotificationMarkPosition,
|
||||
NotificationMarkText, new Size(NotificationMarkSize, NotificationMarkSize), NotificationMarkOffset, NotificationMarkColor);
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
_ImageRenderBounds = Rectangle.Empty;
|
||||
_TextRenderBounds = Rectangle.Empty;
|
||||
base.RecalcSize();
|
||||
}
|
||||
|
||||
private Rectangle _ImageRenderBounds = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets cached image rendering bounds.
|
||||
/// </summary>
|
||||
internal Rectangle ImageRenderBounds
|
||||
{
|
||||
get { return _ImageRenderBounds; }
|
||||
set { _ImageRenderBounds = value; }
|
||||
}
|
||||
|
||||
private Rectangle _TextRenderBounds = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets cached text rendering bounds.
|
||||
/// </summary>
|
||||
internal Rectangle TextRenderBounds
|
||||
{
|
||||
get { return _TextRenderBounds; }
|
||||
set { _TextRenderBounds = value;}
|
||||
}
|
||||
|
||||
private bool _RenderTabState = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether tab renders its state. Used internally by DotNetBar. Do not set.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
internal bool RenderTabState
|
||||
{
|
||||
get { return _RenderTabState; }
|
||||
set
|
||||
{
|
||||
_RenderTabState = value;
|
||||
if (this.ContainerControl is System.Windows.Forms.Control)
|
||||
((System.Windows.Forms.Control)this.ContainerControl).Invalidate();
|
||||
else
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool IsFadeEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the additional padding added around the tab item in pixels. Default value is 0.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(0), Category("Layout"), Description("Indicates additional padding added around the tab item in pixels.")]
|
||||
public int PaddingHorizontal
|
||||
{
|
||||
get { return _PaddingHorizontal; }
|
||||
set
|
||||
{
|
||||
_PaddingHorizontal = value;
|
||||
UpdateTabAppearance();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects the tab.
|
||||
/// </summary>
|
||||
public void Select()
|
||||
{
|
||||
this.Checked = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets whether size of the tab has been reduced below the default calculated size.
|
||||
/// </summary>
|
||||
internal bool ReducedSize
|
||||
{
|
||||
get { return _ReducedSize; }
|
||||
set { _ReducedSize = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the predefined color of item. Color specified here applies to items with Office 2007 style only. It does not have
|
||||
/// any effect on other styles. Default value is eMetroTabColor.Default
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(eMetroTabColor.Default), Category("Appearance"), Description("Indicates predefined color of item when Office 2007 style is used.")]
|
||||
public new eMetroTabColor ColorTable
|
||||
{
|
||||
get { return _ColorTable; }
|
||||
set
|
||||
{
|
||||
if (_ColorTable != value)
|
||||
{
|
||||
_ColorTable = value;
|
||||
_CashedColorTableName = Enum.GetName(typeof(eMetroTabColor), _ColorTable);
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override string GetColorTableName()
|
||||
{
|
||||
return this.CustomColorName != "" ? this.CustomColorName : _CashedColorTableName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the panel assigned to this tab item.
|
||||
/// </summary>
|
||||
[Browsable(false),DefaultValue(null)]
|
||||
public MetroTabPanel Panel
|
||||
{
|
||||
get {return _Panel;}
|
||||
set
|
||||
{
|
||||
_Panel=value;
|
||||
OnPanelChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPanelChanged()
|
||||
{
|
||||
ChangePanelVisibility();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after Checked property has changed.
|
||||
/// </summary>
|
||||
protected override void OnCheckedChanged()
|
||||
{
|
||||
if(this.Checked && this.Parent!=null)
|
||||
{
|
||||
ChangePanelVisibility();
|
||||
foreach(BaseItem item in this.Parent.SubItems)
|
||||
{
|
||||
if(item==this)
|
||||
continue;
|
||||
MetroTabItem b = item as MetroTabItem;
|
||||
if (b != null && b.Checked)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
TypeDescriptor.GetProperties(b)["Checked"].SetValue(b, false);
|
||||
else
|
||||
b.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (BarFunctions.IsOffice2007Style(this.EffectiveStyle) && this.ContainerControl is System.Windows.Forms.Control)
|
||||
((System.Windows.Forms.Control)this.ContainerControl).Invalidate();
|
||||
if(!this.Checked)
|
||||
ChangePanelVisibility();
|
||||
InvokeCheckedChanged();
|
||||
}
|
||||
|
||||
private void ChangePanelVisibility()
|
||||
{
|
||||
if(this.Checked && _Panel!=null)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
{
|
||||
if (!_Panel.Visible) _Panel.Visible = true;
|
||||
TypeDescriptor.GetProperties(_Panel)["Visible"].SetValue(_Panel, true);
|
||||
_Panel.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_Panel.IsDisposed)
|
||||
{
|
||||
// Following 3 lines reduce flashing of panel's child controls when Dock panel is shown
|
||||
System.Windows.Forms.DockStyle oldDock = _Panel.Dock;
|
||||
_Panel.Dock = System.Windows.Forms.DockStyle.None;
|
||||
_Panel.Location = new Point(-32000, 32000);
|
||||
_Panel.Enabled = true;
|
||||
_Panel.Visible = true;
|
||||
_Panel.BringToFront();
|
||||
if (_Panel.Dock != oldDock)
|
||||
_Panel.Dock = oldDock;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(!this.Checked && _Panel!=null && !_Panel.IsPopupMode) // Panels in popup mode will be taken care of by Ribbon
|
||||
{
|
||||
if (this.DesignMode)
|
||||
TypeDescriptor.GetProperties(_Panel)["Visible"].SetValue(_Panel, false);
|
||||
else
|
||||
{
|
||||
_Panel.Visible = false;
|
||||
_Panel.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs just before Click event is fired.
|
||||
/// </summary>
|
||||
protected override void OnClick()
|
||||
{
|
||||
base.OnClick();
|
||||
if (!this.Checked)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
TypeDescriptor.GetProperties(this)["Checked"].SetValue(this, true);
|
||||
else
|
||||
{
|
||||
MetroShell shell = GetMetroShell();
|
||||
if (shell != null && !shell.ValidateChildren())
|
||||
return;
|
||||
this.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
private MetroShell GetMetroShell()
|
||||
{
|
||||
MetroTabStrip strip = this.ContainerControl as MetroTabStrip;
|
||||
if (strip == null) return null;
|
||||
return strip.Parent as MetroShell;
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when Visibility of the items has changed.
|
||||
/// </summary>
|
||||
/// <param name="bVisible">New Visible state.</param>
|
||||
protected internal override void OnVisibleChanged(bool bVisible)
|
||||
{
|
||||
base.OnVisibleChanged(bVisible);
|
||||
if(!bVisible && this.Checked)
|
||||
{
|
||||
TypeDescriptor.GetProperties(this)["Checked"].SetValue(this,false);
|
||||
// Try to check first item in the group
|
||||
if(this.Parent!=null)
|
||||
{
|
||||
foreach(BaseItem item in this.Parent.SubItems)
|
||||
{
|
||||
if (item == this || !item.GetEnabled() || !item.Visible)
|
||||
continue;
|
||||
MetroTabItem b=item as MetroTabItem;
|
||||
if(b!=null)
|
||||
{
|
||||
TypeDescriptor.GetProperties(b)["Checked"].SetValue(this,true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set the Group item belongs to. The groups allows a user to choose from mutually exclusive options within the group. The choice is reflected by Checked property.
|
||||
/// </summary>
|
||||
[Browsable(false),DevCoBrowsable(false),DefaultValue(""),EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override string OptionGroup
|
||||
{
|
||||
get {return base.OptionGroup;}
|
||||
set {base.OptionGroup=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after item visual style has changed.
|
||||
/// </summary>
|
||||
protected override void OnStyleChanged()
|
||||
{
|
||||
base.OnStyleChanged();
|
||||
UpdateTabAppearance();
|
||||
}
|
||||
|
||||
private void UpdateTabAppearance()
|
||||
{
|
||||
if (StyleManager.Style == eStyle.OfficeMobile2014 || StyleManager.Style == eStyle.Office2016)
|
||||
{
|
||||
this.VerticalPadding = 5;
|
||||
this.HorizontalPadding = 16 + _PaddingHorizontal;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.VerticalPadding = 1;
|
||||
this.HorizontalPadding = 16 + _PaddingHorizontal;
|
||||
}
|
||||
|
||||
this.NeedRecalcSize = true;
|
||||
this.OnAppearanceChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the collection of sub items.
|
||||
/// </summary>
|
||||
[Browsable(false),DevCoBrowsable(false),DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
|
||||
public override SubItemsCollection SubItems
|
||||
{
|
||||
get {return base.SubItems;}
|
||||
}
|
||||
|
||||
internal override void DoAccesibleDefaultAction()
|
||||
{
|
||||
this.Checked = true;
|
||||
}
|
||||
|
||||
protected override void Invalidate(System.Windows.Forms.Control containerControl)
|
||||
{
|
||||
Rectangle r = m_Rect;
|
||||
r.Width++;
|
||||
r.Height++;
|
||||
if (containerControl.InvokeRequired)
|
||||
containerControl.BeginInvoke(new MethodInvoker(delegate { containerControl.Invalidate(r, true); }));
|
||||
else
|
||||
containerControl.Invalidate(r, true);
|
||||
}
|
||||
|
||||
public override bool UseParentSubItemsImageSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Hidden Properties
|
||||
/// <summary>
|
||||
/// Indicates whether the item will auto-collapse (fold) when clicked.
|
||||
/// When item is on popup menu and this property is set to false, menu will not
|
||||
/// close when item is clicked.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Behavior"), DefaultValue(true), Description("Indicates whether the item will auto-collapse (fold) when clicked.")]
|
||||
public override bool AutoCollapseOnClick
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoCollapseOnClick;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AutoCollapseOnClick=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the item will auto-expand when clicked.
|
||||
/// When item is on top level bar and not on menu and contains sub-items, sub-items will be shown only if user
|
||||
/// click the expand part of the button. Setting this propert to true will expand the button and show sub-items when user
|
||||
/// clicks anywhere inside of the button. Default value is false which indicates that button is expanded only
|
||||
/// if its expand part is clicked.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DevCoBrowsable(false), Category("Behavior"), Description("Indicates whether the item will auto-collapse (fold) when clicked.")]
|
||||
public override bool AutoExpandOnClick
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoExpandOnClick;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AutoExpandOnClick=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item can be customized by end user.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(true), System.ComponentModel.Category("Behavior"), System.ComponentModel.Description("Indicates whether item can be customized by user.")]
|
||||
public override bool CanCustomize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.CanCustomize;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.CanCustomize=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set a value indicating whether the button is in the checked state.
|
||||
/// </summary>
|
||||
[Browsable(false),DevCoBrowsable(false),Category("Appearance"),Description("Indicates whether item is checked or not."),DefaultValue(false)]
|
||||
public override bool Checked
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Checked;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Checked=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Click event will be auto repeated when mouse button is kept pressed over the item.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(false), Category("Behavior"), Description("Gets or sets whether Click event will be auto repeated when mouse button is kept pressed over the item.")]
|
||||
public override bool ClickAutoRepeat
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ClickAutoRepeat;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ClickAutoRepeat=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(600), Category("Behavior"), Description("Gets or sets the auto-repeat interval for the click event when mouse button is kept pressed over the item.")]
|
||||
public override int ClickRepeatInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ClickRepeatInterval;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ClickRepeatInterval=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the item is enabled.
|
||||
/// </summary>
|
||||
[Browsable(false),DevCoBrowsable(false),DefaultValue(true),Category("Behavior"),Description("Indicates whether is item enabled.")]
|
||||
public override bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Enabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Enabled=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates item's visiblity when on pop-up menu.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Appearance"), Description("Indicates item's visiblity when on pop-up menu."), DefaultValue(eMenuVisibility.VisibleAlways)]
|
||||
public override eMenuVisibility MenuVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.MenuVisibility;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.MenuVisibility=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates when menu items are displayed when MenuVisiblity is set to VisibleIfRecentlyUsed and RecentlyUsed is true.
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DevCoBrowsable(false), Category("Appearance"), Description("Indicates when menu items are displayed when MenuVisiblity is set to VisibleIfRecentlyUsed and RecentlyUsed is true."), DefaultValue(ePersonalizedMenus.Disabled)]
|
||||
public override ePersonalizedMenus PersonalizedMenus
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PersonalizedMenus;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PersonalizedMenus=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates Animation type for Popups.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Behavior"), Description("Indicates Animation type for Popups."), DefaultValue(ePopupAnimation.ManagerControlled)]
|
||||
public override ePopupAnimation PopupAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupAnimation;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupAnimation=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the font that will be used on the popup window.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Appearance"), Description("Indicates the font that will be used on the popup window."), DefaultValue(null)]
|
||||
public override System.Drawing.Font PopupFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupFont;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupFont=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether sub-items are shown on popup Bar or popup menu.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Appearance"), Description("Indicates whether sub-items are shown on popup Bar or popup menu."), DefaultValue(ePopupType.Menu)]
|
||||
public override ePopupType PopupType
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupType;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupType=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the inital width for the Bar that hosts pop-up items. Applies to PopupType.Toolbar only.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Layout"), Description("Specifies the inital width for the Bar that hosts pop-up items. Applies to PopupType.Toolbar only."), DefaultValue(200)]
|
||||
public override int PopupWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PopupWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.PopupWidth=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item will display sub items.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(true), Category("Behavior"), Description("Determines whether sub-items are displayed.")]
|
||||
public override bool ShowSubItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ShowSubItems;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ShowSubItems=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the item expands automatically to fill out the remaining space inside the container. Applies to Items on stretchable, no-wrap Bars only.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(false), Category("Appearance"), Description("Indicates whether item will stretch to consume empty space. Items on stretchable, no-wrap Bars only.")]
|
||||
public override bool Stretch
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Stretch;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Stretch=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the expand part of the button item.
|
||||
/// </summary>
|
||||
[Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), Category("Behavior"), Description("Indicates the width of the expand part of the button item."), DefaultValue(12)]
|
||||
public override int SubItemsExpandWidth
|
||||
{
|
||||
get {return base.SubItemsExpandWidth;}
|
||||
set
|
||||
{
|
||||
base.SubItemsExpandWidth=value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set the alternative shortcut text.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DevCoBrowsable(false), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Gets or set the alternative Shortcut Text. This text appears next to the Text instead of any shortcuts"), System.ComponentModel.DefaultValue("")]
|
||||
public override string AlternateShortCutText
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AlternateShortCutText;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.AlternateShortCutText = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item separator is shown before this item.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates whether this item is beginning of the group.")]
|
||||
public override bool BeginGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BeginGroup;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BeginGroup = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns category for this item. If item cannot be customzied using the
|
||||
/// customize dialog category is empty string.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.DefaultValue(""), System.ComponentModel.Category("Design"), System.ComponentModel.Description("Indicates item category used to group similar items at design-time."), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override string Category
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return base.Category;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Category = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text color of the button when mouse is over the item.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The foreground color used to display text when mouse is over the item."), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override Color HotForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.HotForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.HotForeColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the way item is painting the picture when mouse is over it. Setting the value to Color will render the image in gray-scale when mouse is not over the item.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("Indicates the way item is painting the picture when mouse is over it. Setting the value to Color will render the image in gray-scale when mouse is not over the item."), System.ComponentModel.DefaultValue(eHotTrackingStyle.Default), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override eHotTrackingStyle HotTrackingStyle
|
||||
{
|
||||
get { return base.HotTrackingStyle; }
|
||||
set
|
||||
{
|
||||
base.HotTrackingStyle = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text color of the button.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), DevCoBrowsable(false), EditorBrowsable(EditorBrowsableState.Never), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The foreground color used to display text.")]
|
||||
public override Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the button style which controls the appearance of the button elements. Changing the property can display image only, text only or image and text on the button at all times.
|
||||
/// </summary>
|
||||
[Browsable(false), Category("Appearance"), Description("Determines the style of the button."), DefaultValue(eButtonStyle.ImageAndText), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override eButtonStyle ButtonStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ButtonStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ButtonStyle = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies predefined color assigned to Metro Tab.
|
||||
/// </summary>
|
||||
public enum eMetroTabColor
|
||||
{
|
||||
Default,
|
||||
Complement1,
|
||||
Complement2,
|
||||
Complement3,
|
||||
Complement4
|
||||
}
|
||||
}
|
77
PROMS/DotNetBar Source Code/Metro/MetroTabItemContainer.cs
Normal file
77
PROMS/DotNetBar Source Code/Metro/MetroTabItemContainer.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
internal class MetroTabItemContainer : SimpleItemContainer
|
||||
{
|
||||
//protected override bool OnBeforeLayout()
|
||||
//{
|
||||
// if (this.Orientation != eOrientation.Horizontal)
|
||||
// return true;
|
||||
|
||||
// ArrayList ribbonTabItems = new ArrayList();
|
||||
// int totalWidth = 0;
|
||||
// int totalRibbonTabItemsWidth = 0;
|
||||
// int minimumSize = 24;
|
||||
// int availableWidth = this.WidthInternal - (this.PaddingLeft + this.PaddingRight);
|
||||
|
||||
// foreach (BaseItem item in this.SubItems)
|
||||
// {
|
||||
// if (!item.Visible)
|
||||
// continue;
|
||||
// item.RecalcSize();
|
||||
// totalWidth += (item.WidthInternal + this.ItemSpacing);
|
||||
// if (item is RibbonTabItem)
|
||||
// {
|
||||
// // Reset reduced size flag
|
||||
// ((RibbonTabItem)item).ReducedSize = false;
|
||||
// ribbonTabItems.Add(item);
|
||||
// totalRibbonTabItemsWidth += (item.WidthInternal + this.ItemSpacing);
|
||||
// }
|
||||
// }
|
||||
|
||||
// int totalReduction = totalWidth - availableWidth;
|
||||
|
||||
// if (totalWidth > availableWidth && totalRibbonTabItemsWidth > 0)
|
||||
// {
|
||||
// if (totalReduction >= totalRibbonTabItemsWidth - (minimumSize * ribbonTabItems.Count + ribbonTabItems.Count - 1))
|
||||
// {
|
||||
// foreach (RibbonTabItem item in ribbonTabItems)
|
||||
// {
|
||||
// item.WidthInternal = minimumSize;
|
||||
// item.ReducedSize = true;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// float reduction = 1 - (float)totalReduction / (float)totalRibbonTabItemsWidth;
|
||||
// bool reducedSize = false;
|
||||
// if (reduction <= .75)
|
||||
// reducedSize = true;
|
||||
// for (int i = 0; i < ribbonTabItems.Count; i++)
|
||||
// {
|
||||
// RibbonTabItem item = ribbonTabItems[i] as RibbonTabItem;
|
||||
// item.ReducedSize = reducedSize;
|
||||
// if (i == ribbonTabItems.Count - 1)
|
||||
// {
|
||||
// item.WidthInternal -= totalReduction;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// int width = (int)(item.WidthInternal * reduction);
|
||||
// if (width < minimumSize)
|
||||
// width = minimumSize;
|
||||
// totalReduction -= (item.WidthInternal - width);
|
||||
// item.WidthInternal = width;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
}
|
352
PROMS/DotNetBar Source Code/Metro/MetroTabPanel.cs
Normal file
352
PROMS/DotNetBar Source Code/Metro/MetroTabPanel.cs
Normal file
@@ -0,0 +1,352 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro.Rendering;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents panel used by MetroTabItem as a container panel for the control.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), Designer("DevComponents.DotNetBar.Design.MetroTabPanelDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
|
||||
public class MetroTabPanel: PanelControl, IKeyTipsControl
|
||||
{
|
||||
#region Private Variables
|
||||
private const string INFO_TEXT="Drop controls here. Drag and Drop tabs and items to re-order.";
|
||||
private MetroTabItem _TabItem=null;
|
||||
private bool _UseCustomStyle=false;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Creates new instance of the panel.
|
||||
/// </summary>
|
||||
public MetroTabPanel()
|
||||
: base()
|
||||
{
|
||||
this.ColorSchemeStyle = eDotNetBarStyle.StyleManagerControlled;
|
||||
if (StyleManager.IsMetro(StyleManager.Style))
|
||||
this.BackColor = MetroRender.GetColorTable().CanvasColor;
|
||||
//this.BackColor=SystemColors.Control;
|
||||
}
|
||||
|
||||
protected override ElementStyle GetStyle()
|
||||
{
|
||||
if (!this.Style.Custom)
|
||||
{
|
||||
return GetDefaultStyle();
|
||||
}
|
||||
return base.GetStyle();
|
||||
}
|
||||
|
||||
private bool _PopupMode = false;
|
||||
private MetroShell _MetroTab = null;
|
||||
internal MetroShell GetMetroTab()
|
||||
{
|
||||
if (_PopupMode)
|
||||
return _MetroTab;
|
||||
return this.Parent as MetroShell;
|
||||
}
|
||||
|
||||
internal bool IsPopupMode
|
||||
{
|
||||
get { return _PopupMode; }
|
||||
}
|
||||
|
||||
internal void SetPopupMode(bool popupMode, MetroShell rc)
|
||||
{
|
||||
_PopupMode = popupMode;
|
||||
if (_PopupMode)
|
||||
{
|
||||
_MetroTab = rc;
|
||||
|
||||
#if FRAMEWORK20
|
||||
if (this.Padding.Bottom > 0)
|
||||
{
|
||||
this.Height += this.Padding.Bottom;
|
||||
this.Padding = new System.Windows.Forms.Padding(this.Padding.Left, this.Padding.Bottom, this.Padding.Right, this.Padding.Bottom);
|
||||
}
|
||||
#else
|
||||
if (this.DockPadding.Bottom > 0)
|
||||
{
|
||||
this.DockPadding.Top = this.DockPadding.Bottom;
|
||||
this.Height += this.DockPadding.Bottom;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
if (this.Padding.Top > 0)
|
||||
{
|
||||
this.Height -= this.Padding.Top;
|
||||
this.Padding = new System.Windows.Forms.Padding(this.Padding.Left, 0, this.Padding.Right, this.Padding.Bottom);
|
||||
}
|
||||
#else
|
||||
if (this.DockPadding.Top > 0)
|
||||
{
|
||||
this.Height -= this.DockPadding.Top;
|
||||
this.DockPadding.Top = 0;
|
||||
}
|
||||
#endif
|
||||
_MetroTab = null;
|
||||
}
|
||||
}
|
||||
|
||||
private ElementStyle GetDefaultStyle()
|
||||
{
|
||||
return MetroRender.GetColorTable().MetroTab.TabPanelBackgroundStyle;
|
||||
}
|
||||
|
||||
|
||||
private Rectangle GetThemedRect(Rectangle r)
|
||||
{
|
||||
const int offset=6;
|
||||
r.Y-=offset;
|
||||
r.Height+=offset;
|
||||
return r;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
bool baseCall=true;
|
||||
if(DrawThemedPane && BarFunctions.ThemedOS)
|
||||
{
|
||||
Rectangle r=GetThemedRect(this.ClientRectangle);
|
||||
eTabStripAlignment tabAlignment=eTabStripAlignment.Top;
|
||||
|
||||
Rectangle rTemp=new Rectangle(0,0,r.Width,r.Height);
|
||||
if(tabAlignment==eTabStripAlignment.Right || tabAlignment==eTabStripAlignment.Left)
|
||||
rTemp=new Rectangle(0,0,rTemp.Height,rTemp.Width);
|
||||
if(m_ThemeCachedBitmap==null || m_ThemeCachedBitmap.Size!=rTemp.Size)
|
||||
{
|
||||
DisposeThemeCachedBitmap();
|
||||
Bitmap bmp=new Bitmap(rTemp.Width,rTemp.Height,e.Graphics);
|
||||
try
|
||||
{
|
||||
Graphics gTemp=Graphics.FromImage(bmp);
|
||||
try
|
||||
{
|
||||
using(SolidBrush brush=new SolidBrush(Color.Transparent))
|
||||
gTemp.FillRectangle(brush,0,0,bmp.Width,bmp.Height);
|
||||
this.ThemeTab.DrawBackground(gTemp,ThemeTabParts.Pane,ThemeTabStates.Normal,rTemp);
|
||||
}
|
||||
finally
|
||||
{
|
||||
gTemp.Dispose();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(tabAlignment==eTabStripAlignment.Left)
|
||||
bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
|
||||
else if(tabAlignment==eTabStripAlignment.Right)
|
||||
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
|
||||
else if(tabAlignment==eTabStripAlignment.Bottom)
|
||||
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
||||
e.Graphics.DrawImageUnscaled(bmp,r.X,r.Y);
|
||||
m_ThemeCachedBitmap=bmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
e.Graphics.DrawImageUnscaled(m_ThemeCachedBitmap,r.X,r.Y);
|
||||
|
||||
baseCall=false;
|
||||
}
|
||||
|
||||
if(baseCall)
|
||||
base.OnPaint(e);
|
||||
|
||||
if(this.DesignMode && this.Controls.Count==0 && this.Text=="")
|
||||
{
|
||||
Rectangle r=this.ClientRectangle;
|
||||
r.Inflate(-2,-2);
|
||||
StringFormat sf=BarFunctions.CreateStringFormat();
|
||||
sf.Alignment=StringAlignment.Center;
|
||||
sf.LineAlignment=StringAlignment.Center;
|
||||
sf.Trimming=StringTrimming.EllipsisCharacter;
|
||||
Font font=new Font(this.Font,FontStyle.Bold);
|
||||
e.Graphics.DrawString(INFO_TEXT,font,new SolidBrush(ControlPaint.Dark(this.Style.BackColor)),r,sf);
|
||||
font.Dispose();
|
||||
sf.Dispose();
|
||||
}
|
||||
if (this.Parent is MetroShell) ((MetroShell)this.Parent).MetroTabStrip.InvalidateKeyTipsCanvas();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether style of the panel is managed by tab control automatically.
|
||||
/// Set this to true if you would like to control style of the panel.
|
||||
/// </summary>
|
||||
[Browsable(true),DefaultValue(false),Category("Appearance"),Description("Indicates whether style of the panel is managed by tab control automatically. Set this to true if you would like to control style of the panel.")]
|
||||
public bool UseCustomStyle
|
||||
{
|
||||
get {return _UseCustomStyle;}
|
||||
set {_UseCustomStyle=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets TabItem that this panel is attached to.
|
||||
/// </summary>
|
||||
[Browsable(false),DefaultValue(null),DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public MetroTabItem MetroTabItem
|
||||
{
|
||||
get {return _TabItem;}
|
||||
set {_TabItem=value;}
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
DisposeThemeCachedBitmap();
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets which edge of the parent container a control is docked to.
|
||||
/// </summary>
|
||||
[Browsable(false),DefaultValue(DockStyle.None)]
|
||||
public override DockStyle Dock
|
||||
{
|
||||
get {return base.Dock;}
|
||||
set {base.Dock=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the control.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public new Size Size
|
||||
{
|
||||
get {return base.Size;}
|
||||
set {base.Size=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public new Point Location
|
||||
{
|
||||
get {return base.Location;}
|
||||
set {base.Location=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the control is displayed.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public new bool Visible
|
||||
{
|
||||
get {return base.Visible;}
|
||||
set {base.Visible=value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets which edges of the control are anchored to the edges of its container.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public override AnchorStyles Anchor
|
||||
{
|
||||
get {return base.Anchor;}
|
||||
set {base.Anchor=value;}
|
||||
}
|
||||
|
||||
[Browsable(false), DefaultValue("")]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
private class XPositionComparer : IComparer
|
||||
{
|
||||
// Calls CaseInsensitiveComparer.Compare with the parameters reversed.
|
||||
int IComparer.Compare(object x, object y)
|
||||
{
|
||||
if (x is Control && y is Control)
|
||||
{
|
||||
return ((Control)x).Left - ((Control)y).Left;
|
||||
}
|
||||
else
|
||||
return ((new CaseInsensitiveComparer()).Compare(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
bool IKeyTipsControl.ProcessMnemonicEx(char charCode)
|
||||
{
|
||||
if (this.Controls.Count == 0) return false;
|
||||
|
||||
Control[] ca = new Control[this.Controls.Count];
|
||||
this.Controls.CopyTo(ca, 0);
|
||||
ArrayList controls = new ArrayList(ca);
|
||||
controls.Sort(new XPositionComparer());
|
||||
foreach (Control c in controls)
|
||||
{
|
||||
IKeyTipsControl ktc = c as IKeyTipsControl;
|
||||
if (ktc!=null && c.Visible && c.Enabled)
|
||||
{
|
||||
string oldStack = ktc.KeyTipsKeysStack;
|
||||
bool ret = ktc.ProcessMnemonicEx(charCode);
|
||||
if (ret)
|
||||
return true;
|
||||
if (ktc.KeyTipsKeysStack != oldStack)
|
||||
{
|
||||
((IKeyTipsControl)this).KeyTipsKeysStack = ktc.KeyTipsKeysStack;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool _ShowKeyTips = false;
|
||||
bool IKeyTipsControl.ShowKeyTips
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ShowKeyTips;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ShowKeyTips = value;
|
||||
Control[] controls = new Control[this.Controls.Count];
|
||||
this.Controls.CopyTo(controls, 0);
|
||||
foreach (Control c in controls)
|
||||
{
|
||||
if (c is IKeyTipsControl && c.Enabled && (c.Visible || !_ShowKeyTips))
|
||||
((IKeyTipsControl)c).ShowKeyTips = _ShowKeyTips;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string m_KeyTipsKeysStack = "";
|
||||
string IKeyTipsControl.KeyTipsKeysStack
|
||||
{
|
||||
get { return m_KeyTipsKeysStack; }
|
||||
set
|
||||
{
|
||||
m_KeyTipsKeysStack = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
if (c is IKeyTipsControl && c.Visible && c.Enabled)
|
||||
((IKeyTipsControl)c).KeyTipsKeysStack = m_KeyTipsKeysStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLayout(LayoutEventArgs levent)
|
||||
{
|
||||
base.OnLayout(levent);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
1470
PROMS/DotNetBar Source Code/Metro/MetroTabStrip.cs
Normal file
1470
PROMS/DotNetBar Source Code/Metro/MetroTabStrip.cs
Normal file
File diff suppressed because it is too large
Load Diff
2348
PROMS/DotNetBar Source Code/Metro/MetroTileItem.cs
Normal file
2348
PROMS/DotNetBar Source Code/Metro/MetroTileItem.cs
Normal file
File diff suppressed because it is too large
Load Diff
100
PROMS/DotNetBar Source Code/Metro/MetroTilePanel.cs
Normal file
100
PROMS/DotNetBar Source Code/Metro/MetroTilePanel.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents panel for Metro Tiles.
|
||||
/// </summary>
|
||||
[ToolboxBitmap(typeof(MetroTilePanel), "Metro.MetroTilePanel.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.MetroTilePanelDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
|
||||
public class MetroTilePanel : ItemPanel
|
||||
{
|
||||
#region Events
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroTilePanel class.
|
||||
/// </summary>
|
||||
public MetroTilePanel()
|
||||
{
|
||||
this.ResizeItemsToFit = false;
|
||||
this.ItemSpacing = DefaultItemSpacing;
|
||||
this.AutoScroll = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
if (!this.DesignMode)
|
||||
this.GetBaseItemContainer().AllowDrop = false;
|
||||
base.OnHandleCreated(e);
|
||||
}
|
||||
protected override void OnDragInProgressChanged()
|
||||
{
|
||||
if (!this.DragInProgress)
|
||||
AnimateNextPaintRequest = true;
|
||||
this.Invalidate();
|
||||
base.OnDragInProgressChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the control enables the user to scroll to items placed outside of its visible boundaries.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(true)]
|
||||
public new virtual bool AutoScroll
|
||||
{
|
||||
get { return base.AutoScroll; }
|
||||
set { base.AutoScroll = value; }
|
||||
}
|
||||
|
||||
private const int DefaultItemSpacing = 32;
|
||||
/// <summary>
|
||||
/// Gets or sets spacing in pixels between items. Default value is 1.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(DefaultItemSpacing), Category("Layout"), Description("Indicates spacing in pixels between items.")]
|
||||
public override int ItemSpacing
|
||||
{
|
||||
get { return base.ItemSpacing; }
|
||||
set
|
||||
{
|
||||
base.ItemSpacing = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether items contained by container are resized to fit the container bounds. When container is in horizontal
|
||||
/// layout mode then all items will have the same height. When container is in vertical layout mode then all items
|
||||
/// will have the same width. Default value is true.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(false), Category("Layout")]
|
||||
public override bool ResizeItemsToFit
|
||||
{
|
||||
get { return base.ResizeItemsToFit; }
|
||||
set
|
||||
{
|
||||
base.ResizeItemsToFit = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size DefaultSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Size(600, 400);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDragOverProcessed(int x, int y, System.Windows.Forms.DragEventArgs dragArgs)
|
||||
{
|
||||
base.OnMouseDragOverProcessed(x, y, dragArgs);
|
||||
this.Invalidate();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/Metro/MetroTilePanel.ico
Normal file
BIN
PROMS/DotNetBar Source Code/Metro/MetroTilePanel.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
637
PROMS/DotNetBar Source Code/Metro/MetroToolbar.cs
Normal file
637
PROMS/DotNetBar Source Code/Metro/MetroToolbar.cs
Normal file
@@ -0,0 +1,637 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.DotNetBar.Metro.Rendering;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
[ToolboxBitmap(typeof(MetroShell), "MetroToolbar.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.MetroToolbarDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false)]
|
||||
public class MetroToolbar : ItemControl
|
||||
{
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Occurs before Expanded property has changed, i.e. control expanded or collapsed and allows you to cancel action by setting Cancel=true on event arguments.
|
||||
/// </summary>
|
||||
[Description("Occurs before Expanded property has changed, i.e. control expanded or collapsed and allows you to cancel action by setting Cancel=true on event arguments.")]
|
||||
public event CancelEventHandler ExpandedChanging;
|
||||
/// <summary>
|
||||
/// Raises ExpandedChanging event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnExpandedChanging(CancelEventArgs e)
|
||||
{
|
||||
CancelEventHandler handler = ExpandedChanging;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after Expanded property value has changed, i.e. control was expanded or collapsed.
|
||||
/// </summary>
|
||||
[Description("Occurs after Expanded property value has changed, i.e. control was expanded or collapsed.")]
|
||||
public event EventHandler ExpandedChanged;
|
||||
/// <summary>
|
||||
/// Raises ExpandedChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides event arguments.</param>
|
||||
protected virtual void OnExpandedChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler = ExpandedChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
private MetroToolbarContainer _ItemContainer = null;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MetroStatusBar class.
|
||||
/// </summary>
|
||||
public MetroToolbar()
|
||||
{
|
||||
_ItemContainer = new MetroToolbarContainer(this);
|
||||
_ItemContainer.GlobalItem = false;
|
||||
_ItemContainer.ContainerControl = this;
|
||||
_ItemContainer.Stretch = true;
|
||||
_ItemContainer.Displayed = true;
|
||||
_ItemContainer.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
//base.AutoSize = true;
|
||||
this.ColorScheme.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
_ItemContainer.SetOwner(this);
|
||||
this.SetBaseItemContainer(_ItemContainer);
|
||||
this.DragDropSupport = true;
|
||||
this.ItemAdded += new EventHandler(ChildItemAdded);
|
||||
this.ItemRemoved += new ItemRemovedEventHandler(ChildItemRemoved);
|
||||
StyleManager.Register(this);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
StyleManager.Unregister(this);
|
||||
this.ItemAdded -= new EventHandler(ChildItemAdded);
|
||||
this.ItemRemoved -= new ItemRemovedEventHandler(ChildItemRemoved);
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
/// <summary>
|
||||
/// Called by StyleManager to notify control that style on manager has changed and that control should refresh its appearance if
|
||||
/// its style is controlled by StyleManager.
|
||||
/// </summary>
|
||||
/// <param name="newStyle">New active style.</param>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void StyleManagerStyleChanged(eDotNetBarStyle newStyle)
|
||||
{
|
||||
_ItemContainer.NeedRecalcSize = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
protected override void PaintControlBackground(ItemPaintArgs pa)
|
||||
{
|
||||
MetroRender.Paint(this, pa);
|
||||
base.PaintControlBackground(pa);
|
||||
}
|
||||
private void ChildItemAdded(object sender, EventArgs e)
|
||||
{
|
||||
this.RecalcLayout();
|
||||
}
|
||||
private void ChildItemRemoved(object sender, ItemRemovedEventArgs e)
|
||||
{
|
||||
this.RecalcLayout();
|
||||
}
|
||||
protected override void OnForeColorChanged(EventArgs e)
|
||||
{
|
||||
_ItemContainer.UpdateSystemColors();
|
||||
base.OnForeColorChanged(e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns collection of items on a bar.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Browsable(false)]
|
||||
public SubItemsCollection Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ItemContainer.MainItemsContainer.SubItems;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets spacing between items, default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0), Category("Appearance"), Description("Gets or sets spacing between items.")]
|
||||
public int ItemSpacing
|
||||
{
|
||||
get { return _ItemContainer.MainItemsContainer.ItemSpacing; }
|
||||
set
|
||||
{
|
||||
_ItemContainer.MainItemsContainer.ItemSpacing = value;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns collection of items on a bar.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Browsable(false)]
|
||||
public SubItemsCollection ExtraItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ItemContainer.ExtraItemsContainer.SubItems;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _ToolbarRegistered = false;
|
||||
protected override void OnParentChanged(EventArgs e)
|
||||
{
|
||||
if (_AutoRegister)
|
||||
RegisterToolbar();
|
||||
base.OnParentChanged(e);
|
||||
}
|
||||
protected override void OnHandleDestroyed(EventArgs e)
|
||||
{
|
||||
if (_AutoRegister)
|
||||
UnregisterToolbar();
|
||||
base.OnHandleDestroyed(e);
|
||||
}
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
if (_AutoRegister)
|
||||
RegisterToolbar();
|
||||
if (_SetExpandedDelayed)
|
||||
this.Expanded = _ExpandedDelayed;
|
||||
}
|
||||
|
||||
private void RegisterToolbar()
|
||||
{
|
||||
RegisterToolbar(GetMetroTab());
|
||||
}
|
||||
/// <summary>
|
||||
/// Registers toolbar with MetroTab so it can participate in Quick Access Toolbar operations.
|
||||
/// </summary>
|
||||
/// <param name="tab">MetroTab</param>
|
||||
public void RegisterToolbar(MetroShell tab)
|
||||
{
|
||||
if (_ToolbarRegistered) return;
|
||||
if (tab == null) return;
|
||||
tab.RegisterToolbar(this);
|
||||
_ToolbarRegistered = true;
|
||||
}
|
||||
private void UnregisterToolbar()
|
||||
{
|
||||
UnregisterToolbar(GetMetroTab());
|
||||
}
|
||||
/// <summary>
|
||||
/// Unregisters previously registered toolbar from MetroTab and removes it from Quick Access Toolbar operations.
|
||||
/// </summary>
|
||||
public void UnregisterToolbar(MetroShell tab)
|
||||
{
|
||||
if (!_ToolbarRegistered) return;
|
||||
if (tab == null) return;
|
||||
tab.UnregisterToolbar(this);
|
||||
_ToolbarRegistered = false;
|
||||
}
|
||||
private MetroShell GetMetroTab()
|
||||
{
|
||||
MetroAppForm form = this.FindForm() as MetroAppForm;
|
||||
if (form == null)
|
||||
{
|
||||
// Walk up the chain perhaps its there
|
||||
Control parent = this.Parent;
|
||||
while (parent != null)
|
||||
{
|
||||
if(parent is MetroShell)
|
||||
return (MetroShell)parent;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
MetroShell tab = form.MetroShell;
|
||||
return tab;
|
||||
}
|
||||
|
||||
private bool _AutoRegister = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether toolbar is attempted to be automatically registered with parent MetroShell control so it can participate in Quick Access Toolbar operations. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Browsable(false), Category("Behavior"), Description("Indicates whether toolbar is attempted to be automatically registered with parent MetroTab control so it can participate in Quick Access Toolbar operations")]
|
||||
public bool AutoRegister
|
||||
{
|
||||
get { return _AutoRegister; }
|
||||
set
|
||||
{
|
||||
_AutoRegister = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool _SetExpandedDelayed = false;
|
||||
private bool _ExpandedDelayed = false;
|
||||
private bool _Expanded = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control is expanded or not. When control is expanded both main and extra toolbar items are visible. When collapsed
|
||||
/// only main items are visible. Default value is false.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Browsable(true), Category("Layout"), Description("Indicates whether control is expanded or not. When control is expanded both main and extra toolbar items are visible.")]
|
||||
public bool Expanded
|
||||
{
|
||||
get { return _Expanded; }
|
||||
set
|
||||
{
|
||||
if (_Expanded != value)
|
||||
{
|
||||
CancelEventArgs cargs = new CancelEventArgs();
|
||||
OnExpandedChanging(cargs);
|
||||
if (cargs.Cancel) return;
|
||||
|
||||
if (IsUpdateSuspended || !BarFunctions.IsHandleValid(this))
|
||||
{
|
||||
_SetExpandedDelayed = true;
|
||||
_ExpandedDelayed = value;
|
||||
return;
|
||||
}
|
||||
_SetExpandedDelayed = false;
|
||||
_Expanded = value;
|
||||
OnExpandedChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RecalcSize()
|
||||
{
|
||||
if (_ChangingExpanded) return;
|
||||
|
||||
base.RecalcSize();
|
||||
int height = GetAutoSizeHeight();
|
||||
if (height != this.Height)
|
||||
this.Height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns automatically calculated height of the control given current content.
|
||||
/// </summary>
|
||||
/// <returns>Height in pixels.</returns>
|
||||
public override int GetAutoSizeHeight()
|
||||
{
|
||||
ElementStyle style = GetBackgroundStyle();
|
||||
int styleWhiteSpace = 0;
|
||||
if (style != null)
|
||||
styleWhiteSpace = ElementStyleLayout.VerticalStyleWhiteSpace(style);
|
||||
|
||||
if (_Expanded)
|
||||
{
|
||||
//if (_ItemContainer.MainItemsContainer.SubItems.Count == 0 && _ItemContainer.ExtraItemsContainer.SubItems.Count == 0)
|
||||
// return 28;
|
||||
return _ItemContainer.HeightInternal;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (_ItemContainer.MainItemsContainer.SubItems.Count == 0)
|
||||
// return 28;
|
||||
return _ItemContainer.MainItemsContainer.HeightInternal;
|
||||
}
|
||||
}
|
||||
|
||||
private eExpandDirection _LastExpandDirection = eExpandDirection.Auto;
|
||||
private bool _ChangingExpanded = false;
|
||||
private void OnExpandedChanged()
|
||||
{
|
||||
_ChangingExpanded = true;
|
||||
|
||||
try
|
||||
{
|
||||
Rectangle startRect = this.Bounds;
|
||||
Rectangle endRect;
|
||||
|
||||
ElementStyle style = GetBackgroundStyle();
|
||||
int styleWhiteSpace = 0;
|
||||
if (style != null)
|
||||
styleWhiteSpace = ElementStyleLayout.VerticalStyleWhiteSpace(style);
|
||||
|
||||
if (_Expanded)
|
||||
{
|
||||
eExpandDirection direction = GetExpandDirection();
|
||||
if (direction == eExpandDirection.Bottom)
|
||||
endRect = new Rectangle(this.Left, this.Top, this.Width, _ItemContainer.HeightInternal + styleWhiteSpace);
|
||||
else
|
||||
endRect = new Rectangle(this.Left, this.Top - (_ItemContainer.HeightInternal - _ItemContainer.MainItemsContainer.HeightInternal), this.Width, _ItemContainer.HeightInternal + styleWhiteSpace);
|
||||
_LastExpandDirection = direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_LastExpandDirection == eExpandDirection.Bottom)
|
||||
endRect = new Rectangle(this.Left, this.Top, this.Width, _ItemContainer.MainItemsContainer.HeightInternal + styleWhiteSpace);
|
||||
else
|
||||
endRect = new Rectangle(this.Left, this.Top + (_ItemContainer.HeightInternal - _ItemContainer.MainItemsContainer.HeightInternal), this.Width, _ItemContainer.MainItemsContainer.HeightInternal + styleWhiteSpace);
|
||||
}
|
||||
|
||||
if (_AnimationSpeed <= 0 || this.DesignMode)
|
||||
{
|
||||
if (this.DesignMode)
|
||||
TypeDescriptor.GetProperties(this)["Bounds"].SetValue(this, endRect);
|
||||
else
|
||||
this.Bounds = endRect;
|
||||
}
|
||||
else
|
||||
BarFunctions.AnimateControl(this, true, _AnimationSpeed, startRect, endRect);
|
||||
|
||||
OnExpandedChanged(EventArgs.Empty);
|
||||
|
||||
if (_Expanded)
|
||||
{
|
||||
if (_AutoCollapse && !this.DesignMode)
|
||||
TrackAutoCollapse();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_AutoCollapse)
|
||||
StopAutoCollapseTracking();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ChangingExpanded = false;
|
||||
}
|
||||
}
|
||||
|
||||
private Timer _ActiveWindowTimer = null;
|
||||
private IntPtr _ForegroundWindow = IntPtr.Zero;
|
||||
private IntPtr _ActiveWindow = IntPtr.Zero;
|
||||
private void TrackAutoCollapse()
|
||||
{
|
||||
if (_ActiveWindowTimer != null)
|
||||
return;
|
||||
_ActiveWindowTimer = new Timer();
|
||||
_ActiveWindowTimer.Interval = 100;
|
||||
_ActiveWindowTimer.Tick += new EventHandler(ActiveWindowTimer_Tick);
|
||||
|
||||
_ForegroundWindow = NativeFunctions.GetForegroundWindow();
|
||||
_ActiveWindow = NativeFunctions.GetActiveWindow();
|
||||
|
||||
_ActiveWindowTimer.Start();
|
||||
|
||||
}
|
||||
private void ActiveWindowTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (_ActiveWindowTimer == null)
|
||||
return;
|
||||
|
||||
IntPtr f = NativeFunctions.GetForegroundWindow();
|
||||
IntPtr a = NativeFunctions.GetActiveWindow();
|
||||
|
||||
if (f != _ForegroundWindow || a != _ActiveWindow)
|
||||
{
|
||||
if (a != IntPtr.Zero)
|
||||
{
|
||||
Control c = Control.FromHandle(a);
|
||||
if (c is PopupContainer || c is PopupContainerControl || c is Balloon)
|
||||
return;
|
||||
}
|
||||
_ActiveWindowTimer.Stop();
|
||||
OnActiveWindowTrackingChanged();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called after change of active window has been detected. SetupActiveWindowTimer must be called to enable detection.
|
||||
/// </summary>
|
||||
private void OnActiveWindowTrackingChanged()
|
||||
{
|
||||
if (this.Expanded)
|
||||
CollapseToolbar(eEventSource.Code);
|
||||
ReleaseActiveWindowTimer();
|
||||
}
|
||||
private void StopAutoCollapseTracking()
|
||||
{
|
||||
if (_ActiveWindowTimer != null)
|
||||
{
|
||||
Timer timer = _ActiveWindowTimer;
|
||||
_ActiveWindowTimer = null;
|
||||
timer.Stop();
|
||||
timer.Tick -= new EventHandler(ActiveWindowTimer_Tick);
|
||||
timer.Dispose();
|
||||
}
|
||||
}
|
||||
protected override void OnItemMouseUp(BaseItem item, MouseEventArgs e)
|
||||
{
|
||||
base.OnItemMouseUp(item, e);
|
||||
|
||||
if (e.Button == MouseButtons.Right && item.CanCustomize)
|
||||
{
|
||||
MetroShell tab = GetAppMetroTab();
|
||||
if (tab != null)
|
||||
tab.ShowCustomizeContextMenu(item, true);
|
||||
}
|
||||
}
|
||||
private MetroShell GetAppMetroTab()
|
||||
{
|
||||
MetroAppForm form = this.FindForm() as MetroAppForm;
|
||||
if (form != null)
|
||||
{
|
||||
return form.MetroShell;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the ItemClick event.
|
||||
/// </summary>
|
||||
/// <param name="item">Reference to the item that was clicked.</param>
|
||||
protected override void OnItemClick(BaseItem item)
|
||||
{
|
||||
base.OnItemClick(item);
|
||||
|
||||
if (_Expanded && _AutoCollapse && !item.SystemItem)
|
||||
{
|
||||
if (item is PopupItem && !((PopupItem)item).AutoCollapseOnClick)
|
||||
return;
|
||||
CollapseToolbar(eEventSource.Code);
|
||||
}
|
||||
}
|
||||
protected override bool OnSysMouseDown(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (!this.DesignMode && _AutoCollapse && this.Expanded && !this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition)))
|
||||
CollapseToolbar(eEventSource.Mouse);
|
||||
return base.OnSysMouseDown(hWnd, wParam, lParam);
|
||||
}
|
||||
private void CollapseToolbar(eEventSource source)
|
||||
{
|
||||
if (this.Expanded)
|
||||
this.Expanded = false;
|
||||
}
|
||||
private eExpandDirection GetExpandDirection()
|
||||
{
|
||||
if (_ExpandDirection != eExpandDirection.Auto)
|
||||
return _ExpandDirection;
|
||||
if (this.Parent == null)
|
||||
return eExpandDirection.Bottom;
|
||||
Rectangle parentRect = this.Parent.ClientRectangle;
|
||||
if (this.Top + _ItemContainer.HeightInternal > parentRect.Bottom)
|
||||
return eExpandDirection.Top;
|
||||
return eExpandDirection.Bottom;
|
||||
}
|
||||
|
||||
private bool _AutoCollapse = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether control is automatically collapsed, Expanded property set to False, if control was expanded and any button on the control was clicked or mouse is clicked elsewhere, parent form has lost input focus or some other control gains input focus.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Indicates whether control is automatically collapsed, Expanded property set to False, if control was expanded and any button on the control was clicked or mouse is clicked elsewhere, parent form has lost input focus or some other control gains input focus.")]
|
||||
public bool AutoCollapse
|
||||
{
|
||||
get { return _AutoCollapse; }
|
||||
set
|
||||
{
|
||||
if (value != _AutoCollapse)
|
||||
{
|
||||
bool oldValue = _AutoCollapse;
|
||||
_AutoCollapse = value;
|
||||
OnAutoCollapseChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when AutoCollapse property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnAutoCollapseChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("AutoCollapse"));
|
||||
}
|
||||
|
||||
private int _AnimationSpeed = 150;
|
||||
/// <summary>
|
||||
/// Gets or sets the animation speed duration in milliseconds. Default value is 150 milliseconds. Set to zero, 0 to disable animation.
|
||||
/// </summary>
|
||||
[DefaultValue(150), Category("Behavior"), Description("Indicates animation speed duration in milliseconds. Default value is 150 milliseconds. Set to zero, 0 to disable animation.")]
|
||||
public int AnimationSpeed
|
||||
{
|
||||
get { return _AnimationSpeed; }
|
||||
set
|
||||
{
|
||||
if (value != _AnimationSpeed)
|
||||
{
|
||||
int oldValue = _AnimationSpeed;
|
||||
_AnimationSpeed = value;
|
||||
OnAnimationSpeedChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when AnimationSpeed property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnAnimationSpeedChanged(int oldValue, int newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("AnimationSpeed"));
|
||||
}
|
||||
|
||||
private eExpandDirection _ExpandDirection = eExpandDirection.Auto;
|
||||
/// <summary>
|
||||
/// Gets or sets the expand direction for the toolbar. Default value is Auto.
|
||||
/// </summary>
|
||||
[DefaultValue(eExpandDirection.Auto), Category("Behavior"), Description("Indicates expand direction for the toolbar")]
|
||||
public eExpandDirection ExpandDirection
|
||||
{
|
||||
get { return _ExpandDirection; }
|
||||
set
|
||||
{
|
||||
if (value != _ExpandDirection)
|
||||
{
|
||||
eExpandDirection oldValue = _ExpandDirection;
|
||||
_ExpandDirection = value;
|
||||
OnExpandDirectionChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when ExpandDirection property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnExpandDirectionChanged(eExpandDirection oldValue, eExpandDirection newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("ExpandDirection"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Expand button is visible. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance"), Description("Indicates whether Expand button is visible")]
|
||||
public bool ExpandButtonVisible
|
||||
{
|
||||
get { return _ItemContainer.ExpandButtonVisible; }
|
||||
set
|
||||
{
|
||||
_ItemContainer.ExpandButtonVisible = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether control height is set automatically based on the content. Default value is false.
|
||||
/// </summary>
|
||||
[Browsable(false), Category("Layout"), Description("Indicates whether control height is set automatically."), DefaultValue(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
#if FRAMEWORK20
|
||||
public override bool AutoSize
|
||||
#else
|
||||
public bool AutoSize
|
||||
#endif
|
||||
{
|
||||
get { return base.AutoSize; }
|
||||
set
|
||||
{
|
||||
base.AutoSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Licensing
|
||||
#if !TRIAL
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (NativeFunctions.keyValidated2 != 266)
|
||||
TextDrawing.DrawString(e.Graphics, "Invalid License", this.Font, Color.FromArgb(180, Color.Red), this.ClientRectangle, eTextFormat.Bottom | eTextFormat.HorizontalCenter);
|
||||
}
|
||||
|
||||
private string _LicenseKey = "";
|
||||
[Browsable(false), DefaultValue("")]
|
||||
public string LicenseKey
|
||||
{
|
||||
get { return _LicenseKey; }
|
||||
set
|
||||
{
|
||||
if (NativeFunctions.ValidateLicenseKey(value))
|
||||
return;
|
||||
_LicenseKey = (!NativeFunctions.CheckLicenseKey(value) ? "9dsjkhds7" : value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines expand direction behavior for MetroToolbar.
|
||||
/// </summary>
|
||||
public enum eExpandDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Expand direction is automatically determined by the position of the control on the form.
|
||||
/// </summary>
|
||||
Auto,
|
||||
/// <summary>
|
||||
/// Control is expanded up so bottom of the control is fixed.
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// Control sis expanded down so top of the control is fixed.
|
||||
/// </summary>
|
||||
Bottom
|
||||
}
|
||||
}
|
BIN
PROMS/DotNetBar Source Code/Metro/MetroToolbar.ico
Normal file
BIN
PROMS/DotNetBar Source Code/Metro/MetroToolbar.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
306
PROMS/DotNetBar Source Code/Metro/MetroToolbarContainer.cs
Normal file
306
PROMS/DotNetBar Source Code/Metro/MetroToolbarContainer.cs
Normal file
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.DotNetBar.Metro.Rendering;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the internal container item for the MetroToolbar control.
|
||||
/// </summary>
|
||||
[System.ComponentModel.ToolboxItem(false), System.ComponentModel.DesignTimeVisible(false)]
|
||||
public class MetroToolbarContainer : ImageItem, IDesignTimeProvider
|
||||
{
|
||||
#region Internal Implementation
|
||||
private SimpleItemContainer _MainItemsContainer = null;
|
||||
private ButtonItem _ExpandButton = null;
|
||||
private ItemContainer _ExtraItemsContainer = null;
|
||||
private MetroToolbar _MetroToolbar = null;
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initializes it with the parent RibbonStrip control.
|
||||
/// </summary>
|
||||
/// <param name="parent">Reference to parent MetroToolbar control</param>
|
||||
public MetroToolbarContainer(MetroToolbar parent)
|
||||
{
|
||||
_MetroToolbar = parent;
|
||||
|
||||
// We contain other controls
|
||||
m_IsContainer = true;
|
||||
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
|
||||
_MainItemsContainer = new SimpleItemContainer();
|
||||
//_MainItemsContainer.LayoutOrientation = eOrientation.Horizontal;
|
||||
_MainItemsContainer.GlobalItem = false;
|
||||
_MainItemsContainer.Displayed = true;
|
||||
//_MainItemsContainer.ItemSpacing = 0;
|
||||
_MainItemsContainer.SetSystemContainer(true);
|
||||
_MainItemsContainer.ContainerControl = parent;
|
||||
_MainItemsContainer.DesignTimeVisible = false;
|
||||
_MainItemsContainer.Name = "_MainItemsContainer";
|
||||
this.SubItems.Add(_MainItemsContainer);
|
||||
|
||||
_ExpandButton = new ButtonItem();
|
||||
_ExpandButton.Click += new EventHandler(ExpandButtonClick);
|
||||
_ExpandButton.ImagePaddingHorizontal = 12;
|
||||
_ExpandButton.ImagePaddingVertical = 10;
|
||||
_ExpandButton.Name = "sysMetroToolbarExpandButton";
|
||||
_ExpandButton.SetSystemItem(true);
|
||||
_ExpandButton.ContainerControl = parent;
|
||||
_ExpandButton.DesignTimeVisible = false;
|
||||
UpdateExpandButtonImage();
|
||||
this.SubItems.Add(_ExpandButton);
|
||||
|
||||
_ExtraItemsContainer = new ItemContainer();
|
||||
_ExtraItemsContainer.LayoutOrientation = eOrientation.Horizontal;
|
||||
_ExtraItemsContainer.GlobalItem = false;
|
||||
_ExtraItemsContainer.Displayed = true;
|
||||
_ExtraItemsContainer.MultiLine = true;
|
||||
_ExtraItemsContainer.SetSystemContainer(true);
|
||||
_ExtraItemsContainer.ContainerControl = parent;
|
||||
_ExtraItemsContainer.DesignTimeVisible = false;
|
||||
_ExtraItemsContainer.Name = "_ExtraItemsContainer";
|
||||
this.SubItems.Add(_ExtraItemsContainer);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_ExpandButton.Image != null)
|
||||
{
|
||||
Image image = _ExpandButton.Image;
|
||||
_ExpandButton.Image = null;
|
||||
image.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void UpdateExpandButtonImage()
|
||||
{
|
||||
if (_ExpandButton.Image != null)
|
||||
{
|
||||
Image image = _ExpandButton.Image;
|
||||
_ExpandButton.Image = null;
|
||||
image.Dispose();
|
||||
}
|
||||
|
||||
Bitmap bitmap = new Bitmap(16, 16);
|
||||
using (Graphics g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
using (SolidBrush brush = new SolidBrush(MetroRender.GetColorTable().ForeColor))
|
||||
{
|
||||
g.FillEllipse(brush, new Rectangle(0, 2, 4, 4));
|
||||
g.FillEllipse(brush, new Rectangle(6, 2, 4, 4));
|
||||
g.FillEllipse(brush, new Rectangle(12, 2, 4, 4));
|
||||
}
|
||||
}
|
||||
_ExpandButton.Image = bitmap;
|
||||
}
|
||||
void ExpandButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
_MetroToolbar.Expanded = !_MetroToolbar.Expanded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints this base container
|
||||
/// </summary>
|
||||
public override void Paint(ItemPaintArgs pa)
|
||||
{
|
||||
if (this.SuspendLayout)
|
||||
return;
|
||||
|
||||
_MainItemsContainer.Paint(pa);
|
||||
_ExpandButton.Paint(pa);
|
||||
_ExtraItemsContainer.Paint(pa);
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
if (ExpandButtonVisible)
|
||||
{
|
||||
_ExpandButton.Displayed = true;
|
||||
_ExpandButton.RecalcSize();
|
||||
_ExpandButton.SetDisplayRectangle(new Rectangle(this.WidthInternal - _ExpandButton.WidthInternal, this.TopInternal, _ExpandButton.WidthInternal, _ExpandButton.HeightInternal));
|
||||
}
|
||||
else
|
||||
{
|
||||
_ExpandButton.Displayed = false;
|
||||
_ExpandButton.HeightInternal = 0;
|
||||
_ExpandButton.WidthInternal = 0;
|
||||
}
|
||||
|
||||
_MainItemsContainer.LeftInternal = this.LeftInternal;
|
||||
_MainItemsContainer.TopInternal = this.TopInternal;
|
||||
if (_MainItemsContainer.VisibleSubItems == 0)
|
||||
{
|
||||
_MainItemsContainer.MinimumSize = new Size(this.WidthInternal - _ExpandButton.WidthInternal, 28);
|
||||
}
|
||||
else
|
||||
{
|
||||
_MainItemsContainer.MinimumSize = Size.Empty;
|
||||
_MainItemsContainer.WidthInternal = this.WidthInternal - _ExpandButton.WidthInternal;
|
||||
_MainItemsContainer.HeightInternal = 0;
|
||||
}
|
||||
_MainItemsContainer.RecalcSize();
|
||||
|
||||
|
||||
const int MainExtraItemsSpacing = 1;
|
||||
_ExtraItemsContainer.TopInternal = this.TopInternal + Math.Max(_MainItemsContainer.HeightInternal, _ExpandButton.HeightInternal) + MainExtraItemsSpacing;
|
||||
if (_ExtraItemsContainer.VisibleSubItems == 0)
|
||||
{
|
||||
_ExtraItemsContainer.MinimumSize = new Size(this.WidthInternal, 28);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ExtraItemsContainer.MinimumSize = Size.Empty;
|
||||
_ExtraItemsContainer.WidthInternal = this.WidthInternal;
|
||||
_ExtraItemsContainer.HeightInternal = 0;
|
||||
}
|
||||
_ExtraItemsContainer.RecalcSize();
|
||||
|
||||
|
||||
this.HeightInternal = Math.Max(_ExpandButton.HeightInternal, _MainItemsContainer.HeightInternal) + _ExtraItemsContainer.HeightInternal + MainExtraItemsSpacing;
|
||||
|
||||
base.RecalcSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of GenericItemContainer item
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
MetroToolbarContainer objCopy = new MetroToolbarContainer(_MetroToolbar);
|
||||
this.CopyToItem(objCopy);
|
||||
|
||||
return objCopy;
|
||||
}
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
RibbonStripContainerItem objCopy = copy as RibbonStripContainerItem;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
private bool _ExpandButtonVisible = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether Expand button is visible. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true)]
|
||||
public bool ExpandButtonVisible
|
||||
{
|
||||
get { return _ExpandButtonVisible; }
|
||||
set
|
||||
{
|
||||
if (value != _ExpandButtonVisible)
|
||||
{
|
||||
bool oldValue = _ExpandButtonVisible;
|
||||
_ExpandButtonVisible = value;
|
||||
OnExpandButtonVisibleChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when ExpandButtonVisible property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnExpandButtonVisibleChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("ExpandButtonVisible"));
|
||||
this.NeedRecalcSize = true;
|
||||
_MetroToolbar.RecalcLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to container that host items.
|
||||
/// </summary>
|
||||
public SimpleItemContainer MainItemsContainer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MainItemsContainer;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to container that hosts extra items.
|
||||
/// </summary>
|
||||
public ItemContainer ExtraItemsContainer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ExtraItemsContainer;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSystemColors()
|
||||
{
|
||||
UpdateExpandButtonImage();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDesignTimeProvider Members
|
||||
|
||||
public InsertPosition GetInsertPosition(Point pScreen, BaseItem DragItem)
|
||||
{
|
||||
InsertPosition pos = null;
|
||||
Point clientPoint = _MetroToolbar.PointToClient(pScreen);
|
||||
if(_MainItemsContainer.DisplayRectangle.Contains(clientPoint) || !_MetroToolbar.Expanded)
|
||||
pos = ((IDesignTimeProvider)_MainItemsContainer).GetInsertPosition(pScreen, DragItem);
|
||||
|
||||
if (pos == null && _MetroToolbar.Expanded)
|
||||
{
|
||||
pos = ((IDesignTimeProvider)_ExtraItemsContainer).GetInsertPosition(pScreen, DragItem);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void DrawReversibleMarker(int iPos, bool Before)
|
||||
{
|
||||
DesignTimeProviderContainer.DrawReversibleMarker(this, iPos, Before);
|
||||
}
|
||||
|
||||
public void InsertItemAt(BaseItem objItem, int iPos, bool Before)
|
||||
{
|
||||
DesignTimeProviderContainer.InsertItemAt(this, objItem, iPos, Before);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the item is expanded or not. For Popup items this would indicate whether the item is popped up or not.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DefaultValue(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
|
||||
public override bool Expanded
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Expanded;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Expanded = value;
|
||||
if (!value)
|
||||
{
|
||||
foreach (BaseItem item in this.SubItems)
|
||||
item.Expanded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When parent items does recalc size for its sub-items it should query
|
||||
/// image size and store biggest image size into this property.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(false), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public override System.Drawing.Size SubItemsImageSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.SubItemsImageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
//m_SubItemsImageSize = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
102
PROMS/DotNetBar Source Code/Metro/Rendering/DrawingHelpers.cs
Normal file
102
PROMS/DotNetBar Source Code/Metro/Rendering/DrawingHelpers.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal static class DrawingHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the border.
|
||||
/// </summary>
|
||||
/// <param name="g">Graphics canvas.</param>
|
||||
/// <param name="bounds">Bounds for border.</param>
|
||||
/// <param name="borderThickness">Border thickness.</param>
|
||||
/// <param name="borderColor">Border color.</param>
|
||||
public static void DrawBorder(Graphics g, RectangleF bounds, Thickness borderThickness, BorderColors borderColor)
|
||||
{
|
||||
if (borderColor.IsEmpty || borderThickness.IsZero) return;
|
||||
|
||||
bounds.Width -= (float)borderThickness.Right;
|
||||
bounds.Height -= (float)borderThickness.Bottom;
|
||||
if (borderThickness.Right > 1) bounds.Width++;
|
||||
if (borderThickness.Bottom > 1) bounds.Height++;
|
||||
|
||||
System.Drawing.Drawing2D.SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
|
||||
|
||||
if (borderThickness.Left > 0d && !borderColor.Left.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(borderColor.Left, (float)borderThickness.Left))
|
||||
{
|
||||
pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
|
||||
g.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
if (borderThickness.Top > 0d && !borderColor.Top.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(borderColor.Top, (float)borderThickness.Top))
|
||||
{
|
||||
pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
|
||||
g.DrawLine(pen, bounds.X, bounds.Y, bounds.Right, bounds.Y);
|
||||
}
|
||||
}
|
||||
|
||||
if (borderThickness.Right > 0d && !borderColor.Right.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(borderColor.Right, (float)borderThickness.Right))
|
||||
{
|
||||
pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
|
||||
g.DrawLine(pen, bounds.Right, bounds.Y, bounds.Right, bounds.Bottom + (float)borderThickness.Bottom / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (borderThickness.Bottom > 0d && !borderColor.Bottom.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(borderColor.Bottom, (float)borderThickness.Bottom))
|
||||
{
|
||||
pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
|
||||
g.DrawLine(pen, bounds.X, bounds.Bottom, bounds.Right, bounds.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
/// <summary>
|
||||
/// Draws background.
|
||||
/// </summary>
|
||||
/// <param name="g">Graphics canvas.</param>
|
||||
/// <param name="bounds">Background bounds.</param>
|
||||
/// <param name="color">Background color</param>
|
||||
public static void DrawBackground(Graphics g, RectangleF bounds, string color)
|
||||
{
|
||||
if (string.IsNullOrEmpty(color)) return;
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(ColorScheme.GetColor(color)))
|
||||
g.FillRectangle(brush, bounds);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deflates the rectangle by the border thickness.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Rectangle.</param>
|
||||
/// <param name="borderThickness">Border thickness</param>
|
||||
/// <returns>Rectangle deflated by the border thickness</returns>
|
||||
public static RectangleF Deflate(RectangleF bounds, Thickness borderThickness)
|
||||
{
|
||||
if (borderThickness.IsZero) return bounds;
|
||||
|
||||
bounds.X += (float)borderThickness.Left;
|
||||
bounds.Width -= (float)(borderThickness.Left + borderThickness.Right);
|
||||
bounds.Y += (float)borderThickness.Top;
|
||||
bounds.Height -= (float)(borderThickness.Top + borderThickness.Bottom);
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroAppButtonPainter : Office2007ButtonItemPainter
|
||||
{
|
||||
public override Office2007ButtonItemColorTable GetColorTable(ButtonItem button, eButtonContainer buttonCont)
|
||||
{
|
||||
Office2007ColorTable colorTable = this.ColorTable;
|
||||
Office2007ButtonItemColorTable buttonColorTable = null;
|
||||
|
||||
if (button.CustomColorName != "")
|
||||
buttonColorTable = colorTable.ApplicationButtonColors[button.CustomColorName];
|
||||
|
||||
if (buttonColorTable == null)
|
||||
buttonColorTable = colorTable.ApplicationButtonColors[button.GetColorTableName()];
|
||||
|
||||
if (buttonColorTable == null && colorTable.ApplicationButtonColors.Count > 0)
|
||||
buttonColorTable = colorTable.ApplicationButtonColors[0];
|
||||
|
||||
if (buttonColorTable == null) // Return fall back static table
|
||||
buttonColorTable = DevComponents.DotNetBar.Metro.ColorTables.MetroOfficeColorTableInitializer.GetAppFallBackColorTable();
|
||||
|
||||
return buttonColorTable;
|
||||
}
|
||||
|
||||
protected override Rectangle GetDisplayRectangle(ButtonItem button)
|
||||
{
|
||||
Rectangle r = button.DisplayRectangle;
|
||||
if (button is ApplicationButton && ((ApplicationButton)button).IsMenuOverlayPaint)
|
||||
{
|
||||
r.Width += 4;
|
||||
r.Height += 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private static readonly int RibbonFormWidthOffset = 2;
|
||||
public override void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image)
|
||||
{
|
||||
Rectangle r = GetDisplayRectangle(button);
|
||||
r.Inflate(-1, -1);
|
||||
r.Width--;
|
||||
|
||||
if (pa.ContainerControl.FindForm() is RibbonForm)
|
||||
r.Width -= RibbonFormWidthOffset+2;
|
||||
|
||||
if (button is ApplicationButton && ((ApplicationButton)button).IsMenuOverlayPaint)
|
||||
{
|
||||
r.Height -= 1;
|
||||
r.Width +=3;
|
||||
}
|
||||
|
||||
eTextFormat format = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.HidePrefix;
|
||||
TextDrawing.DrawString(pa.Graphics, button.Text, pa.Font, textColor, r, format);
|
||||
}
|
||||
|
||||
protected override Color GetTextColor(ButtonItem button, ItemPaintArgs pa)
|
||||
{
|
||||
return base.GetTextColor(button, pa, GetColorTable(button, eButtonContainer.RibbonStrip));
|
||||
}
|
||||
|
||||
public override void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(button.Text)) return;
|
||||
Rectangle r = GetDisplayRectangle(button);
|
||||
r.X = r.X + (r.Width - imagebounds.Width) / 2;
|
||||
r.Y = r.Y + (r.Height - imagebounds.Height) / 2;
|
||||
r.Width = imagebounds.Width;
|
||||
r.Height = imagebounds.Height;
|
||||
base.PaintButtonImage(button, pa, image, r);
|
||||
}
|
||||
|
||||
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image)
|
||||
{
|
||||
Office2007ButtonItemColorTable colors = GetColorTable(button, eButtonContainer.RibbonStrip);
|
||||
Office2007ButtonItemStateColorTable stateColors = colors.Default;
|
||||
|
||||
if (button.IsMouseDown)
|
||||
stateColors = colors.Pressed;
|
||||
else if (button.IsMouseOver)
|
||||
stateColors = colors.MouseOver;
|
||||
Rectangle bounds = GetDisplayRectangle(button);
|
||||
bounds.Width--;
|
||||
//bounds.Height--;
|
||||
Graphics g = pa.Graphics;
|
||||
|
||||
if (pa.ContainerControl.FindForm() is RibbonForm)
|
||||
bounds.Width -= RibbonFormWidthOffset;
|
||||
|
||||
//using (GraphicsPath borderPath = DisplayHelp.GetRoundedRectanglePath(bounds, 0, 2, 2, 0))
|
||||
{
|
||||
//DisplayHelp.FillPath(g, borderPath, stateColors.Background);
|
||||
DisplayHelp.FillRectangle(g, bounds, stateColors.Background);
|
||||
|
||||
if (stateColors.BottomBackgroundHighlight != null && !stateColors.BottomBackgroundHighlight.IsEmpty)
|
||||
{
|
||||
Rectangle ellipse = new Rectangle(bounds.X - 12, bounds.Y + bounds.Height / 2 - 4, bounds.Width + 24, bounds.Height + 4);
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddEllipse(ellipse);
|
||||
using (PathGradientBrush brush = new PathGradientBrush(path))
|
||||
{
|
||||
brush.CenterColor = stateColors.BottomBackgroundHighlight.Start;
|
||||
brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End };
|
||||
brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Bottom - 1);
|
||||
|
||||
g.FillRectangle(brush, bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stateColors.InnerBorder != null && !stateColors.InnerBorder.IsEmpty)
|
||||
{
|
||||
Rectangle innerBorder = bounds;
|
||||
innerBorder.Inflate(-1, -1);
|
||||
using (GraphicsPath innerBorderPath = new GraphicsPath())
|
||||
{
|
||||
innerBorderPath.AddRectangle(innerBorder);
|
||||
DisplayHelp.DrawGradientPath(g, innerBorderPath, innerBorder, stateColors.InnerBorder, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (stateColors.OuterBorder != null && !stateColors.OuterBorder.IsEmpty)
|
||||
DisplayHelp.DrawRectangle(g, stateColors.OuterBorder.Start, bounds); //DisplayHelp.DrawGradientPathBorder(g, borderPath, stateColors.OuterBorder, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroButtonItemPainter : Office2007ButtonItemPainter
|
||||
{
|
||||
private static RoundRectangleShapeDescriptor _DefaultMetroShape = new RoundRectangleShapeDescriptor(0);
|
||||
private static RoundRectangleShapeDescriptor _DefaultMobileShape = new RoundRectangleShapeDescriptor(2);
|
||||
protected override IShapeDescriptor GetButtonShape(ButtonItem button, ItemPaintArgs pa)
|
||||
{
|
||||
IShapeDescriptor shape = MetroButtonItemPainter.GetButtonShape(button);
|
||||
|
||||
if (pa.ContainerControl is ButtonX)
|
||||
shape = ((ButtonX)pa.ContainerControl).GetButtonShape();
|
||||
else if (pa.ContainerControl is NavigationBar)
|
||||
shape = ((NavigationBar)pa.ContainerControl).ButtonShape;
|
||||
return shape;
|
||||
}
|
||||
private static IShapeDescriptor GetButtonShape(ButtonItem button)
|
||||
{
|
||||
if (button.Shape != null)
|
||||
return button.Shape;
|
||||
else if(StyleManager.Style == eStyle.OfficeMobile2014)
|
||||
return _DefaultMobileShape;
|
||||
return _DefaultMetroShape;
|
||||
}
|
||||
|
||||
public override DotNetBar.Rendering.Office2007ButtonItemColorTable GetColorTable(ButtonItem button, eButtonContainer buttonCont)
|
||||
{
|
||||
if (buttonCont == eButtonContainer.MetroTabStrip)
|
||||
{
|
||||
Office2007ColorTable colorTable = this.ColorTable;
|
||||
object st = null;
|
||||
if (colorTable.ContextualTables.TryGetValue(Office2007ColorTable.GetContextualKey(ButtonColorTableType, "MetroTabStrip"), out st))
|
||||
return (Office2007ButtonItemColorTable)st;
|
||||
}
|
||||
else if (buttonCont == eButtonContainer.NavigationPane)
|
||||
{
|
||||
Office2007ColorTable colorTable = this.ColorTable;
|
||||
object st = null;
|
||||
if (colorTable.ContextualTables.TryGetValue(Office2007ColorTable.GetContextualKey(ButtonColorTableType, "NavigationBar"), out st))
|
||||
return (Office2007ButtonItemColorTable)st;
|
||||
}
|
||||
|
||||
return base.GetColorTable(button, buttonCont);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroCaptionItemPainter : Office2007SystemCaptionItemPainter
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override Rectangle GetSignRect(Rectangle r, Size s)
|
||||
{
|
||||
if (r.Height < 10)
|
||||
return Rectangle.Empty;
|
||||
|
||||
return new Rectangle(r.X + (r.Width - s.Width) / 2, r.Y + (int)Math.Ceiling((double)(r.Height - s.Height)/2), s.Width, s.Height);
|
||||
//return new Rectangle(r.X + (r.Width - s.Width) / 2, r.Bottom - r.Height / 4 - s.Height - 3, s.Width, s.Height);
|
||||
}
|
||||
|
||||
protected override void PaintMinimize(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
Size s = new Size(Dpi.Width9, Dpi.Height2);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
if (isEnabled)
|
||||
DisplayHelp.FillRectangle(g, rm, foreground);
|
||||
else
|
||||
DisplayHelp.FillRectangle(g, rm, GetDisabledColor(foreground.Start), GetDisabledColor(foreground.End), foreground.GradientAngle);
|
||||
}
|
||||
|
||||
internal static Color GetDisabledColor(Color color)
|
||||
{
|
||||
if (color.IsEmpty) return color;
|
||||
return Color.FromArgb(128, color);
|
||||
}
|
||||
|
||||
|
||||
protected override void PaintRestore(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.None;
|
||||
|
||||
Size s = new Size(Dpi.Width10, Dpi.Height10);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
Region oldClip = g.Clip;
|
||||
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
LinearGradientColorTable buttonTable = isEnabled ? foreground : new LinearGradientColorTable(GetDisabledColor(foreground.Start), GetDisabledColor(foreground.End), foreground.GradientAngle);
|
||||
using (Brush fill = DisplayHelp.CreateBrush(rm, foreground))
|
||||
{
|
||||
Rectangle inner = new Rectangle(rm.X + Dpi.Width4, rm.Y + Dpi.Width2, Dpi.Width6, Dpi.Height4);
|
||||
g.SetClip(inner, CombineMode.Exclude);
|
||||
g.SetClip(new Rectangle(rm.X + Dpi.Width1, rm.Y + Dpi.Height5, Dpi.Width6, Dpi.Height4), CombineMode.Exclude);
|
||||
|
||||
g.FillRectangle(fill, rm.X + Dpi.Width3, rm.Y, Dpi.Width8, Dpi.Height7);
|
||||
g.ResetClip();
|
||||
|
||||
inner = new Rectangle(rm.X + Dpi.Width1, rm.Y + Dpi.Height5, Dpi.Width6, Dpi.Height4);
|
||||
g.SetClip(inner, CombineMode.Exclude);
|
||||
g.FillRectangle(fill, rm.X, rm.Y + Dpi.Height3, Dpi.Width8, Dpi.Height7);
|
||||
g.ResetClip();
|
||||
}
|
||||
if (oldClip != null)
|
||||
{
|
||||
g.Clip = oldClip;
|
||||
oldClip.Dispose();
|
||||
}
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
|
||||
protected override void PaintMaximize(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
Size s = new Size(Dpi.Width10, Dpi.Height10);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
Region oldClip = g.Clip;
|
||||
|
||||
Rectangle inner = new Rectangle(rm.X + Dpi.Width1, rm.Y + Dpi.Height3, (ct.DarkShade.IsEmpty ? Dpi.Width8 : Dpi.Width7), (ct.DarkShade.IsEmpty ? Dpi.Height6 : Dpi.Height5));
|
||||
g.SetClip(inner, CombineMode.Exclude);
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
if (isEnabled)
|
||||
DisplayHelp.FillRectangle(g, rm, foreground);
|
||||
else
|
||||
DisplayHelp.FillRectangle(g, rm, GetDisabledColor(foreground.Start), GetDisabledColor(foreground.End), foreground.GradientAngle);
|
||||
|
||||
if (oldClip != null)
|
||||
{
|
||||
g.Clip = oldClip;
|
||||
oldClip.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PaintClose(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
|
||||
Size s = new Size(Dpi.Width8, Dpi.Height8);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
Rectangle r1 = rm;
|
||||
r1.Offset(0, -1);
|
||||
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
if (isEnabled)
|
||||
{
|
||||
using (Pen pen = new Pen(foreground.Start, Dpi.Width2))
|
||||
{
|
||||
g.DrawLine(pen, r1.X, r1.Y, r1.Right, r1.Bottom);
|
||||
g.DrawLine(pen, r1.Right, r1.Y, r1.X, r1.Bottom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pen pen = new Pen(GetDisabledColor(foreground.Start), Dpi.Width2))
|
||||
{
|
||||
g.DrawLine(pen, r1.X, r1.Y, r1.Right, r1.Bottom);
|
||||
g.DrawLine(pen, r1.Right, r1.Y, r1.X, r1.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
|
||||
protected override void PaintHelp(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
TextRenderingHint th = g.TextRenderingHint;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
#if FRAMEWORK20
|
||||
using (Font font = new Font(SystemFonts.DefaultFont, FontStyle.Bold))
|
||||
#else
|
||||
using(Font font = new Font("Arial", 10, FontStyle.Bold))
|
||||
#endif
|
||||
{
|
||||
Size s = TextDrawing.MeasureString(g, "?", font);
|
||||
s.Width += Dpi.Width4;
|
||||
s.Height -= Dpi.Width2;
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
rm.Offset(1, 1);
|
||||
Color color = isEnabled ? ct.DarkShade : GetDisabledColor(ct.DarkShade);
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
g.DrawString("?", font, brush, rm);
|
||||
rm.Offset(-1, -1);
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
color = isEnabled ? foreground.Start : GetDisabledColor(foreground.Start);
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
g.DrawString("?", font, brush, rm);
|
||||
|
||||
}
|
||||
g.SmoothingMode = sm;
|
||||
g.TextRenderingHint = th;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroFormRenderer : MetroRenderer
|
||||
{
|
||||
public override void Render(MetroRendererInfo renderingInfo)
|
||||
{
|
||||
MetroAppForm form = renderingInfo.Control as MetroAppForm;
|
||||
BorderOverlay overlay = renderingInfo.Control as BorderOverlay;
|
||||
if (form == null && overlay != null) form = overlay.Parent as MetroAppForm;
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
MetroAppFormColorTable fct = renderingInfo.ColorTable.MetroAppForm;
|
||||
|
||||
Thickness borderThickness = form.BorderThickness;
|
||||
BorderColors colors = form.BorderColor;
|
||||
if (borderThickness.IsZero && colors.IsEmpty)
|
||||
{
|
||||
// Get it from table
|
||||
borderThickness = form.IsGlassEnabled ? fct.BorderThickness : fct.BorderPlainThickness;
|
||||
colors = form.IsActive ? fct.BorderColors : fct.BorderColorsInactive;
|
||||
}
|
||||
|
||||
if (overlay == null) // If overlay is being rendered it does not need fill
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(form.BackColor))
|
||||
g.FillRectangle(brush, new Rectangle(0, 0, form.Width, form.Height));
|
||||
}
|
||||
|
||||
|
||||
if (!borderThickness.IsZero && !colors.IsEmpty)
|
||||
{
|
||||
RectangleF br = new RectangleF(0, 0, form.Width, form.Height);
|
||||
DrawingHelpers.DrawBorder(g, br, borderThickness, colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroKeyTipsPainter : Office2007KeyTipsPainter
|
||||
{
|
||||
public override void PaintKeyTips(KeyTipsRendererEventArgs e)
|
||||
{
|
||||
Rectangle r = e.Bounds;
|
||||
r.Inflate(1, 1);
|
||||
|
||||
Color textColor = ColorTable.KeyTips.KeyTipText;
|
||||
Color backColor = ColorTable.KeyTips.KeyTipBackground;
|
||||
|
||||
if (e.ReferenceObject is BaseItem && !((BaseItem)e.ReferenceObject).Enabled)
|
||||
{
|
||||
int alpha = 128;
|
||||
backColor = Color.FromArgb(alpha, backColor);
|
||||
textColor = Color.FromArgb(alpha, textColor);
|
||||
}
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
string keyTip = e.KeyTip;
|
||||
Font font = e.Font;
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(backColor))
|
||||
DisplayHelp.FillRoundedRectangle(g, brush, r, 1);
|
||||
using (Pen pen = new Pen(textColor, 1))
|
||||
DisplayHelp.DrawRoundedRectangle(g, pen, r, 1);
|
||||
|
||||
//DisplayHelp.FillRectangle(g, r, backColor);
|
||||
//using (Pen pen = new Pen(textColor, 1))
|
||||
// DisplayHelp.DrawRoundedRectangle(g, pen, r, 2);
|
||||
TextDrawing.DrawString(g, keyTip, font, textColor, r, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter);
|
||||
}
|
||||
}
|
||||
}
|
229
PROMS/DotNetBar Source Code/Metro/Rendering/MetroRender.cs
Normal file
229
PROMS/DotNetBar Source Code/Metro/Rendering/MetroRender.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
public static class MetroRender
|
||||
{
|
||||
private static MetroRenderer[] _Renderers;
|
||||
static MetroRender()
|
||||
{
|
||||
_Renderers = new MetroRenderer[Enum.GetNames(typeof(Renderers)).Length];
|
||||
_Renderers[(int)Renderers.MetroForm] = new MetroFormRenderer();
|
||||
_Renderers[(int)Renderers.MetroTabItem] = new MetroTabItemPainter();
|
||||
_Renderers[(int)Renderers.MetroTabStrip] = new MetroTabStripPainter();
|
||||
_Renderers[(int)Renderers.MetroStatusBar] = new MetroStatusBarPainter();
|
||||
_Renderers[(int)Renderers.MetroToolbar] = new MetroToolbarPainter();
|
||||
_Renderers[(int)Renderers.MetroTileItem] = new MetroTileItemPainter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the MetroTileItem.
|
||||
/// </summary>
|
||||
/// <param name="item">MetroTileItem to render.</param>
|
||||
/// <param name="e">Rendering event arguments.</param>
|
||||
public static void Paint(MetroTileItem item, ItemPaintArgs pa)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroTileItem);
|
||||
renderer.Render(GetRenderingInfo(item, pa, GetColorTable()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the MetroForm.
|
||||
/// </summary>
|
||||
/// <param name="form">Form to render.</param>
|
||||
/// <param name="e">Rendering event arguments.</param>
|
||||
public static void Paint(MetroAppForm form, PaintEventArgs e)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroForm);
|
||||
renderer.Render(GetRenderingInfo(form, e, GetColorTable()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the MetroForm.
|
||||
/// </summary>
|
||||
/// <param name="formOverlay">Form to render.</param>
|
||||
/// <param name="e">Rendering event arguments.</param>
|
||||
internal static void Paint(BorderOverlay formOverlay, PaintEventArgs e)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroForm);
|
||||
renderer.Render(GetRenderingInfo(formOverlay, e, GetColorTable()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the MetroTabItem.
|
||||
/// </summary>
|
||||
/// <param name="tab">Form to render.</param>
|
||||
/// <param name="e">Rendering event arguments.</param>
|
||||
public static void Paint(MetroTabItem tab, ItemPaintArgs pa)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroTabItem);
|
||||
renderer.Render(GetRenderingInfo(tab, pa, GetColorTable()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the MetroTabStrip
|
||||
/// </summary>
|
||||
/// <param name="tabStrip">TabStrip to render.</param>
|
||||
/// <param name="pa">Paint args</param>
|
||||
public static void Paint(MetroTabStrip tabStrip, ItemPaintArgs pa)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroTabStrip);
|
||||
MetroRendererInfo info = GetRenderingInfo(tabStrip, pa, GetColorTable());
|
||||
renderer.Render(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Renders the MetroStatusBar.
|
||||
/// </summary>
|
||||
/// <param name="bar">Status bar to render</param>
|
||||
/// <param name="pa">Paint args</param>
|
||||
public static void Paint(MetroStatusBar bar, ItemPaintArgs pa)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroStatusBar);
|
||||
renderer.Render(GetRenderingInfo(bar, pa, GetColorTable()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the MetroStatusBar.
|
||||
/// </summary>
|
||||
/// <param name="bar">Status bar to render</param>
|
||||
/// <param name="pa">Paint args</param>
|
||||
public static void Paint(MetroToolbar bar, ItemPaintArgs pa)
|
||||
{
|
||||
MetroRenderer renderer = GetRenderer(Renderers.MetroToolbar);
|
||||
renderer.Render(GetRenderingInfo(bar, pa, GetColorTable()));
|
||||
}
|
||||
|
||||
private static MetroRenderer GetRenderer(Renderers renderer)
|
||||
{
|
||||
return _Renderers[(int)renderer];
|
||||
}
|
||||
|
||||
private static MetroRendererInfo _RenderingInfo = new MetroRendererInfo();
|
||||
private static MetroRendererInfo GetRenderingInfo(Control control, PaintEventArgs e, MetroColorTable colorTable)
|
||||
{
|
||||
_RenderingInfo.Control = control;
|
||||
_RenderingInfo.PaintEventArgs = e;
|
||||
_RenderingInfo.ColorTable = colorTable;
|
||||
_RenderingInfo.DefaultFont = control.Font;
|
||||
_RenderingInfo.RightToLeft = (control.RightToLeft == RightToLeft.Yes);
|
||||
return _RenderingInfo;
|
||||
}
|
||||
private static MetroRendererInfo GetRenderingInfo(Control control, ItemPaintArgs e, MetroColorTable colorTable)
|
||||
{
|
||||
_RenderingInfo.Control = control;
|
||||
_RenderingInfo.PaintEventArgs = e.PaintEventArgs;
|
||||
_RenderingInfo.DefaultFont = e.Font;
|
||||
_RenderingInfo.ColorTable = colorTable;
|
||||
_RenderingInfo.RightToLeft = e.RightToLeft;
|
||||
_RenderingInfo.ItemPaintArgs = e;
|
||||
return _RenderingInfo;
|
||||
}
|
||||
private static MetroRendererInfo GetRenderingInfo(MetroTabStrip control, ItemPaintArgs e, MetroColorTable colorTable)
|
||||
{
|
||||
_RenderingInfo.Control = control;
|
||||
_RenderingInfo.PaintEventArgs = e.PaintEventArgs;
|
||||
_RenderingInfo.DefaultFont = e.Font;
|
||||
if (e.Font.Bold)
|
||||
_RenderingInfo.DefaultPlainFont = new Font(e.Font, FontStyle.Regular);
|
||||
_RenderingInfo.ColorTable = colorTable;
|
||||
_RenderingInfo.RightToLeft = e.RightToLeft;
|
||||
_RenderingInfo.ItemPaintArgs = e;
|
||||
return _RenderingInfo;
|
||||
}
|
||||
private static MetroRendererInfo GetRenderingInfo(object control, ItemPaintArgs e, MetroColorTable colorTable)
|
||||
{
|
||||
_RenderingInfo.Control = control;
|
||||
_RenderingInfo.PaintEventArgs = e.PaintEventArgs;
|
||||
_RenderingInfo.DefaultFont = e.Font;
|
||||
_RenderingInfo.ColorTable = colorTable;
|
||||
_RenderingInfo.RightToLeft = e.RightToLeft;
|
||||
_RenderingInfo.ItemPaintArgs = e;
|
||||
return _RenderingInfo;
|
||||
}
|
||||
|
||||
private static MetroColorTable _ColorTable = null;
|
||||
public static MetroColorTable GetColorTable()
|
||||
{
|
||||
if (_ColorTable == null)
|
||||
{
|
||||
UpdateColorTable(MetroColorGeneratorParameters.Default);
|
||||
}
|
||||
return _ColorTable;
|
||||
}
|
||||
|
||||
internal static void UpdateColorTable(MetroColorGeneratorParameters colorParams)
|
||||
{
|
||||
if (StyleManager.IsVisualStudio2012(StyleManager.Style))
|
||||
_ColorTable = VisualStudio2012ColorTableInitializer.CreateColorTable(colorParams);
|
||||
else if (StyleManager.Style == eStyle.OfficeMobile2014)
|
||||
_ColorTable = OfficeMobile2014MetroInitializer.CreateColorTable(colorParams);
|
||||
else if (StyleManager.Style == eStyle.Office2016)
|
||||
_ColorTable = Office2016MetroInitializer.CreateColorTable(colorParams);
|
||||
else
|
||||
_ColorTable = MetroColorTableInitializer.CreateColorTable(colorParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines class for passing rendering information to renderer.
|
||||
/// </summary>
|
||||
public class MetroRendererInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the control to render.
|
||||
/// </summary>
|
||||
public object Control = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the paint event arguments to use to render out control.
|
||||
/// </summary>
|
||||
public PaintEventArgs PaintEventArgs = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the current color table.
|
||||
/// </summary>
|
||||
public MetroColorTable ColorTable;
|
||||
/// <summary>
|
||||
/// Gets or sets default font.
|
||||
/// </summary>
|
||||
public Font DefaultFont = SystemFonts.DefaultFont;
|
||||
/// <summary>
|
||||
/// Gets or sets default plain font.
|
||||
/// </summary>
|
||||
public Font DefaultPlainFont = null;
|
||||
/// <summary>
|
||||
/// Gets or sets right-to-left setting.
|
||||
/// </summary>
|
||||
public bool RightToLeft = false;
|
||||
/// <summary>
|
||||
/// Gets or sets the paint information for items.
|
||||
/// </summary>
|
||||
public ItemPaintArgs ItemPaintArgs = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Abstract renderer for rendering Metro-UI controls.
|
||||
/// </summary>
|
||||
public abstract class MetroRenderer
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Renders the
|
||||
/// </summary>
|
||||
/// <param name="renderingInfo"></param>
|
||||
public abstract void Render(MetroRendererInfo renderingInfo);
|
||||
}
|
||||
|
||||
public enum Renderers : int
|
||||
{
|
||||
MetroForm,
|
||||
MetroTabItem,
|
||||
MetroTabStrip,
|
||||
MetroStatusBar,
|
||||
MetroToolbar,
|
||||
MetroTileItem
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroRibbonTabGroupPainter : Office2007RibbonTabGroupPainter
|
||||
{
|
||||
protected override void PaintTabGroupBackground(System.Drawing.Graphics g, DevComponents.DotNetBar.Rendering.Office2007RibbonTabGroupColorTable colorTable, System.Drawing.Rectangle bounds, System.Drawing.Rectangle groupBounds, bool glassEnabled)
|
||||
{
|
||||
DisplayHelp.FillRectangle(g, groupBounds, colorTable.Background);
|
||||
|
||||
if (StyleManager.Style != eStyle.Office2016)
|
||||
{
|
||||
Rectangle top = new Rectangle(groupBounds.X, groupBounds.Y, groupBounds.Width, 3);
|
||||
DisplayHelp.FillRectangle(g, top, colorTable.Border);
|
||||
if (StyleManager.Style == eStyle.OfficeMobile2014)
|
||||
{
|
||||
DisplayHelp.DrawGradientLine(g, groupBounds.X, groupBounds.Y, groupBounds.X, 24, colorTable.Border, 1);
|
||||
DisplayHelp.DrawGradientLine(g, groupBounds.Right - 1, groupBounds.Y, groupBounds.Right - 1, 24, colorTable.Border, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.ScrollBar;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroScrollBarPainter : ScrollBarPainter, IOffice2007Painter
|
||||
{
|
||||
#region Private Variables
|
||||
private Office2007ColorTable m_ColorTable = null;
|
||||
private bool m_AppStyleScrollBar = false;
|
||||
private Presentation.ShapeBorder m_ThumbOuterBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeBorder m_ThumbInnerBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeFill m_ThumbInnerFill = new Presentation.ShapeFill();
|
||||
private Presentation.ShapeFill m_ThumbSignFill = new Presentation.ShapeFill();
|
||||
private Presentation.Shape m_ThumbShape = null;
|
||||
private Presentation.ShapePath m_ThumbSignShape = null;
|
||||
private Size m_ThumbSignSize = new Size(9, 5);
|
||||
|
||||
private Presentation.Shape m_TrackShape = null;
|
||||
private Presentation.ShapeBorder m_TrackOuterBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeBorder m_TrackInnerBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeFill m_TrackInnerFill = new Presentation.ShapeFill();
|
||||
|
||||
private Presentation.Shape m_BackgroundShape = null;
|
||||
private Presentation.ShapeBorder m_BackgroundBorder = new Presentation.ShapeBorder(1);
|
||||
private Presentation.ShapeFill m_BackgroundFill = new Presentation.ShapeFill();
|
||||
#endregion
|
||||
|
||||
#region IOffice2007Painter Members
|
||||
|
||||
public DevComponents.DotNetBar.Rendering.Office2007ColorTable ColorTable
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ColorTable;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ColorTable = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Implemementation
|
||||
public MetroScrollBarPainter()
|
||||
{
|
||||
m_ThumbShape = GetThumbShape();
|
||||
m_TrackShape = GetTrackShape();
|
||||
m_BackgroundShape = GetBackgroundShape();
|
||||
}
|
||||
|
||||
public override void PaintThumb(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, eScrollThumbPosition position, eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Initialize Colors
|
||||
m_ThumbOuterBorder.Width = Dpi.Width1;
|
||||
m_ThumbOuterBorder.Apply(ct.ThumbOuterBorder);
|
||||
m_ThumbSignFill.Apply(ct.ThumbSignBackground);
|
||||
|
||||
m_ThumbSignShape.Path = GetThumbSignPath(position);
|
||||
m_ThumbShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
m_ThumbSignShape.Path.Dispose();
|
||||
m_ThumbSignShape.Path = null;
|
||||
}
|
||||
|
||||
private Office2007ScrollBarStateColorTable GetColorTable(eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarColorTable csb = m_AppStyleScrollBar ? m_ColorTable.AppScrollBar : m_ColorTable.ScrollBar;
|
||||
if (state == eScrollBarState.Normal)
|
||||
return csb.Default;
|
||||
else if (state == eScrollBarState.Disabled)
|
||||
return csb.Disabled;
|
||||
else if (state == eScrollBarState.ControlMouseOver)
|
||||
return csb.MouseOverControl;
|
||||
else if (state == eScrollBarState.PartMouseOver)
|
||||
return csb.MouseOver;
|
||||
else if (state == eScrollBarState.Pressed)
|
||||
return csb.Pressed;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void PaintTrackHorizontal(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Apply Colors...
|
||||
// Apply Colors...
|
||||
m_TrackInnerFill.Apply(ct.TrackSignBackground);
|
||||
m_TrackOuterBorder.Width = Dpi.Width1;
|
||||
m_TrackOuterBorder.Apply(ct.TrackOuterBorder);
|
||||
m_TrackShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
}
|
||||
|
||||
public override void PaintTrackVertical(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, eScrollBarState state)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Apply Colors...
|
||||
m_TrackInnerFill.Apply(ct.TrackSignBackground);
|
||||
m_TrackOuterBorder.Apply(ct.TrackOuterBorder);
|
||||
m_TrackShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
}
|
||||
|
||||
public override void PaintBackground(Graphics g, Rectangle bounds, eScrollBarState state, bool horizontal, bool sideBorderOnly, bool rtl)
|
||||
{
|
||||
Office2007ScrollBarStateColorTable ct = GetColorTable(state);
|
||||
if (ct == null) return;
|
||||
|
||||
// Apply Colors...
|
||||
m_BackgroundBorder.Width = Dpi.Width1;
|
||||
if (sideBorderOnly)
|
||||
m_BackgroundBorder.Apply(null);
|
||||
else
|
||||
m_BackgroundBorder.Apply(ct.Border);
|
||||
|
||||
m_BackgroundFill.Apply(ct.Background);
|
||||
m_BackgroundFill.GradientAngle = horizontal ? 90 : 0;
|
||||
|
||||
m_BackgroundShape.Paint(new Presentation.ShapePaintInfo(g, bounds));
|
||||
if (sideBorderOnly && !ct.Border.Start.IsEmpty)
|
||||
{
|
||||
if (horizontal)
|
||||
DisplayHelp.DrawLine(g, bounds.X, bounds.Y, bounds.Right, bounds.Y, ct.Border.Start, Dpi.Width1);
|
||||
else
|
||||
{
|
||||
if (rtl)
|
||||
DisplayHelp.DrawLine(g, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom, ct.Border.Start, Dpi.Width1);
|
||||
else
|
||||
DisplayHelp.DrawLine(g, 0, bounds.Y, 0, bounds.Bottom, ct.Border.Start, Dpi.Width1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Presentation.Shape GetBackgroundShape()
|
||||
{
|
||||
Presentation.Rectangle b = new Presentation.Rectangle();
|
||||
b.Border = m_BackgroundBorder;
|
||||
b.Fill = m_BackgroundFill;
|
||||
return b;
|
||||
}
|
||||
|
||||
private Presentation.Shape GetThumbShape()
|
||||
{
|
||||
Presentation.Rectangle thumb = new Presentation.Rectangle();
|
||||
thumb.Border = m_ThumbOuterBorder;
|
||||
thumb.Padding = new Presentation.PaddingInfo(1,1,1,1);
|
||||
m_ThumbSignShape = new Presentation.ShapePath();
|
||||
m_ThumbSignShape.Fill = m_ThumbSignFill;
|
||||
thumb.Children.Add(m_ThumbSignShape);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private Presentation.Shape GetTrackShape()
|
||||
{
|
||||
Presentation.Rectangle thumb = new Presentation.Rectangle();
|
||||
thumb.Padding = new DevComponents.DotNetBar.Presentation.PaddingInfo(1, 1, 1, 1);
|
||||
thumb.Border = m_TrackOuterBorder;
|
||||
Presentation.Rectangle innerRect = new Presentation.Rectangle();
|
||||
innerRect.Padding = new Presentation.PaddingInfo(2, 2, 2, 2);
|
||||
innerRect.Fill = m_TrackInnerFill;
|
||||
thumb.Children.Add(innerRect);
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private GraphicsPath GetThumbSignPath(eScrollThumbPosition pos)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
Size signSize = Dpi.Size(m_ThumbSignSize);
|
||||
|
||||
if (pos == eScrollThumbPosition.Left || pos == eScrollThumbPosition.Right)
|
||||
{
|
||||
int w = signSize.Width;
|
||||
signSize.Width = signSize.Height;
|
||||
signSize.Height = w;
|
||||
}
|
||||
|
||||
if (pos == eScrollThumbPosition.Top)
|
||||
{
|
||||
path.AddPolygon(new PointF[] {new PointF(-Dpi.Width1, signSize.Height),
|
||||
new PointF(signSize.Width / 2 , -Dpi.Width1),
|
||||
new PointF(signSize.Width / 2, -Dpi.Width1), new PointF(signSize.Width, signSize.Height),
|
||||
new PointF(signSize.Width, signSize.Height), new PointF(-1, signSize.Height)});
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else if (pos == eScrollThumbPosition.Bottom)
|
||||
{
|
||||
path.AddLine(signSize.Width / 2, signSize.Height + Dpi.Width1, signSize.Width, Dpi.Width1);
|
||||
path.AddLine(signSize.Width, Dpi.Width1, 0, Dpi.Width1);
|
||||
path.AddLine(0, 1, signSize.Width / 2, signSize.Height + Dpi.Width1);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else if (pos == eScrollThumbPosition.Left)
|
||||
{
|
||||
//signSize.Width++;
|
||||
signSize.Height += Dpi.Height1;
|
||||
int h2 = (int)(signSize.Height / 2);
|
||||
path.AddLine(0, h2, signSize.Width, 0);
|
||||
path.AddLine(signSize.Width, 0, signSize.Width, signSize.Height);
|
||||
path.AddLine(signSize.Width, signSize.Height, 0, h2);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
else if (pos == eScrollThumbPosition.Right)
|
||||
{
|
||||
signSize.Height += Dpi.Height1;
|
||||
path.AddLine(signSize.Width, signSize.Height / 2, 0, 0);
|
||||
path.AddLine(0, 0, 0, signSize.Height);
|
||||
path.AddLine(0, signSize.Height, signSize.Width, signSize.Height / 2);
|
||||
path.CloseAllFigures();
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public bool AppStyleScrollBar
|
||||
{
|
||||
get { return m_AppStyleScrollBar; }
|
||||
set { m_AppStyleScrollBar = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroStatusBarPainter : MetroRenderer
|
||||
{
|
||||
public override void Render(MetroRendererInfo renderingInfo)
|
||||
{
|
||||
MetroStatusBar bar = (MetroStatusBar)renderingInfo.Control;
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
MetroStatusBarColorTable ct = renderingInfo.ColorTable.MetroStatusBar;
|
||||
Rectangle bounds = bar.ClientRectangle;
|
||||
|
||||
if (ct.BackgroundStyle != null)
|
||||
{
|
||||
ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(ct.BackgroundStyle, g, bounds);
|
||||
ElementStyleDisplay.PaintBackground(di);
|
||||
}
|
||||
|
||||
if (ct.TopBorders != null && ct.TopBorders.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < ct.TopBorders.Length; i++)
|
||||
{
|
||||
using (Pen pen = new Pen(ct.TopBorders[i]))
|
||||
g.DrawLine(pen, bounds.X, bounds.Y + i, bounds.Right, bounds.Y + i);
|
||||
}
|
||||
}
|
||||
|
||||
if (ct.BottomBorders != null && ct.BottomBorders.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < ct.BottomBorders.Length; i++)
|
||||
{
|
||||
using (Pen pen = new Pen(ct.BottomBorders[i]))
|
||||
g.DrawLine(pen, bounds.X, bounds.Bottom - i - 1, bounds.Right, bounds.Bottom - i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (bar.ResizeHandleVisible)
|
||||
{
|
||||
Form form = bar.FindForm();
|
||||
if (form != null && form.WindowState == FormWindowState.Normal)
|
||||
DevComponents.DotNetBar.Rendering.ResizeHandlePainter.DrawResizeHandle(
|
||||
g, bounds, ct.ResizeMarkerLightColor, ct.ResizeMarkerColor, (bar.RightToLeft == RightToLeft.Yes));
|
||||
}
|
||||
|
||||
#if TRIAL
|
||||
Rectangle tr = bounds;
|
||||
tr.Inflate(-2, -2);
|
||||
using(Font font=new Font(bar.Font.FontFamily, 8f, FontStyle.Regular))
|
||||
TextDrawing.DrawString(g, "DotNetBar Trial", font, Color.FromArgb(80, Color.Black), tr, eTextFormat.Bottom | eTextFormat.HorizontalCenter);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using DevComponents.DotNetBar.Ribbon;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
class MetroSwitchButtonPainter : Office2010SwitchButtonPainter
|
||||
{
|
||||
public override void Paint(SwitchButtonRenderEventArgs e)
|
||||
{
|
||||
SwitchButtonItem switchButton = e.SwitchButtonItem;
|
||||
bool enabled = switchButton.Enabled;
|
||||
SwitchButtonColorTable colorTable = enabled ? this.ColorTable.SwitchButton.Default : this.ColorTable.SwitchButton.Disabled;
|
||||
if (colorTable == null) colorTable = new SwitchButtonColorTable();
|
||||
|
||||
Rectangle bounds = switchButton.Bounds;
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
int buttonWidth = Dpi.Width(switchButton.ButtonWidth);
|
||||
Padding margin = Dpi.Size(switchButton.Margin);
|
||||
if (e.ItemPaintArgs != null && e.ItemPaintArgs.ContainerControl is AdvTree.AdvTree)
|
||||
{
|
||||
if (switchButton.ItemAlignment == eItemAlignment.Far)
|
||||
bounds.X = bounds.Right - margin.Right - buttonWidth;
|
||||
else if (switchButton.ItemAlignment == eItemAlignment.Center)
|
||||
bounds.X += (bounds.Width - buttonWidth) / 2;
|
||||
}
|
||||
else
|
||||
bounds.X = bounds.Right - margin.Right - buttonWidth;
|
||||
bounds.Width = buttonWidth;
|
||||
int buttonHeight = Dpi.Height(switchButton.ButtonHeight);
|
||||
bounds.Y += margin.Top + (bounds.Height - margin.Vertical - buttonHeight) / 2;
|
||||
bounds.Height = buttonHeight;
|
||||
switchButton.ButtonBounds = bounds;
|
||||
bool rendersOnGlass = (e.ItemPaintArgs != null && e.ItemPaintArgs.GlassEnabled && (switchButton.Parent is CaptionItemContainer && !(e.ItemPaintArgs.ContainerControl is QatToolbar) || (switchButton.Parent is RibbonTabItemContainer && switchButton.EffectiveStyle == eDotNetBarStyle.Office2010)));
|
||||
|
||||
if (switchButton.TextVisible && !string.IsNullOrEmpty(switchButton.Text))
|
||||
{
|
||||
Rectangle textRect = switchButton.Bounds;
|
||||
Padding textPadding = Dpi.Size(switchButton.TextPadding);
|
||||
textRect.Width -= buttonWidth + margin.Right + textPadding.Horizontal;
|
||||
textRect.Y += textPadding.Top;
|
||||
textRect.X += textPadding.Left;
|
||||
textRect.Height -= textPadding.Vertical;
|
||||
bool rtl = e.RightToLeft;
|
||||
Color textColor = (switchButton.TextColor.IsEmpty || !enabled) ? colorTable.TextColor : switchButton.TextColor;
|
||||
Font textFont = e.Font;
|
||||
eTextFormat tf = eTextFormat.Left | eTextFormat.VerticalCenter;
|
||||
if (switchButton.TextMarkupBody != null)
|
||||
{
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, textFont, textColor, rtl);
|
||||
d.HotKeyPrefixVisible = !((tf & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
|
||||
if ((tf & eTextFormat.VerticalCenter) == eTextFormat.VerticalCenter)
|
||||
textRect.Y = switchButton.TopInternal + (switchButton.Bounds.Height - switchButton.TextMarkupBody.Bounds.Height) / 2;
|
||||
else if ((tf & eTextFormat.Bottom) == eTextFormat.Bottom)
|
||||
textRect.Y += (switchButton.TextMarkupBody.Bounds.Height - textRect.Height) + 1;
|
||||
textRect.Height = switchButton.TextMarkupBody.Bounds.Height;
|
||||
switchButton.TextMarkupBody.Bounds = textRect;
|
||||
switchButton.TextMarkupBody.Render(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
if (rendersOnGlass)
|
||||
{
|
||||
if (!e.ItemPaintArgs.CachedPaint)
|
||||
Office2007RibbonControlPainter.PaintTextOnGlass(g, switchButton.Text, textFont, textRect, TextDrawing.GetTextFormat(tf));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
TextDrawing.DrawString(g, switchButton.Text, textFont, textColor, textRect, tf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool switchState = switchButton.Value;
|
||||
string offText = switchButton.OffText;
|
||||
string onText = switchButton.OnText;
|
||||
Font font = (switchButton.SwitchFont == null) ? new Font(e.Font, FontStyle.Bold) : switchButton.SwitchFont;
|
||||
Color textOffColor = (switchButton.OffTextColor.IsEmpty || !enabled) ? colorTable.OffTextColor : switchButton.OffTextColor;
|
||||
Color textOnColor = (switchButton.OnTextColor.IsEmpty || !enabled) ? colorTable.OnTextColor : switchButton.OnTextColor;
|
||||
|
||||
int switchWidth = Dpi.Width(switchButton.SwitchWidth);
|
||||
int switchX = Math.Min(bounds.X + switchButton.SwitchOffset, bounds.Right);
|
||||
if (switchState)
|
||||
{
|
||||
switchX = Math.Max(bounds.Right - switchWidth - switchButton.SwitchOffset, bounds.X);
|
||||
}
|
||||
|
||||
Color borderColor = (switchButton.BorderColor.IsEmpty || !enabled) ? colorTable.BorderColor : switchButton.BorderColor;
|
||||
Color offBackgroundColor = (switchButton.OffBackColor.IsEmpty || !enabled) ? colorTable.OffBackColor : switchButton.OffBackColor;
|
||||
Color onBackgroundColor = (switchButton.OnBackColor.IsEmpty || !enabled) ? colorTable.OnBackColor : switchButton.OnBackColor;
|
||||
|
||||
// Main control border
|
||||
DisplayHelp.DrawRectangle(g, borderColor, bounds);
|
||||
|
||||
// Set clip
|
||||
Rectangle innerBoundsClip = bounds;
|
||||
innerBoundsClip.Inflate(-2, -2);
|
||||
GraphicsPath innerClipPath = new GraphicsPath();
|
||||
innerClipPath.AddRectangle(innerBoundsClip);
|
||||
Region oldClip = g.Clip;
|
||||
g.SetClip(innerClipPath, System.Drawing.Drawing2D.CombineMode.Intersect);
|
||||
innerClipPath.Dispose();
|
||||
|
||||
|
||||
// Draw On Background, it is to the left of the switch
|
||||
Rectangle onBounds = new Rectangle(switchX - (bounds.Width - switchWidth), bounds.Y, bounds.Width - switchWidth + 2, bounds.Height);
|
||||
switchButton.OnPartBounds = onBounds;
|
||||
onBounds.Inflate(-2, -2);
|
||||
DisplayHelp.FillRectangle(g, onBounds, onBackgroundColor);
|
||||
if (!string.IsNullOrEmpty(onText))
|
||||
{
|
||||
// Draw On Text
|
||||
if (rendersOnGlass && BarUtilities.UseTextRenderer)
|
||||
TextDrawing.DrawStringLegacy(g, onText, font, textOnColor, onBounds, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter);
|
||||
else
|
||||
TextDrawing.DrawString(g, onText, font, textOnColor, onBounds, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.NoClipping);
|
||||
}
|
||||
|
||||
// Draw Off Background, it is on the right of the switch
|
||||
Rectangle offBounds = new Rectangle(switchX + switchWidth - 2, bounds.Y, bounds.Width - switchWidth + 2, bounds.Height);
|
||||
switchButton.OffPartBounds = offBounds;
|
||||
offBounds.Inflate(-2, -2);
|
||||
DisplayHelp.FillRectangle(g, offBounds, offBackgroundColor);
|
||||
|
||||
if (!string.IsNullOrEmpty(offText))
|
||||
{
|
||||
// Draw Off Text
|
||||
if (rendersOnGlass && BarUtilities.UseTextRenderer)
|
||||
TextDrawing.DrawStringLegacy(g, offText, font, textOffColor, offBounds, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter);
|
||||
else
|
||||
TextDrawing.DrawString(g, offText, font, textOffColor, offBounds, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.NoClipping);
|
||||
}
|
||||
|
||||
// Restore old clip
|
||||
g.Clip = oldClip;
|
||||
oldClip.Dispose();
|
||||
|
||||
// Draw Switch on top
|
||||
Rectangle switchBounds = new Rectangle(switchX, bounds.Y, switchWidth, bounds.Height);
|
||||
switchButton.SwitchBounds = switchBounds;
|
||||
Color switchBorderColor = (switchButton.SwitchBorderColor.IsEmpty || !enabled) ? colorTable.SwitchBorderColor : switchButton.SwitchBorderColor;
|
||||
Color switchFillColor = (switchButton.SwitchBackColor.IsEmpty || !enabled) ? colorTable.SwitchBackColor : switchButton.SwitchBackColor;
|
||||
if (!colorTable.SwitchOnBackColor.IsEmpty && switchButton.Value && switchButton.SwitchBackColor.IsEmpty)
|
||||
switchFillColor = colorTable.SwitchOnBackColor;
|
||||
|
||||
DisplayHelp.FillRectangle(g, switchBounds, switchFillColor);
|
||||
if(!switchBorderColor.IsEmpty)
|
||||
DisplayHelp.DrawRectangle(g, switchBorderColor, switchBounds);
|
||||
|
||||
if (switchButton.IsReadOnly && switchButton.ShowReadOnlyMarker)
|
||||
{
|
||||
Color markerColor = switchButton.ReadOnlyMarkerColor;
|
||||
Rectangle marker = new Rectangle(switchBounds.X + (switchBounds.Width - 7) / 2, switchBounds.Y + (switchBounds.Height - 10) / 2, 7, 10);
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.None;
|
||||
using (SolidBrush brush = new SolidBrush(markerColor))
|
||||
{
|
||||
g.FillRectangle(brush, new Rectangle(marker.X, marker.Y + 4, marker.Width, marker.Height - 4));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(marker.X + 3, marker.Y + 5, 1, 2));
|
||||
}
|
||||
using (Pen pen = new Pen(markerColor, 1))
|
||||
{
|
||||
g.DrawLine(pen, marker.X + 2, marker.Y + 0, marker.X + 4, marker.Y + 0);
|
||||
g.DrawLine(pen, marker.X + 1, marker.Y + 1, marker.X + 1, marker.Y + 3);
|
||||
g.DrawLine(pen, marker.X + 5, marker.Y + 1, marker.X + 5, marker.Y + 3);
|
||||
}
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroTabItemPainter : MetroRenderer
|
||||
{
|
||||
public override void Render(MetroRendererInfo renderingInfo)
|
||||
{
|
||||
MetroTabItem tab = (MetroTabItem)renderingInfo.Control;
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
MetroTabItemColorTable cti = renderingInfo.ColorTable.MetroTab.MetroTabItem;
|
||||
MetroTabItemStateColorTable color = cti.Default;
|
||||
if (!tab.Enabled)
|
||||
color = cti.Disabled;
|
||||
else if (tab.Checked)
|
||||
color = cti.Selected;
|
||||
else if (tab.IsMouseDown && cti.Pressed != null)
|
||||
color = cti.Pressed;
|
||||
else if (tab.IsMouseOver && cti.MouseOver != null)
|
||||
color = cti.MouseOver;
|
||||
|
||||
Rectangle bounds = tab.Bounds;
|
||||
Rectangle textBounds = tab.TextRenderBounds;
|
||||
Rectangle imageBounds = tab.ImageRenderBounds;
|
||||
CompositeImage image = tab.GetImage();
|
||||
|
||||
if (color.Background != null)
|
||||
{
|
||||
Font font = renderingInfo.DefaultFont;
|
||||
if (!tab.Checked && font.Bold && renderingInfo.DefaultPlainFont != null)
|
||||
font = renderingInfo.DefaultPlainFont;
|
||||
ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(color.Background, g, bounds);
|
||||
ElementStyleDisplay.Paint(di);
|
||||
|
||||
if (image != null && tab.ButtonStyle != eButtonStyle.TextOnlyAlways)
|
||||
{
|
||||
if (imageBounds.IsEmpty)
|
||||
imageBounds = GetImageRectangle(tab, image);
|
||||
if (textBounds.IsEmpty)
|
||||
textBounds = GetTextRectangle(tab, image, imageBounds);
|
||||
|
||||
}
|
||||
else if (textBounds.IsEmpty)
|
||||
textBounds = bounds;
|
||||
|
||||
if (tab.TextMarkupBody == null)
|
||||
{
|
||||
di.Bounds = textBounds;
|
||||
|
||||
ElementStyleDisplay.PaintText(di, tab.Text, font);
|
||||
}
|
||||
else
|
||||
{
|
||||
eTextFormat stringFormat = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter;
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, color.Background.TextColor, renderingInfo.RightToLeft);
|
||||
d.HotKeyPrefixVisible = !((stringFormat & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
|
||||
d.ContextObject = tab;
|
||||
Rectangle mr = new Rectangle(textBounds.X, textBounds.Y + (textBounds.Height - tab.TextMarkupBody.Bounds.Height) / 2 + 1, tab.TextMarkupBody.Bounds.Width, tab.TextMarkupBody.Bounds.Height);
|
||||
if ((stringFormat & eTextFormat.HorizontalCenter) != 0)
|
||||
mr.Offset((textBounds.Width - mr.Width) / 2, 0);
|
||||
if (tab._FixedSizeCenterText) mr.Y--;
|
||||
tab.TextMarkupBody.Bounds = mr;
|
||||
tab.TextMarkupBody.Render(d);
|
||||
}
|
||||
tab.TextRenderBounds = textBounds;
|
||||
tab.ImageRenderBounds = imageBounds;
|
||||
}
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
if (!tab.IsMouseOver && tab.HotTrackingStyle == eHotTrackingStyle.Color)
|
||||
{
|
||||
// Draw gray-scale image for this hover style...
|
||||
float[][] array = new float[5][];
|
||||
array[0] = new float[5] { 0.2125f, 0.2125f, 0.2125f, 0, 0 };
|
||||
array[1] = new float[5] { 0.5f, 0.5f, 0.5f, 0, 0 };
|
||||
array[2] = new float[5] { 0.0361f, 0.0361f, 0.0361f, 0, 0 };
|
||||
array[3] = new float[5] { 0, 0, 0, 1, 0 };
|
||||
array[4] = new float[5] { 0.2f, 0.2f, 0.2f, 0, 1 };
|
||||
ColorMatrix grayMatrix = new ColorMatrix(array);
|
||||
ImageAttributes att = new ImageAttributes();
|
||||
att.SetColorMatrix(grayMatrix);
|
||||
image.DrawImage(g, imageBounds, 0, 0, image.ActualWidth, image.ActualHeight, GraphicsUnit.Pixel, att);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.DrawImage(g, imageBounds);
|
||||
}
|
||||
}
|
||||
|
||||
//g.FillRectangle(Brushes.Red, bounds);
|
||||
}
|
||||
|
||||
private Rectangle GetImageRectangle(MetroTabItem tab, CompositeImage image)
|
||||
{
|
||||
Rectangle imageRect = Rectangle.Empty;
|
||||
// Calculate image position
|
||||
if (image != null)
|
||||
{
|
||||
Size imageSize = tab.ImageSize;
|
||||
|
||||
if (tab.ImagePosition == eImagePosition.Top || tab.ImagePosition == eImagePosition.Bottom)
|
||||
imageRect = new Rectangle(tab.ImageDrawRect.X, tab.ImageDrawRect.Y, tab.DisplayRectangle.Width, tab.ImageDrawRect.Height);
|
||||
else if(tab.ImagePosition == eImagePosition.Left)
|
||||
imageRect = new Rectangle(tab.ImageDrawRect.X+4, tab.ImageDrawRect.Y, tab.ImageDrawRect.Width, tab.ImageDrawRect.Height);
|
||||
else if (tab.ImagePosition == eImagePosition.Right)
|
||||
imageRect = new Rectangle(tab.ImageDrawRect.X + tab.ImagePaddingHorizontal+4, tab.ImageDrawRect.Y, tab.ImageDrawRect.Width, tab.ImageDrawRect.Height);
|
||||
imageRect.Offset(tab.DisplayRectangle.Left, tab.DisplayRectangle.Top);
|
||||
imageRect.Offset((imageRect.Width - imageSize.Width) / 2, (imageRect.Height - imageSize.Height) / 2);
|
||||
|
||||
imageRect.Width = imageSize.Width;
|
||||
imageRect.Height = imageSize.Height;
|
||||
}
|
||||
|
||||
return imageRect;
|
||||
}
|
||||
|
||||
private Rectangle GetTextRectangle(MetroTabItem tab, CompositeImage image, Rectangle imageBounds)
|
||||
{
|
||||
Rectangle itemRect = tab.DisplayRectangle;
|
||||
Rectangle textRect = tab.TextDrawRect;
|
||||
|
||||
if (tab.ImagePosition == eImagePosition.Top || tab.ImagePosition == eImagePosition.Bottom)
|
||||
{
|
||||
textRect = new Rectangle(1, textRect.Y, itemRect.Width - 2, textRect.Height);
|
||||
}
|
||||
textRect.Offset(itemRect.Left, itemRect.Top);
|
||||
|
||||
if (tab.ImagePosition == eImagePosition.Left)
|
||||
textRect.X = imageBounds.Right + tab.ImagePaddingHorizontal;
|
||||
|
||||
if (textRect.Right > itemRect.Right)
|
||||
textRect.Width = itemRect.Right - textRect.Left;
|
||||
|
||||
return textRect;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,365 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroTabStripPainter : MetroRenderer
|
||||
{
|
||||
public override void Render(MetroRendererInfo renderingInfo)
|
||||
{
|
||||
MetroTabStrip strip = (MetroTabStrip)renderingInfo.Control;
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
MetroTabStripColorTable ct = renderingInfo.ColorTable.MetroTab.TabStrip;
|
||||
Rectangle bounds = strip.ClientRectangle;
|
||||
|
||||
if (ct.BackgroundStyle != null)
|
||||
{
|
||||
ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(ct.BackgroundStyle, g, bounds);
|
||||
ElementStyleDisplay.PaintBackground(di);
|
||||
}
|
||||
|
||||
if (strip.CaptionVisible)
|
||||
{
|
||||
if (strip.CaptionBounds.IsEmpty || strip.SystemCaptionItemBounds.IsEmpty || strip.QuickToolbarBounds.IsEmpty)
|
||||
SetQatAndCaptionItemBounds(strip, renderingInfo);
|
||||
Color captionTextColor = renderingInfo.ColorTable.MetroTab.ActiveCaptionText;
|
||||
eTextFormat textFormat = renderingInfo.ColorTable.MetroTab.CaptionTextFormat;
|
||||
System.Windows.Forms.Form form = strip.FindForm();
|
||||
bool isFormActive = true;
|
||||
if (form != null && (form != System.Windows.Forms.Form.ActiveForm && form.MdiParent == null ||
|
||||
form.MdiParent != null && form.MdiParent.ActiveMdiChild != form))
|
||||
{
|
||||
captionTextColor = renderingInfo.ColorTable.MetroTab.InactiveCaptionText;
|
||||
isFormActive = false;
|
||||
}
|
||||
|
||||
Font font = SystemFonts.DefaultFont; // System.Windows.Forms.SystemInformation.MenuFont;
|
||||
bool disposeFont = true;
|
||||
if (strip.CaptionFont != null)
|
||||
{
|
||||
font.Dispose();
|
||||
font = strip.CaptionFont;
|
||||
disposeFont = false;
|
||||
}
|
||||
string text = strip.TitleText;
|
||||
if (string.IsNullOrEmpty(text) && form != null) text = form.Text;
|
||||
bool isTitleTextMarkup = strip.TitleTextMarkupBody != null;
|
||||
Rectangle captionRect = strip.CaptionBounds;
|
||||
const int CAPTION_TEXT_PADDING = 12;
|
||||
captionRect.X += CAPTION_TEXT_PADDING;
|
||||
captionRect.Width -= CAPTION_TEXT_PADDING;
|
||||
|
||||
if(StyleManager.Style == eStyle.OfficeMobile2014)
|
||||
{
|
||||
captionRect.Y -= 2;
|
||||
captionRect.Height -= 2;
|
||||
// Center text in center of window instead of center of available space
|
||||
if (!strip.SystemCaptionItemBounds.IsEmpty && captionRect.Width > strip.SystemCaptionItemBounds.Width)
|
||||
{
|
||||
captionRect.X += strip.SystemCaptionItemBounds.Width / 2 + 18;
|
||||
captionRect.Width -= strip.SystemCaptionItemBounds.Width / 2 +18;
|
||||
}
|
||||
if (!strip.QuickToolbarBounds.IsEmpty && captionRect.Width > strip.QuickToolbarBounds.Width)
|
||||
{
|
||||
captionRect.X -= strip.QuickToolbarBounds.Width / 2;
|
||||
captionRect.Width += strip.QuickToolbarBounds.Width / 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTitleTextMarkup)
|
||||
TextDrawing.DrawString(g, text, font, captionTextColor, captionRect, textFormat);
|
||||
else
|
||||
{
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, captionTextColor, strip.RightToLeft == System.Windows.Forms.RightToLeft.Yes, captionRect, false);
|
||||
d.AllowMultiLine = false;
|
||||
d.IgnoreFormattingColors = !isFormActive;
|
||||
TextMarkup.BodyElement body = strip.TitleTextMarkupBody;
|
||||
if (strip.TitleTextMarkupLastArrangeBounds != captionRect)
|
||||
{
|
||||
body.Measure(captionRect.Size, d);
|
||||
body.Arrange(captionRect, d);
|
||||
strip.TitleTextMarkupLastArrangeBounds = captionRect;
|
||||
Rectangle mr = body.Bounds;
|
||||
if (mr.Width < captionRect.Width)
|
||||
mr.Offset((captionRect.Width - mr.Width) / 2, 0);
|
||||
if (mr.Height < captionRect.Height)
|
||||
mr.Offset(0, (captionRect.Height - mr.Height) / 2);
|
||||
body.Bounds = mr;
|
||||
}
|
||||
Region oldClip = g.Clip;
|
||||
g.SetClip(captionRect, CombineMode.Intersect);
|
||||
body.Render(d);
|
||||
g.Clip = oldClip;
|
||||
if (oldClip != null) oldClip.Dispose();
|
||||
}
|
||||
|
||||
if (disposeFont) font.Dispose();
|
||||
}
|
||||
|
||||
//g.FillRectangle(Brushes.Yellow, strip.QuickToolbarBounds);
|
||||
//g.FillRectangle(Brushes.Green, strip.CaptionBounds);
|
||||
//g.FillRectangle(Brushes.Indigo, strip.SystemCaptionItemBounds);
|
||||
|
||||
}
|
||||
|
||||
private void SetQatAndCaptionItemBounds(MetroTabStrip strip,MetroRendererInfo renderingInfo)
|
||||
{
|
||||
if (!strip.CaptionVisible)
|
||||
return;
|
||||
bool rightToLeft = (strip.RightToLeft == System.Windows.Forms.RightToLeft.Yes);
|
||||
|
||||
System.Windows.Forms.Form form = strip.FindForm();
|
||||
bool isMaximized = false;
|
||||
if (form != null) isMaximized = form.WindowState == System.Windows.Forms.FormWindowState.Maximized;
|
||||
|
||||
// Get right most X position of the Quick Access Toolbar
|
||||
int right = 0, sysLeft = 0;
|
||||
Size qatSize = Size.Empty;
|
||||
for (int i = strip.QuickToolbarItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
BaseItem item = strip.QuickToolbarItems[i];
|
||||
if (!item.Visible || !item.Displayed)
|
||||
continue;
|
||||
if (item is QatCustomizeItem) qatSize = item.DisplayRectangle.Size;
|
||||
if (item.ItemAlignment == eItemAlignment.Near && item.Visible && i > 0)
|
||||
{
|
||||
if (rightToLeft)
|
||||
right = item.DisplayRectangle.X;
|
||||
else
|
||||
right = item.DisplayRectangle.Right;
|
||||
break;
|
||||
}
|
||||
else if (item.ItemAlignment == eItemAlignment.Far && item.Visible)
|
||||
{
|
||||
if (rightToLeft)
|
||||
sysLeft = item.DisplayRectangle.Right;
|
||||
else
|
||||
sysLeft = item.DisplayRectangle.X;
|
||||
}
|
||||
}
|
||||
|
||||
if (strip.CaptionContainerItem is CaptionItemContainer && ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems != null)
|
||||
{
|
||||
if (rightToLeft)
|
||||
right = ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems.DisplayRectangle.X;
|
||||
else
|
||||
right = ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems.DisplayRectangle.Right;
|
||||
qatSize = ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems.DisplayRectangle.Size;
|
||||
}
|
||||
|
||||
Rectangle r = new Rectangle(right, 2, strip.CaptionContainerItem.WidthInternal - right - (strip.CaptionContainerItem.WidthInternal-sysLeft), strip.GetTotalCaptionHeight());
|
||||
strip.CaptionBounds = r;
|
||||
|
||||
if (sysLeft > 0)
|
||||
{
|
||||
if (rightToLeft)
|
||||
strip.SystemCaptionItemBounds = new Rectangle(r.X, r.Y, sysLeft, r.Height);
|
||||
else
|
||||
strip.SystemCaptionItemBounds = new Rectangle(sysLeft, r.Y, strip.CaptionContainerItem.WidthInternal - sysLeft, r.Height);
|
||||
}
|
||||
|
||||
if (right == 0 || r.Height <= 0 || r.Width <= 0)
|
||||
return;
|
||||
|
||||
BaseItem startButton = strip.GetApplicationButton();
|
||||
if (startButton != null)
|
||||
{
|
||||
int startIndex = strip.QuickToolbarItems.IndexOf(startButton);
|
||||
if (strip.QuickToolbarItems.Count - 1 > startIndex)
|
||||
{
|
||||
BaseItem firstItem = strip.QuickToolbarItems[startIndex + 1];
|
||||
if (rightToLeft)
|
||||
{
|
||||
r.Width -= r.Right - firstItem.DisplayRectangle.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Width -= firstItem.DisplayRectangle.X - r.X;
|
||||
r.X = firstItem.DisplayRectangle.X;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r.Height = ((CaptionItemContainer)strip.CaptionContainerItem).MaxItemHeight + 6;
|
||||
r.X = 0;
|
||||
r.Width = right;
|
||||
strip.QuickToolbarBounds = r;
|
||||
}
|
||||
|
||||
//private void PaintCaptionText(MetroTabStrip rs)
|
||||
//{
|
||||
// if (!rs.CaptionVisible || rs.CaptionBounds.IsEmpty)
|
||||
// return;
|
||||
|
||||
// Graphics g = e.Graphics;
|
||||
// bool isMaximized = false;
|
||||
// bool isFormActive = true;
|
||||
// Rendering.Office2007FormStateColorTable formct = m_ColorTable.Form.Active;
|
||||
// System.Windows.Forms.Form form = rs.FindForm();
|
||||
// if (form != null && (form != System.Windows.Forms.Form.ActiveForm && form.MdiParent == null ||
|
||||
// form.MdiParent != null && form.MdiParent.ActiveMdiChild != form))
|
||||
// {
|
||||
// formct = m_ColorTable.Form.Inactive;
|
||||
// isFormActive = false;
|
||||
// }
|
||||
// string text = e.RibbonControl.TitleText;
|
||||
// string plainText = text;
|
||||
// bool isTitleTextMarkup = e.RibbonControl.RibbonStrip.TitleTextMarkupBody != null;
|
||||
// if (isTitleTextMarkup)
|
||||
// plainText = e.RibbonControl.RibbonStrip.TitleTextMarkupBody.PlainText;
|
||||
// if (form != null)
|
||||
// {
|
||||
// if (text == "")
|
||||
// {
|
||||
// text = form.Text;
|
||||
// plainText = text;
|
||||
// }
|
||||
// isMaximized = form.WindowState == System.Windows.Forms.FormWindowState.Maximized;
|
||||
// }
|
||||
|
||||
// Rectangle captionRect = rs.CaptionBounds;
|
||||
|
||||
// // Exclude quick access toolbar if any
|
||||
// if (!rs.QuickToolbarBounds.IsEmpty)
|
||||
// DisplayHelp.ExcludeEdgeRect(ref captionRect, rs.QuickToolbarBounds);
|
||||
// else
|
||||
// {
|
||||
// BaseItem sb = e.RibbonControl.GetApplicationButton();
|
||||
// if (sb != null && sb.Visible && sb.Displayed)
|
||||
// DisplayHelp.ExcludeEdgeRect(ref captionRect, sb.Bounds);
|
||||
// else
|
||||
// DisplayHelp.ExcludeEdgeRect(ref captionRect, new Rectangle(0, 0, 22, 22)); // The system button in top-left corner
|
||||
// }
|
||||
|
||||
// if (!rs.SystemCaptionItemBounds.IsEmpty)
|
||||
// DisplayHelp.ExcludeEdgeRect(ref captionRect, rs.SystemCaptionItemBounds);
|
||||
|
||||
|
||||
// // Array of the rectangles after they are split
|
||||
// ArrayList rects = new ArrayList(5);
|
||||
// ArrayList tempRemoveList = new ArrayList(5);
|
||||
// // Exclude Context Tabs Captions if any
|
||||
// if (rs.TabGroupsVisible)
|
||||
// {
|
||||
// foreach (RibbonTabItemGroup group in rs.TabGroups)
|
||||
// {
|
||||
// foreach (Rectangle r in group.DisplayPositions)
|
||||
// {
|
||||
// if (rects.Count > 0)
|
||||
// {
|
||||
// tempRemoveList.Clear();
|
||||
// Rectangle[] arrCopy = new Rectangle[rects.Count];
|
||||
// rects.CopyTo(arrCopy);
|
||||
// for (int irc = 0; irc < arrCopy.Length; irc++)
|
||||
// {
|
||||
// if (arrCopy[irc].IntersectsWith(r))
|
||||
// {
|
||||
// tempRemoveList.Add(irc);
|
||||
// Rectangle[] splitRects = DisplayHelp.ExcludeRectangle(arrCopy[irc], r);
|
||||
// rects.AddRange(splitRects);
|
||||
// }
|
||||
// }
|
||||
// foreach (int idx in tempRemoveList)
|
||||
// rects.RemoveAt(idx);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (r.IntersectsWith(captionRect))
|
||||
// {
|
||||
// Rectangle[] splitRects = DisplayHelp.ExcludeRectangle(captionRect, r);
|
||||
// if (splitRects.Length > 0)
|
||||
// {
|
||||
// rects.AddRange(splitRects);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Font font = System.Windows.Forms.SystemInformation.MenuFont;
|
||||
// bool disposeFont = true;
|
||||
// if (rs.CaptionFont != null)
|
||||
// {
|
||||
// font.Dispose();
|
||||
// font = rs.CaptionFont;
|
||||
// disposeFont = false;
|
||||
// }
|
||||
// Size textSize = Size.Empty;
|
||||
// if (isTitleTextMarkup)
|
||||
// {
|
||||
// textSize = e.RibbonControl.RibbonStrip.TitleTextMarkupBody.Bounds.Size;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// textSize = TextDrawing.MeasureString(g, plainText, font);
|
||||
// }
|
||||
|
||||
// if (rects.Count > 0)
|
||||
// {
|
||||
// rs.CaptionTextBounds = (Rectangle[])rects.ToArray(typeof(Rectangle));
|
||||
// if (e.RibbonControl.RightToLeft == System.Windows.Forms.RightToLeft.No)
|
||||
// rects.Reverse();
|
||||
// captionRect = Rectangle.Empty;
|
||||
// foreach (Rectangle r in rects)
|
||||
// {
|
||||
// if (r.Width >= textSize.Width)
|
||||
// {
|
||||
// captionRect = r;
|
||||
// break;
|
||||
// }
|
||||
// else if (r.Width > captionRect.Width)
|
||||
// captionRect = r;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// rs.CaptionTextBounds = new Rectangle[] { captionRect };
|
||||
|
||||
// if (captionRect.Width > 6 && captionRect.Height > 6)
|
||||
// {
|
||||
// if (e.GlassEnabled && e.ItemPaintArgs != null && e.ItemPaintArgs.ThemeWindow != null && !e.RibbonControl.IsDesignMode)
|
||||
// {
|
||||
// if (!e.ItemPaintArgs.CachedPaint || isMaximized)
|
||||
// PaintGlassText(g, plainText, font, captionRect, isMaximized);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (!isTitleTextMarkup)
|
||||
// TextDrawing.DrawString(g, plainText, font, formct.CaptionText, captionRect, eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter | eTextFormat.EndEllipsis | eTextFormat.NoPrefix);
|
||||
// else
|
||||
// {
|
||||
// TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, formct.CaptionText, e.RibbonControl.RightToLeft == System.Windows.Forms.RightToLeft.Yes, captionRect, false);
|
||||
// d.AllowMultiLine = false;
|
||||
// d.IgnoreFormattingColors = !isFormActive;
|
||||
// TextMarkup.BodyElement body = e.RibbonControl.RibbonStrip.TitleTextMarkupBody;
|
||||
// if (e.RibbonControl.RibbonStrip.TitleTextMarkupLastArrangeBounds != captionRect)
|
||||
// {
|
||||
// body.Measure(captionRect.Size, d);
|
||||
// body.Arrange(captionRect, d);
|
||||
// e.RibbonControl.RibbonStrip.TitleTextMarkupLastArrangeBounds = captionRect;
|
||||
// Rectangle mr = body.Bounds;
|
||||
// if (mr.Width < captionRect.Width)
|
||||
// mr.Offset((captionRect.Width - mr.Width) / 2, 0);
|
||||
// if (mr.Height < captionRect.Height)
|
||||
// mr.Offset(0, (captionRect.Height - mr.Height) / 2);
|
||||
// body.Bounds = mr;
|
||||
// }
|
||||
// Region oldClip = g.Clip;
|
||||
// g.SetClip(captionRect, CombineMode.Intersect);
|
||||
// body.Render(d);
|
||||
// g.Clip = oldClip;
|
||||
// if (oldClip != null) oldClip.Dispose();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (disposeFont) font.Dispose();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,345 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroTileItemPainter : MetroRenderer
|
||||
{
|
||||
private static readonly int InflatePixels = 1;
|
||||
private static readonly int InflatePixelsMouseDown = 2;
|
||||
private static readonly int DragEffectInflatePixels = -4;
|
||||
private static readonly int DragInsertOffsetPixels = 10;
|
||||
|
||||
//private static readonly Point ImageIndent = new Point(2, 2);
|
||||
public override void Render(MetroRendererInfo renderingInfo)
|
||||
{
|
||||
MetroTileItem item = (MetroTileItem)renderingInfo.Control;
|
||||
if (item.Frames.Count == 0)
|
||||
{
|
||||
using (HatchBrush brush = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Red))
|
||||
renderingInfo.PaintEventArgs.Graphics.FillRectangle(brush, item.Bounds);
|
||||
return;
|
||||
}
|
||||
|
||||
Matrix currentTransform = null;
|
||||
float zoom = 0.95f;
|
||||
System.Drawing.Drawing2D.Matrix mx = null;
|
||||
|
||||
if (renderingInfo.ItemPaintArgs.DragInProgress)
|
||||
{
|
||||
currentTransform = renderingInfo.PaintEventArgs.Graphics.Transform;
|
||||
|
||||
mx = new System.Drawing.Drawing2D.Matrix(zoom, 0, 0, zoom, 0, 0);
|
||||
float offsetX = (item.WidthInternal * (1.0f / zoom) - item.WidthInternal) / 2;
|
||||
float offsetY = (item.HeightInternal * (1.0f / zoom) - item.HeightInternal) / 2;
|
||||
mx.Translate(offsetX, offsetY);
|
||||
renderingInfo.PaintEventArgs.Graphics.Transform = mx;
|
||||
}
|
||||
|
||||
if (item.CurrentFrameOffset != 0 && item.LastFrame != item.CurrentFrame)
|
||||
{
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
if (currentTransform == null)
|
||||
currentTransform = g.Transform;
|
||||
g.TranslateTransform(0, -(item.HeightInternal - item.CurrentFrameOffset - InflatePixels * 2), MatrixOrder.Append);
|
||||
// Draw last frame first then offset the current frame
|
||||
RenderFrame(renderingInfo, item.LastFrame);
|
||||
if (mx != null)
|
||||
g.Transform = mx;
|
||||
else
|
||||
g.Transform = currentTransform;
|
||||
g.TranslateTransform(0, item.CurrentFrameOffset, MatrixOrder.Append);
|
||||
|
||||
RenderFrame(renderingInfo, item.CurrentFrame);
|
||||
}
|
||||
else
|
||||
RenderFrame(renderingInfo, item.CurrentFrame);
|
||||
|
||||
if (currentTransform != null)
|
||||
{
|
||||
renderingInfo.PaintEventArgs.Graphics.Transform = currentTransform;
|
||||
currentTransform.Dispose();
|
||||
}
|
||||
}
|
||||
private void RenderFrame(MetroRendererInfo renderingInfo, int frameIndex)
|
||||
{
|
||||
MetroTileItem item = (MetroTileItem)renderingInfo.Control;
|
||||
MetroTileFrame frame = item.Frames[frameIndex];
|
||||
MetroTileColorTable colorTable = renderingInfo.ColorTable.MetroTile;
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
Rectangle bounds = item.Bounds;
|
||||
Region clip = null;
|
||||
if (!item.DragStartPoint.IsEmpty) // When dragging tile moves with the mouse
|
||||
{
|
||||
bounds.Location = renderingInfo.ItemPaintArgs.ContainerControl.PointToClient(Control.MousePosition);
|
||||
bounds.Location.Offset(-item.DragStartPoint.X, -item.DragStartPoint.Y);
|
||||
clip = g.Clip;
|
||||
g.SetClip(bounds, CombineMode.Replace);
|
||||
}
|
||||
Control control = item.ContainerControl as Control;
|
||||
bounds.Inflate(-InflatePixels, -InflatePixels);
|
||||
if (item.IsLeftMouseButtonDown)
|
||||
bounds.Inflate(-InflatePixelsMouseDown, -InflatePixelsMouseDown);
|
||||
else if (item.IsMouseOver)
|
||||
bounds.Inflate(InflatePixels, InflatePixels);
|
||||
|
||||
//if (renderingInfo.ItemPaintArgs.DragInProgress)
|
||||
// bounds.Inflate(DragEffectInflatePixels, DragEffectInflatePixels);
|
||||
|
||||
eDesignInsertPosition insertMarker = item.DesignInsertMarker;
|
||||
if (insertMarker == eDesignInsertPosition.After)
|
||||
{
|
||||
if (item.IsDesignMarkHorizontal)
|
||||
bounds.Offset(-DragInsertOffsetPixels, 0);
|
||||
else
|
||||
bounds.Offset(0, -DragInsertOffsetPixels);
|
||||
g.ResetClip();
|
||||
}
|
||||
else if (insertMarker == eDesignInsertPosition.Before)
|
||||
{
|
||||
if (item.IsDesignMarkHorizontal)
|
||||
bounds.Offset(DragInsertOffsetPixels, 0);
|
||||
else
|
||||
bounds.Offset(0, DragInsertOffsetPixels);
|
||||
g.ResetClip();
|
||||
}
|
||||
|
||||
bool dispose = false;
|
||||
bool enabled = item.GetEnabled(renderingInfo.ItemPaintArgs.ContainerControl);
|
||||
ElementStyle style = ElementStyleDisplay.GetElementStyle(frame.EffectiveStyle, out dispose);
|
||||
|
||||
if (bounds.Width > 2048) bounds.Width = 2048;
|
||||
if (bounds.Height > 1600) bounds.Height = 1600;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(style, g, bounds);
|
||||
ElementStyleDisplay.Paint(di);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(item.DisabledBackColor.IsEmpty ? renderingInfo.ColorTable.MetroPartColors.CanvasColorLighterShade : item.DisabledBackColor))
|
||||
g.FillRectangle(brush, bounds);
|
||||
}
|
||||
|
||||
Rectangle textRect = bounds;
|
||||
textRect.X += style.PaddingLeft;
|
||||
textRect.Y += style.PaddingTop;
|
||||
textRect.Width -= style.PaddingHorizontal;
|
||||
textRect.Height -= style.PaddingVertical;
|
||||
if (item.IsLeftMouseButtonDown)
|
||||
{
|
||||
textRect.Width += InflatePixelsMouseDown*2;
|
||||
textRect.Height += InflatePixelsMouseDown*2;
|
||||
}
|
||||
else if(item.IsMouseOver)
|
||||
textRect.Inflate(-InflatePixels, -InflatePixels);
|
||||
Size tileSize = Dpi.Size(item.TileSize);
|
||||
if (item.SubItems.Count > 0 && frameIndex < item.SubItems.Count)
|
||||
{
|
||||
BaseItem child = item.SubItems[frameIndex];
|
||||
if (child.Displayed)
|
||||
{
|
||||
child.TopInternal = bounds.Y + style.PaddingTop + ((bounds.Height - style.PaddingTop - frame.TitleTextBounds.Height) - child.HeightInternal) / 2;
|
||||
child.LeftInternal = bounds.X + style.PaddingLeft;
|
||||
child.WidthInternal = tileSize.Width - style.PaddingHorizontal;
|
||||
child.Paint(renderingInfo.ItemPaintArgs);
|
||||
}
|
||||
}
|
||||
|
||||
Image image = frame.Image;
|
||||
ContentAlignment imageTextAlign = frame.ImageTextAlignment;
|
||||
Color textColor = enabled ? style.TextColor : renderingInfo.ColorTable.MetroPartColors.CanvasColorLightShade;
|
||||
Color symbolColor = textColor;
|
||||
if (!frame.SymbolColor.IsEmpty) symbolColor = frame.SymbolColor;
|
||||
if (image != null || !string.IsNullOrEmpty(frame.SymbolRealized))
|
||||
{
|
||||
Font symFont = null;
|
||||
Rectangle imageRect = Rectangle.Empty;
|
||||
if (string.IsNullOrEmpty(frame.SymbolRealized))
|
||||
imageRect = new Rectangle(0, 0, Dpi.ImageWidth(image.Width), Dpi.ImageHeight(image.Height));
|
||||
else
|
||||
{
|
||||
symFont = Symbols.GetFont(frame.SymbolSize, frame.SymbolSet);
|
||||
Size imageSize = TextDrawing.MeasureString(g, frame.SymbolRealized, symFont);
|
||||
int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
|
||||
symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
|
||||
imageSize.Height -= descent;
|
||||
imageRect = new Rectangle(0, 0, imageSize.Width, imageSize.Height);
|
||||
}
|
||||
|
||||
imageRect.Offset(bounds.Location);
|
||||
|
||||
if (imageTextAlign == ContentAlignment.TopLeft)
|
||||
{
|
||||
textRect.X += (imageRect.Width + frame.ImageIndent.X);
|
||||
textRect.Width -= (imageRect.Width + frame.ImageIndent.X);
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.TopCenter)
|
||||
{
|
||||
imageRect.X += (tileSize.Width - imageRect.Width) / 2;
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
textRect.Y += (imageRect.Height + frame.ImageIndent.Y);
|
||||
textRect.Height -= (imageRect.Height);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.TopRight)
|
||||
{
|
||||
imageRect.X += (tileSize.Width - imageRect.Width - frame.ImageIndent.X);
|
||||
imageRect.Offset(0, frame.ImageIndent.Y);
|
||||
textRect.Width -= (imageRect.Width + frame.ImageIndent.X);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.BottomCenter)
|
||||
{
|
||||
imageRect.Offset((tileSize.Width - imageRect.Width) / 2, tileSize.Height - imageRect.Height);
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
textRect.Height -= (imageRect.Height);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.BottomLeft)
|
||||
{
|
||||
imageRect.Offset(0, tileSize.Height - imageRect.Height);
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
textRect.X += (imageRect.Width + frame.ImageIndent.X);
|
||||
textRect.Width -= (imageRect.Width + frame.ImageIndent.X);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.BottomRight)
|
||||
{
|
||||
imageRect.Offset((tileSize.Width - imageRect.Width - frame.ImageIndent.X), tileSize.Height - imageRect.Height);
|
||||
imageRect.Offset(0, frame.ImageIndent.Y);
|
||||
textRect.Width -= (imageRect.Width + frame.ImageIndent.X);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.MiddleCenter)
|
||||
{
|
||||
imageRect.Offset((tileSize.Width - imageRect.Width) / 2, (tileSize.Height - imageRect.Height) / 2);
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
textRect.Height = Math.Max(0, textRect.Bottom - imageRect.Bottom);
|
||||
textRect.Y = imageRect.Bottom + 1;
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.MiddleLeft)
|
||||
{
|
||||
imageRect.Offset(0, (tileSize.Height - imageRect.Height) / 2);
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
textRect.X += (imageRect.Width + frame.ImageIndent.X);
|
||||
textRect.Width -= (imageRect.Width + frame.ImageIndent.X);
|
||||
}
|
||||
else if (imageTextAlign == ContentAlignment.MiddleRight)
|
||||
{
|
||||
imageRect.Offset((tileSize.Width - imageRect.Width - frame.ImageIndent.X), (tileSize.Height - imageRect.Height) / 2);
|
||||
imageRect.Offset(0, frame.ImageIndent.Y);
|
||||
textRect.Width -= (imageRect.Width + frame.ImageIndent.X);
|
||||
}
|
||||
else
|
||||
imageRect.Offset(frame.ImageIndent.X, frame.ImageIndent.Y);
|
||||
|
||||
if (string.IsNullOrEmpty(frame.SymbolRealized))
|
||||
g.DrawImage(image, imageRect);
|
||||
else
|
||||
TextDrawing.DrawStringLegacy(g, frame.SymbolRealized, symFont, symbolColor, new Rectangle(imageRect.X, imageRect.Y, 0, 0), eTextFormat.Default);
|
||||
}
|
||||
|
||||
if (textRect.Width > 0 && textRect.Height > 0 && frame.Text != null)
|
||||
{
|
||||
Font font = renderingInfo.DefaultFont;
|
||||
if (style.Font != null)
|
||||
font = style.Font;
|
||||
bool rightToLeft = renderingInfo.RightToLeft;
|
||||
if (frame.TextMarkupBody == null)
|
||||
{
|
||||
eTextFormat textFormat = eTextFormat.Default | eTextFormat.WordBreak | eTextFormat.NoClipping;
|
||||
if (style.TextLineAlignment == eStyleTextAlignment.Center)
|
||||
textFormat |= eTextFormat.VerticalCenter;
|
||||
else if (style.TextLineAlignment == eStyleTextAlignment.Far)
|
||||
textFormat |= eTextFormat.Bottom;
|
||||
if (style.TextAlignment == eStyleTextAlignment.Center)
|
||||
textFormat |= eTextFormat.HorizontalCenter;
|
||||
else if (style.TextAlignment == eStyleTextAlignment.Far)
|
||||
textFormat |= eTextFormat.Right;
|
||||
//if (frame.Text.Contains("Explorer")) Console.WriteLine("{0} {1}", textRect, DateTime.Now);
|
||||
TextDrawing.DrawString(g, frame.Text, font, textColor, textRect, textFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, textColor, rightToLeft);
|
||||
d.HotKeyPrefixVisible = false;
|
||||
d.ContextObject = item;
|
||||
Rectangle markupBounds = textRect;
|
||||
// Can't do this because it will break all apps default for TextLineAlignment is eStyleTextAlignment.Center
|
||||
//if (style.TextLineAlignment == eStyleTextAlignment.Center)
|
||||
// markupBounds = new Rectangle(new Point(textRect.X, textRect.Y + (textRect.Height - frame.TextMarkupBody.Bounds.Height) / 2), frame.TextMarkupBody.Bounds.Size);
|
||||
//else if (style.TextLineAlignment == eStyleTextAlignment.Far)
|
||||
// markupBounds = new Rectangle(new Point(textRect.X, textRect.Bottom - frame.TextMarkupBody.Bounds.Height), frame.TextMarkupBody.Bounds.Size);
|
||||
|
||||
frame.TextMarkupBody.Bounds = markupBounds;
|
||||
frame.TextMarkupBody.Render(d);
|
||||
}
|
||||
}
|
||||
|
||||
if (frame.TitleText != null)
|
||||
{
|
||||
Color titleTextColor = enabled ? frame.TitleTextColor : renderingInfo.ColorTable.MetroPartColors.CanvasColorLightShade;
|
||||
if (titleTextColor.IsEmpty)
|
||||
titleTextColor = style.TextColor;
|
||||
Font font = item.GetTitleTextFont(frame, style, control);
|
||||
Rectangle titleTextRect = frame.TitleTextBounds;
|
||||
titleTextRect.Offset(bounds.Location);
|
||||
if (item.IsLeftMouseButtonDown)
|
||||
titleTextRect.Offset(1, 1);
|
||||
else if (item.IsMouseOver)
|
||||
titleTextRect.Offset(InflatePixels, InflatePixels);
|
||||
if (frame.TitleTextMarkupBody == null)
|
||||
TextDrawing.DrawString(g, frame.TitleText, font, titleTextColor, titleTextRect, eTextFormat.Default | eTextFormat.SingleLine);
|
||||
else
|
||||
{
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, titleTextColor, renderingInfo.RightToLeft);
|
||||
d.HotKeyPrefixVisible = false;
|
||||
d.ContextObject = item;
|
||||
Rectangle markupBounds = titleTextRect;
|
||||
frame.TitleTextMarkupBody.Bounds = markupBounds;
|
||||
frame.TitleTextMarkupBody.Render(d);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.Checked)
|
||||
{
|
||||
Size checkMarkSize = Dpi.Size(CheckMarkSize);
|
||||
Rectangle markBounds = new Rectangle(bounds.Right - checkMarkSize.Width, bounds.Y, checkMarkSize.Width, checkMarkSize.Height);
|
||||
using (GraphicsPath markPath = new GraphicsPath())
|
||||
{
|
||||
markPath.AddLine(markBounds.X, markBounds.Y, markBounds.Right - 1, markBounds.Y);
|
||||
markPath.AddLine(markBounds.Right - 1, markBounds.Y, markBounds.Right - 1, markBounds.Bottom - 1);
|
||||
markPath.CloseFigure();
|
||||
using (SolidBrush brush = new SolidBrush(colorTable.CheckBackground))
|
||||
g.FillPath(brush, markPath);
|
||||
}
|
||||
using (SolidBrush brush = new SolidBrush(colorTable.CheckForeground))
|
||||
{
|
||||
Rectangle checkCircleBounds = new Rectangle();
|
||||
checkCircleBounds.Size = new Size(Dpi.Width11, Dpi.Height11);
|
||||
checkCircleBounds.X = markBounds.Right - checkCircleBounds.Size.Width - Dpi.Width3;
|
||||
checkCircleBounds.Y = markBounds.Y + Dpi.Height2;
|
||||
using (Pen pen = new Pen(colorTable.CheckForeground, Dpi.Width2))
|
||||
{
|
||||
g.DrawEllipse(pen, checkCircleBounds);
|
||||
g.DrawLine(pen, checkCircleBounds.X + Dpi.Width3, checkCircleBounds.Y + Dpi.Height5, checkCircleBounds.X + Dpi.Width6, checkCircleBounds.Y + Dpi.Height8);
|
||||
g.DrawLine(pen, checkCircleBounds.X + Dpi.Width6, checkCircleBounds.Y + Dpi.Height8, checkCircleBounds.X + Dpi.Width9, checkCircleBounds.Y + Dpi.Height3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dispose) style.Dispose();
|
||||
|
||||
if (clip != null)
|
||||
{
|
||||
g.Clip = clip;
|
||||
clip.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Size CheckMarkSize = new Size(27, 27);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro.Rendering
|
||||
{
|
||||
internal class MetroToolbarPainter : MetroRenderer
|
||||
{
|
||||
public override void Render(MetroRendererInfo renderingInfo)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)renderingInfo.Control;
|
||||
Graphics g = renderingInfo.PaintEventArgs.Graphics;
|
||||
MetroToolbarColorTable ct = renderingInfo.ColorTable.MetroToolbar;
|
||||
Rectangle bounds = bar.ClientRectangle;
|
||||
|
||||
if (ct.BackgroundStyle != null)
|
||||
{
|
||||
ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(ct.BackgroundStyle, g, bounds);
|
||||
ElementStyleDisplay.PaintBackground(di);
|
||||
}
|
||||
|
||||
#if TRIAL
|
||||
if (bar.Expanded)
|
||||
{
|
||||
Rectangle tr = bounds;
|
||||
tr.Inflate(-2, -2);
|
||||
using (Font font = new Font(bar.Font.FontFamily, 8f, FontStyle.Regular))
|
||||
TextDrawing.DrawString(g, "DotNetBar Trial", font, Color.FromArgb(32, Color.Black), tr, eTextFormat.Bottom | eTextFormat.Right);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
377
PROMS/DotNetBar Source Code/Metro/Thickness.cs
Normal file
377
PROMS/DotNetBar Source Code/Metro/Thickness.cs
Normal file
@@ -0,0 +1,377 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using DevComponents.DotNetBar.Metro.Helpers;
|
||||
|
||||
namespace DevComponents.DotNetBar.Metro
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines Thickness structure used by borders and margins.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential), TypeConverter(typeof(ThicknessConverter))]
|
||||
public struct Thickness : IEquatable<Thickness>
|
||||
{
|
||||
#region Constructor
|
||||
private double _Left;
|
||||
private double _Top;
|
||||
private double _Right;
|
||||
private double _Bottom;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="uniformLength">Uniform Thickness</param>
|
||||
public Thickness(double uniformThickness)
|
||||
{
|
||||
_Left = _Top = _Right = _Bottom = uniformThickness;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="left">Left Thickness</param>
|
||||
/// <param name="top">Top Thickness</param>
|
||||
/// <param name="right">Right Thickness</param>
|
||||
/// <param name="bottom">Bottom Thickness</param>
|
||||
public Thickness(double left, double top, double right, double bottom)
|
||||
{
|
||||
_Left = left;
|
||||
_Top = top;
|
||||
_Right = right;
|
||||
_Bottom = bottom;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Gets whether object equals to this instance.
|
||||
/// </summary>
|
||||
/// <param name="obj">object to test.</param>
|
||||
/// <returns>returns whether objects are Equals</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Thickness)
|
||||
{
|
||||
Thickness thickness = (Thickness)obj;
|
||||
return (this == thickness);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether object equals to this instance.
|
||||
/// </summary>
|
||||
/// <param name="thickness">object to test.</param>
|
||||
/// <returns>returns whether objects are Equals</returns>
|
||||
public bool Equals(Thickness thickness)
|
||||
{
|
||||
return (this == thickness);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns hash code for object.
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (((_Left.GetHashCode() ^ _Top.GetHashCode()) ^ _Right.GetHashCode()) ^ _Bottom.GetHashCode());
|
||||
}
|
||||
|
||||
const string StringValueSeparator = ",";
|
||||
/// <summary>
|
||||
/// Returns string representation of object.
|
||||
/// </summary>
|
||||
/// <returns>string representing Thickness</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Convert.ToString(_Left) + StringValueSeparator + Convert.ToString(_Top) + StringValueSeparator + Convert.ToString(_Right) + StringValueSeparator + Convert.ToString(_Bottom);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets string representation of object.
|
||||
/// </summary>
|
||||
/// <param name="cultureInfo">Culture info.</param>
|
||||
/// <returns>string representing Thickness</returns>
|
||||
internal string ToString(CultureInfo cultureInfo)
|
||||
{
|
||||
return Convert.ToString(_Left, cultureInfo) + StringValueSeparator + Convert.ToString(_Top, cultureInfo) + StringValueSeparator + Convert.ToString(_Right, cultureInfo) + StringValueSeparator + Convert.ToString(_Bottom, cultureInfo);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether all values are zero.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsZero
|
||||
{
|
||||
get
|
||||
{
|
||||
return (((DoubleHelpers.IsZero(this.Left) && DoubleHelpers.IsZero(this.Top)) && DoubleHelpers.IsZero(this.Right)) && DoubleHelpers.IsZero(this.Bottom));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether all values are the same.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsUniform
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((DoubleHelpers.AreClose(this.Left, this.Top) && DoubleHelpers.AreClose(this.Left, this.Right)) && DoubleHelpers.AreClose(this.Left, this.Bottom));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether object holds valid value.
|
||||
/// </summary>
|
||||
/// <param name="allowNegative">Specifies whether negative values are allowed.</param>
|
||||
/// <param name="allowNaN">Specifies whether NaN values are allowed.</param>
|
||||
/// <param name="allowPositiveInfinity">Specifies whether positive infinity values are allowed</param>
|
||||
/// <param name="allowNegativeInfinity">Specifies whether negative infinity values are allowed</param>
|
||||
/// <returns>true if object holds valid value</returns>
|
||||
internal bool IsValid(bool allowNegative, bool allowNaN, bool allowPositiveInfinity, bool allowNegativeInfinity)
|
||||
{
|
||||
if (!allowNegative && (((this.Left < 0.0) || (this.Right < 0.0)) || ((this.Top < 0.0) || (this.Bottom < 0.0))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!allowNaN && ((DoubleHelpers.IsNaN(this.Left) || DoubleHelpers.IsNaN(this.Right)) || (DoubleHelpers.IsNaN(this.Top) || DoubleHelpers.IsNaN(this.Bottom))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!allowPositiveInfinity && ((double.IsPositiveInfinity(this.Left) || double.IsPositiveInfinity(this.Right)) || (double.IsPositiveInfinity(this.Top) || double.IsPositiveInfinity(this.Bottom))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (allowNegativeInfinity || ((!double.IsNegativeInfinity(this.Left) && !double.IsNegativeInfinity(this.Right)) && (!double.IsNegativeInfinity(this.Top) && !double.IsNegativeInfinity(this.Bottom))));
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if two objects are close.
|
||||
/// </summary>
|
||||
/// <param name="thickness">Thickness to test.</param>
|
||||
/// <returns>true if values are close.</returns>
|
||||
internal bool IsClose(Thickness thickness)
|
||||
{
|
||||
return (((DoubleHelpers.AreClose(this.Left, thickness.Left) && DoubleHelpers.AreClose(this.Top, thickness.Top)) && DoubleHelpers.AreClose(this.Right, thickness.Right)) && DoubleHelpers.AreClose(this.Bottom, thickness.Bottom));
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if two objects are close.
|
||||
/// </summary>
|
||||
/// <param name="thickness1">Thickness 1</param>
|
||||
/// <param name="thickness2">Thickness 2</param>
|
||||
/// <returns>true if values are close.</returns>
|
||||
internal static bool AreClose(Thickness thickness1, Thickness thickness2)
|
||||
{
|
||||
return thickness1.IsClose(thickness2);
|
||||
}
|
||||
|
||||
public static bool operator ==(Thickness t1, Thickness t2)
|
||||
{
|
||||
return (((((t1._Left == t2._Left) || (DoubleHelpers.IsNaN(t1._Left) && DoubleHelpers.IsNaN(t2._Left))) && ((t1._Top == t2._Top) || (DoubleHelpers.IsNaN(t1._Top) && DoubleHelpers.IsNaN(t2._Top)))) && ((t1._Right == t2._Right) || (DoubleHelpers.IsNaN(t1._Right) && DoubleHelpers.IsNaN(t2._Right)))) && ((t1._Bottom == t2._Bottom) || (DoubleHelpers.IsNaN(t1._Bottom) && DoubleHelpers.IsNaN(t2._Bottom))));
|
||||
}
|
||||
|
||||
public static bool operator !=(Thickness t1, Thickness t2)
|
||||
{
|
||||
return !(t1 == t2);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the left Thickness.
|
||||
/// </summary>
|
||||
public double Left
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Left;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Left = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the top Thickness.
|
||||
/// </summary>
|
||||
public double Top
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Top;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Top = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the Right Thickness.
|
||||
/// </summary>
|
||||
public double Right
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Right;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Right = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the Bottom Thickness.
|
||||
/// </summary>
|
||||
public double Bottom
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Bottom;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Bottom = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total horizontal thickness i.e. Left+Right.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public double Horizontal
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Left + _Right;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the total vertical thickness i.e. Top+Bottom.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public double Vertical
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Top + _Bottom;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region ThicknessConverter
|
||||
/// <summary>
|
||||
/// Provides Thickness TypeConverter.
|
||||
/// </summary>
|
||||
public class ThicknessConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return ((destinationType == typeof(InstanceDescriptor)) || base.CanConvertTo(context, destinationType));
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
string str = value as string;
|
||||
if (str == null)
|
||||
{
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
string str2 = str.Trim();
|
||||
if (str2.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
char ch = culture.TextInfo.ListSeparator[0];
|
||||
string[] strArray = str2.Split(new char[] { ch });
|
||||
double[] numArray = new double[strArray.Length];
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(typeof(double));
|
||||
for (int i = 0; i < numArray.Length; i++)
|
||||
{
|
||||
numArray[i] = (double)converter.ConvertFromString(context, culture, strArray[i]);
|
||||
}
|
||||
if (numArray.Length != 4)
|
||||
{
|
||||
throw new ArgumentException("Text Parsing Failed");
|
||||
}
|
||||
return new Thickness(numArray[0], numArray[1], numArray[2], numArray[3]);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
if (value is Thickness)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
Thickness Thickness = (Thickness)value;
|
||||
if (culture == null)
|
||||
{
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
}
|
||||
string separator = culture.TextInfo.ListSeparator + " ";
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(typeof(double));
|
||||
string[] strArray = new string[4];
|
||||
int num = 0;
|
||||
strArray[num++] = converter.ConvertToString(context, culture, Thickness.Left);
|
||||
strArray[num++] = converter.ConvertToString(context, culture, Thickness.Top);
|
||||
strArray[num++] = converter.ConvertToString(context, culture, Thickness.Right);
|
||||
strArray[num++] = converter.ConvertToString(context, culture, Thickness.Bottom);
|
||||
return string.Join(separator, strArray);
|
||||
}
|
||||
if (destinationType == typeof(InstanceDescriptor))
|
||||
{
|
||||
Thickness Thickness2 = (Thickness)value;
|
||||
ConstructorInfo constructor = typeof(Thickness).GetConstructor(new Type[] { typeof(double), typeof(double), typeof(double), typeof(double) });
|
||||
if (constructor != null)
|
||||
{
|
||||
return new InstanceDescriptor(constructor, new object[] { Thickness2.Left, Thickness2.Top, Thickness2.Right, Thickness2.Bottom });
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
|
||||
{
|
||||
if (propertyValues == null)
|
||||
{
|
||||
throw new ArgumentNullException("propertyValues");
|
||||
}
|
||||
object left = propertyValues["Left"];
|
||||
object top = propertyValues["Top"];
|
||||
object right = propertyValues["Right"];
|
||||
object bottom = propertyValues["Bottom"];
|
||||
if ((((left == null) || (top == null)) || ((right == null) || (bottom == null))) || ((!(left is double) || !(top is double)) || (!(right is double) || !(bottom is double))))
|
||||
{
|
||||
throw new ArgumentException(string.Format("Property Value Invalid: left={0}, top={1}, right={2}, bottom={3}", left, top, right, bottom));
|
||||
}
|
||||
return new Thickness((double)left, (double)top, (double)right, (double)bottom);
|
||||
}
|
||||
|
||||
public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
return TypeDescriptor.GetProperties(typeof(Thickness), attributes).Sort(new string[] { "Left", "Top", "Right", "Bottom" });
|
||||
}
|
||||
|
||||
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
Reference in New Issue
Block a user