3using System.Collections.Generic;
5using System.Xml.Schema;
16 private const string xmlRootElement =
"ClientConnections";
17 private const string xmlNamespace =
"http://waher.se/Schema/ClientConnections.xsd";
20 private readonly List<TreeNode> connections =
new List<TreeNode>();
21 private bool modified =
false;
43 lock (this.connections)
45 this.connections.Add(RootNode);
57 lock (this.connections)
59 if (this.connections.Remove(RootNode))
76 lock (this.connections)
78 if (this.connections.Remove(RootNode))
94 internal set{ this.modified =
true; }
101 public void Save(
string FileName)
103 lock (this.connections)
105 using (FileStream f = File.Create(FileName))
109 w.WriteStartElement(xmlRootElement, xmlNamespace);
111 foreach (
TreeNode RootNode
in this.connections)
119 this.modified =
false;
127 public void Load(
string FileName)
129 XmlDocument Xml =
new XmlDocument()
131 PreserveWhitespace =
true
135 this.
Load(FileName, Xml);
142 public void Load(
string FileName, XmlDocument Xml)
144 XSL.
Validate(FileName, Xml, xmlRootElement, xmlNamespace, schema);
146 lock (this.connections)
148 this.connections.Clear();
150 foreach (XmlNode N
in Xml.DocumentElement.ChildNodes)
162 private static readonly XmlSchema schema =
XSL.
LoadSchema(
"Waher.Client.WPF.Schema.ClientConnections.xsd");
171 lock (this.connections)
173 ToDispose = this.connections.ToArray();
174 this.connections.Clear();
177 foreach (
TreeNode Node
in ToDispose)
188 lock (this.connections)
190 return this.connections.ToArray();
Interaction logic for xaml
Maintains the set of open connections.
bool Remove(TreeNode RootNode)
Removes an existing connection.
void Save(string FileName)
Saves connections to an XML file.
Connections(MainWindow Owner)
Maintains the set of open connections.
bool Delete(TreeNode RootNode)
Deletes a new connection.
void Load(string FileName)
Loads the environment from an XML file.
void New()
Creates a new environment.
void Add(TreeNode RootNode)
Adds a new connection.
MainWindow Owner
Owner of connections.
void Load(string FileName, XmlDocument Xml)
Loads the environment from an XML file.
TreeNode[] RootNodes
Available root nodes.
bool Modified
If the source has been changed.
Abstract base class for tree nodes in the connection view.
abstract void Write(XmlWriter Output)
Saves the object to a file.
virtual void Dispose()
Disposes of the node and its resources.
Class representing a normal XMPP account.
Helps with common XML-related tasks.
static XmlWriterSettings WriterSettings(bool Indent, bool OmitXmlDeclaration)
Gets an XML writer settings object.
Static class managing loading of XSL resources stored as embedded resources or in content files.
static XmlSchema LoadSchema(string ResourceName)
Loads an XML schema from an embedded resource.
static void Validate(string ObjectID, XmlDocument Xml, params XmlSchema[] Schemas)
Validates an XML document given a set of XML schemas.