public class bit { System.Drawing.Graphics zona_des; System.Drawing.SolidBrush pens_bit; System.Drawing.Bitmap img; Graphics g; System.Drawing.Pen creion_contur = new System.Drawing.Pen(System.Drawing.Color.Blue); System.Drawing.SolidBrush pens_stins = new System.Drawing.SolidBrush(System.Drawing.Color.Gray); System.Drawing.SolidBrush pens_rad = new System.Drawing.SolidBrush(System.Drawing.Color.White); int x0; // pozitia pe x a bitului int y0; // pozitia pe y a bitului int wd; // latimea int tp; // tipul formei de afisat public bit(System.Drawing.Graphics desen, int x, int y, int wi, int tip, System.Drawing.SolidBrush culoare_bit) { zona_des = desen; pens_bit = culoare_bit; // culoarea cu care va fi desenta bitul x0 = x; // pozitia pe x a bitului y0 = y; // pozitia pe y a bitului wd = wi; // latimea tp = tip; // tipul formei de afisat // 1=cerc // 2=patrat // 3=sageata stanga // 4=sageata dreapta // 5=sageata jos // 6=sageata sus } public void setval(bool val) { img = new Bitmap(wd + 2, wd + 2, zona_des); g = Graphics.FromImage(img); // sterg continutul imaginii g.FillRectangle(pens_rad, 0, 0, wd + 2, wd + 2); // desenez bit // cerc if (tp == 1) { // umplere cerc if (val) g.FillEllipse(pens_bit, 0, 0, wd, wd); else g.FillEllipse(pens_stins, 0, 0, wd, wd); // trasare conturn g.DrawEllipse(creion_contur, 0, 0, wd, wd); } // patrat if (tp == 2) { // umplere patrat if (val) g.FillRectangle(pens_bit, 0, 0, wd, wd); else g.FillRectangle(pens_stins, 0, 0, wd, wd); // trasare conturn g.DrawRectangle(creion_contur, 0, 0, wd, wd); } // sageata stanga if (tp == 3) { Point p1 = new Point(wd / 2, 0); Point p2 = new Point(wd / 2, wd / 4); Point p3 = new Point(wd, wd / 4); Point p4 = new Point(wd, wd * 3 / 4); Point p5 = new Point(wd / 2, wd * 3 / 4); Point p6 = new Point(wd/2, wd ); Point p7 = new Point(0, wd / 2); Point[] puncte = { p1, p2, p3, p4, p5, p6, p7}; // umplere poligon if (val) g.FillPolygon(pens_bit, puncte); else g.FillPolygon(pens_stins, puncte); // trasare conturn poligon g.DrawPolygon(creion_contur, puncte); } // sageata dreapta if (tp == 4) { Point p1 = new Point(0, wd / 4); Point p2 = new Point(wd / 2, wd / 4); Point p3 = new Point(wd / 2, 0); Point p4 = new Point(wd, wd / 2); Point p5 = new Point(wd / 2, wd); Point p6 = new Point(wd / 2, wd * 3 / 4); Point p7 = new Point(0, wd * 3 / 4); Point[] puncte = { p1, p2, p3, p4, p5, p6, p7 }; // umplere poligon if (val) g.FillPolygon(pens_bit, puncte); else g.FillPolygon(pens_stins, puncte); // trasare conturn poligon g.DrawPolygon(creion_contur, puncte); } // sageata jos if (tp == 5) { Point p1 = new Point(wd / 4, 0); Point p2 = new Point(wd * 3 / 4, 0); Point p3 = new Point(wd * 3 / 4, wd/2); Point p4 = new Point(wd, wd/2); Point p5 = new Point(wd / 2, wd); Point p6 = new Point(0,wd / 2); Point p7 = new Point(wd/4, wd/2); Point[] puncte = { p1, p2, p3, p4, p5, p6, p7 }; // umplere poligon if (val) g.FillPolygon(pens_bit, puncte); else g.FillPolygon(pens_stins, puncte); // trasare conturn poligon g.DrawPolygon(creion_contur, puncte); } // sageata sus if (tp == 6) { Point p1 = new Point(0,wd / 2); Point p2 = new Point(wd /2, 0); Point p3 = new Point(wd, wd / 2); Point p4 = new Point(wd*3/4, wd / 2); Point p5 = new Point(wd *3/4, wd); Point p6 = new Point(wd/4, wd); Point p7 = new Point(wd / 4, wd / 2); Point[] puncte = { p1, p2, p3, p4, p5, p6, p7 }; // umplere poligon if (val) g.FillPolygon(pens_bit, puncte); else g.FillPolygon(pens_stins, puncte); // trasare conturn poligon g.DrawPolygon(creion_contur, puncte); } // plasez imaginea finala zona_des.DrawImage(img, x0, y0); } }