public LinesSelection(RectPrimitive r_pr) { masPointFront = r_pr.MasLinesFront; masPointRight = r_pr.MasLinesRight; masPointTop = r_pr.MasLinesTop; #region CreatingMasRectS masRectsFront[0] = new Rectangle(masPointFront[0].X - 2, masPointFront[0].Y - 2, 4, 4); masRectsFront[1] = new Rectangle(masPointFront[1].X - 2, masPointFront[1].Y - 2, 4, 4); masRectsFront[2] = new Rectangle(masPointFront[2].X - 2, masPointFront[2].Y - 2, 4, 4); masRectsFront[3] = new Rectangle(masPointFront[3].X - 2, masPointFront[3].Y - 2, 4, 4); masRectsFront[4] = new Rectangle(masPointFront[5].X - 2, masPointFront[5].Y - 2, 4, 4); masRectsFront[5] = new Rectangle(masPointFront[6].X - 2, masPointFront[6].Y - 2, 4, 4); masRectsFront[6] = new Rectangle(masPointFront[7].X - 2, masPointFront[7].Y - 2, 4, 4); masRectsFront[7] = new Rectangle(masPointFront[8].X - 2, masPointFront[8].Y - 2, 4, 4); masRectsRight[0] = new Rectangle(masPointRight[0].X - 2, masPointRight[0].Y - 2, 4, 4); masRectsRight[1] = new Rectangle(masPointRight[1].X - 2, masPointRight[1].Y - 2, 4, 4); masRectsRight[2] = new Rectangle(masPointRight[2].X - 2, masPointRight[2].Y - 2, 4, 4); masRectsRight[3] = new Rectangle(masPointRight[3].X - 2, masPointRight[3].Y - 2, 4, 4); masRectsRight[4] = new Rectangle(masPointRight[5].X - 2, masPointRight[5].Y - 2, 4, 4); masRectsRight[5] = new Rectangle(masPointRight[6].X - 2, masPointRight[6].Y - 2, 4, 4); masRectsRight[6] = new Rectangle(masPointRight[7].X - 2, masPointRight[7].Y - 2, 4, 4); masRectsRight[7] = new Rectangle(masPointRight[8].X - 2, masPointRight[8].Y - 2, 4, 4); masRectsTop[0] = new Rectangle(masPointTop[0].X - 2, masPointTop[0].Y - 2, 4, 4); masRectsTop[1] = new Rectangle(masPointTop[1].X - 2, masPointTop[1].Y - 2, 4, 4); masRectsTop[2] = new Rectangle(masPointTop[2].X - 2, masPointTop[2].Y - 2, 4, 4); masRectsTop[3] = new Rectangle(masPointTop[3].X - 2, masPointTop[3].Y - 2, 4, 4); masRectsTop[4] = new Rectangle(masPointTop[5].X - 2, masPointTop[5].Y - 2, 4, 4); masRectsTop[5] = new Rectangle(masPointTop[6].X - 2, masPointTop[6].Y - 2, 4, 4); masRectsTop[6] = new Rectangle(masPointTop[7].X - 2, masPointTop[7].Y - 2, 4, 4); masRectsTop[7] = new Rectangle(masPointTop[8].X - 2, masPointTop[8].Y - 2, 4, 4); #endregion }
private void CreateSel(RectPrimitive rp, string name) { if (rp != null) { if (name == "Front") { int maxX = rp.MasLinesFront[0].X; int minX = rp.MasLinesFront[0].X; int maxY = rp.MasLinesFront[0].Y; int minY = rp.MasLinesFront[0].Y; for (int i = 0; i < 10; i++) { if (maxX < rp.MasLinesFront[i].X) { maxX = rp.MasLinesFront[i].X; } if (minX > rp.MasLinesFront[i].X) { minX = rp.MasLinesFront[i].X; } if (maxY < rp.MasLinesFront[i].Y) { maxY = rp.MasLinesFront[i].Y; } if (minY > rp.MasLinesFront[i].Y) { minY = rp.MasLinesFront[i].Y; } } rectSelFront = Rectangle.FromLTRB(minX, minY, maxX, maxY); masRectOfSelFront[0].X = rectSelFront.X - 2; masRectOfSelFront[0].Y = rectSelFront.Y - 2; masRectOfSelFront[0].Width = 4; masRectOfSelFront[0].Height = 4; masRectOfSelFront[1].X = rectSelFront.X + rectSelFront.Width / 2 - 2; masRectOfSelFront[1].Y = rectSelFront.Y - 2; masRectOfSelFront[1].Width = 4; masRectOfSelFront[1].Height = 4; masRectOfSelFront[2].X = rectSelFront.X + rectSelFront.Width - 2; masRectOfSelFront[2].Y = rectSelFront.Y - 2; masRectOfSelFront[2].Width = 4; masRectOfSelFront[2].Height = 4; masRectOfSelFront[3].X = rectSelFront.X + rectSelFront.Width - 2; masRectOfSelFront[3].Y = rectSelFront.Y + rectSelFront.Height / 2 - 2; masRectOfSelFront[3].Width = 4; masRectOfSelFront[3].Height = 4; masRectOfSelFront[4].X = rectSelFront.X + rectSelFront.Width - 2; masRectOfSelFront[4].Y = rectSelFront.Y + rectSelFront.Height - 2; masRectOfSelFront[4].Width = 4; masRectOfSelFront[4].Height = 4; masRectOfSelFront[5].X = rectSelFront.X + rectSelFront.Width / 2 - 2; masRectOfSelFront[5].Y = rectSelFront.Y + rectSelFront.Height - 2; masRectOfSelFront[5].Width = 4; masRectOfSelFront[5].Height = 4; masRectOfSelFront[6].X = rectSelFront.X - 2; masRectOfSelFront[6].Y = rectSelFront.Y + rectSelFront.Height - 2; masRectOfSelFront[6].Width = 4; masRectOfSelFront[6].Height = 4; masRectOfSelFront[7].X = rectSelFront.X - 2; masRectOfSelFront[7].Y = rectSelFront.Y + rectSelFront.Height / 2 - 2; masRectOfSelFront[7].Width = 4; masRectOfSelFront[7].Height = 4; } if (name == "Right") { int maxX = rp.MasLinesRight[0].X; int minX = rp.MasLinesRight[0].X; int maxY = rp.MasLinesRight[0].Y; int minY = rp.MasLinesRight[0].Y; for (int i = 0; i < 10; i++) { if (maxX < rp.MasLinesRight[i].X) { maxX = rp.MasLinesRight[i].X; } if (minX > rp.MasLinesRight[i].X) { minX = rp.MasLinesRight[i].X; } if (maxY < rp.MasLinesRight[i].Y) { maxY = rp.MasLinesRight[i].Y; } if (minY > rp.MasLinesRight[i].Y) { minY = rp.MasLinesRight[i].Y; } } rectSelRight = Rectangle.FromLTRB(minX, minY, maxX, maxY); masRectOfSelRight[0].X = rectSelRight.X - 2; masRectOfSelRight[0].Y = rectSelRight.Y - 2; masRectOfSelRight[0].Width = 4; masRectOfSelRight[0].Height = 4; masRectOfSelRight[1].X = rectSelRight.X + rectSelRight.Width / 2 - 2; masRectOfSelRight[1].Y = rectSelRight.Y - 2; masRectOfSelRight[1].Width = 4; masRectOfSelRight[1].Height = 4; masRectOfSelRight[2].X = rectSelRight.X + rectSelRight.Width - 2; masRectOfSelRight[2].Y = rectSelRight.Y - 2; masRectOfSelRight[2].Width = 4; masRectOfSelRight[2].Height = 4; masRectOfSelRight[3].X = rectSelRight.X + rectSelRight.Width - 2; masRectOfSelRight[3].Y = rectSelRight.Y + rectSelRight.Height / 2 - 2; masRectOfSelRight[3].Width = 4; masRectOfSelRight[3].Height = 4; masRectOfSelRight[4].X = rectSelRight.X + rectSelRight.Width - 2; masRectOfSelRight[4].Y = rectSelRight.Y + rectSelRight.Height - 2; masRectOfSelRight[4].Width = 4; masRectOfSelRight[4].Height = 4; masRectOfSelRight[5].X = rectSelRight.X + rectSelRight.Width / 2 - 2; masRectOfSelRight[5].Y = rectSelRight.Y + rectSelRight.Height - 2; masRectOfSelRight[5].Width = 4; masRectOfSelRight[5].Height = 4; masRectOfSelRight[6].X = rectSelRight.X - 2; masRectOfSelRight[6].Y = rectSelRight.Y + rectSelRight.Height - 2; masRectOfSelRight[6].Width = 4; masRectOfSelRight[6].Height = 4; masRectOfSelRight[7].X = rectSelRight.X - 2; masRectOfSelRight[7].Y = rectSelRight.Y + rectSelRight.Height / 2 - 2; masRectOfSelRight[7].Width = 4; masRectOfSelRight[7].Height = 4; } if (name == "Top") { int maxX = rp.MasLinesTop[0].X; int minX = rp.MasLinesTop[0].X; int maxY = rp.MasLinesTop[0].Y; int minY = rp.MasLinesTop[0].Y; for (int i = 0; i < 10; i++) { if (maxX < rp.MasLinesTop[i].X) { maxX = rp.MasLinesTop[i].X; } if (minX > rp.MasLinesTop[i].X) { minX = rp.MasLinesTop[i].X; } if (maxY < rp.MasLinesTop[i].Y) { maxY = rp.MasLinesTop[i].Y; } if (minY > rp.MasLinesTop[i].Y) { minY = rp.MasLinesTop[i].Y; } } rectSelTop = Rectangle.FromLTRB(minX, minY, maxX, maxY); masRectOfSelTop[0].X = rectSelTop.X - 2; masRectOfSelTop[0].Y = rectSelTop.Y - 2; masRectOfSelTop[0].Width = 4; masRectOfSelTop[0].Height = 4; masRectOfSelTop[1].X = rectSelTop.X + rectSelTop.Width / 2 - 2; masRectOfSelTop[1].Y = rectSelTop.Y - 2; masRectOfSelTop[1].Width = 4; masRectOfSelTop[1].Height = 4; masRectOfSelTop[2].X = rectSelTop.X + rectSelTop.Width - 2; masRectOfSelTop[2].Y = rectSelTop.Y - 2; masRectOfSelTop[2].Width = 4; masRectOfSelTop[2].Height = 4; masRectOfSelTop[3].X = rectSelTop.X + rectSelTop.Width - 2; masRectOfSelTop[3].Y = rectSelTop.Y + rectSelTop.Height / 2 - 2; masRectOfSelTop[3].Width = 4; masRectOfSelTop[3].Height = 4; masRectOfSelTop[4].X = rectSelTop.X + rectSelTop.Width - 2; masRectOfSelTop[4].Y = rectSelTop.Y + rectSelTop.Height - 2; masRectOfSelTop[4].Width = 4; masRectOfSelTop[4].Height = 4; masRectOfSelTop[5].X = rectSelTop.X + rectSelTop.Width / 2 - 2; masRectOfSelTop[5].Y = rectSelTop.Y + rectSelTop.Height - 2; masRectOfSelTop[5].Width = 4; masRectOfSelTop[5].Height = 4; masRectOfSelTop[6].X = rectSelTop.X - 2; masRectOfSelTop[6].Y = rectSelTop.Y + rectSelTop.Height - 2; masRectOfSelTop[6].Width = 4; masRectOfSelTop[6].Height = 4; masRectOfSelTop[7].X = rectSelTop.X - 2; masRectOfSelTop[7].Y = rectSelTop.Y + rectSelTop.Height / 2 - 2; masRectOfSelTop[7].Width = 4; masRectOfSelTop[7].Height = 4; } } }
public void Form1_SelectObject(RectPrimitive rp, RectPrimitive convertedRpr) { selPrimitive = rp; convertedPrimitive = convertedRpr; }