0
我需要复制这个窗口的底部使用我自己的窗体。如何在第二和第三区域之间重新创建这种暗影效果?
我需要复制这个窗口的底部使用我自己的窗体。如何在第二和第三区域之间重新创建这种暗影效果?
你需要做的是覆盖现有控制的绘画或创建自己的控制。就我个人而言,我会覆盖Panel
控件的绘画,这将成为窗口整个底部的面板。
渐变面板是一个常见的要求,并有一个博客文章here(代码如下)。
显然你不想绘制完整的渐变,但它展示了绘画如何在控件上工作。
您既可以使用整个面板的较小子集绘制渐变,也可以使用类似Graphics.DrawPath
的东西绘制渐变,并以正确的颜色绘制直线。
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace PostXING.Controls
{
/// <summary>
/// GradientPanel is just like a regular panel except it optionally
/// shows a gradient.
/// </summary>
[ToolboxBitmap(typeof(Panel))]
public class GradientPanel : Panel
{
/// <summary>
/// Property GradientColor (Color)
/// </summary>
private Color _gradientColor;
public Color GradientColor {
get { return this._gradientColor;}
set { this._gradientColor = value;}
}
/// <summary>
/// Property Rotation (float)
/// </summary>
private float _rotation;
public float Rotation {
get { return this._rotation;}
set { this._rotation = value;}
}
protected override void OnPaint(PaintEventArgs e) {
if(e.ClipRectangle.IsEmpty) return; //why draw if non-visible?
using(LinearGradientBrush lgb = new
LinearGradientBrush(this.ClientRectangle,
this.BackColor,
this.GradientColor,
this.Rotation)){
e.Graphics.FillRectangle(lgb, this.ClientRectangle);
}
base.OnPaint (e); //right, want anything handled to be drawn too.
}
}
}
做这样行动中心这样做,使用Paint事件。 – 2012-07-16 08:54:06