-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter.cs
79 lines (66 loc) · 2.1 KB
/
Character.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Drawing;
namespace UnitaleFontMaker
{
/// <summary>
/// 用于绘制字符类
/// </summary>
public class Character
{
private char _char;
private Rectangle rect;
public static char[] ENGLISH_CHARS = { '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'r', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '/', '*', '-', '+', ',', '.', '?', '!', '\'', '"', ':', ';', '/', '\\', '<', '>', '(', ')', '[', ']', '(', ')', '-', '_', '=', '~', '@', '#', '$', '%', '^', '&', '*', '(', ')', ' ' }; //别忘了空格字符!
public char Char
{
get { return _char; }
}
public int X
{
get { return rect.X; }
set { rect.X = value; }
}
public int Y
{
get { return rect.Y; }
set { rect.Y = value; }
}
public int Width
{
get { return rect.Width; }
set { rect.Width = value; }
}
public int Height
{
get { return rect.Height; }
set { rect.Height = value; }
}
public Rectangle Rect { get { return this.rect; } }
public Character(char character, Rectangle rect)
{
this._char = character;
this.rect = rect;
}
public Character(char character, int x, int y, int width, int height)
: this(character, new Rectangle(x, y, width, height))
{
}
/// <summary>
/// 检查传入的字符是否是英文字符
/// </summary>
/// <param name="c">要检查的字符</param>
/// <returns>结果</returns>
public static bool isEnglishChar(char c)
{
return Array.IndexOf(ENGLISH_CHARS, c) >= 0;
}
/// <summary>
/// 检查传入的字符是否是英文字符
/// </summary>
/// <param name="c">要检查的字符</param>
/// <returns>结果</returns>
public static bool isEnglishChar(Character c)
{
return Array.IndexOf(ENGLISH_CHARS, c.Char) >= 0;
}
}
}