我在VS中有两个快捷按钮问题。
首先,当有可用的更新时,我想创建一个发光按钮(我知道,让我烦恼)。我正在使用dotnetbar中的一个buttonx,我会想要继续单击按钮,但要自动完成。
我目前设置了一个定时器,每半秒更改一次检查状态,但它不会像点击它时那样淡入和淡出颜色......
我也想知道如何禁用按钮,但看起来很正常。
答案 0 :(得分:3)
我创建了一个自定义UserControl来使用GDI +绘制一个按钮。它不会“发光”,但你可以做类似的事情来产生外部发光效果。
public partial class AquaButton : UserControl
{
private bool m_IsMouseOver = false;
protected string m_text = string.Empty;
[Category("Appearance")]
[Description("Gets / Sets Button Text")]
[EditorBrowsable(EditorBrowsableState.Always), Browsable(true),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
Bindable(true)]
public override string Text
{
get { return m_text; }
set { m_text = value; this.Invalidate(); }
}
public AquaButton()
{
InitializeComponent();
}
private void AquaButton_Resize(object sender, EventArgs e)
{
this.Width = 130;
this.Height = 28;
}
private void AquaButton_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
ExtendedGraphics eg = new ExtendedGraphics(g);
//SolidBrush br1 = new SolidBrush(Color.FromArgb(130, 125,236,255));
LinearGradientBrush br1 = new LinearGradientBrush(
new Point(60, 0),
new Point(60, 28),
Color.FromArgb(125, 236, 255),
Color.FromArgb(0, 130, 255)
);
eg.FillRoundRectangle(br1, 1, 1, 124, 25, 12);
if (m_IsMouseOver)
{
GraphicsPath GP = new GraphicsPath();
GP.AddEllipse(25, -7, 70, 70);
PathGradientBrush PGB = new PathGradientBrush(GP);
PGB.CenterColor = Color.FromArgb(0, 255, 0);
PGB.SurroundColors = new Color[] { Color.FromArgb(0, 0, 0, 0) };
g.FillRectangle(PGB, 0, 0, 130, 26);
}
Pen pn1 = new Pen(Color.Black, 2f);
eg.DrawRoundRectangle(pn1, 1, 1, 124, 25, 12);
Rectangle rect1 = new Rectangle(0, 0, this.Width, this.Height);
StringFormat strForm = new StringFormat();
strForm.Alignment = StringAlignment.Center;
strForm.LineAlignment = StringAlignment.Center;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.DrawString(m_text,
new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold),
Brushes.Black,
rect1,
strForm
);
}
private void AquaButton_MouseEnter(object sender, EventArgs e)
{
m_IsMouseOver = true;
this.Invalidate();
}
private void AquaButton_MouseLeave(object sender, EventArgs e)
{
m_IsMouseOver = false;
this.Invalidate();
}
}