| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 | using LYFZ.OtherExpansion.SkinClass;using System;using System.Drawing;using System.Drawing.Drawing2D;namespace LYFZ.OtherExpansion.SkinControl{	internal class CmbRenderHelper	{		internal static void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, bool drawBorder, bool drawGlass, LinearGradientMode mode)		{			CmbRenderHelper.RenderBackgroundInternal(g, rect, baseColor, borderColor, innerBorderColor, style, 8, drawBorder, drawGlass, mode);		}		internal static void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, bool drawBorder, bool drawGlass, LinearGradientMode mode)		{			CmbRenderHelper.RenderBackgroundInternal(g, rect, baseColor, borderColor, innerBorderColor, style, 8, 0.45f, drawBorder, drawGlass, mode);		}		internal static void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode)		{			if (drawBorder)			{				rect.Width--;				rect.Height--;			}			using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode))			{				Color[] colors = new Color[]				{					CmbRenderHelper.GetColor(baseColor, 0, 35, 24, 9),					CmbRenderHelper.GetColor(baseColor, 0, 13, 8, 3),					baseColor,					CmbRenderHelper.GetColor(baseColor, 0, 35, 24, 9)				};				brush.InterpolationColors = new ColorBlend				{					Positions = new float[]					{						0f,						basePosition,						basePosition + 0.05f,						1f					},					Colors = colors				};				if (style != RoundStyle.None)				{					using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))					{						g.FillPath(brush, path);					}					if (baseColor.A > 80)					{						Rectangle rectTop = rect;						if (mode == LinearGradientMode.Vertical)						{							rectTop.Height = (int)((float)rectTop.Height * basePosition);						}						else						{							rectTop.Width = (int)((float)rect.Width * basePosition);						}						using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath(rectTop, roundWidth, RoundStyle.Top, false))						{							using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255)))							{								g.FillPath(brushAlpha, pathTop);							}						}					}					if (drawGlass)					{						RectangleF glassRect = rect;						if (mode == LinearGradientMode.Vertical)						{							glassRect.Y = (float)rect.Y + (float)rect.Height * basePosition;							glassRect.Height = ((float)rect.Height - (float)rect.Height * basePosition) * 2f;						}						else						{							glassRect.X = (float)rect.X + (float)rect.Width * basePosition;							glassRect.Width = ((float)rect.Width - (float)rect.Width * basePosition) * 2f;						}						ControlPaintEx.DrawGlass(g, glassRect, 170, 0);					}					if (!drawBorder)					{						goto IL_412;					}					using (GraphicsPath path2 = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))					{						using (Pen pen = new Pen(borderColor))						{							g.DrawPath(pen, path2);						}					}					rect.Inflate(-1, -1);					using (GraphicsPath path3 = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))					{						using (Pen pen2 = new Pen(innerBorderColor))						{							g.DrawPath(pen2, path3);						}						goto IL_412;					}				}				g.FillRectangle(brush, rect);				if (baseColor.A > 80)				{					Rectangle rectTop2 = rect;					if (mode == LinearGradientMode.Vertical)					{						rectTop2.Height = (int)((float)rectTop2.Height * basePosition);					}					else					{						rectTop2.Width = (int)((float)rect.Width * basePosition);					}					using (SolidBrush brushAlpha2 = new SolidBrush(Color.FromArgb(128, 255, 255, 255)))					{						g.FillRectangle(brushAlpha2, rectTop2);					}				}				if (drawGlass)				{					RectangleF glassRect2 = rect;					if (mode == LinearGradientMode.Vertical)					{						glassRect2.Y = (float)rect.Y + (float)rect.Height * basePosition;						glassRect2.Height = ((float)rect.Height - (float)rect.Height * basePosition) * 2f;					}					else					{						glassRect2.X = (float)rect.X + (float)rect.Width * basePosition;						glassRect2.Width = ((float)rect.Width - (float)rect.Width * basePosition) * 2f;					}					ControlPaintEx.DrawGlass(g, glassRect2, 200, 0);				}				if (drawBorder)				{					using (Pen pen3 = new Pen(borderColor))					{						g.DrawRectangle(pen3, rect);					}					rect.Inflate(-1, -1);					using (Pen pen4 = new Pen(innerBorderColor))					{						g.DrawRectangle(pen4, rect);					}				}				IL_412:;			}		}		internal static Color GetColor(Color colorBase, int a, int r, int g, int b)		{			int a2 = (int)colorBase.A;			int r2 = (int)colorBase.R;			int g2 = (int)colorBase.G;			int b2 = (int)colorBase.B;			if (a + a2 > 255)			{				a = 255;			}			else			{				a = Math.Max(0, a + a2);			}			if (r + r2 > 255)			{				r = 255;			}			else			{				r = Math.Max(0, r + r2);			}			if (g + g2 > 255)			{				g = 255;			}			else			{				g = Math.Max(0, g + g2);			}			if (b + b2 > 255)			{				b = 255;			}			else			{				b = Math.Max(0, b + b2);			}			return Color.FromArgb(a, r, g, b);		}	}}
 |