本文整理汇总了C#中System.Windows.Documents.TextRange.Split方法的典型用法代码示例。如果您正苦于以下问题:C# TextRange.Split方法的具体用法?C# TextRange.Split怎么用?C# TextRange.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.TextRange
的用法示例。
在下文中一共展示了TextRange.Split方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportXml
/// <summary>
/// Exports the XML.
/// </summary>
private void ExportXml()
{
string content = new TextRange(txtLines.Document.ContentStart, txtLines.Document.ContentEnd).Text;
var lines = content.Split("\n".ToCharArray());
var xml = new XElement(
"output",
lines.Select(
line =>
new XElement(
"Item", line.Split(',').Select((column, index) => new XElement("Column" + index, column)))));
var builder = new StringBuilder();
xml.WriteTo(new XmlTextWriter(new IndentedTextWriter(new StringWriter(builder))));
txtLines.Document.Blocks.Clear();
txtLines.AppendText(builder.ToString());
}
示例2: OutputEnumCode_Click
private void OutputEnumCode_Click(object sender, RoutedEventArgs e)
{
string myText = new TextRange(EnumInBox.Document.ContentStart, EnumInBox.Document.ContentEnd).Text;
if (myText.Length > 0)
{
try
{
EnumOutBox.Document.Blocks.Clear();
string[] lines = myText.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
int lastSpaceIndex = lines[0].LastIndexOf(" ");
string enumName = lines[0].Substring(lastSpaceIndex, lines[0].Length - lastSpaceIndex).Trim();
StringBuilder output1 = new StringBuilder();
StringBuilder output2 = new StringBuilder();
output1.AppendLine("boost::unordered_map<std::string, " + enumName + "> = boost::assign::map_list_of");
output2.AppendLine("boost::unordered_map<" + enumName + ", std::string> = boost::assign::map_list_of");
for (int i = 1; i < lines.Length; ++i)
{
lines[i] = lines[i].Trim();
lines[i] = lines[i].Replace("\r", String.Empty);
lines[i] = lines[i].Replace("\t", String.Empty);
lines[i] = lines[i].Replace("\n", String.Empty);
lines[i] = lines[i].Replace(",", String.Empty);
if (lines[i] != "};" && lines[i] != "{" && lines[i] != String.Empty)
{
int commentIndex = lines[i].IndexOf("//");
if (commentIndex > 0)
{
lines[i] = lines[i].Substring(0, commentIndex).Trim();
}
output1.AppendLine("\t(\"" + lines[i] + "\", " + enumName + "::" + lines[i] + ")");
output2.AppendLine("\t(" + enumName + "::" + lines[i] + ", \"" + lines[i] + "\")");
}
}
output1.AppendLine(";");
output2.AppendLine(";");
output1.Append(output2.ToString());
EnumOutTextBox.Text = output1.ToString();
//System.IO.MemoryStream stream = new System.IO.MemoryStream(ASCIIEncoding.Default.GetBytes(output1.ToString()));
//this.EnumOutBox.Selection.Load(stream, DataFormats.Rtf);
}
catch (System.Exception ex)
{
}
}
}