当前位置: 首页>>代码示例>>C#>>正文


C# TextRange.Split方法代码示例

本文整理汇总了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());
        }
开发者ID:ashtewari,项目名称:BBSchedule,代码行数:21,代码来源:MainWindow.xaml.cs

示例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)
         {
            
         }
         
     }
 }
开发者ID:MegatronX,项目名称:KHMPOld,代码行数:49,代码来源:Editor.xaml.cs


注:本文中的System.Windows.Documents.TextRange.Split方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。