本文整理汇总了C#中Commlink.Print方法的典型用法代码示例。如果您正苦于以下问题:C# Commlink.Print方法的具体用法?C# Commlink.Print怎么用?C# Commlink.Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commlink
的用法示例。
在下文中一共展示了Commlink.Print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintToStream
/// <summary>
/// Print this character information to a MemoryStream. This creates only the character object itself, not any of the opening or closing XmlDocument items.
/// This can be used to write multiple characters to a single XmlDocument.
/// </summary>
/// <param name="objStream">MemoryStream to use.</param>
/// <param name="objWriter">XmlTextWriter to write to.</param>
public void PrintToStream(MemoryStream objStream, XmlTextWriter objWriter)
{
XmlDocument objXmlDocument = new XmlDocument();
XmlDocument objMetatypeDoc = new XmlDocument();
XmlNode objMetatypeNode;
string strMetatype = "";
string strMetavariant = "";
// Get the name of the Metatype and Metavariant.
objMetatypeDoc = XmlManager.Instance.Load("metatypes.xml");
{
objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _strMetatype + "\"]");
if (objMetatypeNode == null)
objMetatypeDoc = XmlManager.Instance.Load("critters.xml");
objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _strMetatype + "\"]");
if (objMetatypeNode["translate"] != null)
strMetatype = objMetatypeNode["translate"].InnerText;
else
strMetatype = _strMetatype;
if (_strMetavariant != "")
{
objMetatypeNode = objMetatypeNode.SelectSingleNode("metavariants/metavariant[name = \"" + _strMetavariant + "\"]");
if (objMetatypeNode["translate"] != null)
strMetavariant = objMetatypeNode["translate"].InnerText;
else
strMetavariant = _strMetavariant;
}
}
Guid guiImage = new Guid();
guiImage = Guid.NewGuid();
// This line left in for debugging. Write the output to a fixed file name.
//FileStream objStream = new FileStream("D:\\temp\\print.xml", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);//(_strFileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
// <character>
objWriter.WriteStartElement("character");
// <metatype />
objWriter.WriteElementString("metatype", strMetatype);
// <metatype_english />
objWriter.WriteElementString("metatype_english", _strMetatype);
// <metavariant />
objWriter.WriteElementString("metavariant", strMetavariant);
// <metavariant_english />
objWriter.WriteElementString("metavariant_english", _strMetavariant);
// <movement />
objWriter.WriteElementString("movement", FullMovement());
// <walk />
objWriter.WriteElementString("walk", FullMovement());
// <run />
objWriter.WriteElementString("run", FullMovement());
// <sprint />
objWriter.WriteElementString("sprint", FullMovement());
// <movementwalk />
objWriter.WriteElementString("movementwalk", Movement);
// <movementswim />
objWriter.WriteElementString("movementswim", Swim);
// <movementfly />
objWriter.WriteElementString("movementfly", Fly);
// <gameplayoption />
objWriter.WriteElementString("gameplayoption", _strGameplayOption);
// <maxkarma />
objWriter.WriteElementString("maxkarma", _intMaxKarma.ToString());
// <maxnuyen />
objWriter.WriteElementString("maxnuyen", _intMaxKarma.ToString());
// <contactmultiplier />
objWriter.WriteElementString("contactmultiplier", _intContactMultiplier.ToString());
// <prioritymetatype />
objWriter.WriteElementString("prioritymetatype", _strPriorityMetatype);
// <priorityattributes />
objWriter.WriteElementString("priorityattributes", _strPriorityAttributes);
// <priorityspecial />
objWriter.WriteElementString("priorityspecial", _strPrioritySpecial);
// <priorityskills />
objWriter.WriteElementString("priorityskills", _strPrioritySkills);
// <priorityresources />
objWriter.WriteElementString("priorityresources", _strPriorityResources);
// <priorityskill1 />
objWriter.WriteElementString("priorityskill1", _strSkill1);
// <priorityskill2 />
objWriter.WriteElementString("priorityskill2", _strSkill2);
// <priorityskillgroup />
objWriter.WriteElementString("priorityskillgroup", _strSkillGroup);
// If the character does not have a name, call them Unnamed Character. This prevents a transformed document from having a self-terminated title tag which causes browser to not rendering anything.
// <name />
if (_strName != "")
objWriter.WriteElementString("name", _strName);
else
objWriter.WriteElementString("name", LanguageManager.Instance.GetString("String_UnnamedCharacter"));
//.........这里部分代码省略.........
示例2: PrintToStream
/// <summary>
/// Print this character information to a MemoryStream. This creates only the character object itself, not any of the opening or closing XmlDocument items.
/// This can be used to write multiple characters to a single XmlDocument.
/// </summary>
/// <param name="objStream">MemoryStream to use.</param>
/// <param name="objWriter">XmlTextWriter to write to.</param>
public void PrintToStream(MemoryStream objStream, XmlTextWriter objWriter)
{
XmlDocument objXmlDocument = new XmlDocument();
XmlDocument objMetatypeDoc = new XmlDocument();
XmlNode objMetatypeNode;
string strMetatype = "";
string strMetavariant = "";
// Get the name of the Metatype and Metavariant.
objMetatypeDoc = XmlManager.Instance.Load("metatypes.xml");
{
objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _strMetatype + "\"]");
if (objMetatypeNode == null)
objMetatypeDoc = XmlManager.Instance.Load("critters.xml");
objMetatypeNode = objMetatypeDoc.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _strMetatype + "\"]");
if (objMetatypeNode["translate"] != null)
strMetatype = objMetatypeNode["translate"].InnerText;
else
strMetatype = _strMetatype;
if (_strMetavariant != "")
{
objMetatypeNode = objMetatypeNode.SelectSingleNode("metavariants/metavariant[name = \"" + _strMetavariant + "\"]");
if (objMetatypeNode["translate"] != null)
strMetavariant = objMetatypeNode["translate"].InnerText;
else
strMetavariant = _strMetavariant;
}
}
Guid guiImage = new Guid();
guiImage = Guid.NewGuid();
// This line left in for debugging. Write the output to a fixed file name.
//FileStream objStream = new FileStream("D:\\temp\\print.xml", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);//(_strFileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
// <character>
objWriter.WriteStartElement("character");
// <metatype />
objWriter.WriteElementString("metatype", strMetatype);
// <metatype_english />
objWriter.WriteElementString("metatype_english", _strMetatype);
// <metavariant />
objWriter.WriteElementString("metavariant", strMetavariant);
// <metavariant_english />
objWriter.WriteElementString("metavariant_english", _strMetavariant);
// <movement />
objWriter.WriteElementString("movement", FullMovement());
// <movementwalk />
objWriter.WriteElementString("movementwalk", Movement);
// <movementswim />
objWriter.WriteElementString("movementswim", Swim);
// <movementfly />
objWriter.WriteElementString("movementfly", Fly);
// If the character does not have a name, call them Unnamed Character. This prevents a transformed document from having a self-terminated title tag which causes browser to not rendering anything.
// <name />
if (_strName != "")
objWriter.WriteElementString("name", _strName);
else
objWriter.WriteElementString("name", LanguageManager.Instance.GetString("String_UnnamedCharacter"));
// Since IE is retarded and can't handle base64 images before IE9, we need to dump the image to a temporary directory and re-write the information.
// If you give it an extension of jpg, gif, or png, it expects the file to be in that format and won't render the image unless it was originally that type.
// But if you give it the extension img, it will render whatever you give it (which doesn't make any damn sense, but that's IE for you).
string strMugshotPath = "";
if (_strMugshot != "")
{
if (!Directory.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "mugshots"))
Directory.CreateDirectory(Application.StartupPath + Path.DirectorySeparatorChar + "mugshots");
byte[] bytImage = Convert.FromBase64String(_strMugshot);
MemoryStream objImageStream = new MemoryStream(bytImage, 0, bytImage.Length);
objImageStream.Write(bytImage, 0, bytImage.Length);
Image imgMugshot = Image.FromStream(objImageStream, true);
imgMugshot.Save(Application.StartupPath + Path.DirectorySeparatorChar + "mugshots" + Path.DirectorySeparatorChar + guiImage.ToString() + ".img");
strMugshotPath = "file://" + (Application.StartupPath + Path.DirectorySeparatorChar + "mugshots" + Path.DirectorySeparatorChar + guiImage.ToString() + ".img").Replace(Path.DirectorySeparatorChar, '/');
}
// <mugshot />
objWriter.WriteElementString("mugshot", strMugshotPath);
// <mugshotbase64 />
objWriter.WriteElementString("mugshotbase64", _strMugshot);
// <sex />
objWriter.WriteElementString("sex", _strSex);
// <age />
objWriter.WriteElementString("age", _strAge);
// <eyes />
objWriter.WriteElementString("eyes", _strEyes);
// <height />
objWriter.WriteElementString("height", _strHeight);
// <weight />
objWriter.WriteElementString("weight", _strWeight);
// <skin />
//.........这里部分代码省略.........