1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Uni_Trend.MSO7000X.Common.Helper
- {
- public static class ColorHelper
- {
- /// <summary>
- /// 混合两个颜色,主要是用于控件禁用后颜色的修改
- /// </summary>
- /// <param name="cA"></param>
- /// <param name="cB"></param>
- /// <param name="pA"></param>
- /// <returns></returns>
- public static Color MixColor(this Color cA, Color cB, int pA = 20)
- {
- decimal percentA = 1 - (decimal)pA / 100;
- decimal R = cA.R - (cA.R - cB.R) * percentA;
- decimal G = cA.G - (cA.G - cB.G) * percentA;
- decimal B = cA.B - (cA.B - cB.B) * percentA;
- return Color.FromArgb((int)R, (int)G, (int)B);
- }
- /// <summary>
- /// 根据当前颜色创建控件禁用颜色
- /// </summary>
- /// <param name="cA"></param>
- /// <param name="pA"></param>
- /// <returns></returns>
- public static Color MixColor(this Color cA, int pA = 20)
- {
- Color cB = Color.Gray;
- decimal percentA = 1 - (decimal)pA / 100;
- decimal R = cA.R - (cA.R - cB.R) * percentA;
- decimal G = cA.G - (cA.G - cB.G) * percentA;
- decimal B = cA.B - (cA.B - cB.B) * percentA;
- return Color.FromArgb((int)R, (int)G, (int)B);
- }
- }
- }
|