public class ser { System.Drawing.Graphics zona_des; int x0; //pozitia pe x int y0; //pozitia pe y int w; //latimea int wp; //latimea pistonului int h; //inaltimea double val_max; //valoarea maxima double val_min; //valoarea minima public void desenez(System.Drawing.Color culoare_contur, System.Drawing.Color culoare_gradatii, System.Drawing.Color culoare_valori) { System.Drawing.Pen creion_contur = new System.Drawing.Pen(culoare_contur); System.Drawing.Pen creion_gradatii = new System.Drawing.Pen(culoare_gradatii); System.Drawing.SolidBrush pens_valori = new System.Drawing.SolidBrush(culoare_valori); System.Drawing.Font font_ni = new System.Drawing.Font("Nina", 8); zona_des.DrawRectangle(creion_contur, x0, y0, w+wp, h); for (int i = 0; i <= w; i += 5)// desenez gradatii { if (i % 25 == 0) { zona_des.DrawLine(creion_gradatii, x0 + i, y0 + h+12, x0 + i, y0 + h+1); zona_des.DrawString(System.Convert.ToString(val_min + (int) (i * (val_max - val_min) / w)), font_ni, pens_valori, x0+i-5, y0 + h+15); } else { zona_des.DrawLine(creion_gradatii, x0 + i, y0 + h+1, x0 + i, y0 + h+7); } } } public void setval(double val, System.Drawing.Color culoare_ser, System.Drawing.Color culoare_piston, System.Drawing.Color culoare_radiera) { System.Drawing.SolidBrush pens_ser = new System.Drawing.SolidBrush(culoare_ser); System.Drawing.SolidBrush pens_piston = new System.Drawing.SolidBrush(culoare_piston); System.Drawing.SolidBrush rad = new System.Drawing.SolidBrush(culoare_radiera); zona_des.FillRectangle(rad, x0 + 1, y0 + 1, w+wp-1, h - 1); if (val > val_max) val = val_max; if (val < val_min) val = val_min; int vl = System.Convert.ToInt16(System.Convert.ToDouble(val - val_min) * (System.Convert.ToDouble(w) / System.Convert.ToDouble(val_max - val_min))); //scalare zona_des.FillRectangle(pens_ser, x0 + 1, y0 + 1, vl, h-1); zona_des.FillRectangle(pens_piston, x0+1 + vl, y0+1, wp-2, h-1); zona_des.FillRectangle(pens_piston, x0+1 + vl, y0+1 + h / 2-1, w-vl+wp, 2); } public ser(System.Drawing.Graphics desen, int pozx, int pozy, int lat, int inalt, int w_piston, double vmin, double vmax) { zona_des = desen; x0 = pozx; y0 = pozy; w = lat; wp = w_piston; h = inalt; val_max = vmax; val_min = vmin; } }