Решена проблема с загрузкой

This commit is contained in:
Arklightning 2022-12-24 19:34:00 +04:00
parent 7a9c7c16a2
commit f3d97ecbf3
9 changed files with 136 additions and 131 deletions

View File

@ -86,8 +86,8 @@ namespace Trolleybus
return false;
}
float airplaneWidth = rightX - leftX;
float airplaneHeight = bottomY - topY;
float trolleybusWidth = rightX - leftX;
float trolleybusHeight = bottomY - topY;
int x = _random.Next(0, 10);
int y = _random.Next(0, 10);
@ -97,7 +97,7 @@ namespace Trolleybus
{
if (_map[i, j] == _barrier)
{
if (x + airplaneWidth >= _size_x * i && x <= _size_x * i && y + airplaneHeight > _size_y * j && y <= _size_y * j)
if (x + trolleybusWidth >= _size_x * i && x <= _size_x * i && y + trolleybusHeight > _size_y * j && y <= _size_y * j)
{
return false;
}

View File

@ -56,9 +56,9 @@ namespace Trolleybus
{
Trolleybus = new EntityTrolleybus(speed, weight, bodyColor);
}
protected DrawingTrolleybus(int speed, float weight, Color bodyColor, int trolleybusWidth, int trolleybusHeight)
protected DrawingTrolleybus(int speed, float weight, Color bodyColor, int trolleybusWidth, int trolleybusHeight) :
this(speed, weight, bodyColor)
{
Trolleybus = new EntityTrolleybus(speed, weight, bodyColor);
_trolleybusWidth = trolleybusWidth;
_trolleybusHeight = trolleybusHeight;
}
@ -69,13 +69,10 @@ namespace Trolleybus
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
// public void SetPosition(int x, int y, int startX, int startY, int width, int height)
public void SetPosition(int x, int y, int width, int height)
{
_startPosX = x;
_startPosY = y;
// _startX = startX;
// _startY = startY;
_pictureWidth = width;
_pictureHeight = height;
}
@ -93,22 +90,22 @@ namespace Trolleybus
{
//вправо
case Direction.Right:
if(_startPosX + _trolleybusWidth + Trolleybus.Step < _pictureWidth)
if (_startPosX + _trolleybusWidth + Trolleybus.Step < _pictureWidth)
{
_startPosX += Trolleybus.Step;
}
break;
//влево
case Direction.Left:
// if (_startPosX > _startX)
// if (_startPosX > _startX)
if (_startPosX - Trolleybus.Step > 0)
{
_startPosX -= Trolleybus.Step;
{
_startPosX -= Trolleybus.Step;
}
break;
//вверх
case Direction.Up:
// if (_startPosY > _startY)
// if (_startPosY > _startY)
if (_startPosY - Trolleybus.Step > 0)
{
_startPosY -= Trolleybus.Step;
@ -170,7 +167,7 @@ namespace Trolleybus
{
_pictureWidth = width;
_pictureHeight = height;
if(_pictureWidth <= _trolleybusWidth || _pictureHeight <= _trolleybusHeight)
if (_pictureWidth <= _trolleybusWidth || _pictureHeight <= _trolleybusHeight)
{
_pictureWidth = null;
_pictureHeight = null;

View File

@ -44,10 +44,6 @@ namespace Trolleybus
}
public string GetInfo() => _trolleybus?.GetDataForSave();
public static IDrawningObject Create(string data)
{
return new DrawningObjectTrolleybus(data.CreateDrawingTrolleybus());
}
public static IDrawningObject Create(string data) => new DrawningObjectTrolleybus(data.CreateDrawingTrolleybus());
}
}

View File

@ -19,7 +19,7 @@ namespace Trolleybus
return new DrawingTrolleybus(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromName(strs[2]));
}
if (strs.Length == 6)
if (strs.Length == 7)
{
return new DrawningSmallTrolleybus(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromName(strs[2]),
@ -37,7 +37,7 @@ namespace Trolleybus
{
return str;
}
return $"{str}{_separatorForObject}{smallTrolleybus.DopColor.Name}{_separatorForObject}{smallTrolleybus.Horns}{_separatorForObject}{smallTrolleybus.Battary}";
return $"{str}{_separatorForObject}{smallTrolleybus.DopColor.Name}{_separatorForObject}{smallTrolleybus.BodyKit}{_separatorForObject}{smallTrolleybus.Horns}{_separatorForObject}{smallTrolleybus.Battary}";
}
}
}

View File

@ -38,11 +38,6 @@ namespace Trolleybus
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
}
foreach (string map in _mapsCollection.Keys)
{
listBoxMaps.Items.Add(map);
}
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
{
listBoxMaps.SelectedIndex = 0;
@ -64,6 +59,11 @@ namespace Trolleybus
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (textBoxNewMapName.Text.Contains('|') || textBoxNewMapName.Text.Contains(':') || textBoxNewMapName.Text.Contains(';'))
{
MessageBox.Show("Присутствуют символы, недопустимые для имени карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
ReloadMaps();
}
@ -131,24 +131,6 @@ namespace Trolleybus
formTrolleybusConfig.AddEvent(AddTrolleybus);
formTrolleybusConfig.Show();
/*if (listBoxMaps.SelectedIndex == -1)
{
return;
}
Form1 form = new();
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObjectTrolleybus tractor = new(form.SelectedTrolleybus);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + tractor != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}*/
}
/// <summary>
/// Удаление объекта
@ -264,4 +246,4 @@ namespace Trolleybus
}
}
}
}

