و این هم دکمه ای که وقتی غیر فعال می شه رنگ تصویرش سیاه و سفید می شه
Untitled.jpg
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace btnvoo
{
public partial class Form1 : Form
{
Image disabledButton = null;
Image enabledButton = null;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
enabledButton = button1.Image;
disabledButton = Image.FromHbitmap(MakeGrayscale(new Bitmap(button1.Image)).GetHbitmap());
button1.Image = disabledButton;
}
private void button1_Enter(object sender, EventArgs e)
{
button1.Image = enabledButton;
}
private void button1_Leave(object sender, EventArgs e)
{
button1.Image = disabledButton;
}
public static Bitmap MakeGrayscale(Bitmap original)
{
Bitmap newBitmap = new Bitmap(original.Width, original.Height);
for (int i = 0; i < original.Width; i++)
{
for (int j = 0; j < original.Height; j++)
{
Color originalColor = original.GetPixel(i, j);
int grayScale = (int)((originalColor.R * .3) + (originalColor.G * .59)
+ (originalColor.B * .11));
Color newColor = Color.FromArgb(grayScale, grayScale, grayScale);
newBitmap.SetPixel(i, j, newColor);
}
}
return newBitmap;
}
}
}