2023-11-15 10:25:49 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Lab.Entities;
|
|
|
|
|
using Lab.DrawningObjects;
|
|
|
|
|
|
|
|
|
|
namespace Lab
|
|
|
|
|
{
|
|
|
|
|
public static class ExtentionDrawingTanker
|
|
|
|
|
{
|
|
|
|
|
public static DrawTanker? CreateDrawTanker(this string info, char separatorForObject, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
string[] strs = info.Split(separatorForObject);
|
|
|
|
|
if (strs.Length == 3)
|
|
|
|
|
{
|
|
|
|
|
return new DrawTanker(Convert.ToInt32(strs[0]),
|
2023-11-17 19:29:08 +04:00
|
|
|
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
2023-11-15 10:25:49 +04:00
|
|
|
|
}
|
|
|
|
|
if (strs.Length == 7)
|
|
|
|
|
{
|
|
|
|
|
return new DrawGasolineTanker(Convert.ToInt32(strs[0]),
|
|
|
|
|
Convert.ToInt32(strs[1]),
|
2023-11-17 19:29:08 +04:00
|
|
|
|
Color.FromName(strs[2]),
|
|
|
|
|
Color.FromName(strs[3]),
|
2023-11-15 10:25:49 +04:00
|
|
|
|
Convert.ToBoolean(strs[4]),
|
|
|
|
|
Convert.ToBoolean(strs[5]),
|
|
|
|
|
Convert.ToBoolean(strs[6]), width, height);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetDataForSave(this DrawTanker tanker, char separatorForObject)
|
|
|
|
|
{
|
|
|
|
|
var Tanker = tanker._gasolineTanker;
|
|
|
|
|
if (Tanker == null)
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
2023-11-17 19:29:08 +04:00
|
|
|
|
var str = $"{Tanker.Speed}{separatorForObject}{Tanker.Weight}{separatorForObject}{Tanker.BodyColor.Name}";
|
2023-11-15 10:25:49 +04:00
|
|
|
|
if (Tanker is not GasolineTanker gasTanker)
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
2023-11-17 19:29:08 +04:00
|
|
|
|
return $"{str}{separatorForObject}{gasTanker.AdditionalColor.Name}{separatorForObject}{gasTanker.BodyKit}{separatorForObject}{gasTanker.Wing}{separatorForObject}{gasTanker.SportLine}";
|
2023-11-15 10:25:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|