perfecto
This commit is contained in:
parent
8c86fdc0ca
commit
2807485943
@ -52,14 +52,11 @@ namespace ProjectTrolleybus.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator +(BusesGenericCollection<T, U> collect, T?
|
public static BusesGenericCollection<T, U>? operator +(BusesGenericCollection<T, U>? collect, T? obj)
|
||||||
obj)
|
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj != null)
|
||||||
{
|
collect?._collection.Insert(obj);
|
||||||
return false;
|
return collect;
|
||||||
}
|
|
||||||
return collect?._collection.Insert(obj) ?? false;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
@ -67,15 +64,14 @@ namespace ProjectTrolleybus.Generics
|
|||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? operator -(BusesGenericCollection<T, U> collect, int
|
public static BusesGenericCollection<T, U>? operator -(BusesGenericCollection<T, U> collect, int pos)
|
||||||
pos)
|
|
||||||
{
|
{
|
||||||
T? obj = collect._collection.Get(pos);
|
T? obj = collect._collection.Get(pos);
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
collect._collection.Remove(pos);
|
collect?._collection.Remove(pos);
|
||||||
}
|
}
|
||||||
return obj;
|
return collect;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject
|
/// Получение объекта IMoveableObject
|
||||||
@ -130,11 +126,10 @@ namespace ProjectTrolleybus.Generics
|
|||||||
if (trolleybus != null)
|
if (trolleybus != null)
|
||||||
{
|
{
|
||||||
int inRow = _pictureWidth / _placeSizeWidth;
|
int inRow = _pictureWidth / _placeSizeWidth;
|
||||||
trolleybus.SetPosition(i % inRow * _placeSizeWidth, (_collection.Count / inRow - 1 - i / inRow) * _placeSizeHeight);
|
trolleybus.SetPosition(_placeSizeWidth * (inRow - 1) - (i % inRow * _placeSizeWidth), i / inRow * _placeSizeHeight);
|
||||||
trolleybus.DrawTransport(g);
|
trolleybus.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -91,9 +91,10 @@
|
|||||||
//
|
//
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
//
|
//
|
||||||
|
pictureBoxCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
pictureBoxCollection.Location = new Point(0, 2);
|
pictureBoxCollection.Location = new Point(0, 2);
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
pictureBoxCollection.Size = new Size(532, 448);
|
pictureBoxCollection.Size = new Size(537, 448);
|
||||||
pictureBoxCollection.TabIndex = 1;
|
pictureBoxCollection.TabIndex = 1;
|
||||||
pictureBoxCollection.TabStop = false;
|
pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -101,12 +102,12 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(805, 450);
|
||||||
Controls.Add(groupBoxTrolleybus);
|
Controls.Add(groupBoxTrolleybus);
|
||||||
Controls.Add(pictureBoxCollection);
|
Controls.Add(pictureBoxCollection);
|
||||||
Name = "FormBusCollection";
|
Name = "FormBusCollection";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "FormBusCollection";
|
Text = "Набор автобусов";
|
||||||
groupBoxTrolleybus.ResumeLayout(false);
|
groupBoxTrolleybus.ResumeLayout(false);
|
||||||
groupBoxTrolleybus.PerformLayout();
|
groupBoxTrolleybus.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
|
@ -32,7 +32,7 @@ namespace ProjectTrolleybus
|
|||||||
FormTrolleybus form = new();
|
FormTrolleybus form = new();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (_buses + form.SelectedBus)
|
if (_buses + form.SelectedBus != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBoxCollection.Image = _buses.ShowBuses();
|
pictureBoxCollection.Image = _buses.ShowBuses();
|
||||||
|
@ -78,7 +78,6 @@ namespace ProjectTrolleybus.Generics
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
|
||||||
if (!(position >= 0 && position < Count))
|
if (!(position >= 0 && position < Count))
|
||||||
return null;
|
return null;
|
||||||
return _places[position];
|
return _places[position];
|
||||||
|
Loading…
Reference in New Issue
Block a user