public class manom { System.Drawing.Pen creion_lg, creion_rad, creion_g, creion_r; System.Drawing.SolidBrush pens_a, pens_r, pens_rad; System.Drawing.Font font_arial; System.Drawing.Graphics zona_des; System.Drawing.Bitmap img; Graphics g; int x0, y0, xi, xe, xm, xgr, xgm, xtx, w, val_m, diam_i, diam_e, diam_m, diam_gr, diam_gm, diam_tx; int gr; //grosimea arcului de cerc bool af_grd; // se afiseaza gradatii public void setval(int val) { int vl = val; int alfa = 360 * vl / val_m; // sterg interiorul g.FillEllipse(pens_rad, xe-1, xe-1, diam_e+2, diam_e+2); // trasez arc de cerc g.DrawArc(creion_lg, xm, xm, diam_m, diam_m, 90, alfa); if ((w >= 150) && af_grd) { g.DrawEllipse(creion_g, xi, xi, diam_i, diam_i); g.DrawEllipse(creion_g, xe, xe, diam_e, diam_e); } g.DrawString(vl.ToString(), font_arial, pens_r, (w - gr) / 2 - gr / 3, (w - gr) / 2 - 3*gr / 5); g.DrawString("/" + val_m.ToString(), font_arial, pens_a, (w - gr) / 2 - gr / 3, (w - gr) / 2 + gr / 2); // afisez imaginea zona_des.DrawImage(img, x0, y0); } public manom(System.Drawing.Graphics desen, int pozx, int pozy, bool af_gradatii, int diam, int val_max) { x0 = pozx; // pozitia pe x a instrumentului y0 = pozy; // pozitia pe y a instrumentului if(diam>99) w = diam; // latimea instrumentului else w = 100; // minima latimea instrumentului gr = w/11; // grosimea arcului de cerc af_grd = af_gradatii; // afisare gradatii diam_i = diam - 7 * gr; // diametrul cercului interior diam_e = diam_i + 2 * gr; // diametrul cercului exterior diam_m = (diam_e + diam_i) / 2; // diametrul cercului mediu pentru arcul de cerc diam_gr = diam_e + 2 * gr / 3; // diametrul cercului pentru gradatii diam_gm = diam_e + 4 * gr / 3; // diametrul cercului pentru gradatii mari diam_tx = diam_e + 3 * gr; // diametrul cercului pentru texte val_m = val_max; // valoarea maxima afisata xi = (w - diam_i) / 2; // coordonata pentru cercul interior xe = (w - diam_e) / 2; // coordonata pentru cercul exterior xm = (w - diam_m) / 2; // coordonata pentru cercul mediu xgr = (w - diam_gr) / 2; // coordonata pentru cercul gradatiilor mici xgm = (w - diam_gm) / 2; // coordonata pentru cercul gradatiilor mari xtx = (w - diam_tx)/2-gr/3; // coordonata pentru cercul valorilor creion_lg = new System.Drawing.Pen(System.Drawing.Color.LightGray, gr); creion_rad = new System.Drawing.Pen(System.Drawing.Color.White, gr); creion_g = new System.Drawing.Pen(System.Drawing.Color.Gray); creion_r = new System.Drawing.Pen(System.Drawing.Color.Blue); font_arial = new System.Drawing.Font("Arial", 10); pens_a = new System.Drawing.SolidBrush(System.Drawing.Color.Gray); pens_r = new System.Drawing.SolidBrush(System.Drawing.Color.Red); pens_rad = new System.Drawing.SolidBrush(System.Drawing.Color.White); zona_des = desen; img = new Bitmap(w, w, zona_des); g = Graphics.FromImage(img); g.FillRectangle(pens_rad, 0, 0, w + 2, w + 2); int k = 0; double grd; // grade hexazecimale // trasez gradatii si valori for (grd = 630; grd > 270; grd -= 3.6) { double rad = 2 * System.Math.PI * grd / 360; int x1 = Convert.ToInt16(xe + (diam_e / 2) + (diam_e / 2) * System.Math.Cos(rad)); int y1 = Convert.ToInt16(xe + (diam_e / 2) - (diam_e / 2) * System.Math.Sin(rad)); int x2 = Convert.ToInt16(xgr + (diam_gr / 2) + (diam_gr / 2) * System.Math.Cos(rad)); int y2 = Convert.ToInt16(xgr + (diam_gr / 2) - (diam_gr / 2) * System.Math.Sin(rad)); int x3 = Convert.ToInt16(xgm + (diam_gm / 2) + (diam_gm / 2) * System.Math.Cos(rad)); int y3 = Convert.ToInt16(xgm + (diam_gm / 2) - (diam_gm / 2) * System.Math.Sin(rad)); int x4 = Convert.ToInt16(xtx + (diam_tx / 2) + (diam_tx / 2) * System.Math.Cos(rad)); int y4 = Convert.ToInt16(xtx + (diam_tx / 2) - (diam_tx / 2) * System.Math.Sin(rad)); if ((w >= 150) && af_grd) { if (k % 10 != 0) { if(w>=200) g.DrawLine(creion_g, x1, y1, x2, y2); } else { g.DrawLine(creion_r, x1, y1, x3, y3); g.DrawString((k * val_m / 100).ToString(), font_arial, pens_a, x4 - gr / 2, y4); } k++; } } } }