本文整理匯總了C#中System.Xml.XmlTextReader.ReadContentAsFloat方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadContentAsFloat方法的具體用法?C# XmlTextReader.ReadContentAsFloat怎麽用?C# XmlTextReader.ReadContentAsFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadContentAsFloat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Deserialize
internal void Deserialize(XmlTextReader reader)
{
bool keepreading = true;
while (keepreading)
{
reader.Read();
if (reader.Name.Equals("material") && reader.NodeType.Equals(XmlNodeType.Element))
{
VoxMaterial mat = new VoxMaterial();
mat.ID = (byte)reader.ReadContentAsInt();
mat.Name = reader.ReadContentAsString();
mat.Flags = (MatFlags)Enum.Parse(typeof(MatFlags), reader.ReadContentAsString());
mat.Density = reader.ReadContentAsFloat();
mat.Deposit = (DepositType)Enum.Parse(typeof(DepositType), reader.ReadContentAsString());
mat.Texture = UUID.Parse(reader.ReadContentAsString());
mat.Type = (MaterialType)Enum.Parse(typeof(MaterialType), reader.ReadContentAsString());
if (mat.ID > index)
{
index = mat.ID;
index++;
}
mMaterials.Add(mat.ID, mat);
mName2Byte.Add(mat.Name, mat.ID);
}
}
}
示例2: FromXMLFile
/// <summary>
/// Reads style data from xml file
/// </summary>
/// <param name="xmlFile">XML file</param>
public void FromXMLFile(string xmlFile)
{
m_xmlFile = xmlFile;
XmlTextReader reader = new XmlTextReader(xmlFile);
reader.WhitespaceHandling = WhitespaceHandling.None;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "GUI")
{
// Read in the image file name
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
if (reader.Name == "ImageFile")
{
m_guiTexture = DefaultValues.MediaPath + reader.Value;
m_imageInfo = TextureLoader.ImageInformationFromFile(m_guiTexture);
}
else if (reader.Name == "StyleName")
{
m_name = reader.Value;
}
else if (reader.Name == "FntFile")
{
char[] separator = new char[] { ';' };
string[] tokens = reader.Value.Split(separator);
foreach (string token in tokens)
{
string fntFile = DefaultValues.FontPath + token;
BitmapFont font = GM.FontManager.GetFont(fntFile);
if (font == null)
GM.GeneralLog.Write("Wczytywanie GUIStyle, nie znaleziono czcionki:" + fntFile);
else
m_fontName = font.Name;
}
}
}
}
else if (reader.Name == "Control")
{
ControlNode controlNode = new ControlNode();
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
if (reader.Name == "Name")
{
controlNode.Name = reader.Value;
}
}
// Read the Image elements of this Control
while (reader.NodeType != XmlNodeType.EndElement)
{
reader.Read();
if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "Image"))
{
ImageNode imageNode = new ImageNode();
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
if (reader.Name == "Name")
{
imageNode.Name = reader.Value;
}
else if (reader.Name == "X")
{
imageNode.Rectangle.X = reader.ReadContentAsFloat();
}
else if (reader.Name == "Y")
{
imageNode.Rectangle.Y = reader.ReadContentAsFloat();
}
else if (reader.Name == "Width")
{
imageNode.Rectangle.Width = reader.ReadContentAsFloat();
}
else if (reader.Name == "Height")
{
imageNode.Rectangle.Height = reader.ReadContentAsFloat();
}
else if (reader.Name == "Color")
{
imageNode.Color = StringToColor(reader.Value);
}
}
controlNode.Images.Add(imageNode);
}
else if (reader.Name == "DefaultValues")
{
controlNode.Defaults= new ControlDefaults();
controlNode.Defaults.TextSize = float.Parse(reader.GetAttribute("TextSize"));
controlNode.Defaults.Color = this.StringToColor(reader.GetAttribute("Color"));
}
}
//.........這裏部分代碼省略.........