diff --git a/Trolleybus/Trolleybus/AbstractStrategy.cs b/Trolleybus/Trolleybus/AbstractStrategy.cs
index 44693cb..46d991a 100644
--- a/Trolleybus/Trolleybus/AbstractStrategy.cs
+++ b/Trolleybus/Trolleybus/AbstractStrategy.cs
@@ -39,7 +39,7 @@ namespace ProjectTrolleybus.MovementStrategy
}
MoveToTarget();
}
- protected bool MoveLeft() => MoveTo(DirectionType.Left);
+ protected bool MoveLeft() => MoveTo(DirectionType.Left);
protected bool MoveRight() => MoveTo(DirectionType.Right);
protected bool MoveUp() => MoveTo(DirectionType.Up);
protected bool MoveDown() => MoveTo(DirectionType.Down);
diff --git a/Trolleybus/Trolleybus/BusesGenericCollection.cs b/Trolleybus/Trolleybus/BusesGenericCollection.cs
index 3ee8865..3de065c 100644
--- a/Trolleybus/Trolleybus/BusesGenericCollection.cs
+++ b/Trolleybus/Trolleybus/BusesGenericCollection.cs
@@ -52,14 +52,11 @@ namespace ProjectTrolleybus.Generics
///
///
///
- public static bool operator +(BusesGenericCollection collect, T?
- obj)
+ public static BusesGenericCollection? operator +(BusesGenericCollection? collect, T? obj)
{
- if (obj == null)
- {
- return false;
- }
- return collect?._collection.Insert(obj) ?? false;
+ if (obj != null)
+ collect?._collection.Insert(obj);
+ return collect;
}
///
/// Перегрузка оператора вычитания
@@ -67,15 +64,14 @@ namespace ProjectTrolleybus.Generics
///
///
///
- public static T? operator -(BusesGenericCollection collect, int
- pos)
+ public static BusesGenericCollection? operator -(BusesGenericCollection collect, int pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
- collect._collection.Remove(pos);
+ collect?._collection.Remove(pos);
}
- return obj;
+ return collect;
}
///
/// Получение объекта IMoveableObject
@@ -130,11 +126,10 @@ namespace ProjectTrolleybus.Generics
if (trolleybus != null)
{
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);
}
}
}
-
}
-}
+}
\ No newline at end of file
diff --git a/Trolleybus/Trolleybus/FormBusCollection.Designer.cs b/Trolleybus/Trolleybus/FormBusCollection.Designer.cs
index d30a04d..37f5e48 100644
--- a/Trolleybus/Trolleybus/FormBusCollection.Designer.cs
+++ b/Trolleybus/Trolleybus/FormBusCollection.Designer.cs
@@ -91,9 +91,10 @@
//
// pictureBoxCollection
//
+ pictureBoxCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pictureBoxCollection.Location = new Point(0, 2);
pictureBoxCollection.Name = "pictureBoxCollection";
- pictureBoxCollection.Size = new Size(532, 448);
+ pictureBoxCollection.Size = new Size(537, 448);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
@@ -101,12 +102,12 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
+ ClientSize = new Size(805, 450);
Controls.Add(groupBoxTrolleybus);
Controls.Add(pictureBoxCollection);
Name = "FormBusCollection";
StartPosition = FormStartPosition.CenterScreen;
- Text = "FormBusCollection";
+ Text = "Набор автобусов";
groupBoxTrolleybus.ResumeLayout(false);
groupBoxTrolleybus.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
diff --git a/Trolleybus/Trolleybus/FormBusCollection.cs b/Trolleybus/Trolleybus/FormBusCollection.cs
index e13776b..70d420c 100644
--- a/Trolleybus/Trolleybus/FormBusCollection.cs
+++ b/Trolleybus/Trolleybus/FormBusCollection.cs
@@ -32,7 +32,7 @@ namespace ProjectTrolleybus
FormTrolleybus form = new();
if (form.ShowDialog() == DialogResult.OK)
{
- if (_buses + form.SelectedBus)
+ if (_buses + form.SelectedBus != null)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _buses.ShowBuses();
diff --git a/Trolleybus/Trolleybus/SetGeneric.cs b/Trolleybus/Trolleybus/SetGeneric.cs
index 4a7e499..73af66c 100644
--- a/Trolleybus/Trolleybus/SetGeneric.cs
+++ b/Trolleybus/Trolleybus/SetGeneric.cs
@@ -78,7 +78,6 @@ namespace ProjectTrolleybus.Generics
///
public T? Get(int position)
{
- // TODO проверка позиции
if (!(position >= 0 && position < Count))
return null;
return _places[position];