//新建畫板
System.Drawing.Graphics G = System.Drawing.Graphics.FromImage(methods.bitmap);
G.Clear(Color.White);
int cs2 = cs * 2;
//設置顏色,寬度
Pen pen = new Pen(Color.Black, 2);
G.DrawLine(new Pen(Color.LightSteelBlue, 1), 300, 250 - id / 2 - cs - 40, 300, 250 + id / 2 + cs);
G.DrawLine(new Pen(Color.LightSteelBlue, 1), 300 - id / 2 - cs - 20, 230, 300 + id / 2 + cs + 20, 230);
//大圓
G.DrawEllipse(pen, ((300 - id / 2) - cs), ((230 - id / 2) - cs), (id + cs2), (id + cs2));
//小圓
G.DrawEllipse(pen, (300 - id / 2), (230 - id / 2), id, id);
G.DrawLine(new Pen(Color.LightSteelBlue, 1), 300, 250 + id / 2 + 30 + cs, 300, 250 + id / 2 + 70 + cs * 2);
G.DrawLine(new Pen(Color.LightSteelBlue, 1), 300 - id / 2, 250 + id / 2 + 5 + cs, 300 - id / 2, 250 + id / 2 + 35 + cs * 2);
G.DrawLine(new Pen(Color.LightSteelBlue, 1), 300 + id / 2, 250 + id / 2 + 5 + cs, 300 + id / 2, 250 + id / 2 + 35 + cs * 2);
//小圓
Rectangle r1 = new Rectangle(300 - id / 2 - cs, (300 + id / 2 + cs), cs, cs);
Rectangle r2 = new Rectangle(300 + id / 2, (300 + id / 2 + cs), cs, cs);
//直線
G.DrawLine(new Pen(Color.SkyBlue, 1), 300 - id / 2 - cs / 2, (300 + id / 2 + cs), 300 + id / 2 + cs / 2, (300 + id / 2 + cs));
//直線
G.DrawLine(new Pen(Color.SkyBlue, 1), 300 - id / 2 - cs / 2, (300 + id / 2 + cs) + cs, 300 + id / 2 + cs / 2, (300 + id / 2 + cs) + cs);
HatchBrush hb = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.LightSteelBlue, Color.White);
G.DrawEllipse(pen, r2);
G.FillEllipse(hb, r2);
G.DrawEllipse(pen, r1);
G.FillEllipse(hb, r1);
int x = 300 - id / 2;
int y = 250 + id / 2 + 20 + cs;
int x1 = 300 + id / 2;
//
Point[] ps = new Point[8];
ps[0] = new Point(x + 5, y + 5);
ps[1] = new Point(x, y);
ps[2] = new Point(x + 5, y - 5);
ps[3] = new Point(x, y);
ps[4] = new Point(x1, y);
ps[5] = new Point(x1 - 5, y - 5);
ps[6] = new Point(x1, y);
ps[7] = new Point(x1 - 5, y + 5);
G.DrawLines(new Pen(Color.SkyBlue, 1), ps);
//設置字體
System.Drawing.Font f = new System.Drawing.Font("宋体", 10);
//設置顏色
System.Drawing.Brush b = new SolidBrush(Color.Black);
if (!Methods.units.Equals("mm"))
{
ids = Methods.GetINCH(ids);
css = Methods.GetINCH(css);
}
G.DrawString("Ø" + ids + "±" + this.txtIdT.Text.Trim(), f, b, 270, (300 + id / 2 + 20) + cs / 2 - 30);
G.DrawString("Ø" + css + "±" + this.txtCST.Text.Trim(), f, b, 300 + id / 2 + cs, (300 + id / 2 + 20 + cs));
G.Dispose();
//保存高清晰度的缩略图
methods.bitmap.Save(Methods.paths, System.Drawing.Imaging.ImageFormat.Jpeg);
methods.bitmap.Dispose();
畫板
最新推荐文章于 2024-10-13 19:30:05 发布