ایجاد طیف رنگ (Gradient) بعنوان پشت زمینه ی کنترلها
پنج شنبه 11 اردیبهشت 1393 9:42 AM
ایجاد طیف رنگ (Gradient) بعنوان پشت زمینه ی کنترلها
using System.Drawing.Drawing2D;
using System.Drawing;
public void PaintGradient(Control _control, LinearGradientMode _direction, Color _gradientColorStart, Color _gradientColorEnd) { LinearGradientBrush gradBrush;
gradBrush = new LinearGradientBrush(new Rectangle(0, 0, _control.Width, _control.Height), _gradientColorStart, _gradientColorEnd, _direction); Bitmap bmp = new Bitmap(_control.Width, _control.Height);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(gradBrush, new Rectangle(0, 0, _control.Width, _control.Height));
_control.BackgroundImage = bmp; _control.BackgroundImageLayout = ImageLayout.Stretch; }
حال این متود رو در رخداد Paint کنترلهای دلخواه (فرم، دکمه، پنل ...) بنویسید :
private void Form1_Paint(object sender, PaintEventArgs e) { PaintGradient(this, LinearGradientMode.Vertical, Color.RoyalBlue, Color.DarkBlue); }
خصوصا ظاهر بهتر و مناسبتری برای دکمه های شما ایجاد میکند.
ترکی زبان قربون صدقه رفتنه داریم که: گوزلرین گیلهسین قاداسین آلیم که یعنی درد و بلای مردمک چشات به جونم …!.