将资源文件应用在Skin

王朝other·作者佚名  2006-01-27
窄屏简体版  字體: |||超大  

思路来源:http://community.csdn.net//Expert/TopicView1.asp?id=4514237

private ResourceManager rm;

private Bitmap titlemiddle;

private Bitmap titleleft;

private Bitmap bottom;

private Bitmap right;

private Bitmap left;

private Bitmap system3back;

private Bitmap system3max;

private Bitmap systembutton;

private Brush brush;

......

rm = new ResourceManager("Cool.XPResources", Assembly.GetExecutingAssembly());

titleleft = (Bitmap)rm.GetObject("titleleft.jpg");

titlemiddle = (Bitmap)rm.GetObject("titlemiddle.jpg");

system3back = (Bitmap)rm.GetObject("system3back.jpg");

system3max = (Bitmap)rm.GetObject("system3max.jpg");

bottom = (Bitmap)rm.GetObject("bottom.jpg");

right = (Bitmap)rm.GetObject("right.jpg");

left = (Bitmap)rm.GetObject("left.jpg");

if(this.WindowState == System.Windows.Forms.FormWindowState.Maximized )

systembutton = system3back;

else

systembutton = system3max;

}

...

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint (e);

g = e.Graphics;

DrawTop_Left(g);//画标题栏左边

DrawTop_Right(g);//画标题栏右边

DrawTop_Middle(g);//画标题栏中间

g.Dispose();

g = null;

}

...

private void DrawTop_Left(Graphics g)

{//画标题栏左边(左上角)

brush = new TextureBrush(titleleft, new Rectangle(0, 0, titleleft.Width, titleleft.Height));

g.FillRectangle(brush, 0, 0, titleleft.Width, titleleft.Height);

brush.Dispose();

brush = null;

this.ititleleftWidth = titleleft.Width;

this.ititleleftHeight = titleleft.Height;

GC.Collect();

}

...

private void DrawTop_Right(Graphics g)

{//画标题栏右边(右上角)

iTop_Right_Width = systembutton.Width;

iTop_Right_Height = systembutton.Height;

brush = new TextureBrush(systembutton, new Rectangle(0, 0, systembutton.Width , systembutton.Height));

g.FillRectangle(brush,this.Width - systembutton.Width,0,systembutton.Width,systembutton.Height);

brush.Dispose();

brush = null;

GC.Collect();

}

...

private void DrawTop_Middle(Graphics g)

{//画标题栏中间

brush = new TextureBrush(titlemiddle,new Rectangle(0, 0, titlemiddle.Width , titlemiddle.Height));

g.FillRectangle(brush,ititleleftWidth ,0, this.Width - ititleleftWidth - iTop_Right_Width , titlemiddle.Height);

brush.Dispose();

brush = null;

System.GC.Collect();

}

...

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航