Click here to Skip to main content
15,913,709 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: asmx web service to access SQL server database. Pin
code4wcf19-Jul-10 9:58
code4wcf19-Jul-10 9:58 
GeneralRe: asmx web service to access SQL server database. Pin
Not Active19-Jul-10 10:16
mentorNot Active19-Jul-10 10:16 
GeneralRe: asmx web service to access SQL server database. Pin
Ennis Ray Lynch, Jr.19-Jul-10 10:30
Ennis Ray Lynch, Jr.19-Jul-10 10:30 
AnswerRe: asmx web service to access SQL server database. Pin
Luc Pattyn19-Jul-10 10:56
sitebuilderLuc Pattyn19-Jul-10 10:56 
GeneralRe: asmx web service to access SQL server database. Pin
Not Active19-Jul-10 11:32
mentorNot Active19-Jul-10 11:32 
GeneralRe: asmx web service to access SQL server database. Pin
code4wcf21-Jul-10 16:19
code4wcf21-Jul-10 16:19 
QuestionHow do i draw my "user control UI" faster and more efficient [modified] Pin
Rejnev19-Jul-10 2:14
Rejnev19-Jul-10 2:14 
AnswerRe: How i draw my "user control UI" faster and more efficient Pin
Eddy Vluggen19-Jul-10 2:38
professionalEddy Vluggen19-Jul-10 2:38 
Hi,

Most of our readers don't download archives to browse code, you'd get more replies if you'd add the code to the post (using PRE tags) I've included a small snippet of your code below for reference;
C#
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();
    }


On to your question; you're drawing in a dedicated method, called draw. This builds a bitmap in turn, and setting that as a backgroundimage.

You can paint directly on the canvas by overriding the Paint-handler;
C#
protected override void OnPaint(PaintEventArgs e)
{
    Graphics g = e.Graphics;
}
You can then use the Graphics object to draw directly to the canvas of the control.

Next, if your control needs redrawing, don't call the draw method, but call the Invalidate[^] method. Third tip would be to re-using objects like brushes and pens, as opposed to creating new ones each time you have to draw.

Hope this helps Smile | :)
I are Troll Suspicious | :suss:

GeneralRe: How i draw my "user control UI" faster and more efficient [modified] Pin
Rejnev19-Jul-10 3:00
Rejnev19-Jul-10 3:00 
GeneralRe: How i draw my "user control UI" faster and more efficient Pin
Eddy Vluggen19-Jul-10 5:16
professionalEddy Vluggen19-Jul-10 5:16 
Generalit's done Pin
Rejnev19-Jul-10 5:30
Rejnev19-Jul-10 5:30 
GeneralRe: it's done Pin
Eddy Vluggen19-Jul-10 5:58
professionalEddy Vluggen19-Jul-10 5:58 
Questionconvert to shortname Pin
vijiajai18-Jul-10 18:45
vijiajai18-Jul-10 18:45 
AnswerRe: convert to shortname Pin
Peace ON18-Jul-10 21:01
Peace ON18-Jul-10 21:01 
GeneralRe: convert to shortname Pin
vijiajai18-Jul-10 21:15
vijiajai18-Jul-10 21:15 
Answer[Repost] Re: convert to shortname Pin
Peace ON18-Jul-10 22:30
Peace ON18-Jul-10 22:30 
GeneralRe: ... posting anything ... Pin
The Man from U.N.C.L.E.18-Jul-10 23:15
The Man from U.N.C.L.E.18-Jul-10 23:15 
GeneralRe: ... posting anything ... Pin
Peace ON18-Jul-10 23:19
Peace ON18-Jul-10 23:19 
Questionabout datagrid Pin
rajpar17-Jul-10 20:07
rajpar17-Jul-10 20:07 
AnswerRe: about datagrid Pin
Abhinav S17-Jul-10 20:45
Abhinav S17-Jul-10 20:45 
AnswerRe: about datagrid Pin
Alicia Ouellet5-Oct-10 7:07
Alicia Ouellet5-Oct-10 7:07 
QuestionProblem binding data to a gridview on key press. Pin
Clint Westwood16-Jul-10 23:08
Clint Westwood16-Jul-10 23:08 
AnswerRe: Problem binding data to a gridview on key press. Pin
Peace ON16-Jul-10 23:25
Peace ON16-Jul-10 23:25 
QuestionMessage Removed Pin
16-Jul-10 1:19
sr15916-Jul-10 1:19 
Answer[Repost] Re: how to restore mysql dump file to database using C#, ASP.net Pin
Peace ON16-Jul-10 1:32
Peace ON16-Jul-10 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.