View File

@ -73,9 +73,11 @@
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
this.groupBoxConfig.Controls.Add(this.labelWeight);
this.groupBoxConfig.Controls.Add(this.labelSpeed);
this.groupBoxConfig.Location = new System.Drawing.Point(13, 13);
this.groupBoxConfig.Location = new System.Drawing.Point(9, 8);
this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBoxConfig.Name = "groupBoxConfig";
this.groupBoxConfig.Size = new System.Drawing.Size(657, 457);
this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBoxConfig.Size = new System.Drawing.Size(438, 297);
this.groupBoxConfig.TabIndex = 0;
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
@ -83,9 +85,10 @@
// checkBoxBodyKit
//
this.checkBoxBodyKit.AutoSize = true;
this.checkBoxBodyKit.Location = new System.Drawing.Point(11, 224);
this.checkBoxBodyKit.Location = new System.Drawing.Point(7, 146);
this.checkBoxBodyKit.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
this.checkBoxBodyKit.Size = new System.Drawing.Size(89, 24);
this.checkBoxBodyKit.Size = new System.Drawing.Size(62, 17);
this.checkBoxBodyKit.TabIndex = 10;
this.checkBoxBodyKit.Text = "BodyKit";
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
@ -93,9 +96,10 @@
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(483, 214);
this.labelModifiedObject.Location = new System.Drawing.Point(322, 139);
this.labelModifiedObject.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(130, 34);
this.labelModifiedObject.Size = new System.Drawing.Size(87, 23);
this.labelModifiedObject.TabIndex = 9;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -104,9 +108,10 @@
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(336, 214);
this.labelSimpleObject.Location = new System.Drawing.Point(224, 139);
this.labelSimpleObject.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(100, 34);
this.labelSimpleObject.Size = new System.Drawing.Size(67, 23);
this.labelSimpleObject.TabIndex = 8;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -122,91 +127,102 @@
this.groupBoxColors.Controls.Add(this.panelBlue);
this.groupBoxColors.Controls.Add(this.panelGreen);
this.groupBoxColors.Controls.Add(this.panelRed);
this.groupBoxColors.Location = new System.Drawing.Point(340, 26);
this.groupBoxColors.Location = new System.Drawing.Point(227, 17);
this.groupBoxColors.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBoxColors.Name = "groupBoxColors";
this.groupBoxColors.Size = new System.Drawing.Size(301, 185);
this.groupBoxColors.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.groupBoxColors.Size = new System.Drawing.Size(201, 120);
this.groupBoxColors.TabIndex = 7;
this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета";
//
// panelPurple
//
this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.panelPurple.Location = new System.Drawing.Point(211, 81);
this.panelPurple.BackColor = System.Drawing.Color.Purple;
this.panelPurple.Location = new System.Drawing.Point(141, 53);
this.panelPurple.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(62, 49);
this.panelPurple.Size = new System.Drawing.Size(41, 32);
this.panelPurple.TabIndex = 2;
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelBlack
//
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(143, 81);
this.panelBlack.Location = new System.Drawing.Point(95, 53);
this.panelBlack.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(62, 49);
this.panelBlack.Size = new System.Drawing.Size(41, 32);
this.panelBlack.TabIndex = 2;
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelGrey
//
this.panelGrey.BackColor = System.Drawing.Color.Silver;
this.panelGrey.Location = new System.Drawing.Point(75, 81);
this.panelGrey.Location = new System.Drawing.Point(50, 53);
this.panelGrey.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelGrey.Name = "panelGrey";
this.panelGrey.Size = new System.Drawing.Size(62, 49);
this.panelGrey.Size = new System.Drawing.Size(41, 32);
this.panelGrey.TabIndex = 2;
this.panelGrey.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelWhite
//
this.panelWhite.BackColor = System.Drawing.Color.Snow;
this.panelWhite.Location = new System.Drawing.Point(7, 81);
this.panelWhite.Location = new System.Drawing.Point(5, 53);
this.panelWhite.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(62, 49);
this.panelWhite.Size = new System.Drawing.Size(41, 32);
this.panelWhite.TabIndex = 2;
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(211, 26);
this.panelYellow.Location = new System.Drawing.Point(141, 17);
this.panelYellow.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(62, 49);
this.panelYellow.Size = new System.Drawing.Size(41, 32);
this.panelYellow.TabIndex = 2;
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(143, 26);
this.panelBlue.Location = new System.Drawing.Point(95, 17);
this.panelBlue.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(62, 49);
this.panelBlue.Size = new System.Drawing.Size(41, 32);
this.panelBlue.TabIndex = 1;
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.panelGreen.Location = new System.Drawing.Point(75, 25);
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(50, 16);
this.panelGreen.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(62, 50);
this.panelGreen.Size = new System.Drawing.Size(41, 32);
this.panelGreen.TabIndex = 1;
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(7, 26);
this.panelRed.Location = new System.Drawing.Point(5, 17);
this.panelRed.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(62, 49);
this.panelRed.Size = new System.Drawing.Size(41, 32);
this.panelRed.TabIndex = 0;
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// checkBoxBattary
//
this.checkBoxBattary.AutoSize = true;
this.checkBoxBattary.Location = new System.Drawing.Point(11, 180);
this.checkBoxBattary.Location = new System.Drawing.Point(7, 117);
this.checkBoxBattary.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.checkBoxBattary.Name = "checkBoxBattary";
this.checkBoxBattary.Size = new System.Drawing.Size(234, 24);
this.checkBoxBattary.Size = new System.Drawing.Size(158, 17);
this.checkBoxBattary.TabIndex = 5;
this.checkBoxBattary.Text = "Признак наличия батареи";
this.checkBoxBattary.UseVisualStyleBackColor = true;
@ -214,18 +230,20 @@
// checkBoxHorns
//
this.checkBoxHorns.AutoSize = true;
this.checkBoxHorns.Location = new System.Drawing.Point(11, 121);
this.checkBoxHorns.Location = new System.Drawing.Point(7, 79);
this.checkBoxHorns.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.checkBoxHorns.Name = "checkBoxHorns";
this.checkBoxHorns.Size = new System.Drawing.Size(216, 24);
this.checkBoxHorns.Size = new System.Drawing.Size(146, 17);
this.checkBoxHorns.TabIndex = 4;
this.checkBoxHorns.Text = "Признак наличия антен";
this.checkBoxHorns.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(95, 75);
this.numericUpDownWeight.Location = new System.Drawing.Point(63, 49);
this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(120, 26);
this.numericUpDownWeight.Size = new System.Drawing.Size(80, 20);
this.numericUpDownWeight.TabIndex = 3;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
@ -235,9 +253,10 @@
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(95, 26);
this.numericUpDownSpeed.Location = new System.Drawing.Point(63, 17);
this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 26);
this.numericUpDownSpeed.Size = new System.Drawing.Size(80, 20);
this.numericUpDownSpeed.TabIndex = 2;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
@ -248,27 +267,30 @@
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(7, 75);
this.labelWeight.Location = new System.Drawing.Point(5, 49);
this.labelWeight.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(37, 20);
this.labelWeight.Size = new System.Drawing.Size(26, 13);
this.labelWeight.TabIndex = 1;
this.labelWeight.Text = "Вес";
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(7, 26);
this.labelSpeed.Location = new System.Drawing.Point(5, 17);
this.labelSpeed.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(81, 20);
this.labelSpeed.Size = new System.Drawing.Size(55, 13);
this.labelSpeed.TabIndex = 0;
this.labelSpeed.Text = "Скорость";
//
// pictureBoxObject
//
this.pictureBoxObject.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pictureBoxObject.Location = new System.Drawing.Point(27, 81);
this.pictureBoxObject.Location = new System.Drawing.Point(18, 53);
this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(346, 208);
this.pictureBoxObject.Size = new System.Drawing.Size(231, 135);
this.pictureBoxObject.TabIndex = 1;
this.pictureBoxObject.TabStop = false;
//
@ -278,9 +300,10 @@
this.panelObject.Controls.Add(this.labelDopColor);
this.panelObject.Controls.Add(this.labelColor);
this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Location = new System.Drawing.Point(698, 39);
this.panelObject.Location = new System.Drawing.Point(465, 25);
this.panelObject.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(412, 316);
this.panelObject.Size = new System.Drawing.Size(275, 205);
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);
@ -289,9 +312,10 @@
//
this.labelDopColor.AllowDrop = true;
this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelDopColor.Location = new System.Drawing.Point(139, 26);
this.labelDopColor.Location = new System.Drawing.Point(93, 17);
this.labelDopColor.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelDopColor.Name = "labelDopColor";
this.labelDopColor.Size = new System.Drawing.Size(106, 52);
this.labelDopColor.Size = new System.Drawing.Size(71, 34);
this.labelDopColor.TabIndex = 3;
this.labelDopColor.Text = "Доп цвет";
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -302,9 +326,10 @@
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(27, 26);
this.labelColor.Location = new System.Drawing.Point(18, 17);
this.labelColor.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(106, 52);
this.labelColor.Size = new System.Drawing.Size(71, 34);
this.labelColor.TabIndex = 2;
this.labelColor.Text = "Цвет";
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -313,9 +338,10 @@
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(725, 361);
this.buttonOk.Location = new System.Drawing.Point(483, 235);
this.buttonOk.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(106, 50);
this.buttonOk.Size = new System.Drawing.Size(71, 32);
this.buttonOk.TabIndex = 3;
this.buttonOk.Text = "Добваить";
this.buttonOk.UseVisualStyleBackColor = true;
@ -323,22 +349,24 @@
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(837, 361);
this.buttonCancel.Location = new System.Drawing.Point(558, 235);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(106, 50);
this.buttonCancel.Size = new System.Drawing.Size(71, 32);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// FormTrolleybusConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1180, 482);
this.ClientSize = new System.Drawing.Size(787, 313);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.groupBoxConfig);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "FormTrolleybusConfig";
this.Text = "FormTrolleybusConfig";
this.groupBoxConfig.ResumeLayout(false);

