diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs index 0339b60..3cfccc9 100644 --- a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs +++ b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs @@ -19,12 +19,12 @@ namespace AccordionBus.Drawnings /// /// /// - /// + /// /// public DrawningAccordionBus(int speed, double weight, Color bodyColor, Color - additionalColor, bool onePart, bool fiveDoors): base(130, 20) + additionalColor, bool hatch, bool fiveDoors): base(130, 20) { - EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, onePart, fiveDoors); + EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, hatch, fiveDoors); } /// @@ -41,60 +41,66 @@ namespace AccordionBus.Drawnings base.DrawTransport(g); - if (!accordionBus.OnePart) + Pen pen = new(Color.Black); + Brush brWhite = new SolidBrush(Color.White); + Brush br = new SolidBrush(accordionBus.BodyColor); + Brush brBlue = new SolidBrush(Color.LightBlue); + Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor); + //корпус + g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15); + g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15); + + //колёса + g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); + g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); + g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); + + //стёкла + g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); + g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); + g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); + + //гормошка + g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3); + g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value); + g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3); + g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value); + g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15); + g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15); + g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12); + g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15); + + //двери + g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); + g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); + if (accordionBus.FiveDoors) { - Pen pen = new(Color.Black); - Brush brWhite = new SolidBrush(Color.White); - Brush br = new SolidBrush(accordionBus.BodyColor); - Brush brBlue = new SolidBrush(Color.LightBlue); - Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor); - //корпус - g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15); - g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); + g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); + g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); + g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); + g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); + g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); + } - //колёса - g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); - g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10); - g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10); - - //стёкла - g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5); - g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); - g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5); - - //гормошка - g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3); - g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value); - g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3); - g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value); - g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15); - g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15); - g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12); - g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15); - - //двери - g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); - g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10); - if (accordionBus.FiveDoors) - { - g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); - g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5); - g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); - g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10); - g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); - g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5); - } + //люки + if (accordionBus.Hatch) + { + g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3); + g.FillRectangle(additionalBrush, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3); + g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3); + g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3); } } } diff --git a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs index 31eb8aa..019fbd5 100644 --- a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs +++ b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs @@ -18,7 +18,7 @@ namespace AccordionBus.Entities /// /// Одна часть /// - public bool OnePart { get; set; } + public bool Hatch { get; set; } /// /// 5 дверей /// @@ -30,13 +30,13 @@ namespace AccordionBus.Entities /// вес /// Основной цвет /// Дополнительный цвет - /// 1 часть + /// 1 часть /// 5 дверей public EntityAccordionBus(int speed, double weight, Color bodyColor, - Color additionalColor, bool onePart, bool fiveDoors) : base(speed, weight, bodyColor) + Color additionalColor, bool hatch, bool fiveDoors) : base(speed, weight, bodyColor) { AdditionalColor = additionalColor; - OnePart = onePart; + Hatch = hatch; FiveDoors = fiveDoors; } diff --git a/AccordionBus/AccordionBus/FormBusConfig.Designer.cs b/AccordionBus/AccordionBus/FormBusConfig.Designer.cs index 04e3be5..9de1234 100644 --- a/AccordionBus/AccordionBus/FormBusConfig.Designer.cs +++ b/AccordionBus/AccordionBus/FormBusConfig.Designer.cs @@ -39,7 +39,7 @@ panelGreen = new Panel(); panelRed = new Panel(); checkBoxFiveDoors = new CheckBox(); - checkBoxOnePart = new CheckBox(); + checkBoxHatch = new CheckBox(); numericUpDownWeight = new NumericUpDown(); labelWeight = new Label(); numericUpDownSpeed = new NumericUpDown(); @@ -64,7 +64,7 @@ // groupBoxConfig.Controls.Add(groupBoxColor); groupBoxConfig.Controls.Add(checkBoxFiveDoors); - groupBoxConfig.Controls.Add(checkBoxOnePart); + groupBoxConfig.Controls.Add(checkBoxHatch); groupBoxConfig.Controls.Add(numericUpDownWeight); groupBoxConfig.Controls.Add(labelWeight); groupBoxConfig.Controls.Add(numericUpDownSpeed); @@ -180,13 +180,13 @@ // // checkBoxOnePart // - checkBoxOnePart.AutoSize = true; - checkBoxOnePart.Location = new Point(24, 118); - checkBoxOnePart.Name = "checkBoxOnePart"; - checkBoxOnePart.Size = new Size(149, 24); - checkBoxOnePart.TabIndex = 6; - checkBoxOnePart.Text = "Простой автобус"; - checkBoxOnePart.UseVisualStyleBackColor = true; + checkBoxHatch.AutoSize = true; + checkBoxHatch.Location = new Point(24, 118); + checkBoxHatch.Name = "checkBoxOnePart"; + checkBoxHatch.Size = new Size(69, 24); + checkBoxHatch.TabIndex = 6; + checkBoxHatch.Text = "Люки"; + checkBoxHatch.UseVisualStyleBackColor = true; // // numericUpDownWeight // @@ -347,7 +347,7 @@ private Label labelWeight; private NumericUpDown numericUpDownSpeed; private NumericUpDown numericUpDownWeight; - private CheckBox checkBoxOnePart; + private CheckBox checkBoxHatch; private CheckBox checkBoxFiveDoors; private GroupBox groupBoxColor; private Panel panelRed; diff --git a/AccordionBus/AccordionBus/FormBusConfig.cs b/AccordionBus/AccordionBus/FormBusConfig.cs index 35421b9..d01ff71 100644 --- a/AccordionBus/AccordionBus/FormBusConfig.cs +++ b/AccordionBus/AccordionBus/FormBusConfig.cs @@ -16,7 +16,7 @@ namespace AccordionBus { private DrawningBus _bus; - private event BusDelegate? _busDelegate; + private event Action _busDelegate; public FormBusConfig() { @@ -34,7 +34,7 @@ namespace AccordionBus buttonCancel.Click += (sender, e) => Close(); } - public void AddEvent(BusDelegate busDelegate) + public void AddEvent(Action busDelegate) { _busDelegate += busDelegate; } @@ -84,7 +84,7 @@ namespace AccordionBus break; case "labelModifiedObject": _bus = new DrawningAccordionBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, - Color.Black, checkBoxOnePart.Checked, checkBoxFiveDoors.Checked); + Color.Black, checkBoxHatch.Checked, checkBoxFiveDoors.Checked); break; } @@ -176,7 +176,7 @@ namespace AccordionBus { if (_bus != null) { - _busDelegate?.Invoke(_bus); + _busDelegate.Invoke(_bus); Close(); } }