PIbd22_Kamcharova_K.A._lab5 #13

Closed
MayDayR wants to merge 2 commits from lab5 into lab4
15 changed files with 670 additions and 55 deletions
Showing only changes of commit 4086d63f23 - Show all commits

View File

@ -11,14 +11,14 @@ namespace DoubleDeckerbus.Drawing
{
public class DrawingBus
{
public IMoveableObject GetMoveableObject => new DrawingObjectBus(this);
public IMoveableObject GetMoveableObject => new DrawingObjectBus(this);
public EntityBus? EntityBus { get; protected set; }
public int _pictureWidth;
public int _pictureHeight;
protected int _startPosX;
protected int _startPosY;
protected readonly int _busWidth = 175;
protected readonly int _busHeight = 115;
protected readonly int _busWidth = 175;
protected readonly int _busHeight = 115;
public int GetPosX => _startPosX;
public int GetPosY => _startPosY;
public int GetWidth => _busWidth;
@ -93,9 +93,9 @@ namespace DoubleDeckerbus.Drawing
Pen pen = new(Color.Black);
Brush additionalBrush = new
SolidBrush(EntityBus.BodyColor);
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 52, 21, 20);
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 71, 30, 27);
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 52, 137, 46);
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 52, 21, 20);
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 71, 30, 27);
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 52, 137, 46);
Brush brBlue = new SolidBrush(Color.LightBlue);
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 55, 15, 15);
g.FillRectangle(brBlue, _startPosX + 42, _startPosY + 55, 15, 15);
@ -125,5 +125,10 @@ namespace DoubleDeckerbus.Drawing
_ => false,
};
}
public void ChangeBordersPicture(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
}
}
}

View File

@ -14,29 +14,26 @@ namespace DoubleDeckerbus.Drawing
{
if (EntityBus != null)
{
EntityBus = new EntityDoubleDeckerBus(speed, weight, bodyColor, additionalColor, secondfloor, stairs);
EntityBus = new EntityDoubleDeckerbus(speed, weight, bodyColor, additionalColor, secondfloor, stairs);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityBus is not EntityDoubleDeckerBus doubleDeckerBus)
if (EntityBus is not EntityDoubleDeckerbus doubleDeckerBus)
{
return;
}
Pen pen = new(Color.Black); //чёрный цвет для колёс
Pen additionalPen = new(doubleDeckerBus.AddColor);
Brush additionalBrush = new SolidBrush(doubleDeckerBus.AddColor);
Pen pen = new(Color.Black);
Pen additionalPen = new(doubleDeckerBus.Body);
Brush additionalBrush = new SolidBrush(doubleDeckerBus.Body);
base.DrawTransport(g);
if (doubleDeckerBus.Secondfloor)
{
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.AddColor);
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.Body);
Brush brBlue = new SolidBrush(Color.LightBlue);
g.FillRectangle(additionalBrush2, _startPosX + 7, _startPosY + 12, 172, 40); //большой прямоугольник
g.FillRectangle(additionalBrush2, _startPosX + 7, _startPosY + 12, 172, 40);
g.DrawLine(pen, _startPosX + 7, _startPosY + 36, _startPosX + 178, _startPosY + 36);
g.FillRectangle(brBlue, _startPosX + 15, _startPosY + 15, 15, 15);
g.FillRectangle(brBlue, _startPosX + 42, _startPosY + 15, 15, 15);
g.FillRectangle(brBlue, _startPosX + 69, _startPosY + 15, 15, 15);

View File

@ -18,5 +18,9 @@ namespace DoubleDeckerbus.Entities
Weight = weight;
BodyColor = bodyColor;
}
public void ChangeBodyColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -7,16 +7,20 @@ using System.Threading.Tasks;
namespace DoubleDeckerbus.Entities
{
public class EntityDoubleDeckerBus : EntityBus
public class EntityDoubleDeckerbus : EntityBus
{
public Color AddColor { get; private set; }
public Color Body { get; private set; }
public bool Secondfloor { get; private set; }
public bool Stairs { get; private set; }
public EntityDoubleDeckerBus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs) : base(speed, weight, bodyColor)
public EntityDoubleDeckerbus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs) : base(speed, weight, bodyColor)
{
AddColor = additionalColor;
Body = additionalColor;
Secondfloor = secondfloor;
Stairs = stairs;
}
public void ChangeAdditionalColor(Color additionalColor)
{
Body = additionalColor;
}
}
}

