Class Library C#

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Class Library C#

Post by Dredric1 on Mon Feb 15, 2010 4:27 pm
([msg=35120]see Class Library C#[/msg])

im making a class library and am running into an error
whenever i import and use its methods it doesnt do what i want it to do

here is the code
Code: Select all
Control c = new Control();
        public class Perimeter
        {
            Rectangle r = new Rectangle();
            Control c = new Control();

            public void CirclePerimeter(Pen pen,int MiddleX, int MiddleY, int Diameter)
            {
                MiddleX = (MiddleX) - (Diameter / 2);
                MiddleY = (MiddleY) - (Diameter / 2);
                r = new Rectangle(MiddleX, MiddleY, Diameter, Diameter);
                using (Graphics g = c.CreateGraphics()) { g.DrawRectangle(pen,r); } 
            }
        }


basicaly it wont draw the rectangle
the code for the void exception between the ear brackets
Code: Select all
public static }void(exception x = new exception(null)){

ok my brackets dont realy look like ears.
if you didnt get that it means there is nothing(no brains) between your ears.
User avatar
Dredric1
Poster
Poster
 
Posts: 188
Joined: Fri Jan 09, 2009 7:29 pm
Blog: View Blog (0)


Re: Class Library C#

Post by faazshift on Mon Feb 15, 2010 4:57 pm
([msg=35127]see Re: Class Library C#[/msg])

Its been a little while since I have done this sort of thing. I have a small program from my programming class a couple years ago that might help you: http://66.93.224.121/pub/programming/Module6/Rain/Rain/. Its only one of my programs that uses graphics. Feel free to take a look at the others (modules 6-11).
faazshift
Contributor
Contributor
 
Posts: 516
Joined: Wed Jun 03, 2009 3:55 pm
Location: Riverton, Utah
Blog: View Blog (0)


Re: Class Library C#

Post by BhaaL on Tue Feb 16, 2010 11:50 am
([msg=35169]see Re: Class Library C#[/msg])

It does draw the graphics, but this is not the correct way to achieve permanent stuff.
The control will redraw itself after some time, which will delete your rectangle.

Attach that painting to c.Paint (or, if you have your own class derived from Control, override the OnPaint method) to get it permanently.
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: Class Library C#

Post by Dredric1 on Tue Feb 16, 2010 10:02 pm
([msg=35193]see Re: Class Library C#[/msg])

thanks so much i now have it figured out
the code for the void exception between the ear brackets
Code: Select all
public static }void(exception x = new exception(null)){

ok my brackets dont realy look like ears.
if you didnt get that it means there is nothing(no brains) between your ears.
User avatar
Dredric1
Poster
Poster
 
Posts: 188
Joined: Fri Jan 09, 2009 7:29 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests