using System.Drawing; namespace ProjectLiner { internal class DrawingLiner { Liner aag; private readonly int _width = 0; private readonly int _height = 0; public DrawingLiner(Liner aag) { this.aag = aag; _height = 60 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15); _width = 150; } public DrawingLiner() { aag = new Liner(); } public void SetPos(Point pos) { aag.position.X = Math.Clamp(pos.X + aag.position.X, 0, Program.faag.ClientSize.Width-_width); aag.position.Y = Math.Clamp(pos.Y + aag.position.Y, 0, Program.faag.ClientSize.Height-_height); } public void MoveTransport(Vector2 way) { if(way == null) { throw new NullReferenceException(); } SetPos(new Point((int)(way.x*aag.Step), (int)(way.y*aag.Step))); } public void Draw(Graphics g) { Pen pen = new Pen(Color.Black); Brush brush1 = new SolidBrush(aag.FirstColor); Brush brush2 = new SolidBrush(aag.SecondColor); //deck g.DrawPolygon(pen, new Point[] { new Point(0 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)), new Point(150 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)), new Point(120 + aag.position.X, 45 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)), new Point(30 + aag.position.X, 45 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15)), new Point(0 + aag.position.X, 15 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15))}); g.FillPolygon(brush1, new Point[] { new Point(0 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)), new Point(150 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)), new Point(120 + aag.position.X, 45 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)), new Point(30 + aag.position.X, 45 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15)), new Point(0 + aag.position.X, 15 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15))}); //mark if (aag.HasMark) { g.DrawLine(new Pen(aag.SecondColor),30+aag.position.X, 20 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 30 + aag.position.X, 35 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15)); g.DrawLine(new Pen(aag.SecondColor), 20+aag.position.X, 25 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 40 + aag.position.X, 25 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15)); } //block for (int j = 0; j <= (int)(aag.NumOfBoxes / 8 + 0.5); j++) { if(aag.NumOfBoxes - j * 8 >= 8) for (int i = 0; i < 8; i++) { g.FillRectangle(brush2, 15 + aag.position.X + i * 15, aag.position.Y - j * 15+((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15); g.DrawRectangle(pen, 15 + aag.position.X + i * 15, aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15); } else for (int i = 0; i < aag.NumOfBoxes%8; i++) { if(aag.NumOfBoxes % 8 == 1) { g.FillRectangle(brush2, 8 + 15 + aag.position.X + (90 / 2), aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15); g.DrawRectangle(pen, 8 + 15 + aag.position.X + (90 / 2), aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15); continue; } g.FillRectangle(brush2,8 +15 + aag.position.X + (90 / (aag.NumOfBoxes % 8 - 1)) * i, aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15); g.DrawRectangle(pen,8 + 15 + aag.position.X + (90 / (aag.NumOfBoxes % 8 - 1)) * i, aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15); } } } } }