View File

@ -89,13 +89,9 @@ namespace Trolleybus
public Bitmap ShowOnMap()
{
Shaking();
for (int i = 0; i < _setTrolleybus.Count; i++)
foreach (var trolleybus in _setTrolleybus.GetTrolleybus())
{
var car = _setTrolleybus[i];
if (car != null)
{
return _map.CreateMap(_pictureWidth, _pictureHeight, car);
}
return _map.CreateMap(_pictureWidth, _pictureHeight, trolleybus);
}
return new(_pictureWidth, _pictureHeight);
}
@ -116,9 +112,9 @@ namespace Trolleybus
public string GetData(char separatorType, char separatorData)
{
string data = $"{_map.GetType().Name}{separatorType}";
foreach (var tractor in _setTrolleybus.GetTrolleybus())
foreach (var trolleybus in _setTrolleybus.GetTrolleybus())
{
data += $"{tractor.GetInfo()}{separatorData}";
data += $"{trolleybus.GetInfo()}{separatorData}";
}
return data;
}
@ -127,7 +123,8 @@ namespace Trolleybus
{
foreach (var rec in records)
{
_setTrolleybus.Insert(DrawningObjectTrolleybus.Create(rec) as T);
if (rec != "")
_setTrolleybus.Insert(DrawningObjectTrolleybus.Create(rec) as T);
}
}
/// <summary>
@ -180,27 +177,28 @@ namespace Trolleybus
/// <param name="g"></param>
private void DrawTrolleybus(Graphics g)
{
int xForLocomotive = _pictureWidth - 2 * _placeSizeWidth + 60;
int yForLocomotive = 10;
int xForTrolleybus = _pictureWidth - 2 * _placeSizeWidth + 60;
int yForTrolleybus = 10;
int countInRow = 0;
for (int i = 0; i < _setTrolleybus.Count; i++)
{
if (countInRow >= _pictureWidth / (_placeSizeWidth + 30))
{
xForLocomotive = _pictureWidth - 2 * _placeSizeWidth + 60;
yForLocomotive += _placeSizeHeight;
xForTrolleybus = _pictureWidth - 2 * _placeSizeWidth + 60;
yForTrolleybus += _placeSizeHeight;
countInRow = 0;
}
if (_setTrolleybus[i] != null)
{
T locomotive = _setTrolleybus[i];
locomotive.SetObject(xForLocomotive, yForLocomotive, _pictureWidth, _pictureHeight);
locomotive.DrawningObject(g);
T trolleybus = _setTrolleybus[i];
trolleybus.SetObject(xForTrolleybus, yForTrolleybus, _pictureWidth, _pictureHeight);
trolleybus.DrawningObject(g);
}
xForLocomotive -= _placeSizeWidth + 30;
xForTrolleybus -= _placeSizeWidth + 30;
countInRow++;
}
}
}
}