403
DoubleDeckerBus/FormBusConfig.Designer.cs generated Normal file
View File

@ -0,0 +1,403 @@
namespace DoubleDeckerbus
{
partial class FormBusConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.labelAdvancedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBoxColor = new System.Windows.Forms.GroupBox();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel();
this.panelPink = new System.Windows.Forms.Panel();
this.panelGray = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelRoyalBlue = new System.Windows.Forms.Panel();
this.panelFirebrick = new System.Windows.Forms.Panel();
this.checkBoxLadder = new System.Windows.Forms.CheckBox();
this.checkBoxSecondFloor = new System.Windows.Forms.CheckBox();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.labelWeight = new System.Windows.Forms.Label();
this.labelSpeed = new System.Windows.Forms.Label();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.panelObject = new System.Windows.Forms.Panel();
this.labelAdditionalColor = new System.Windows.Forms.Label();
this.labelMainColor = new System.Windows.Forms.Label();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConfig.SuspendLayout();
this.groupBoxColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.panelObject.SuspendLayout();
this.SuspendLayout();
//
// groupBoxConfig
//
this.groupBoxConfig.Controls.Add(this.labelAdvancedObject);
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
this.groupBoxConfig.Controls.Add(this.groupBoxColor);
this.groupBoxConfig.Controls.Add(this.checkBoxLadder);
this.groupBoxConfig.Controls.Add(this.checkBoxSecondFloor);
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
this.groupBoxConfig.Controls.Add(this.labelWeight);
this.groupBoxConfig.Controls.Add(this.labelSpeed);
this.groupBoxConfig.Location = new System.Drawing.Point(12, 36);
this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxConfig.Name = "groupBoxConfig";
this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxConfig.Size = new System.Drawing.Size(499, 188);
this.groupBoxConfig.TabIndex = 0;
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
//
// labelAdvancedObject
//
this.labelAdvancedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdvancedObject.Location = new System.Drawing.Point(385, 141);
this.labelAdvancedObject.Name = "labelAdvancedObject";
this.labelAdvancedObject.Size = new System.Drawing.Size(105, 23);
this.labelAdvancedObject.TabIndex = 8;
this.labelAdvancedObject.Text = "Продвинутый";
this.labelAdvancedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdvancedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(248, 141);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(105, 23);
this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// groupBoxColor
//
this.groupBoxColor.Controls.Add(this.panelBlue);
this.groupBoxColor.Controls.Add(this.panelBlack);
this.groupBoxColor.Controls.Add(this.panelPink);
this.groupBoxColor.Controls.Add(this.panelGray);
this.groupBoxColor.Controls.Add(this.panelGreen);
this.groupBoxColor.Controls.Add(this.panelYellow);
this.groupBoxColor.Controls.Add(this.panelRoyalBlue);
this.groupBoxColor.Controls.Add(this.panelFirebrick);
this.groupBoxColor.Location = new System.Drawing.Point(248, 24);
this.groupBoxColor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxColor.Name = "groupBoxColor";
this.groupBoxColor.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.groupBoxColor.Size = new System.Drawing.Size(242, 109);
this.groupBoxColor.TabIndex = 6;
this.groupBoxColor.TabStop = false;
this.groupBoxColor.Text = "Цвета";
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(4, 64);
this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(44, 30);
this.panelBlue.TabIndex = 0;
//
// panelBlack
//
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(66, 64);
this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(44, 30);
this.panelBlack.TabIndex = 0;
//
// panelPink
//
this.panelPink.BackColor = System.Drawing.Color.DeepPink;
this.panelPink.Location = new System.Drawing.Point(127, 64);
this.panelPink.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelPink.Name = "panelPink";
this.panelPink.Size = new System.Drawing.Size(44, 30);
this.panelPink.TabIndex = 0;
//
// panelGray
//
this.panelGray.BackColor = System.Drawing.Color.Gray;
this.panelGray.Location = new System.Drawing.Point(188, 64);
this.panelGray.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelGray.Name = "panelGray";
this.panelGray.Size = new System.Drawing.Size(44, 30);
this.panelGray.TabIndex = 0;
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.panelGreen.Location = new System.Drawing.Point(188, 19);
this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(44, 30);
this.panelGreen.TabIndex = 0;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(127, 19);
this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(44, 30);
this.panelYellow.TabIndex = 0;
//
// panelRoyalBlue
//
this.panelRoyalBlue.BackColor = System.Drawing.Color.RoyalBlue;
this.panelRoyalBlue.Location = new System.Drawing.Point(66, 19);
this.panelRoyalBlue.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelRoyalBlue.Name = "panelRoyalBlue";
this.panelRoyalBlue.Size = new System.Drawing.Size(44, 30);
this.panelRoyalBlue.TabIndex = 0;
//
// panelFirebrick
//
this.panelFirebrick.BackColor = System.Drawing.Color.Firebrick;
this.panelFirebrick.Location = new System.Drawing.Point(4, 19);
this.panelFirebrick.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelFirebrick.Name = "panelFirebrick";
this.panelFirebrick.Size = new System.Drawing.Size(44, 30);
this.panelFirebrick.TabIndex = 0;
//
// checkBoxLadder
//
this.checkBoxLadder.AutoSize = true;
this.checkBoxLadder.Location = new System.Drawing.Point(11, 112);
this.checkBoxLadder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.checkBoxLadder.Name = "checkBoxLadder";
this.checkBoxLadder.Size = new System.Drawing.Size(129, 19);
this.checkBoxLadder.TabIndex = 5;
this.checkBoxLadder.Text = "Наличие лестница";
this.checkBoxLadder.UseVisualStyleBackColor = true;
//
// checkBoxSecondFloor
//
this.checkBoxSecondFloor.AutoSize = true;
this.checkBoxSecondFloor.Location = new System.Drawing.Point(11, 89);
this.checkBoxSecondFloor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.checkBoxSecondFloor.Name = "checkBoxSecondFloor";
this.checkBoxSecondFloor.Size = new System.Drawing.Size(157, 19);
this.checkBoxSecondFloor.TabIndex = 4;
this.checkBoxSecondFloor.Text = "Наличие второго этажа";
this.checkBoxSecondFloor.UseVisualStyleBackColor = true;
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(82, 24);
this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(131, 23);
this.numericUpDownSpeed.TabIndex = 3;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(82, 62);
this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(131, 23);
this.numericUpDownWeight.TabIndex = 2;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(5, 64);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(29, 15);
this.labelWeight.TabIndex = 1;
this.labelWeight.Text = "Вес:";
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(5, 24);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
this.labelSpeed.TabIndex = 0;
this.labelSpeed.Text = "Скорость:";
//
// pictureBoxObject
//
this.pictureBoxObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxObject.Location = new System.Drawing.Point(31, 63);
this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(286, 154);
this.pictureBoxObject.TabIndex = 1;
this.pictureBoxObject.TabStop = false;
//
// panelObject
//
this.panelObject.AllowDrop = true;
this.panelObject.Controls.Add(this.labelAdditionalColor);
this.panelObject.Controls.Add(this.labelMainColor);
this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Location = new System.Drawing.Point(536, 22);
this.panelObject.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(351, 226);
this.panelObject.TabIndex = 2;
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// labelAdditionalColor
//
this.labelAdditionalColor.AllowDrop = true;
this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdditionalColor.Location = new System.Drawing.Point(204, 14);
this.labelAdditionalColor.Name = "labelAdditionalColor";
this.labelAdditionalColor.Size = new System.Drawing.Size(79, 38);
this.labelAdditionalColor.TabIndex = 3;
this.labelAdditionalColor.Text = "Доп. цвет";
this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragDrop);
this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragEnter);
//
// labelMainColor
//
this.labelMainColor.AllowDrop = true;
this.labelMainColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelMainColor.Location = new System.Drawing.Point(67, 14);
this.labelMainColor.Name = "labelMainColor";
this.labelMainColor.Size = new System.Drawing.Size(79, 38);
this.labelMainColor.TabIndex = 2;
this.labelMainColor.Text = "Цвет";
this.labelMainColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelMainColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelMainColor_DragDrop);
this.labelMainColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelMainColor_DragEnter);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(603, 253);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(82, 22);
this.buttonAdd.TabIndex = 3;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(740, 254);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// FormBusConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(903, 287);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxConfig);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormBusConfig";
this.Text = "FormBusConfig";
this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout();
this.groupBoxColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.panelObject.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private NumericUpDown numericUpDownSpeed;
private NumericUpDown numericUpDownWeight;
private Label labelWeight;
private Label labelSpeed;
private CheckBox checkBoxLadder;
private CheckBox checkBoxSecondFloor;
private GroupBox groupBoxColor;
private Panel panelBlue;
private Panel panelBlack;
private Panel panelPink;
private Panel panelGray;
private Panel panelGreen;
private Panel panelYellow;
private Panel panelRoyalBlue;
private Panel panelFirebrick;
private Label labelAdvancedObject;
private Label labelSimpleObject;
private PictureBox pictureBoxObject;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelMainColor;
private Button buttonAdd;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DoubleDeckerbus.Drawing;
using DoubleDeckerbus.Entities;
namespace DoubleDeckerbus
{
public partial class FormBusConfig : Form
{
DrawingBus? _bus = null;
private event Action<DrawingBus>? EventAddBus;
public FormBusConfig()
{
InitializeComponent();
panelFirebrick.MouseDown += PanelColor_MouseDown;
panelRoyalBlue.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
panelBlack.MouseDown += PanelColor_MouseDown;
panelPink.MouseDown += PanelColor_MouseDown;
panelGray.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (s, e) => Close();
}
private void DrawBus()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_bus?.SetPosition(5, 5);
_bus?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
public void AddEvent(Action<DrawingBus> ev)
{
if (EventAddBus == null)
{
EventAddBus = ev;
}
else
{
EventAddBus += ev;
}
}
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_bus = new DrawingBus(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
case "labelAdvancedObject":
_bus = new DrawingDoubleDeckerbus(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White, Color.Black,
checkBoxSecondFloor.Checked, checkBoxLadder.Checked,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawBus();
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
{
var color = (Color)e.Data.GetData(typeof(Color));
_bus.EntityBus.ChangeBodyColor(color);
DrawBus();
}
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null && _bus is DrawingDoubleDeckerbus)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
var color = (Color)e.Data.GetData(typeof(Color));
EntityDoubleDeckerbus? _doubledeckerbus = _bus.EntityBus as EntityDoubleDeckerbus;
_doubledeckerbus.ChangeAdditionalColor(color);
DrawBus();
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
EventAddBus?.Invoke(_bus);
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -4,7 +4,6 @@ using DoubleDeckerbus.Move_Strategy;
namespace DoubleDeckerbus
{
public partial class FormDoubleDeckerbus : Form
{
private DrawingBus? _drawingBus;
@ -61,11 +60,14 @@ namespace DoubleDeckerbus
{
color = dialog.Color;
}
_drawingBus = new DrawingBus(random.Next(100, 300),
random.Next(1000, 3000), color,
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10,100));
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{

View File

@ -46,7 +46,7 @@
// buttonAddBus
//
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonAddBus.Location = new Point(666, 331);
buttonAddBus.Location = new Point(859, 331);
buttonAddBus.Name = "buttonAddBus";
buttonAddBus.Size = new Size(118, 28);
buttonAddBus.TabIndex = 0;
@ -58,7 +58,7 @@
//
pictureBoxCollection.Location = new Point(3, 0);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(639, 436);
pictureBoxCollection.Size = new Size(830, 475);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
@ -67,7 +67,7 @@
labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelInstruments.AutoSize = true;
labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
labelInstruments.Location = new Point(666, 0);
labelInstruments.Location = new Point(859, 0);
labelInstruments.Name = "labelInstruments";
labelInstruments.Size = new Size(108, 21);
labelInstruments.TabIndex = 2;
@ -76,7 +76,7 @@
// buttonUpdate
//
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonUpdate.Location = new Point(658, 130);
buttonUpdate.Location = new Point(851, 130);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(131, 25);
buttonUpdate.TabIndex = 3;
@ -87,7 +87,7 @@
// buttonDeleteBus
//
buttonDeleteBus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonDeleteBus.Location = new Point(666, 394);
buttonDeleteBus.Location = new Point(859, 394);
buttonDeleteBus.Name = "buttonDeleteBus";
buttonDeleteBus.Size = new Size(118, 28);
buttonDeleteBus.TabIndex = 4;
@ -98,7 +98,7 @@
// maskedTextBoxNumber
//
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right;
maskedTextBoxNumber.Location = new Point(658, 365);
maskedTextBoxNumber.Location = new Point(851, 365);
maskedTextBoxNumber.Mask = "00";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(138, 23);
@ -109,7 +109,7 @@
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(658, 38);
label1.Location = new Point(851, 38);
label1.Name = "label1";
label1.Size = new Size(52, 15);
label1.TabIndex = 7;
@ -119,7 +119,7 @@
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 15;
listBoxStorages.Location = new Point(657, 159);
listBoxStorages.Location = new Point(850, 160);
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(132, 109);
@ -128,7 +128,7 @@
//
// buttonAddStorage
//
buttonAddStorage.Location = new Point(657, 101);
buttonAddStorage.Location = new Point(850, 102);
buttonAddStorage.Margin = new Padding(3, 2, 3, 2);
buttonAddStorage.Name = "buttonAddStorage";
buttonAddStorage.Size = new Size(131, 25);
@ -139,7 +139,7 @@
//
// buttonDeleteStorage
//
buttonDeleteStorage.Location = new Point(657, 272);
buttonDeleteStorage.Location = new Point(850, 273);
buttonDeleteStorage.Margin = new Padding(3, 2, 3, 2);
buttonDeleteStorage.Name = "buttonDeleteStorage";
buttonDeleteStorage.Size = new Size(131, 25);
@ -150,7 +150,7 @@
//
// textBoxStorageName
//
textBoxStorageName.Location = new Point(657, 76);
textBoxStorageName.Location = new Point(850, 77);
textBoxStorageName.Margin = new Padding(3, 2, 3, 2);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(132, 23);
@ -160,7 +160,7 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(810, 443);
ClientSize = new Size(1003, 480);
Controls.Add(textBoxStorageName);
Controls.Add(buttonDeleteStorage);
Controls.Add(buttonAddStorage);

View File

@ -65,6 +65,12 @@ namespace DoubleDeckerbus
}
}
private void buttonAddBus_Click(object sender, EventArgs e)
{
var formBusConfig = new FormBusConfig();
formBusConfig.AddEvent(AddBus);
formBusConfig.Show();
}
private void AddBus(DrawingBus selectedBus)
{
if (listBoxStorages.SelectedIndex == -1)
{
@ -76,18 +82,15 @@ namespace DoubleDeckerbus
{
return;
}
FormDoubleDeckerbus form = new();
if (form.ShowDialog() == DialogResult.OK)
selectedBus.ChangeBordersPicture(pictureBoxCollection.Width, pictureBoxCollection.Height);
if (obj + selectedBus != -1)
{
if (obj + form.SelectedBus != -1) //-1
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowBus();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowBus();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
private void buttonDeleteBus_Click(object sender, EventArgs e)
@ -115,7 +118,7 @@ namespace DoubleDeckerbus
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (obj - pos) //!!
if (obj - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = obj.ShowBus();

View File

@ -17,6 +17,7 @@ namespace DoubleDeckerbus.Generic
private readonly int _placeSizeWidth = 200;
private readonly int _placeSizeHeight = 120;
private readonly SetGeneric<T> _collection;
public BusGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
@ -46,10 +47,6 @@ namespace DoubleDeckerbus.Generic
{
return (U?)_collection[pos]?.GetMoveableObject;
}
public int ReturnLength()
{
return _collection.Count;
}
public Bitmap ShowBus()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
@ -72,8 +69,10 @@ namespace DoubleDeckerbus.Generic
}
private void DrawObjects(Graphics g)
{
int x = _pictureWidth / _placeSizeWidth - 1;
int y = 0;
foreach (var bus in _collection.GetBus())
{
if (bus != null)
@ -90,4 +89,5 @@ namespace DoubleDeckerbus.Generic
}
}
}
}
}

View File

@ -14,7 +14,6 @@ namespace DoubleDeckerbus.Generic
public List<string> Keys => _busStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public BusesGenericStorage(int pictureWidth, int pictureHeight)
{
_busStorages = new Dictionary<string, BusGenericCollection<DrawingBus, DrawingObjectBus>>();
@ -39,7 +38,6 @@ namespace DoubleDeckerbus.Generic
{
_busStorages.Remove(name);
}
}
public BusGenericCollection<DrawingBus, DrawingObjectBus>? this[string ind]
{

View File

@ -19,7 +19,7 @@ namespace DoubleDeckerbus.Generic
}
public int Insert(T bus)
{
_places.Insert(0, bus); //0
_places.Insert(0, bus);
return 0;
}
public bool Insert(T bus, int position)
@ -38,6 +38,7 @@ namespace DoubleDeckerbus.Generic
return false;
}
_places.RemoveAt(position);
return true;
}
public T? this[int position]
@ -71,4 +72,4 @@ namespace DoubleDeckerbus.Generic
}
}
}
}
}

View File

@ -38,6 +38,7 @@ namespace DoubleDeckerbus.Move_Strategy
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
if (Math.Abs(diffY) > GetStep())

View File

@ -12,4 +12,4 @@ namespace DoubleDeckerbus.Move_Strategy
InProgress,
Finish
}
}
}