Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Form1()
- {
- InitializeComponent();
- g = panel1.CreateGraphics();
- }
- public enum FigType
- {
- circle, rect, triangle //nbg lfyysq[
- }
- FigType typeF; // == circle
- Graphics g;
- int xOLD; int yOLD;
- private void panel1_MouseDown(object sender, MouseEventArgs e)
- {
- xOLD = e.X;
- yOLD = e.Y;
- }
- private void rect_Click(object sender, EventArgs e)
- {
- typeF = FigType.rect;
- }
- private void circle_Click(object sender, EventArgs e)
- {
- typeF = FigType.circle;
- }
- private void traingle_Click(object sender, EventArgs e)
- {
- typeF = FigType.triangle;
- }
- private void panel1_MouseUp(object sender, MouseEventArgs e)
- {
- int width; int height;
- if (xOLD > e.X && yOLD > e.Y)
- {
- width = xOLD - e.X;
- height = yOLD - e.Y;
- }
- else
- {
- width = e.X - xOLD;
- height = e.Y - yOLD;
- }
- if (typeF == FigType.rect)
- {
- Rectangle rect = new Rectangle(xOLD, yOLD, width, height, colorDialog1.Color, colorDialog2.Color);
- rect.Draw(g);
- }
- if (typeF == FigType.circle)
- {
- Cirkle cirk = new Cirkle(xOLD, yOLD, width, height, colorDialog1.Color, colorDialog2.Color);
- cirk.Draw(g);
- }
- if (typeF == FigType.triangle)
- {
- Traingle cirk = new Traingle(xOLD, yOLD, width, height, colorDialog1.Color, colorDialog2.Color);
- cirk.Draw(g);
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (colorDialog1.ShowDialog() == DialogResult.OK)
- Color.BackColor = colorDialog1.Color;
- }
- private void zalivka_Click(object sender, EventArgs e) // не так фурычит
- {
- if (colorDialog2.ShowDialog() == DialogResult.OK)
- Color.BackColor = colorDialog2.Color;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement