public void InitTool(byte[] data) { int i = 0; int j = 0; Multi = 1; StrokeNum = data[i++]; CompId = BitConverter.ToInt32(data, i); i += 4; CompName = BitConverter.ToString(data, i, NameSize); i += 20; for (j = 0; j < 30; j++) { CompData da = new CompData(); da.Init(data, i + j * CompSize, CompSize); compData[j] = da; } GetToolSize(); }
/// <summary> /// 绘制元件 /// </summary> private void DrawStroke(Graphics Ob, CompData ObjectData) { int X0; int Y0; int X1; int Y1; int X; int Y; int width; int height; X = this.Rect.X + this.Rect.Width / 2; Y = this.Rect.Y + this.Rect.Height / 2; int size = Math.Min(this.Rect.Width, this.Rect.Height); double dxRatio = GetNewPos(ObjectData.X0, size); double dyRatio = GetNewPos(ObjectData.Y0, size); X0 = (int)(dxRatio + X); Y0 = (int)(dyRatio + Y); dxRatio = GetNewPos(ObjectData.X1, size); dyRatio = GetNewPos(ObjectData.Y1, size); X1 = (int)(dxRatio + X); Y1 = (int)(dyRatio + Y); width = Math.Abs(X1 - X0); height = Math.Abs(Y1 - Y0); Pen pen = new Pen(new SolidBrush(Color.Black)); switch (ObjectData.Pentype) { case 1: //点 int t = Multi > 1 ? (int)Multi : 1; Ob.DrawEllipse(pen, new Rectangle(X0, Y0, t, t)); break; //线 case 2: Ob.DrawLine(pen, new Point(X0, Y0), new Point(X1, Y1)); break; //空心矩形 case 6: Ob.DrawRectangle(pen, new Rectangle(X0, Y0, width, height)); break; //'空心圆 case 4: Ob.DrawEllipse(pen, new Rectangle(X0, Y0, width, height)); break; //'实心矩形 case 7: Ob.DrawRectangle(pen, new Rectangle(X0, Y0, width, height)); Ob.FillRectangle(new SolidBrush(Color.Aquamarine), new Rectangle(X0, Y0, width, height)); //Ob.FillColor = QBColor(7) break; //'实心圆 case 5: Ob.FillEllipse(new SolidBrush(Color.Beige), new Rectangle(X0, Y0, width, height)); Ob.DrawEllipse(pen, new Rectangle(X0, Y0, width, height)); break; //'圆弧 case 3: if (width > 0 && height > 0) { Ob.DrawArc(pen, new Rectangle(X0, Y0, width, height), 10, 30); } break; } }