Commit b1f7ed3f HZH

增加内置颜色

1 个父辈 44e0deea
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace HZH_Controls
{
public class BasisColors
{
private static Color light = ColorTranslator.FromHtml("#f5f7fa");
public static Color Light
{
get { return light; }
internal set { light = value; }
}
private static Color medium = ColorTranslator.FromHtml("#f0f2f5");
public static Color Medium
{
get { return medium; }
internal set { medium = value; }
}
private static Color dark = ColorTranslator.FromHtml("#000000");
public static Color Dark
{
get { return dark; }
internal set { dark = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
public class BorderColors
{
private static Color green = ColorTranslator.FromHtml("#f0f9ea");
public static Color Green
{
get { return green; }
internal set { green = value; }
}
private static Color blue = ColorTranslator.FromHtml("#ecf5ff");
public static Color Blue
{
get { return blue; }
internal set { blue = value; }
}
private static Color red = ColorTranslator.FromHtml("#fef0f0");
public static Color Red
{
get { return red; }
internal set { red = value; }
}
private static Color yellow = ColorTranslator.FromHtml("#fdf5e6");
public static Color Yellow
{
get { return yellow; }
internal set { yellow = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
public enum BasisColorsTypes
{
Light,
Medium,
Dark
}
public enum BorderColorsTypes
{
Green,
Blue,
Red,
Yellow
}
public enum GradientColorsTypes
{
Orange,
LightGreen,
Green,
Blue,
BlueGreen,
LightViolet,
Violet,
Gray
}
public enum LineColorsTypes
{
MoreLight,
Light,
Dark,
MoreDark
}
public enum StatusColorsTypes
{
Primary,
Success,
Warning,
Danger,
Info
}
public enum TableColorsTypes
{
Green,
Blue,
Red,
Yellow,
Gray
}
public enum TextColorsTypes
{
MoreLight,
Light,
Dark,
MoreDark
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
public static class ColorExt
{
#region 重置内置的颜色 English:Reset color
public static void ResetColor(
this BasisColors type,
Color light,
Color medium,
Color dark)
{
BasisColors.Light = light;
BasisColors.Medium = medium;
BasisColors.Dark = dark;
}
public static void ResetColor(
this BorderColors type,
Color green,
Color blue,
Color red,
Color yellow)
{
BorderColors.Green = green;
BorderColors.Blue = blue;
BorderColors.Red = red;
BorderColors.Yellow = yellow;
}
public static void ResetColor(
this GradientColors type,
Color[] orange,
Color[] lightGreen,
Color[] green,
Color[] blue,
Color[] blueGreen,
Color[] lightViolet,
Color[] violet,
Color[] gray
)
{
if (orange != null && orange.Length == 2)
GradientColors.Orange = orange;
if (orange != null && orange.Length == 2)
GradientColors.LightGreen = lightGreen;
if (orange != null && orange.Length == 2)
GradientColors.Green = green;
if (orange != null && orange.Length == 2)
GradientColors.Blue = blue;
if (orange != null && orange.Length == 2)
GradientColors.BlueGreen = blueGreen;
if (orange != null && orange.Length == 2)
GradientColors.LightViolet = lightViolet;
if (orange != null && orange.Length == 2)
GradientColors.Violet = violet;
if (orange != null && orange.Length == 2)
GradientColors.Gray = gray;
}
public static void ResetColor(
this LineColors type,
Color moreLight,
Color light,
Color dark,
Color moreDark)
{
LineColors.MoreLight = moreLight;
LineColors.Light = light;
LineColors.Dark = dark;
LineColors.MoreDark = moreDark;
}
public static void ResetColor(
this StatusColors type,
Color primary,
Color success,
Color warning,
Color danger,
Color info
)
{
StatusColors.Primary = primary;
StatusColors.Success = success;
StatusColors.Warning = warning;
StatusColors.Danger = danger;
StatusColors.Info = info;
}
public static void ResetColor(
this TableColors type,
Color green,
Color blue,
Color red,
Color yellow,
Color gray
)
{
TableColors.Green = green;
TableColors.Blue = blue;
TableColors.Red = red;
TableColors.Yellow = yellow;
TableColors.Gray = gray;
}
public static void ResetColor(
this TextColors type,
Color moreLight,
Color light,
Color dark,
Color moreDark)
{
TextColors.MoreLight = moreLight;
TextColors.Light = light;
TextColors.Dark = dark;
TextColors.MoreDark = moreDark;
}
#endregion
#region 获取一个内置颜色 English:Get a built-in color
/// <summary>
/// 功能描述:获取一个内置颜色 English:Get a built-in color
/// 作  者:HZH
/// 创建日期:2019-09-30 11:08:04
/// 任务编号:POS
/// </summary>
/// <param name="t">t</param>
/// <returns>颜色列表</returns>
public static Color[] GetInternalColor<T>(T t)
{
Type type = null;
if (t is BasisColorsTypes)
{
type = typeof(BasisColors);
}
if (type == null)
return new Color[] { Color.Empty };
else
{
string strName = t.ToString();
var pi = type.GetProperty(strName);
if (pi == null)
return new Color[] { Color.Empty };
else
{
var c = pi.GetValue(null, null);
if (c == null)
return new Color[] { Color.Empty };
else if (c is Color[])
return (Color[])c;
else
return new Color[] { (Color)c };
}
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
public class GradientColors
{
private static Color[] orange = new Color[] { Color.FromArgb(252, 196, 136), Color.FromArgb(243, 138, 159) };
public static Color[] Orange
{
get { return GradientColors.orange; }
internal set { GradientColors.orange = value; }
}
private static Color[] lightGreen = new Color[] { Color.FromArgb(210, 251, 123), Color.FromArgb(152, 231, 160) };
public static Color[] LightGreen
{
get { return GradientColors.lightGreen; }
internal set { GradientColors.lightGreen = value; }
}
private static Color[] green = new Color[] { Color.FromArgb(138, 241, 124), Color.FromArgb(32, 190, 179) };
public static Color[] Green
{
get { return GradientColors.green; }
internal set { GradientColors.green = value; }
}
private static Color[] blue = new Color[] { Color.FromArgb(193, 232, 251), Color.FromArgb(162, 197, 253) };
public static Color[] Blue
{
get { return GradientColors.blue; }
internal set { GradientColors.blue = value; }
}
private static Color[] blueGreen = new Color[] { Color.FromArgb(122, 251, 218), Color.FromArgb(16, 193, 252) };
public static Color[] BlueGreen
{
get { return GradientColors.blueGreen; }
internal set { GradientColors.blueGreen = value; }
}
private static Color[] lightViolet = new Color[] { Color.FromArgb(248, 192, 234), Color.FromArgb(164, 142, 210) };
public static Color[] LightViolet
{
get { return GradientColors.lightViolet; }
internal set { GradientColors.lightViolet = value; }
}
private static Color[] violet = new Color[] { Color.FromArgb(185, 154, 241), Color.FromArgb(137, 124, 242) };
public static Color[] Violet
{
get { return GradientColors.violet; }
internal set { GradientColors.violet = value; }
}
private static Color[] gray = new Color[] { Color.FromArgb(233, 238, 239), Color.FromArgb(147, 162, 175) };
public static Color[] Gray
{
get { return GradientColors.gray; }
internal set { GradientColors.gray = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
public class LineColors
{
/// <summary>
/// The more light
/// </summary>
private static Color _MoreLight = ColorTranslator.FromHtml("#f2f6fc");
/// <summary>
/// Gets the more light.
/// </summary>
/// <value>The more light.</value>
public static Color MoreLight
{
get { return _MoreLight; }
internal set { _MoreLight = value; }
}
/// <summary>
/// The light
/// </summary>
private static Color _Light = ColorTranslator.FromHtml("#ebeef5");
/// <summary>
/// Gets the light.
/// </summary>
/// <value>The light.</value>
public static Color Light
{
get { return _Light; }
internal set { _Light = value; }
}
/// <summary>
/// The dark
/// </summary>
private static Color _Dark = ColorTranslator.FromHtml("#e4e7ed");
/// <summary>
/// Gets the dark.
/// </summary>
/// <value>The dark.</value>
public static Color Dark
{
get { return _Dark; }
internal set { _Dark = value; }
}
/// <summary>
/// The more dark
/// </summary>
private static Color _MoreDark = ColorTranslator.FromHtml("#dcdfe6");
/// <summary>
/// Gets the more dark.
/// </summary>
/// <value>The more dark.</value>
public static Color MoreDark
{
get { return _MoreDark; }
internal set { _MoreDark = value; }
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-30
//
// ***********************************************************************
// <copyright file="StatusColor.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
/// <summary>
/// 状态颜色
/// </summary>
public class StatusColors
{
/// <summary>
/// The primary
/// </summary>
private static Color _Primary = ColorTranslator.FromHtml("#409eff");
/// <summary>
/// Gets or sets the primary.
/// </summary>
/// <value>The primary.</value>
public static Color Primary
{
get { return _Primary; }
internal set { _Primary = value; }
}
/// <summary>
/// The success
/// </summary>
private static Color _Success = ColorTranslator.FromHtml("#67c23a");
/// <summary>
/// Gets or sets the success.
/// </summary>
/// <value>The success.</value>
public static Color Success
{
get { return _Success; }
internal set { _Success = value; }
}
/// <summary>
/// The warning
/// </summary>
private static Color _Warning = ColorTranslator.FromHtml("#e6a23c");
/// <summary>
/// Gets or sets the warning.
/// </summary>
/// <value>The warning.</value>
public static Color Warning
{
get { return _Warning; }
internal set { _Warning = value; }
}
/// <summary>
/// The danger
/// </summary>
private static Color _Danger = ColorTranslator.FromHtml("#f56c6c");
/// <summary>
/// Gets or sets the danger.
/// </summary>
/// <value>The danger.</value>
public static Color Danger
{
get { return _Danger; }
internal set { _Danger = value; }
}
/// <summary>
/// The information
/// </summary>
private static Color _Info = ColorTranslator.FromHtml("#909399");
/// <summary>
/// Gets or sets the information.
/// </summary>
/// <value>The information.</value>
public static Color Info
{
get { return _Info; }
internal set { _Info = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
public class TableColors
{
private static Color green = ColorTranslator.FromHtml("#c2e7b0");
public static Color Green
{
get { return green; }
internal set { green = value; }
}
private static Color blue = ColorTranslator.FromHtml("#a3d0fd");
public static Color Blue
{
get { return blue; }
internal set { blue = value; }
}
private static Color red = ColorTranslator.FromHtml("#fbc4c4");
public static Color Red
{
get { return red; }
internal set { red = value; }
}
private static Color yellow = ColorTranslator.FromHtml("#f5dab1");
public static Color Yellow
{
get { return yellow; }
internal set { yellow = value; }
}
private static Color gray = ColorTranslator.FromHtml("#d3d4d6");
public static Color Gray
{
get { return gray; }
internal set { gray = value; }
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-30
//
// ***********************************************************************
// <copyright file="TextColor.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace HZH_Controls
{
/// <summary>
/// Class TextColor.
/// </summary>
public class TextColors
{
/// <summary>
/// The more light
/// </summary>
private static Color _MoreLight = ColorTranslator.FromHtml("#c0c4cc");
/// <summary>
/// Gets the more light.
/// </summary>
/// <value>The more light.</value>
public static Color MoreLight
{
get { return _MoreLight; }
internal set { _MoreLight = value; }
}
/// <summary>
/// The light
/// </summary>
private static Color _Light = ColorTranslator.FromHtml("#909399");
/// <summary>
/// Gets the light.
/// </summary>
/// <value>The light.</value>
public static Color Light
{
get { return _Light; }
internal set { _Light = value; }
}
/// <summary>
/// The dark
/// </summary>
private static Color _Dark = ColorTranslator.FromHtml("#606266");
/// <summary>
/// Gets the dark.
/// </summary>
/// <value>The dark.</value>
public static Color Dark
{
get { return _Dark; }
internal set { _Dark = value; }
}
/// <summary>
/// The more dark
/// </summary>
private static Color _MoreDark = ColorTranslator.FromHtml("#303133");
/// <summary>
/// Gets the more dark.
/// </summary>
/// <value>The more dark.</value>
public static Color MoreDark
{
get { return _MoreDark; }
internal set { _MoreDark = value; }
}
}
}
......@@ -244,7 +244,7 @@ namespace HZH_Controls.Forms
Graphics gBit = Graphics.FromImage(bit);
gBit.SetGDIHigh();
gBit.FillPath(new SolidBrush(_background), path);
gBit.DrawString(strMsg, _font, new SolidBrush(_foreColor), rect, new StringFormat() { Alignment= StringAlignment.Center, LineAlignment= StringAlignment.Center});
gBit.DrawString(strMsg, _font, new SolidBrush(_foreColor), rect, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
gBit.Dispose();
#endregion
......@@ -256,7 +256,7 @@ namespace HZH_Controls.Forms
/// <summary>
/// Shows the tips.
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="anchorControl">The parent control.</param>
/// <param name="strMsg">The string MSG.</param>
/// <param name="location">The location.</param>
/// <param name="background">The background.</param>
......@@ -267,7 +267,7 @@ namespace HZH_Controls.Forms
/// <param name="blnTopMost">是否置顶</param>
/// <returns>FrmAnchorTips.</returns>
public static FrmAnchorTips ShowTips(
Control parentControl,
Control anchorControl,
string strMsg,
AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
Color? background = null,
......@@ -275,22 +275,22 @@ namespace HZH_Controls.Forms
Size? deviation = null,
int fontSize = 10,
int autoCloseTime = 5000,
bool blnTopMost=true)
bool blnTopMost = true)
{
Point p;
if (parentControl is Form)
if (anchorControl is Form)
{
p = parentControl.Location;
p = anchorControl.Location;
}
else
{
p = parentControl.Parent.PointToScreen(parentControl.Location);
p = anchorControl.Parent.PointToScreen(anchorControl.Location);
}
if (deviation != null)
{
p = p + deviation.Value;
}
return ShowTips(new Rectangle(p, parentControl.Size), strMsg, location, background, foreColor, fontSize, autoCloseTime, parentControl.FindForm(),blnTopMost);
return ShowTips(new Rectangle(p, anchorControl.Size), strMsg, location, background, foreColor, fontSize, autoCloseTime, anchorControl.Parent, blnTopMost);
}
#endregion
......@@ -316,14 +316,60 @@ namespace HZH_Controls.Forms
Color? foreColor = null,
int fontSize = 10,
int autoCloseTime = 5000,
Form parentForm = null,
Control parentControl = null,
bool blnTopMost = true)
{
FrmAnchorTips frm = new FrmAnchorTips(rectControl, strMsg, location, background, foreColor, fontSize, autoCloseTime);
frm.TopMost = blnTopMost;
frm.Show(parentForm);
frm.Show(parentControl);
if (parentControl != null)
{
parentControl.Disposed += (a, b) =>
{
};
parentControl.VisibleChanged += (a, b) =>
{
try
{
Control c = a as Control;
if (CheckControlClose(c))
{
frm.Close();
}
}
catch (Exception ex)
{
}
};
parentControl.ParentChanged += (a, b) =>
{
};
parentControl.HandleDestroyed += (a, b) =>
{
};
}
return frm;
}
private static bool CheckControlClose(Control c)
{
if (c.IsDisposed || !c.Visible)
return true;
else if (c.Parent != null)
return CheckControlClose(c.Parent);
else
{
if (c is Form)
return false;
else
return true;
}
}
#endregion
#region Override
......
......@@ -487,25 +487,10 @@ namespace HZH_Controls.Forms
/// </summary>
public enum TipsState
{
/// <summary>
/// The default
/// </summary>
Default = -1,
/// <summary>
/// The success
/// </summary>
Success = -6566849,
/// <summary>
/// The information
/// </summary>
Info = -12477983,
/// <summary>
/// The warning
/// </summary>
Warning = -357816,
/// <summary>
/// The error
/// </summary>
Default = -12542209,
Success = -9977286,
Info = -7299687,
Warning = -693140,
Error = -1097849
}
}
......@@ -46,6 +46,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Colors\BasisColors.cs" />
<Compile Include="Colors\ColorEnums.cs" />
<Compile Include="Colors\BorderColors.cs" />
<Compile Include="Colors\ColorExt.cs" />
<Compile Include="Colors\GradientColors.cs" />
<Compile Include="Colors\StatusColors.cs" />
<Compile Include="Controls\Charts\AuxiliaryLable.cs" />
<Compile Include="Controls\Charts\AuxiliaryLine.cs" />
<Compile Include="Controls\Charts\BarChart\BarChartItem.cs" />
......@@ -331,6 +337,9 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Helpers\WindowsHook.cs" />
<Compile Include="Colors\LineColors.cs" />
<Compile Include="Colors\TableColors.cs" />
<Compile Include="Colors\TextColors.cs" />
<Compile Include="UIEditor\FrmSelectImage.cs">
<SubType>Form</SubType>
</Compile>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!