Готовая лаба 3
This commit is contained in:
parent
c69b8824c6
commit
b3d0980f05
1
Tank/Tank/FormTank.Designer.cs
generated
1
Tank/Tank/FormTank.Designer.cs
generated
@ -173,7 +173,6 @@
|
|||||||
Margin = new Padding(3, 4, 3, 4);
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormTank";
|
Name = "FormTank";
|
||||||
Text = "FormTank";
|
Text = "FormTank";
|
||||||
Load += FormTank_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
@ -128,10 +128,5 @@ namespace Tank
|
|||||||
SelectedTank = _Tank;
|
SelectedTank = _Tank;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormTank_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
namespace Tank
|
namespace Tank
|
||||||
{
|
{
|
||||||
partial class CollectionsFrame
|
partial class FormTanksCollections
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
@ -13,11 +13,11 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Tank
|
namespace Tank
|
||||||
{
|
{
|
||||||
public partial class CollectionsFrame : Form
|
public partial class FormTanksCollections : Form
|
||||||
{
|
{
|
||||||
private readonly TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank> _tanks;
|
private readonly TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank> _tanks;
|
||||||
|
|
||||||
public CollectionsFrame()
|
public FormTanksCollections()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_tanks = new TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>(DrawTank.Width, DrawTank.Height);
|
_tanks = new TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>(DrawTank.Width, DrawTank.Height);
|
@ -11,7 +11,7 @@ namespace Tank
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new CollectionsFrame());
|
Application.Run(new FormTanksCollections());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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)
|
if (position < 0 || position >= Count)
|
||||||
return -1;
|
return false;
|
||||||
if (_places[position] == null)
|
if (_places[position] == null)
|
||||||
{
|
{
|
||||||
_places[position] = tank;
|
_places[position] = tank;
|
||||||
return position;
|
return true;
|
||||||
}
|
}
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for(int i = position; i < Count; i++)
|
for(int i = position; i < Count; i++)
|
||||||
@ -62,13 +62,13 @@ namespace Tank
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return -1;
|
return false;
|
||||||
for(int i = index; index > position; i--)
|
for(int i = index; index > position; i--)
|
||||||
{
|
{
|
||||||
_places[i] = _places[i - 1];
|
_places[i] = _places[i - 1];
|
||||||
}
|
}
|
||||||
_places[position] = tank;
|
_places[position] = tank;
|
||||||
return position;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Удаление объекта из набора с конкретной позиции
|
// Удаление объекта из набора с конкретной позиции
|
||||||
|
@ -99,7 +99,7 @@ namespace Tank.Generics
|
|||||||
DrawArmoVehicle? tank = _collection.Get(i);
|
DrawArmoVehicle? tank = _collection.Get(i);
|
||||||
if (tank == null)
|
if (tank == null)
|
||||||
continue;
|
continue;
|
||||||
tank.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
|
tank.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
|
||||||
tank.DrawTransport(g);
|
tank.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user