コード例 #1
0
        /// <summary>
        /// Reads an OTF from a stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public void Read(Stream stream)
        {
            var doc = new XmlDocument();

            doc.Load(stream);

            var tables = doc.GetElementsByTagName("T");

            Tables = new OTFTable[tables.Count];

            for (var i = 0; i < tables.Count; i++)
            {
                var table      = tables.Item(i);
                var tableEntry = new OTFTable();
                tableEntry.ID   = int.Parse(table.Attributes["i"].Value);
                tableEntry.Name = table.Attributes["n"].Value;

                var numKeys = table.ChildNodes.Count;
                tableEntry.Keys = new OTFTableKey[numKeys];

                for (var x = 0; x < numKeys; x++)
                {
                    var key      = table.ChildNodes[x];
                    var keyEntry = new OTFTableKey();
                    keyEntry.ID        = int.Parse(key.Attributes["i"].Value);
                    keyEntry.Label     = key.Attributes["l"].Value;
                    keyEntry.Value     = int.Parse(key.Attributes["v"].Value);
                    tableEntry.Keys[x] = keyEntry;
                }

                Tables[i] = tableEntry;
            }
        }
コード例 #2
0
ファイル: OTF.cs プロジェクト: ddfczm/Project-Dollhouse
        /// <summary>
        /// Reads an OTF from a stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public void Read(Stream stream)
        {
            var doc = new XmlDocument();
            doc.Load(stream);

            var tables = doc.GetElementsByTagName("T");
            Tables = new OTFTable[tables.Count];

            for (var i = 0; i < tables.Count; i++)
            {
                var table = tables.Item(i);
                var tableEntry = new OTFTable();
                tableEntry.ID = int.Parse(table.Attributes["i"].Value);
                tableEntry.Name = table.Attributes["n"].Value;

                var numKeys = table.ChildNodes.Count;
                tableEntry.Keys = new OTFTableKey[numKeys];

                for (var x = 0; x < numKeys; x++)
                {
                    var key = table.ChildNodes[x];
                    var keyEntry = new OTFTableKey();
                    keyEntry.ID = int.Parse(key.Attributes["i"].Value);
                    keyEntry.Label = key.Attributes["l"].Value;
                    keyEntry.Value = int.Parse(key.Attributes["v"].Value);
                    tableEntry.Keys[x] = keyEntry;
                }

                Tables[i] = tableEntry;
            }
        }