Results 1 to 4 of 4

Thread: A puzzling GDI+ Q...;)

  1. #1

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Cool A puzzling GDI+ Q...;)

    Hello everyone...
    Heres a puzzling question..
    I want to draw bars across a form...and I am not able to draw all across the form..(Not doing a very serious project,just having fun doing something crazy.)
    Code:
    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    		{
    			
    		drawbars(e.Graphics,Color.Red,Color.Blue,3,0);
    			drawbars(e.Graphics,Color.Yellow,Color.Red,(this.Width/6),0);
    			drawbars(e.Graphics,Color.Green,Color.Blue,(this.Width/3),0);
    			drawbars(e.Graphics,Color.Chocolate,Color.White,(this.Width/2),0);
    			
    			
    			//drawbars(e.Graphics,Color.BlueViolet,Color.Honeydew,(this.Width/-1),0);
    
    		}
    		private void drawbars(Graphics g,Color x,Color y,int i,int j)
    		{
    
    			System.Drawing.Rectangle rec=new Rectangle(i,j,(this.Width/5),(this.Height));
    			LinearGradientBrush grad=new LinearGradientBrush(rec,x,y,10,true);
    
    g.FillRectangle(grad,rec);
    
    		}
    
    		private void Form1_Resize(object sender, System.EventArgs e)
    		{
    			this.Invalidate();
    
    		}
    So,can someone help me achieve drawing bars till the right end of the form?
    Thank Youuu
    Godwin

    Help someone else with what someone helped you!

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: A puzzling GDI+ Q...;)

    well just the wrong math
    drawbars(e.Graphics,Color.Red,Color.Blue,3,0);
    drawbars(e.Graphics,Color.Yellow,Color.Red,(this.Width/4),0);
    drawbars(e.Graphics,Color.Green,Color.Blue,(this.Width/2),0);
    drawbars(e.Graphics,Color.Chocolate,Color.White,(int)(this.Width *3.0/4),0);

    I just changed the width * whatever's
    and inside the draw function, change /5 to /4
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: A puzzling GDI+ Q...;)

    Wow Mr Polite,You're too good at Math too...Awesomeeee

    hmmm,but,this correction you made leaves a white gap between each bar.Its perfect apart from that.
    Godwin

    Help someone else with what someone helped you!

  4. #4

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: A puzzling GDI+ Q...;)

    I was actually trying to draw many bars all across the form..without any gaps between the bars and no empty space on the right side.I dont know what math i should use though.
    Forgive me since Im bad at math.
    Godwin

    Help someone else with what someone helped you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width