All without change Insert

This commit is contained in:
shadowik 2022-12-11 23:17:18 +04:00
parent e527ff439b
commit 4fd89af30e
3 changed files with 69 additions and 4 deletions

View File

@ -10,8 +10,49 @@ namespace DoubleDeckerBus
{
public int Compare(IDrawingObject? x, IDrawingObject? y)
{
// TODO реализовать
throw new NotImplementedException();
if (x == null && y == null)
{
return 0;
}
if (x == null && y != null)
{
return 1;
}
if (x != null && y == null)
{
return -1;
}
var xBus = x as DrawingObjectBus;
var yBus = y as DrawingObjectBus;
if (xBus == null && yBus == null)
{
return 0;
}
if (xBus == null && yBus != null)
{
return 1;
}
if (xBus != null && yBus == null)
{
return -1;
}
var baseColorCompare = xBus.GetBus.Bus.BodyColor.ToString().CompareTo(yBus.GetBus.Bus.BodyColor.ToString());
if (baseColorCompare != 0)
{
return baseColorCompare;
}
if (xBus.GetBus.Bus is EntityDDB xDDB && yBus.GetBus.Bus is EntityDDB yDDB) {
var extraColorCompare = xDDB.BodyColor.ToString().CompareTo(yDDB.BodyColor.ToString());
if (extraColorCompare != 0)
{
return extraColorCompare;
}
}
return 0;
}
}
}
}

View File

@ -87,7 +87,26 @@ namespace DoubleDeckerBus
{
return false;
}
// TODO доделать проверки в случае продвинутого объекта
if (bus is EntityDDB DDB) {
if (other is not EntityDDB otherDDB) {
return false;
}
if (DDB.Ledder != otherDDB.Ledder) {
return false;
}
if (DDB.SecondStage != otherDDB.SecondStage) {
return false;
}
if (DDB.ExtraColor != otherDDB.ExtraColor)
{
return false;
}
}
return true;
}

View File

@ -260,7 +260,12 @@ namespace DoubleDeckerBus
private void ButtonSortByColor_Click(object sender, EventArgs e)
{
// TODO прописать логику
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].Sort(new BusCompareByColor());
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
}
}