public CPColor GetCPColor(Color color) { lock (cpcolors) { object tmp = cpcolors [color]; if (tmp == null) { CPColor cpcolor = new CPColor(); cpcolor.Dark = ControlPaint.Dark(color); cpcolor.DarkDark = ControlPaint.DarkDark(color); cpcolor.Light = ControlPaint.Light(color); cpcolor.LightLight = ControlPaint.LightLight(color); cpcolors.Add(color, cpcolor); return(cpcolor); } return((CPColor)tmp); } }
protected virtual void DrawGradientBackground(Graphics g) { int radius = RoundCornerDiameter / 2; using (LinearGradientBrush brush = new LinearGradientBrush( new Point(this.Width / 2, 0), new Point(this.Width / 2, this.Height), this.BackGradientLightColor, this.BackGradientDarkColor )) { g.FillRoundedRectangle(brush, 0, 0, this.Width, this.Height, radius); } if (ShowShade) { Rectangle shadeArea = new Rectangle(1, this.Height / 2, this.Width - 4, this.Height / 2); using (LinearGradientBrush brush = new LinearGradientBrush(shadeArea, this.ShadeColor, ControlPaint.LightLight(this.ShadeColor), 90f)) { g.FillRoundedRectangle( brush, shadeArea, radius); // 填补顶部的边线(出现的原因未知) using (Pen earser = new Pen(this.ShadeColor)) { g.DrawLine(earser, shadeArea.X + radius, shadeArea.Y, shadeArea.Width - radius, shadeArea.Y); } } } }