forked from wmjordan/PDFPatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookmarkSettings.cs
82 lines (69 loc) · 2.1 KB
/
BookmarkSettings.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
using System;
using System.Drawing;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using PDFPatcher.Common;
namespace PDFPatcher.Model
{
/// <summary>
/// 在合并文件功能中使用的书签设置。
/// </summary>
public class BookmarkSettings : ICloneable, IXmlSerializable
{
public string Title { get; set; }
public bool IsBold { get; set; }
public bool IsItalic { get; set; }
public bool IsOpened { get; set; }
public bool GoToTop { get; set; }
public Color ForeColor { get; set; }
public BookmarkSettings() {
ForeColor = Color.Transparent;
}
public BookmarkSettings(string title) {
Title = title;
}
public BookmarkSettings Clone() {
return (BookmarkSettings)MemberwiseClone();
}
public BookmarkSettings(BookmarkElement element) {
Title = element.Title;
IsBold = (element.TextStyle & FontStyle.Bold) == FontStyle.Bold;
IsItalic = (element.TextStyle & FontStyle.Italic) == FontStyle.Italic;
IsOpened = element.IsOpen;
ForeColor = element.ForeColor;
}
#region ICloneable 成员
object ICloneable.Clone() {
return Clone();
}
#endregion
#region IXmlSerializable 成员
public System.Xml.Schema.XmlSchema GetSchema() {
return null;
}
public void ReadXml(XmlReader reader) {
if (reader.Read() == false) {
return;
}
Title = reader.GetAttribute("title");
IsBold = reader.GetValue("bold", false);
IsItalic = reader.GetValue("italic", false);
IsOpened = reader.GetValue("opened", false);
GoToTop = reader.GetValue("goToTop", false);
string c = reader.GetAttribute("color");
ForeColor = c is null ? Color.Transparent : Color.FromArgb(c.ToInt32());
}
public void WriteXml(XmlWriter writer) {
writer.WriteStartElement("bookmark");
writer.WriteValue("title", Title, null);
writer.WriteValue("bold", IsBold, false);
writer.WriteValue("italic", IsItalic, false);
writer.WriteValue("opened", IsOpened, false);
writer.WriteValue("goToTop", GoToTop, false);
writer.WriteValue("color", ForeColor.ToArgb(), Color.Transparent.ToArgb());
writer.WriteEndElement();
}
#endregion
}
}