Ask Experts Questions for FREE Help !
Ask
    Teutn's Avatar
    Teutn Posts: 2, Reputation: 1
    New Member
     
    #1

    Jun 11, 2010, 03:01 AM
    Problem with a drawing program in visual basic 2008 (c sharp)(gui)
    Hello all,

    I am learning myself c sharp and for that I have been working on a drawing program where the user is capable of drawing lines in 3 different strokes and 4 different colors,

    My first problem is how to let the user make a line by 2 mouseclicks on the panel.

    This is the code I have so far:
    Namespace WindowsFormsApplication1
    Code:
    namespace WindowsFormsApplication1{
    public partial class Form1 : Form
        {
            Graphics e;
            Pen p;
            Point punt1, punt2;
            int nPunt = 0;
    
            
            public Form1()
            {
                InitializeComponent();
                
                p = new Pen(Color.Black);
            }
    
            public void tekenpaneel_MouseClick(object sender, MouseEventArgs e)
            {
                if (nPunt == 0)
                {
                    punt1 = new Point(e.X, e.Y);
                    nPunt++;
                }
                else if (nPunt == 1)
                {
                    punt2 = new Point(e.X, e.Y);
                    nPunt = 0;
                }
            }
    
    public void tekenpaneel_Paint(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawLine( p, punt1, punt2);
            }
    
        }
    }



    I don't got any errors but the program isn't doing anything when I click on the panel, I would be verry gratefull if someone could help me out :)
    Teutn's Avatar
    Teutn Posts: 2, Reputation: 1
    New Member
     
    #2

    Jun 11, 2010, 08:10 AM
    OK now a quick update of how my code is now so its easier to help me :)
    Already a big thanks, getting to really understand csharp now :D

    Code:
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public int A, B, X, Y;
            public Color m_Color;
            public Point punt1;
            public Point punt2;
            public int nPunt;
    
            public Form1()
            {
                InitializeComponent();
            }
            public void tekenpaneel_MouseClick(object sender, MouseEventArgs e)
            {
                if (nPunt == 0)
                {
                    punt1 = new Point(e.X, e.Y);
                    nPunt++;
                }
                else if (nPunt == 1)
                {
                    punt2 = new Point(e.X, e.Y);
                    nPunt = 0;
                }
            }
    
            private void zwartBtn2_CheckedChanged(object sender, EventArgs e)
            {
                m_Color = Color.Black;
            }
    
            private void roodBtn2_CheckedChanged(object sender, EventArgs e)
            {
                m_Color = Color.Red;
            }
    
            private void geelBtn2_CheckedChanged(object sender, EventArgs e)
            {
                m_Color = Color.Yellow;
            }
    
            private void blauwBtn2_CheckedChanged(object sender, EventArgs e)
            {
                m_Color = Color.Blue;
            }
            
            public void tekenpaneel_Paint(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawLine(new Pen(m_Color, 2), punt1, punt2);
            }
           
        }
    }
    I get no errors but no lines either... any help would be welcome :) THANKS!

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Is there any Gui Based Program in Linux as Task Manager in Windows [ 5 Answers ]

Hello I'm new to Linux I'm getting problem in process handling Is there any GUI based program in Linux as Task Manager in Windows so that I can handle processs easily Please assist me Regards

Palindrome in Visual Basic 2008 [ 1 Answers ]

May anyone tell me how to create a palindrome function in Visual Basic 2008, I need some help in my project...


View more questions Search