2 Replies - 379 Views - Last Post: 17 March 2010 - 02:05 PM Rate Topic: -----

#1 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Problem with Form Painting

Posted 16 March 2010 - 05:24 PM

Ok, well my problem is that i have to make two classes, one called plano_cartesiano and one called vector.
The class plano cartesiano(coordinate plane) has to draw a new Form with a coordinate plane.
Now the class vector has to draw different vectors entered by the user on the coordinate plane created.

So here is what i have

class coordinate plane
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace PlanoCartesian
{
    class Plano_Cartesiano
    {
        protected Form planoCartesiano;
        protected int midx;
        protected int midy;
        protected Graphics graf;

        public Plano_Cartesiano()
        {
            planoCartesiano = new Form();
            planoCartesiano.SuspendLayout();
            planoCartesiano.AutoScaleDimensions = new SizeF(6, 13);
            planoCartesiano.AutoScaleMode = AutoScaleMode.Font;
            planoCartesiano.Width = 800;
            planoCartesiano.Height = 800;
            planoCartesiano.ResumeLayout(false);
            planoCartesiano.PerformLayout();
            planoCartesiano.Show();
            graf = planoCartesiano.CreateGraphics();
            midx = planoCartesiano.Width / 2;
            midy = planoCartesiano.Height / 2;
            graf.DrawLine(new Pen(Color.Blue, 2), new Point(0, midy),
                new Point(planoCartesiano.Width, midy));
            graf.DrawLine(new Pen(Color.Blue, 2), new Point(midx, 0),
                new Point(midx, planoCartesiano.Height));
        }
    }
}


class vectores
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace PlanoCartesian
{
    class Vectores : Plano_Cartesiano
    {
        public Vectores(int xuno, int yuno)
        {
            graf.DrawLine(new Pen(Color.Red), new Point(midx, midy), new Point(midx + xuno, midy - yuno));
            planoCartesiano.Update();
        }
    }
}


My problem is that i cant find a way to make the vector be drawn in the form once created, what this testprogram does is creates a new Form and draws the vector, what i need is to draw the vector on the same form created originaly.

How can i do this?

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with Form Painting

#2 liz hundy  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 8
  • Joined: 03-June 09

Re: Problem with Form Painting

Posted 17 March 2010 - 11:24 AM

I would think that class Vectores should not be a subclass of your coordinate plane.

Instead you could try including a list of vectors in the coordinate plane.
Then the coordinate plane would be able to iterate through the list and draw all the vectors.

---Liz
Was This Post Helpful? 2
  • +
  • -

#3 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Re: Problem with Form Painting

Posted 17 March 2010 - 02:05 PM

Thanks for the reply its a good idea im going to give it a shot
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1