View File

@ -36,15 +36,16 @@ namespace Trolleybus
/// <param name="map">Карта</param>
public void AddMap(string name, AbstractMap map)
{
if (Keys.Contains(name))
return;
_mapStorages.Add(name, new(_pictureWidth, _pictureHeight, map));
if (!_mapStorages.ContainsKey(name))
{
_mapStorages.Add(name, new MapWithSetTrolleybusGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
}
/// Удаление карты
/// <param name="name">Название карты</param>
public void DelMap(string name)
{
_mapStorages.Remove(name);
if (_mapStorages.ContainsKey(name)) _mapStorages.Remove(name);
}
/// Доступ к депо
/// <param name="ind"></param>
@ -53,8 +54,11 @@ namespace Trolleybus
{
get
{
_mapStorages.TryGetValue(ind, out var mapWithSetTrolleybusGeneric);
return mapWithSetTrolleybusGeneric;
if (_mapStorages.ContainsKey(ind))
{
return _mapStorages[ind];
}
return null;
}
}

View File

@ -47,15 +47,15 @@ namespace Trolleybus
}
// Удаление объекта из набора с конкретной позиции
public T Remove(int position)
{
// проверка позиции
if (!CorrectPos(position))
return null;
// удаление объекта из массива, присовив элементу массива значение null
T temp = _places[position];
_places.RemoveAt(position);
return temp;
}
{
// проверка позиции
if (!CorrectPos(position))
return null;
// удаление объекта из массива, присовив элементу массива значение null
T temp = _places[position];
_places.RemoveAt(position);
return temp;
}
// Получение объекта из набора по позиции
public T this[int position]
{