Сданная лабораторная работа

This commit is contained in:
Дамир Нугаев 2022-12-22 12:06:05 +04:00
parent 7fc885a6f5
commit f90cbcb4cf
5 changed files with 187 additions and 63 deletions

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoubleDeckerBus
{
internal enum CountDoor
{
One = 3,
Two = 4,
Three = 5
}
}

View File

@ -9,18 +9,21 @@ namespace DoubleDeckerBus
internal class DrawingBus
{
public EntityBus Bus { get; private set; }
public DrawingDoor DrawingDoor { get; private set; }
private float _startPosX;
private float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
private readonly int _busWidth = 100;
private readonly int _busHeight = 50;
private readonly int _busWidth = 157;
private readonly int _busHeight = 65 ;
public void Init(int speed, float weight, Color bodyColor)
{
Bus = new EntityBus();
Bus.Init(speed, weight, bodyColor);
DrawingDoor = new();
DrawingDoor.SetCountDoor = 3;
}
public void SetPosition(int x, int y, int width, int height)
@ -95,18 +98,17 @@ namespace DoubleDeckerBus
//стекла
Brush brBlue = new SolidBrush(Color.LightBlue);
g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 20, 10, 20);
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 20, 10, 20);
g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 20, 30, 20);
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 20, 30, 20);
g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 20, 15, 40);
g.DrawRectangle(pen, _startPosX + 70, _startPosY + 20, 15, 40);
g.FillRectangle(brBlue, _startPosX + 85, _startPosY + 20, 15, 40);
g.DrawRectangle(pen, _startPosX + 85, _startPosY + 20, 15, 40);
g.FillRectangle(brBlue, _startPosX + 110, _startPosY + 20, 30, 20);
g.DrawRectangle(pen, _startPosX + 110, _startPosY + 20, 30, 20);
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 20, 10, 20);
g.DrawRectangle(pen, _startPosX + 150, _startPosY + 20, 10, 20);
DrawingDoor.DrawningDoor(g, Bus.BodyColor, _startPosX, _startPosY);
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoubleDeckerBus
{
internal class DrawingDoor
{
private CountDoor _countDoor;
private float _startPosX;
private float _startPosY;
public int SetCountDoor
{
set
{
switch (value)
{
case 1:
_countDoor = CountDoor.Three;
break;
case 2:
_countDoor = CountDoor.One;
break;
case 3:
_countDoor = CountDoor.Two;
break;
default:
_countDoor = CountDoor.Three;
break;
}
}
}
public void DrawningDoor(Graphics g, Color colorDoor, float PosX, float PosY)
{
if ((int)_countDoor == 3)
{
Pen pen = new(Color.White);
Brush brBlue = new SolidBrush(Color.Black);
g.FillRectangle(brBlue, PosX + 11, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 40, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 65, PosY + 21, 10, 40);
}
if ((int)_countDoor == 4)
{
Pen pen = new(Color.White);
Brush brBlue = new SolidBrush(Color.Black);
g.FillRectangle(brBlue, PosX+11, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 40, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 65, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 80, PosY + 21, 10, 40);
}
if ((int)_countDoor == 5)
{
Pen pen = new(Color.White);
Brush brBlue = new SolidBrush(Color.Black);
g.FillRectangle(brBlue, PosX + 11, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 40, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 65, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 80, PosY + 21, 10, 40);
g.FillRectangle(brBlue, PosX + 52, PosY + 21, 10, 40);
}
}
}
}

View File

@ -33,13 +33,16 @@
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelDoor = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonCreate = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.countDoorBox = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.countDoorBox)).BeginInit();
this.SuspendLayout();
//
// pictureBoxBus
@ -59,7 +62,8 @@
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
this.toolStripStatusLabelBodyColor,
this.toolStripStatusLabelDoor});
this.statusStrip1.Location = new System.Drawing.Point(0, 456);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(810, 26);
@ -84,6 +88,12 @@
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// toolStripStatusLabelDoor
//
this.toolStripStatusLabelDoor.Name = "toolStripStatusLabelDoor";
this.toolStripStatusLabelDoor.Size = new System.Drawing.Size(147, 20);
this.toolStripStatusLabelDoor.Text = "Количество дверей:";
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -96,63 +106,82 @@
this.buttonCreate.UseVisualStyleBackColor = false;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// button2
// buttonLeft
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_6;
this.button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button2.Location = new System.Drawing.Point(662, 398);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(45, 45);
this.button2.TabIndex = 3;
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_6;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(662, 398);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(45, 45);
this.buttonLeft.TabIndex = 3;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// button3
// buttonDown
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button3.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_5;
this.button3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button3.Location = new System.Drawing.Point(708, 398);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(45, 45);
this.button3.TabIndex = 4;
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_5;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(708, 398);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(45, 45);
this.buttonDown.TabIndex = 4;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// button4
// buttonRight
//
this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button4.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_4;
this.button4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button4.Location = new System.Drawing.Point(753, 398);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(45, 45);
this.button4.TabIndex = 5;
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_4;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(753, 398);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(45, 45);
this.buttonRight.TabIndex = 5;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// button5
// buttonUp
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button5.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_3;
this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button5.Location = new System.Drawing.Point(708, 353);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(45, 45);
this.button5.TabIndex = 6;
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.Frame_3;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(708, 353);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(45, 45);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// countDoorBox
//
this.countDoorBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.countDoorBox.Location = new System.Drawing.Point(197, 407);
this.countDoorBox.Maximum = new decimal(new int[] {
5,
0,
0,
0});
this.countDoorBox.Name = "countDoorBox";
this.countDoorBox.Size = new System.Drawing.Size(131, 27);
this.countDoorBox.TabIndex = 8;
this.countDoorBox.Value = new decimal(new int[] {
2,
0,
0,
0});
//
// FormBus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(810, 482);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.countDoorBox);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxBus);
this.Controls.Add(this.statusStrip1);
@ -161,6 +190,7 @@
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.countDoorBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -174,9 +204,11 @@
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private Button buttonCreate;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
private Button buttonUp;
private ToolStripStatusLabel toolStripStatusLabelDoor;
private NumericUpDown countDoorBox;
}
}

View File

@ -21,10 +21,12 @@ namespace DoubleDeckerBus
Random rnd = new();
_bus = new DrawingBus();
_bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_bus.DrawingDoor.SetCountDoor = ((int)countDoorBox.Value);
_bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_bus.Bus.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_bus.Bus.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_bus.Bus.BodyColor.Name}";
toolStripStatusLabelDoor.Text = $"Êîëè÷åñòâî äâåðåé: {(int)countDoorBox.Value}";
Draw();
}