Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Link = https://www.dropbox.com/s/yl63nl33xrc3a2m/Capture.JPG?dl=0

Need help creating program using window form application which, the sales people can key in the size of the window frame, and how many sashes do it have in a textbox. In a frame can have more than 1-10 sashes, And it will the draw and generate the whole design according to the frame size, and the sashes is properly organize and spaced, example like in the picture at the top link.

this is some of my code using windows form

[edit]Code block added - OriginalGriff[/edit]

What I have tried:

C#
public partial class Form1 : Form
    {

        Graphics drawArea;
        
        public Form1()
        {
            InitializeComponent();
            drawArea = pictureBox1.CreateGraphics();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            ////frame
            //Pen frame = new Pen(Color.Black);
            //drawArea.DrawRectangle(frame, 30, 30, 1060, 700);
            ////width = 200
            ////height = 300

            ////SolidBrush blueBrush = new SolidBrush(Color.White);
            ////drawArea.FillRectangle(blueBrush, 100, 100, 100, 50);

            ////Sashes
            //Pen sashes = new Pen(Color.Black, 3);

            //// Create array of rectangles.
            //RectangleF[] sashesrec =
            //         {
            //     new RectangleF( 70, 70, 300,620 ),
            //     new RectangleF(410, 70, 300, 620),
            //     new RectangleF(750, 70, 300, 620)
            // };

            //// Draw rectangles to screen.
            //drawArea.DrawRectangles(sashes, sashesrec);

            ////glass
            //Pen glass = new Pen(Color.Black, 3);

            //// Create array of rectangles.
            //RectangleF[] glassrec =
            //         {
            //     new RectangleF( 100, 100, 240,560),
            //     new RectangleF(440, 100, 240,560),
            //     new RectangleF(780, 100, 240, 560)
            // };

            //// Draw rectangles to screen.
            //drawArea.DrawRectangles(panel, glassrec);

            int width, height, panel;

            width = Convert.ToInt32(txtWidth.Text);
            height = Convert.ToInt32(txtHeight.Text);
            panel = Convert.ToInt32(txtPanel.Text);


            //frame
            Pen frame = new Pen(Color.Black);
            drawArea.DrawRectangle(frame, 30, 30, width, height);
            //width = 200
            //height = 300


            //Sashes
            Pen Sashes = new Pen(Color.Black, panel);

            if (panel == 1)
            {
                RectangleF[] sashesrec =
                    {
                 new RectangleF( 70, 70, width - 760 ,height-80 )

             };
                drawArea.DrawRectangles(Sashes, sashesrec);

            }
            else if (panel==2)
            {
                RectangleF[] sashesrec =
                    {
                 new RectangleF( 70, 70, width - 760 ,height-80 ),
                 new RectangleF(410, 70, width - 760 ,height -80)
                
             };
                drawArea.DrawRectangles(Sashes, sashesrec);
            }
            else if(panel==3)
            {
                RectangleF[] sashesrec =
                    {
                 new RectangleF( 70, 70, width - 760 ,height-80 ),
                 new RectangleF(410, 70, width - 760 ,height -80),
                 new RectangleF(750, 70, width - 760 ,height -80)
             };
                drawArea.DrawRectangles(Sashes, sashesrec);
            }
           
       

            // Draw rectangles to screen.
     
}
Posted
Updated 17-Apr-18 22:49pm
v2
Comments
OriginalGriff 18-Apr-18 4:47am    
And?
While this is better than your previous attempt at asking this: https://www.codeproject.com/Questions/1240042/How-to-create-a-Csharp-program-which-u-key-in-the
You haven't told us what it does that you didn't expect, or doesn't do that you did.
What's the problem?
Where are you stuck?
What help do you need?

Just dumping your homework question here with a lump of mostly commented out code and no explanation doesn't help anyone!
F-ES Sitecore 18-Apr-18 4:58am    
This isn't a website where people do your job for you. If you want to start a thread then ask a proper, focused, question, don't just dump your code and expect someone to finish it off.
Richard MacCutchan 18-Apr-18 5:17am    
You really need to do some proper design of your application. Start with an abstract Window class that has the basic properties and methods, including the code to draw itself. Then inherit from that the different specific window classes that may be required.
W Balboos, GHB 18-Apr-18 8:59am    
It sounds like a product for a business - which they will use to make money. If that is the case, they should pay the developer. If that is someone here, at code project, then they should be compensated for their time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900