-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPluginMain.cs
150 lines (127 loc) · 4.16 KB
/
PluginMain.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// <copyright file="Plugin.cs" company="N/A">
// Copyright (c) 2008 All Right Reserved
// </copyright>
// <author>mechgt</author>
// <email>[email protected]</email>
// <date>2008-12-23</date>
namespace TrainingLoad
{
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using TrainingLoad.UI.Actions;
using ZoneFiveSoftware.Common.Data.Fitness;
using ZoneFiveSoftware.Common.Visuals.Fitness;
using TrainingLoad.UI;
using TrainingLoad.Settings;
/// <summary>
/// Plugin class provides interface to the main application and logbook.
/// </summary>
class PluginMain : IPlugin
{
#region Private fields
private static IApplication application;
#endregion
/// <summary>
/// Plugin product Id as listed in license application
/// </summary>
internal static string ProductId
{
get
{
return "tl";
}
}
/// <summary>
/// Number of days in history that data will be displayed.
/// This is the amount of data that will be displayed, not a number of days for a trial version.
/// </summary>
internal static int EvalDays
{
get { return 120; }
}
internal static string SupportEmail
{
get
{
return "[email protected]";
}
}
#region IPlugin Members
/// <summary>
/// Sets interface to SportTracks application
/// </summary>
public IApplication Application
{
set { application = value; }
}
/// <summary>
/// Gets plugin GUID
/// </summary>
public Guid Id
{
// This GUID is currently being used to store/retreive settings data from logbook
get { return GUIDs.PluginMain; }
}
/// <summary>
/// Gets plugin Name
/// </summary>
public string Name
{
get
{
return Resources.Strings.Label_TrainingLoad;
}
}
/// <summary>
/// Gets plugin Version
/// </summary>
public string Version
{
get { return GetType().Assembly.GetName().Version.ToString(3); }
}
public void ReadOptions(XmlDocument xmlDoc, XmlNamespaceManager nsmgr, XmlElement pluginNode)
{
Settings.GlobalSettings settings;
XmlSerializer xs = new XmlSerializer(typeof(GlobalSettings));
MemoryStream memoryStream = new MemoryStream(Utilities.StringToUTF8ByteArray(pluginNode.InnerText));
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
object deserialize = xs.Deserialize(memoryStream);
settings = (GlobalSettings)deserialize;
}
public void WriteOptions(XmlDocument xmlDoc, XmlElement pluginNode)
{
// Serialization
string xmlizedString;
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(GlobalSettings));
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
GlobalSettings settings = new GlobalSettings();
xs.Serialize(xmlTextWriter, settings);
memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
xmlizedString = Utilities.UTF8ByteArrayToString(memoryStream.ToArray());
pluginNode.InnerText = xmlizedString;
}
#endregion
#region Methods
/// <summary>
/// Main SportTracks application
/// </summary>
/// <returns>Returns application interface</returns>
internal static IApplication GetApplication()
{
return application;
}
/// <summary>
/// Currently loaded logbook
/// </summary>
/// <returns>Returns currently loaded logbook</returns>
internal static ILogbook GetLogbook()
{
return GetApplication().Logbook;
}
#endregion
}
}