美化之前:
美化后:
具体代码:
private Bitmap BP;
public struct Form4Show
{
public Color LGcolor1;
public Color LGcolor2;
public Color ControlBorderColor;
public Color ADBannerColor;
public Color DownBarColor1;
public Color DownBarColor2;
}
private StringFormat SF = new StringFormat();
private Form4Show fs = new Form4Show();
private Color tmpColor1;
private Color tmpColor2;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | 0x80000;
return cp;
}
}
public Bitmap timer1_time()
{
string path;
path = "y2.png";//界面图片的路径
Bitmap BP;
BP = new Bitmap(path);
foreach (Control Ct in this.Controls)
{
try
{
Ct.Update();
Ct.DrawToBitmap(BP, Ct.Bounds);
}
catch
{
}
}
return BP;
}
private void Form2_Load(object sender, EventArgs e)
{
dylikeButton1.A_KEY = "D";
dylikeButton1.MakeButtonThisForm(@"D:/编程/DEMO和控件渲染/按钮皮肤控件/buton.png");//按钮图片的路径
dylikeButton1.Hide();
DYD.DYD dyd = new DYD.DYD();
dyd.UserKey = "D";
dyd.DrawBP(this, timer1_time(), 255);
SF.Alignment = StringAlignment.Near;
fs.LGcolor1 = Color.FromArgb(255, 150, 100, 255);
fs.DownBarColor1 = Color.FromArgb(255, 56, 118, 175);
fs.DownBarColor2 = Color.FromArgb(255, 42, 89, 133);
BP = new Bitmap(this.Width, this.Height);
tmpColor1 = fs.LGcolor1;
tmpColor2 = Color.White;
Graphics G = Graphics.FromImage(BP);
System.Drawing.Drawing2D.LinearGradientBrush LG = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(0, this.Height), fs.LGcolor1, fs.LGcolor2);
G.FillRectangle(LG, new Rectangle(0, 0, this.Width, this.Height));
this.BackgroundImage = BP;
}
private void IDcombo_DrawItem(object sender, DrawItemEventArgs e)
{
System.Drawing.Drawing2D.LinearGradientBrush LG2 = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(IDcombo.Width / 10, IDcombo.ItemHeight), fs.DownBarColor1, fs.DownBarColor2);
e.Graphics.FillRectangle(LG2, new Rectangle(0, 0, IDcombo.Width, IDcombo.DropDownHeight));
for (int I = 0; I < IDcombo.Items.Count; I++)
{
if (I != IDcombo.SelectedIndex)
{
e.Graphics.DrawString(IDcombo.Items[I].ToString(), IDcombo.Font, Brushes.Indigo, new Rectangle(0, I * IDcombo.ItemHeight, IDcombo.Width, IDcombo.ItemHeight), SF);//改变下拉框字体颜色
}
}
if (IDcombo.SelectedIndex != -1)
{
if (IDcombo.SelectedIndex > 0 && Modal)
{
}
else
{
System.Drawing.Drawing2D.LinearGradientBrush LG3 = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, IDcombo.SelectedIndex * IDcombo.ItemHeight - IDcombo.ItemHeight), new Point(IDcombo.Width / 10, IDcombo.SelectedIndex * IDcombo.ItemHeight), tmpColor1, tmpColor2);
e.Graphics.FillRectangle(LG3, new Rectangle(0, IDcombo.SelectedIndex * IDcombo.ItemHeight, IDcombo.Width, IDcombo.ItemHeight));
}
e.Graphics.DrawString(IDcombo.Items[IDcombo.SelectedIndex].ToString(), IDcombo.Font, Brushes.Red, new Rectangle(0, IDcombo.SelectedIndex * IDcombo.ItemHeight, IDcombo.Width, IDcombo.ItemHeight), SF);//下拉框中选中字体颜色
}
}
需要用到的类库是有:
这是美化按钮的:
http://www.dylike-soft.com/upfile/2009/5/200953113811795.RAR
这是美化界面的:
http://www.dylike-soft.com/upfile/2009/8/2009817235113385.RAR,
类库是由DYLIKE编写版权所有
关于界面需要设置的属性有:formborderstyle = none,
下拉列表框需要设置的属性有:DrawMode = OwnerDrawFixed.