forked from ischool-desktop/K12.Data
/
TagConfigRecord.cs
128 lines (114 loc) · 3.86 KB
/
TagConfigRecord.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using System.Xml;
namespace K12.Data
{
/// <summary>
/// 標籤設定資訊
/// </summary>
public class TagConfigRecord : IComparable<TagConfigRecord>, IXmlTransform
{
/// <summary>
/// 預設建構式
/// </summary>
public TagConfigRecord()
{
Category = "";
}
/// <summary>
/// XML參數建構式
/// <![CDATA[
/// ]]>
/// </summary>
/// <param name="data"></param>
public TagConfigRecord(XmlElement data)
{
Load(data);
}
/// <summary>
/// 從XML載入設定值
/// <![CDATA[
/// ]]>
/// </summary>
/// <param name="data"></param>
public void Load(XmlElement data)
{
ID = data.GetAttribute("ID");
Prefix = data.SelectSingleNode("Prefix").InnerText;
Name = data.SelectSingleNode("Name").InnerText;
Category = data.SelectSingleNode("Category").InnerText;
XmlElement acc = data.SelectSingleNode("AccessControlCode") as XmlElement;
AccessControlCode = (acc == null ? "" : acc.InnerText);
int ci;
if (int.TryParse(data.SelectSingleNode("Color").InnerText, out ci))
ColorCode = ci;
else
ColorCode = System.Drawing.Color.White.ToArgb(); //預設是白色。
}
/// <summary>
/// 輸出成XML
/// </summary>
/// <returns></returns>
public XmlElement ToXml()
{
return null;
}
/// <summary>
/// 系統編號
/// </summary>
[Field(Caption = "編號", EntityName = "TagConfig", EntityCaption = "類別設定", IsEntityPrimaryKey = true)]
public string ID { get; set; }
/// <summary>
/// 前置詞
/// </summary>
[Field(Caption = "前置詞", EntityName = "TagConfig", EntityCaption = "類別設定")]
public string Prefix { get; set; }
/// <summary>
/// 名稱
/// </summary>
[Field(Caption = "名稱", EntityName = "TagConfig", EntityCaption = "類別設定")]
public string Name { get; set; }
/// <summary>
/// 分類,目前適用於Student、Class、Teacher、Course
/// </summary>
[Field(Caption = "分類", EntityName = "TagConfig", EntityCaption = "類別設定", Remark = "目前分類有『學生』、『班級』、『教師』、『課程』")]
public string Category { get; set; }
/// <summary>
/// 顏色的原始32位元數字
/// </summary>
[Field(Caption = "顏色代碼", EntityName = "TagConfig", EntityCaption = "類別設定")]
public int ColorCode { get; set; }
/// <summary>
/// 顏色
/// </summary>
public System.Drawing.Color Color
{
get { return System.Drawing.Color.FromArgb(ColorCode); }
set { ColorCode = value.ToArgb(); }
}
/// <summary>
/// 權限存取代碼。
/// </summary>
[Field(Caption = "權限代碼", EntityName = "TagConfig", EntityCaption = "類別設定")]
public string AccessControlCode { get; set; }
/// <summary>
/// 完整名稱
/// </summary>
[Field(Caption = "完整名稱", EntityName = "TagConfig", EntityCaption = "類別設定")]
public string FullName
{
get
{
if (string.IsNullOrEmpty(Prefix))
return Name;
else
return string.Format("{0}:{1}", Prefix, Name);
}
}
#region IComparable<TagRecord> 成員
public int CompareTo(TagConfigRecord other)
{
return Prefix.CompareTo(other.Prefix);
}
#endregion
}
}