Compare commits
No commits in common. "74f0ad74bfae763c95bbf91b4486a8c16cdf5663" and "bd7a35bdf7462664d47199687f07d5bc077830f3" have entirely different histories.
74f0ad74bf
...
bd7a35bdf7
@ -81,7 +81,7 @@ namespace ProjectTractor.DrawningObjects {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject из объекта DrawningTractor
|
||||
/// Получение объекта IMoveableObject из объекта DrawningCar
|
||||
/// </summary>
|
||||
public IMoveableObject GetMoveableObject => new
|
||||
DrawningObjectTractor(this);
|
||||
|
@ -14,112 +14,32 @@ using ProjectTractor.MovementStrategy;
|
||||
namespace ProjectTractor
|
||||
{
|
||||
public partial class FormTractorCollection : Form
|
||||
{
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly TractorsGenericStorage _storage;
|
||||
private readonly TractorsGenericCollection<DrawningTractor,
|
||||
DrawningObjectTractor> _cars;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormTractorCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new TractorsGenericStorage(pictureBoxCollection.Width,
|
||||
pictureBoxCollection.Height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение listBoxObjects
|
||||
/// </summary>
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||
>= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
|
||||
index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
///
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void listBoxStorages_SelectedIndexChanged(object sender,
|
||||
EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image =
|
||||
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowTractors();
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
_cars = new TractorsGenericCollection<DrawningTractor,
|
||||
DrawningObjectTractor>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormTractor form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedTractor)
|
||||
if (_cars + form.SelectedTractor)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTractors();
|
||||
pictureBoxCollection.Image = _cars.ShowCars();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -135,26 +55,16 @@ namespace ProjectTractor
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (obj - pos != null)
|
||||
if (_cars - pos)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = obj.ShowTractors();
|
||||
pictureBoxCollection.Image = _cars.ShowCars();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -166,37 +76,22 @@ namespace ProjectTractor
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs
|
||||
e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowTractors();
|
||||
pictureBoxCollection.Image = _cars.ShowCars();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonDelObject = new System.Windows.Forms.Button();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.ButtonAddObject = new System.Windows.Forms.Button();
|
||||
this.textBoxStorageName = new System.Windows.Forms.MaskedTextBox();
|
||||
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
|
||||
this.ButtonRemoveTractor = new System.Windows.Forms.Button();
|
||||
this.ButtonAddTractor = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.groupBox.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
@ -204,79 +99,28 @@ namespace ProjectTractor
|
||||
this.pictureBoxCollection.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(675, 536);
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(620, 437);
|
||||
this.pictureBoxCollection.TabIndex = 1;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// groupBox
|
||||
//
|
||||
this.groupBox.Controls.Add(this.groupBox1);
|
||||
this.groupBox.Controls.Add(this.ButtonRefreshCollection);
|
||||
this.groupBox.Controls.Add(this.ButtonRemoveTractor);
|
||||
this.groupBox.Controls.Add(this.ButtonAddTractor);
|
||||
this.groupBox.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.groupBox.Location = new System.Drawing.Point(681, 12);
|
||||
this.groupBox.Location = new System.Drawing.Point(626, 12);
|
||||
this.groupBox.Name = "groupBox";
|
||||
this.groupBox.Size = new System.Drawing.Size(255, 522);
|
||||
this.groupBox.Size = new System.Drawing.Size(255, 413);
|
||||
this.groupBox.TabIndex = 2;
|
||||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Инструменты";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.ButtonDelObject);
|
||||
this.groupBox1.Controls.Add(this.listBoxStorages);
|
||||
this.groupBox1.Controls.Add(this.ButtonAddObject);
|
||||
this.groupBox1.Controls.Add(this.textBoxStorageName);
|
||||
this.groupBox1.Location = new System.Drawing.Point(16, 29);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(224, 279);
|
||||
this.groupBox1.TabIndex = 9;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Наборы";
|
||||
//
|
||||
// ButtonDelObject
|
||||
//
|
||||
this.ButtonDelObject.Location = new System.Drawing.Point(12, 227);
|
||||
this.ButtonDelObject.Name = "ButtonDelObject";
|
||||
this.ButtonDelObject.Size = new System.Drawing.Size(203, 35);
|
||||
this.ButtonDelObject.TabIndex = 3;
|
||||
this.ButtonDelObject.Text = "Удалить набор";
|
||||
this.ButtonDelObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 20;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(12, 116);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(203, 84);
|
||||
this.listBoxStorages.TabIndex = 2;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxStorages_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(12, 59);
|
||||
this.ButtonAddObject.Name = "ButtonAddObject";
|
||||
this.ButtonAddObject.Size = new System.Drawing.Size(203, 29);
|
||||
this.ButtonAddObject.TabIndex = 1;
|
||||
this.ButtonAddObject.Text = "Добавить набор";
|
||||
this.ButtonAddObject.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(12, 26);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(203, 27);
|
||||
this.textBoxStorageName.TabIndex = 0;
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
//
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(28, 464);
|
||||
this.ButtonRefreshCollection.Location = new System.Drawing.Point(20, 331);
|
||||
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(203, 35);
|
||||
this.ButtonRefreshCollection.Size = new System.Drawing.Size(211, 35);
|
||||
this.ButtonRefreshCollection.TabIndex = 8;
|
||||
this.ButtonRefreshCollection.Text = "Обновить коллекцию";
|
||||
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
@ -284,7 +128,7 @@ namespace ProjectTractor
|
||||
//
|
||||
// ButtonRemoveTractor
|
||||
//
|
||||
this.ButtonRemoveTractor.Location = new System.Drawing.Point(28, 390);
|
||||
this.ButtonRemoveTractor.Location = new System.Drawing.Point(28, 156);
|
||||
this.ButtonRemoveTractor.Name = "ButtonRemoveTractor";
|
||||
this.ButtonRemoveTractor.Size = new System.Drawing.Size(203, 33);
|
||||
this.ButtonRemoveTractor.TabIndex = 7;
|
||||
@ -294,7 +138,7 @@ namespace ProjectTractor
|
||||
//
|
||||
// ButtonAddTractor
|
||||
//
|
||||
this.ButtonAddTractor.Location = new System.Drawing.Point(28, 317);
|
||||
this.ButtonAddTractor.Location = new System.Drawing.Point(28, 46);
|
||||
this.ButtonAddTractor.Name = "ButtonAddTractor";
|
||||
this.ButtonAddTractor.Size = new System.Drawing.Size(203, 34);
|
||||
this.ButtonAddTractor.TabIndex = 6;
|
||||
@ -304,14 +148,14 @@ namespace ProjectTractor
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 357);
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 113);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(203, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 5;
|
||||
//
|
||||
// FormTractorCollection
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(948, 536);
|
||||
this.ClientSize = new System.Drawing.Size(893, 437);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
@ -322,8 +166,6 @@ namespace ProjectTractor
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.groupBox.ResumeLayout(false);
|
||||
this.groupBox.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -333,13 +175,7 @@ namespace ProjectTractor
|
||||
private Button ButtonRemoveTractor;
|
||||
private Button ButtonAddTractor;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private GroupBox groupBox1;
|
||||
private Button ButtonDelObject;
|
||||
private ListBox listBoxStorages;
|
||||
private Button ButtonAddObject;
|
||||
private MaskedTextBox textBoxStorageName;
|
||||
private PictureBox pictureBoxCollection;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,23 +12,18 @@ namespace ProjectTractor.Generics
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly List<T?> _places;
|
||||
private readonly T?[] _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Count;
|
||||
/// <summary>
|
||||
/// Максимальное количество объектов в списке
|
||||
/// </summary>
|
||||
private readonly int _maxCount;
|
||||
public int Count => _places.Length;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
_places = new T?[count];
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
@ -37,22 +32,38 @@ namespace ProjectTractor.Generics
|
||||
/// <returns></returns>
|
||||
public bool Insert(T tractor)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
return false;
|
||||
Insert(tractor, 0);
|
||||
if (_places[0] == null)
|
||||
{
|
||||
_places[0] = tractor;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Insert(tractor, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="tractor">Добавляемый автомобиль</param>
|
||||
/// <param name="car">Добавляемый автомобиль</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T tractor, int position)
|
||||
{
|
||||
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
|
||||
|
||||
if (!(position >= 0 && position < Count))
|
||||
return false;
|
||||
_places.Insert(position, tractor);
|
||||
if (_places[position] != null)
|
||||
{
|
||||
int ind = position;
|
||||
while (ind < Count && _places[ind] != null)
|
||||
ind++;
|
||||
if (ind == Count)
|
||||
return false;
|
||||
for (int i = ind - 1; i >= position; i--)
|
||||
_places[i + 1] = _places[i];
|
||||
}
|
||||
_places[position] = tractor;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@ -63,8 +74,10 @@ namespace ProjectTractor.Generics
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
{
|
||||
return false;
|
||||
_places.RemoveAt(position);
|
||||
}
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@ -72,36 +85,13 @@ namespace ProjectTractor.Generics
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T? this[int position]
|
||||
public T? Get(int position)
|
||||
{
|
||||
get
|
||||
if (!(position >= 0 && position < Count))
|
||||
{
|
||||
if (!(position >= 0 && position <= Count))
|
||||
return null;
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!(position >= 0 && position <= Count))
|
||||
return;
|
||||
_places.Insert(position, value);
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
/// <summary>
|
||||
/// Проход по списку
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T?> GetTractors(int? maxTractors = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxTractors.HasValue && i == maxTractors.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using ProjectTractor.MovementStrategy;
|
||||
namespace ProjectTractor.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный класс для набора объектов DrawningTractor
|
||||
/// Параметризованный класс для набора объектов DrawningCar
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
@ -71,10 +71,9 @@ namespace ProjectTractor.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(TractorsGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
public static bool operator -(TractorsGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
T? obj = collect._collection.Get(pos);
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
@ -88,13 +87,13 @@ namespace ProjectTractor.Generics
|
||||
/// <returns></returns>
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowTractors()
|
||||
public Bitmap ShowCars()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
@ -122,22 +121,21 @@ namespace ProjectTractor.Generics
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var tractor in _collection.GetTractors())
|
||||
for (int i = 0; i < _collection.Count; i++)
|
||||
{
|
||||
|
||||
DrawningTractor? tractor = _collection.Get(i);
|
||||
if (tractor != null)
|
||||
{
|
||||
int countRows = _pictureWidth / _placeSizeWidth;
|
||||
tractor.SetPosition(_pictureWidth - _placeSizeWidth * 2 - (i % countRows * _placeSizeWidth) + 190, _pictureHeight - i / countRows * _placeSizeHeight - 160);
|
||||
tractor.SetPosition(_pictureWidth - _placeSizeWidth*2 - (i % countRows * _placeSizeWidth) + 20, _pictureHeight - i / countRows * _placeSizeHeight - 150);
|
||||
tractor.DrawTransport(g);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectTractor.DrawningObjects;
|
||||
using ProjectTractor.MovementStrategy;
|
||||
using ProjectTractor.Generics;
|
||||
|
||||
namespace ProjectTractor
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для хранения коллекции
|
||||
/// </summary>
|
||||
internal class TractorsGenericStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище)
|
||||
/// </summary>
|
||||
readonly Dictionary<string, TractorsGenericCollection<DrawningTractor, DrawningObjectTractor>> _tractorStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий наборов
|
||||
/// </summary>
|
||||
public List<string> Keys => _tractorStorages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public TractorsGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_tractorStorages = new Dictionary<string,
|
||||
TractorsGenericCollection<DrawningTractor, DrawningObjectTractor>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void AddSet(string name)
|
||||
{
|
||||
_tractorStorages.Add(name,
|
||||
new TractorsGenericCollection<DrawningTractor,
|
||||
DrawningObjectTractor>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (!_tractorStorages.ContainsKey(name))
|
||||
return;
|
||||
_tractorStorages.Remove(name);
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к набору
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public TractorsGenericCollection<DrawningTractor, DrawningObjectTractor>?
|
||||
this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tractorStorages.ContainsKey(ind))
|
||||
return _tractorStorages[ind];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user