PIbd-21 Belianin N.N. LabWork03 #3

Closed
Belnik wants to merge 4 commits from LabWork03 into LabWork02
8 changed files with 10 additions and 16 deletions
Showing only changes of commit b3d0980f05 - Show all commits

View File

@ -173,7 +173,6 @@
Margin = new Padding(3, 4, 3, 4);
Name = "FormTank";
Text = "FormTank";
Load += FormTank_Load;
((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit();
ResumeLayout(false);
}

View File

@ -128,10 +128,5 @@ namespace Tank
SelectedTank = _Tank;
DialogResult = DialogResult.OK;
}
private void FormTank_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -1,6 +1,6 @@
namespace Tank
{
partial class CollectionsFrame
partial class FormTanksCollections
{
/// <summary>
/// Required designer variable.

View File

@ -13,11 +13,11 @@ using System.Windows.Forms;
namespace Tank
{
public partial class CollectionsFrame : Form
public partial class FormTanksCollections : Form
{
private readonly TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank> _tanks;
public CollectionsFrame()
public FormTanksCollections()
{
InitializeComponent();
_tanks = new TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>(DrawTank.Width, DrawTank.Height);

View File

@ -11,7 +11,7 @@ namespace Tank
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new CollectionsFrame());
Application.Run(new FormTanksCollections());
}
}
}

View File

@ -44,14 +44,14 @@ namespace Tank
}
// Добавление объекта в набор на конкретную позицию
public int Insert(T tank, int position)
public bool Insert(T tank, int position)
{
if (position < 0 || position >= Count)
return -1;
return false;
if (_places[position] == null)
{
_places[position] = tank;
return position;
return true;
}
int index = -1;
for(int i = position; i < Count; i++)
@ -62,13 +62,13 @@ namespace Tank
}
}
if (index < 0)
return -1;
return false;
for(int i = index; index > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = tank;
return position;
return true;
}
// Удаление объекта из набора с конкретной позиции

View File

@ -99,7 +99,7 @@ namespace Tank.Generics
DrawArmoVehicle? tank = _collection.Get(i);
if (tank == null)
continue;
tank.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
tank.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
tank.DrawTransport(g);
}
}