From 992a9c227116f8d786efd575a9acefd4cf581d58 Mon Sep 17 00:00:00 2001 From: asoc1al Date: Sat, 7 Oct 2023 11:55:42 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D0=BE=20All=20Done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DumpTruck/DumpTruck/DrawingTruck.cs | 26 +++++++++++++++++--------- DumpTruck/DumpTruck/FormTruck.cs | 4 ++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/DumpTruck/DumpTruck/DrawingTruck.cs b/DumpTruck/DumpTruck/DrawingTruck.cs index b369c3a..8a05ede 100644 --- a/DumpTruck/DumpTruck/DrawingTruck.cs +++ b/DumpTruck/DumpTruck/DrawingTruck.cs @@ -81,7 +81,7 @@ namespace DumpTruck } - public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor) + public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor, bool threeWheels, bool Dump) { if (EntityTruck == null) { @@ -96,13 +96,16 @@ namespace DumpTruck g.FillRectangle(brBodyRandom, _startPosX, _startPosY + 30, 100, 5); Brush brBlack = new SolidBrush(Color.Black); + g.FillEllipse(brBlack, _startPosX, _startPosY + 35, 20, 20); - g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20); + if (threeWheels) + g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20); g.FillEllipse(brBlack, _startPosX + 80, _startPosY + 35, 20, 20); Brush brWhite = new SolidBrush(Color.White); g.FillEllipse(brWhite, _startPosX + 5, _startPosY + 40, 10, 10); - g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10); + if (threeWheels) + g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10); g.FillEllipse(brWhite, _startPosX + 85, _startPosY + 40, 10, 10); Pen pen = new Pen(Color.Black); @@ -110,15 +113,20 @@ namespace DumpTruck g.DrawRectangle(pen, _startPosX + 80, _startPosY, 20, 30); g.DrawRectangle(pen, _startPosX, _startPosY + 30, 100, 5); g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); + if (threeWheels) + g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20); g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - + //Brush brBody = new SolidBrush(EntityTruck?.AdditionalColor ?? Color.Red); - Brush brBodyAdditional = new SolidBrush(additionalColor); - g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); - Pen pen1 = new Pen(Color.Black); - g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); + if (Dump) + { + Brush brBodyAdditional = new SolidBrush(additionalColor); + g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30); + Pen pen1 = new Pen(Color.Black); + g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30); + } + } diff --git a/DumpTruck/DumpTruck/FormTruck.cs b/DumpTruck/DumpTruck/FormTruck.cs index 92a926e..584da64 100644 --- a/DumpTruck/DumpTruck/FormTruck.cs +++ b/DumpTruck/DumpTruck/FormTruck.cs @@ -27,7 +27,7 @@ namespace DumpTruck Bitmap bmp = new(pictureBoxTruck.Width, pictureBoxTruck.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0)); + _drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0), false, true); pictureBoxTruck.Image = bmp; } @@ -40,7 +40,7 @@ namespace DumpTruck { Random random = new(); _drawningTruck = new DrawingTruck(); - _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height); + _drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2))); _drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100)); Draw(); }