Initial commit
This commit is contained in:
commit
8d4b2bc943
17 changed files with 389 additions and 0 deletions
44
WebApp/Coordinate.cs
Normal file
44
WebApp/Coordinate.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
namespace WebApp;
|
||||
|
||||
internal record Coordinate
|
||||
{
|
||||
public string Name { get; }
|
||||
public int Row { get; }
|
||||
public int Col { get; }
|
||||
public string Path => PATH + Name + ".png";
|
||||
|
||||
private const string PATH = "D:/tiles1705/";
|
||||
|
||||
public Coordinate(string name)
|
||||
{
|
||||
Name = name;
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
foreach (var item in name)
|
||||
{
|
||||
if (item >= 'A')
|
||||
{
|
||||
row = row * 26 + (item - 'A' + 1);
|
||||
}
|
||||
else if (item >= '1')
|
||||
{
|
||||
col = col * 10 + (item - '1' + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Row = row;
|
||||
Col = col;
|
||||
}
|
||||
|
||||
public Coordinate(int row, int col)
|
||||
{
|
||||
Row = row;
|
||||
Col = col;
|
||||
Name = Helper.ToLetters(row) + col;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue