Sunday, May 16, 2010

I want to change color of the cirlcle by left clik and change the back ground color by right click , I?

I wote it lik ethis but it doesnt work. Would you guide me?


using System;


using System.Collections.Generic;


using System.ComponentModel;


using System.Data;


using System.Drawing;


using System.Text;


using System.Windows.Forms;





namespace WindowsApplication6


{


public partial class Form1 : Form


{


private int X;


private int Y;


private int Weidth;


private int Height;





public Form1()


{


InitializeComponent();


}





private void pictureBox1_Paint(object sender, PaintEventArgs e)


{


Brush b = new SolidBrush(Color.Orange);


e.Graphics.FillEllipse(b, Weidth, Height, 50 ,50);


}








private void button1_MouseUp(object sender, MouseEventArgs e)


{


button = new button1(Right);


if (e.Button == MouseUp.Right)





pictureBox1.BackColor = Color.DarkMagenta;





pictureBox1.Invalidate();





else





e.Graphics.FillEllipse = Color.DarkMagenta;


}





private void button2_MouseUp(object sender, MouseEventArgs e)


{


pictureBox1.BackColor = Color.Fuchsia;


}





private void button3_MouseUp(object sender, MouseEventArgs e)


{


pictureBox1.BackColor = Color.GreenYellow;


}





private void button4_MouseUp(object sender, MouseEventArgs e)


{


pictureBox1.BackColor = Color.DarkOrange;


}














}


}

I want to change color of the cirlcle by left clik and change the back ground color by right click , I?
could you describe the problem you face with it. At first glance the "button1_MouseUp" must look like this:





// button = new button1(Right); //oh omit this


if (e.Button == MouseUp.Right)


{ //here





pictureBox1.BackColor = Color.DarkMagenta;





pictureBox1.Invalidate();


} //and here





else


{ // and also here


e.Graphics.FillEllipse = Color.DarkMagenta;


Invalidate(); //and also here


}//also here

baby shoes

No comments:

Post a Comment