51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Catamaran
|
|
{
|
|
public static class ExtentionDrawningCatamaran
|
|
{
|
|
|
|
public static DrawningCatamaran? CreateDrawningCatamaran(this string info, char
|
|
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}";
|
|
}
|
|
}
|
|
}
|