Hi, Actually I made a user control that its interface is like "glass windows" in windows vista and seven. My pattern was this url: extremestudio.ro/blog/?p=99
using "Photoshop" and draw every layer with C# and .Net drawing classes, I finally draw it. In first step, i create a bitmap class and then each layer will be drawn on it using graphic path and brushes and so on.
here is the control:glass panel (you must first add the "reflect.png" file to your project resources and then add class to project then build, ...) this control inherits from Panel in forms namespace
protected override void OnCreateControl()
{
draw();
BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
Parent.Move += new EventHandler(Parent_Move);
base.OnCreateControl();
}
void Parent_Move(object sender, EventArgs e)
{
draw();
}
public void draw()
{
if (Width < 20 || Height < 20)
{
return;
}
Bitmap b = new Bitmap(Width, Height);
Graphics gr = Graphics.FromImage(b);
GraphicsPath gp=new GraphicsPath();
LinearGradientBrush br;
gr.SmoothingMode = SmoothingMode.HighSpeed;
//draw shadow(black glow)
for (int i = 0; i < 10; i++)
{
gp = DrawRoundRect(i, i, Width - i * 2 - 1, Height - i * 2 - 1, 7);
br = new LinearGradientBrush(Bounds, Color.FromArgb(i * 3, Color.Black), Color.FromArgb(i * 3, Color.Black), LinearGradientMode.Vertical);
gr.DrawPath(new Pen(br, 4), gp);
br.Dispose();
}
//fill white 50
gp = DrawRoundRect(9, 9, Width - 19, Height - 19, 7);
br = new LinearGradientBrush(Bounds, Color.FromArgb(30, Color.White), Color.FromArgb(30, Color.White), LinearGradientMode.Vertical);
gr.FillPath(br, gp);
it was part of drawing code. I finnaly set the created bitmap to panel background.
i think(dont remember) also i use "onPaint()" overriding method,... but the program crashed. because the paint event consecutive raise.
OK,
my problem is the low efficiency of this control while moving and resizing parent form. because this works, cause calling "draw" method of the control and when calling of method got a lot, it will be slow down the application and more important, it is very CPU hungry.
I want you to learn me a way to draw the user interface of this control
1-using dot net 2.0
2-efficient
is there a way to paint UI using directx,...?(I mean not WPF)
if there is no way, i will remove the reflect part of the code that causes high CPU using.
thank you.