perfecto
This commit is contained in:
parent
8c86fdc0ca
commit
2807485943
@ -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);
|
||||
|
@ -52,14 +52,11 @@ namespace ProjectTrolleybus.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(BusesGenericCollection<T, U> collect, T?
|
||||
obj)
|
||||
public static BusesGenericCollection<T, U>? operator +(BusesGenericCollection<T, U>? collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
if (obj != null)
|
||||
collect?._collection.Insert(obj);
|
||||
return collect;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
@ -67,15 +64,14 @@ namespace ProjectTrolleybus.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(BusesGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
public static BusesGenericCollection<T, U>? operator -(BusesGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection.Get(pos);
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
collect?._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
return collect;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -78,7 +78,6 @@ namespace ProjectTrolleybus.Generics
|
||||
/// <returns></returns>
|
||||
public T? Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if (!(position >= 0 && position < Count))
|
||||
return null;
|
||||
return _places[position];
|
||||
|
Loading…
Reference in New Issue
Block a user