2023-11-28 13:45:08 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Catamaran
|
|
|
|
|
{
|
|
|
|
|
public static class ExtentionDrawningCatamaran
|
|
|
|
|
{
|
|
|
|
|
|
2023-12-13 11:50:29 +04:00
|
|
|
|
public static DrawningCatamaran? CreateDrawningCatamaran(this string info, char
|
2023-11-28 13:45:08 +04:00
|
|
|
|
separatorForObject, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
string[] strs = info.Split(separatorForObject);
|
|
|
|
|
if (strs.Length == 3)
|
|
|
|
|
{
|
|
|
|
|
return new DrawningCatamaran(Convert.ToInt32(strs[0]),
|
|
|
|
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
|
|
|
|
}
|
|
|
|
|
if (strs.Length == 7)
|
|
|
|
|
{
|
|
|
|
|
return new DrawningCatamaranPro(Convert.ToInt32(strs[0]),
|
|
|
|
|
Convert.ToInt32(strs[1]),
|
|
|
|
|
Color.FromName(strs[2]),
|
|
|
|
|
Color.FromName(strs[3]),
|
|
|
|
|
Convert.ToBoolean(strs[4]),
|
|
|
|
|
Convert.ToBoolean(strs[5]),
|
|
|
|
|
Convert.ToBoolean(strs[6]), width, height);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetDataForSave(this DrawningCatamaran DrawningCatamaran,
|
|
|
|
|
char separatorForObject)
|
|
|
|
|
{
|
|
|
|
|
var catamaran = DrawningCatamaran.EntityCatamaran;
|
|
|
|
|
if (catamaran == null)
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
var str = $"{catamaran.Speed}{separatorForObject}{catamaran.Weight}{separatorForObject}{catamaran.BodyColor.Name}";
|
|
|
|
|
if (catamaran is not EntityCatamaranPro CatPro)
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
return $"{str}{separatorForObject}{CatPro.AdditionalColor.Name}{separatorForObject}{CatPro.BodyKit}{separatorForObject}{CatPro.Motor}{separatorForObject}{CatPro.Sail}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|