private void DrawCaptionText(Graphics g, Rectangle textRect, string text, Font font, bool Effect, Color EffetBack, int EffectWidth, Color FrmColor) { if (Effect) { var size = TextRenderer.MeasureText(text, font); var image = SkinTools.ImageLightEffect(text, font, FrmColor, EffetBack, EffectWidth, new Rectangle(0, 0, textRect.Width, size.Height), true); g.DrawImage(image, textRect.X - (EffectWidth / 2), textRect.Y - (EffectWidth / 2)); } }
protected override void OnPaint(PaintEventArgs e) { var graphics = e.Graphics; // Share.GraphicSetup(graphics); // base.OnPaint(e); //绘制质感的标题栏 if (true) { var lgb = new LinearGradientBrush(CaptionRect, Share.LineTop, Share.LineBottom, 90f); graphics.FillRectangle(lgb, CaptionRect); lgb.Dispose(); var p = new Pen(Share.Line, 1); graphics.DrawLine(p, new Point(0, CaptionRect.Height + 3), new Point(CaptionRect.Width, CaptionRect.Height + 3)); //p.Color = Color.Blue; // p.Width = 5; // graphics.DrawLine(p, new Point(0, this.CaptionRect.Height + 1), new Point(this.CaptionRect.Width, this.CaptionRect.Height+1)); p.Dispose(); } //标题文字 var size = TextRenderer.MeasureText(Text, Font); var image = SkinTools.ImageLightEffect(Text, Font, ForeColor, Color.White, 4, new Rectangle(0, 0, Width, size.Height), true); graphics.DrawImage(image, textRect.X - (4 / 2), textRect.Y - (4 / 2)); //画图标 if (Icon != null) { graphics.DrawIcon(Icon, IconRect); } //画关闭按钮 graphics.DrawImage(btnImg, closeRect); //画边框 var rect = ClientRectangle; rect.X += 3; rect.Y += 3; rect.Width -= 7; rect.Height -= 7; using (var pen = new Pen(Color.DarkGray)) { var path = DrawHelper.CreateRoundPathFPoint(rect, 2); graphics.DrawPath(pen, path); path.Dispose(); } }