result
This commit is contained in:
parent
04d7a840bc
commit
c5d48c32a5
@ -59,6 +59,7 @@ namespace DumpTruck.Generics
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
/// <summary>
|
||||
@ -127,25 +128,21 @@ pos)
|
||||
{
|
||||
|
||||
int numPlacesInRow = _pictureWidth / _placeSizeWidth;
|
||||
int i = 0;
|
||||
foreach (var car in _collection.GetCars())
|
||||
{
|
||||
|
||||
if (car != null)
|
||||
{
|
||||
for (int i = 0; i < _collection.Count; i++)
|
||||
{
|
||||
|
||||
// TODO получение объекта
|
||||
// TODO установка позиции
|
||||
// TODO прорисовка объекта
|
||||
|
||||
|
||||
|
||||
car.SetPosition((i % numPlacesInRow) * _placeSizeWidth + _placeSizeWidth / 20, _placeSizeHeight * (i / numPlacesInRow) + _placeSizeHeight / 10);
|
||||
//car.SetPosition(_placeSizeWidth * (i/ numPlacesInColumn) + _placeSizeWidth / 20, (i % numPlacesInColumn ) *_placeSizeHeight + _placeSizeHeight / 10);
|
||||
car.DrawTransport(g);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ namespace DumpTruck.Generics
|
||||
public void AddSet(string name)
|
||||
{
|
||||
// TODO Прописать логику для добавления
|
||||
_carStorages.Add(name, new CarsGenericCollection<DrawningCar, DrawningObjectCar>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
@ -53,7 +54,11 @@ namespace DumpTruck.Generics
|
||||
/// <param name="name">Название набора</param>
|
||||
public void DelSet(string name)
|
||||
{
|
||||
// TODO Прописать логику для удаления
|
||||
if (!_carStorages.ContainsKey(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_carStorages.Remove(name);
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к набору
|
||||
@ -65,7 +70,10 @@ namespace DumpTruck.Generics
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения набора
|
||||
if (_carStorages.ContainsKey(ind))
|
||||
{
|
||||
return _carStorages[ind];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,9 @@
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(848, 482);
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(630, 482);
|
||||
this.pictureBoxCollection.TabIndex = 0;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
@ -60,9 +59,9 @@
|
||||
this.panelCollection.Controls.Add(this.ButtonRefreshCollection);
|
||||
this.panelCollection.Controls.Add(this.panel1);
|
||||
this.panelCollection.Controls.Add(this.panelObjects);
|
||||
this.panelCollection.Location = new System.Drawing.Point(619, 12);
|
||||
this.panelCollection.Location = new System.Drawing.Point(636, 0);
|
||||
this.panelCollection.Name = "panelCollection";
|
||||
this.panelCollection.Size = new System.Drawing.Size(217, 458);
|
||||
this.panelCollection.Size = new System.Drawing.Size(217, 470);
|
||||
this.panelCollection.TabIndex = 1;
|
||||
//
|
||||
// ButtonRefreshCollection
|
||||
@ -140,6 +139,7 @@
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(181, 23);
|
||||
this.textBoxStorageName.TabIndex = 3;
|
||||
this.textBoxStorageName.TextChanged += new System.EventHandler(this.textBoxStorageName_TextChanged);
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
|
@ -41,11 +41,13 @@ pictureBoxCollection.Height);
|
||||
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]);
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||
>= listBoxStorages.Items.Count))
|
||||
{
|
||||
@ -61,21 +63,26 @@ pictureBoxCollection.Height);
|
||||
|
||||
private void ButtonAddCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FormDumpTruck form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedCar != null)
|
||||
|
||||
if (obj + form.SelectedCar != -1)
|
||||
{
|
||||
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowCars();
|
||||
}
|
||||
@ -145,6 +152,7 @@ pictureBoxCollection.Height);
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
@ -171,6 +179,11 @@ MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void textBoxStorageName_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,12 @@ namespace DumpTruck.Generics
|
||||
/// <param name="count"></param>
|
||||
///
|
||||
public int startPointer = 0;
|
||||
|
||||
public int countMax = 0;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new List<T?>(count);
|
||||
countMax = count;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
@ -36,8 +39,9 @@ namespace DumpTruck.Generics
|
||||
/// <returns></returns>
|
||||
public int Insert(T car)
|
||||
{
|
||||
if (_places[Count - 1] != null)
|
||||
return -1;
|
||||
|
||||
if (_places.Count == countMax) { return -1; }
|
||||
|
||||
return Insert(car, 0);
|
||||
}
|
||||
/// <summary>
|
||||
@ -48,22 +52,13 @@ namespace DumpTruck.Generics
|
||||
/// <returns></returns>
|
||||
public int Insert(T car, int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
return -1;
|
||||
if (_places[position] != null)
|
||||
{
|
||||
int indexEnd = position + 1;
|
||||
while (_places[indexEnd] != null)
|
||||
{
|
||||
indexEnd++;
|
||||
}
|
||||
for (int i = indexEnd + 1; i > position; i--)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
|
||||
}
|
||||
_places[position] = car;
|
||||
if (!(position >= 0 && position <= Count && _places.Count < countMax))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_places.Insert(position, car);
|
||||
return position;
|
||||
}
|
||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
|
Loading…
x
Reference in New Issue
Block a user