Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class XmlTheme
- {
- internal protected XDocument Xdoc;
- public Form Window = new Form();
- public Jint.JintEngine JScript = new Jint.JintEngine();
- public string JScriptSource;
- public static XmlTheme FromText(string text)
- {
- var theme = new XmlTheme {Xdoc = XDocument.Parse(text)};
- foreach (var doc in theme.Xdoc.Descendants("theme").Elements("item"))
- {
- var type = typeof(Form).Assembly.CreateInstance(doc.Attribute("type").Value) as Control;
- type.Name = doc.Attribute("name").Value;
- (type as Control).BackColor = Color.Transparent;
- theme.JScript.AddPermission(new System.Security.Permissions.UIPermission(System.Security.Permissions.PermissionState.Unrestricted));
- theme.JScript.SetFunction("alert", new Action<string>(m => MessageBox.Show(m)));
- theme.Window.Controls.Add(type);
- theme.JScriptSource = doc.Value;
- }
- return theme;
- }
- public static XmlTheme FromFile(string filename)
- {
- return FromText(File.ReadAllText(filename));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement