using using using using using using using usins
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms; System.Collection;
namespace assignment { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
}
private void button1_Click(object sender, EventArgs e) { this.BackColor = (Color)colors[comboBox1.SelectedIndex]; } ArrayList colors = new ArrayList(); private void Form1_Load(object sender, EventArgs e) { colors.Add(Color.Red); colors.Add(Color.Green); colors.Add(Color.Blue); }
} Width of line increase on input using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms; System.Collections;
namespace graphics { public partial class Form1 : Form { Graphics g; public Form1() { InitializeComponent(); g = this.CreateGraphics(); } int x1 = 50; int y1 = 30; int x2 = 50; int y2 = 500;
int width = 0; private void button1_Click(object sender, EventArgs e) { g = this.CreateGraphics(); width = Convert.ToInt32(comboBox2.Text); Pen p = new Pen((Color) colors [comboBox1.SelectedIndex],width); g.DrawLine(p, x1, y1, x2, y2); } private void button2_Click(object sender, EventArgs e) { width = Convert.ToInt32(comboBox2.Text); Pen p = new Pen(this.BackColor,width); g.DrawLine(p, x1, y1, x2, y2); } ArrayList colors = new ArrayList(); private void Form1_Load(object sender, EventArgs e) { colors.Add(Color.Red); colors.Add(Color.Green); colors.Add(Color.Blue); } private void Form1_MouseClick(object sender, MouseEventArgs e) { } } } 2 radio buttons of pencil & line draw line according to selection using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms;
namespace pencil { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Graphics g; int x1, y1, x2, y2; private void Form1_Load(object sender, EventArgs e) {
} private void Form1_MouseUp(object sender, MouseEventArgs e) { if (radioButton2.Checked == true) { g = this.CreateGraphics(); x2 = e.X; y2 = e.Y; Point start = new Point(x1,y1); Point end = new Point(x2, y2); x1 = x2; y1 = y2; Pen p = new Pen(Color.Black, 2); g.DrawLine(p, start, end); } } private void Form1_MouseMove(object sender, MouseEventArgs e) { if (radioButton1.Checked == true) { g = this.CreateGraphics(); x2 = e.X; y2 = e.Y; Pen p = new Pen(Color.Black, 2); g.DrawLine(p, x1, y1, x2, y2); x1 = x2; y1 = y2; } } private void Form1_MouseDown(object sender, MouseEventArgs e) { x1 = e.X; y1 = e.Y; } private void button1_Click(object sender, EventArgs e) { g.Clear(this.BackColor); } } }
2 buttons of draw & erase when draw click line drawn and when erase click then erase line using using using using
System; System.Collections.Generic; System.Text; System.Drawing;
namespace ClassLine { public class Line { public int x1, y1, x2, y2; public Pen p1; public Graphics g; public int width; public Line(Color c, int w, Graphics g) { this.g = g; width = w; p1 = new Pen(c, w); } public void DrawLine() { g.DrawLine(p1, x1, y1, x2, y2); } public void Erase(Color c) { Pen p1 = new Pen(c, width); g.DrawLine(p1, x1, y1, x2, y2); } } }
using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms;
namespace ClassLine { public partial class Form1 : Form { Graphics g; public Form1() { InitializeComponent(); g = this.CreateGraphics(); } private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e) { Graphics g1 = this.CreateGraphics(); Line l1 = new Line(Color.Red, 2, g1); l1.x1 = 10; l1.y1 = 20; l1.x2 = 10; l1.y2 = 40; l1.DrawLine(); } private void button2_Click(object sender, EventArgs e) { Graphics g1 = this.CreateGraphics(); Line l1 = new Line(Color.Red, 2, g1); l1.x1 = 10; l1.y1 = 20; l1.x2 = 10; l1.y2 = 40; l1.Erase(this.BackColor); } }
}
using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms; System.Collections;
namespace Defined_Color_Line { public partial class Form1 : Form { Graphics g; int i, j, k, l, h = 0; public Form1() { InitializeComponent(); g = this.CreateGraphics(); } ArrayList colors = new ArrayList();
private void button1_Click(object sender, EventArgs e) { Pen p = new Pen((Color)colors[comboBox1.SelectedIndex], Convert.ToInt32(comboBox2.Text)); Point ptr1 = new Point(i, j); Point ptr2 = new Point(k, l); g.DrawLine(p, ptr1, ptr2); } private void Form1_Load(object sender, EventArgs e) { colors.Add(Color.Blue); colors.Add(Color.Red); colors.Add(Color.Green); colors.Add(Color.White); colors.Add(Color.Olive); colors.Add(Color.Yellow); } private void Form1_MouseClick(object sender, MouseEventArgs e) {
} }
if (h == 0) { i = (e.X); j = (e.Y); h++; } else { k = (e.X); l = (e.Y); }
}
using using using using using using using using
System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms; System.Collections;
namespace @new { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
ArrayList colors = new ArrayList(); private void Form1_Load(object sender, EventArgs e) { colors.Add(Color.Red); colors.Add(Color.Green); colors.Add(Color.Blue); } private void button1_Click(object sender, EventArgs e) { this.BackColor = (Color)colors[comboBox1.SelectedIndex]; } private void button2_Click(object sender, EventArgs e) { foreach (Control c in this.Controls) { if (c.GetType().Name == "TextBox") { if (c.Text == "") { MessageBox.Show("Enter data"); c.Focus(); break; } } else {
comboBox1.Items.Add(colors.Add(Color.FromArgb(Int32 .Parse(textBox1.Text), Int32.Parse(textBox2.Text), Int32.Parse(textBox3.Text))) + nametextBox4.Text); break; } }
} }
}