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


C# TextRange.Replace方法代码示例

本文整理汇总了C#中System.Windows.Documents.TextRange.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# TextRange.Replace方法的具体用法?C# TextRange.Replace怎么用?C# TextRange.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.TextRange的用法示例。


在下文中一共展示了TextRange.Replace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

 /// <summary>
 /// Converts from a WPF FlowDocument to a XAML markup string.
 /// </summary>
 public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value == null) return string.Empty;
     FlowDocument flowDocument = (FlowDocument)XamlReader.Parse((string)value);
     string text = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd).Text;
     text = text.Replace("\r\n", " ");
     return text;
 }
开发者ID:b4p3p,项目名称:omeopauta,代码行数:11,代码来源:StringFlowDocumentToString.cs

示例2: richTextBox1_PreviewKeyDown

        private void richTextBox1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                var command = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                   richTextBox1.CaretPosition).Text;
                command = command.Substring(command.IndexOf(">") + 1).Trim();
                ShowOptions(command);
                return;
            }
            else if (e.Key == Key.Tab || e.Key == Key.Down)
            {
                if (lstOptions.Visibility == Visibility.Visible)
                {
                    lstOptions.Focus();
                    return;
                }
            }
            else
            {
                lstOptions.Visibility = Visibility.Collapsed;
            }

            if (e.Key == Key.Enter)
            {
                var command = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                    richTextBox1.CaretPosition.GetLineStartPosition(1) ?? richTextBox1.CaretPosition.DocumentEnd).Text;
                command = command.Replace("\r", "").Replace("\n", "");
                RunCommand(command);
                e.Handled = true;
            }
            else if (e.Key == Key.Up)
            {
                GetCommand(--commandIdx);
                e.Handled = true;
            }
            else if (e.Key == Key.Down)
            {
                GetCommand(++commandIdx);
                e.Handled = true;
            }
            else if (e.Key == Key.Escape)
            {
                ChangePrompt("",  new SolidColorBrush(Colors.Black));
            }
            else if (e.Key == Key.Back)
            {
                var text = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                    richTextBox1.CaretPosition).Text;
                if (text.EndsWith(">")) e.Handled = true;
            }
            else
            {
                var text = new TextRange(richTextBox1.CaretPosition, richTextBox1.CaretPosition.DocumentEnd).Text;
                if (text.Contains(">")) //e.Handled = true;
                    this.richTextBox1.CaretPosition = this.richTextBox1.CaretPosition.DocumentEnd;
            }
        }
开发者ID:JamesChan,项目名称:Git-Source-Control-Provider,代码行数:58,代码来源:GitConsole.xaml.cs

示例3: GetTextFromRichTextBox

 private string GetTextFromRichTextBox(RichTextBox rtb)
 {
     string txtExpr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd).Text;
     txtExpr = txtExpr.Replace("\r", "");
     txtExpr = txtExpr.Replace("\n", "");
     return txtExpr;
 }
开发者ID:robdobsn,项目名称:ScanMonitor,代码行数:7,代码来源:DocTypeView.xaml.cs

示例4: btnExportcsv_Click

        private void btnExportcsv_Click(object sender, RoutedEventArgs e)
        {
            FieldsNotEmpty();

            string auditname = txtAuditorName.Text;
            string commentsString = new TextRange(rtxtComments.Document.ContentStart, rtxtComments.Document.ContentEnd).Text;

            // SAVING
            SaveFileDialog SaveCSV = new SaveFileDialog()
            {
                Filter = "csv file(*.csv)|*.csv|All files (*.*)|*.*"
            };

            Nullable<bool> result = SaveCSV.ShowDialog();
            if (result == true)
            {
                string filepath = SaveCSV.FileName;     //gets file path

                using (StreamWriter sw = File.CreateText(filepath))
                {
                    sw.WriteLine("$$$###**!!Hardware!!**###$$$," + "," + txtAuditDate.Text.Replace(',', '-') + "," + txtAuditorName.Text.Replace(',', '-') + "," + txtManufacturer.Text.Replace(',', '-') + "," + txtModel.Text.Replace(',', '-') + "," + txtComputerName.Text.Replace(',', '-') + "," + txtOS.Text.Replace(',', '-') + "," + txtOSArch.Text.Replace(',', '-') + "," + txtServicePack.Text.Replace(',', '-') + "," + txtSerialNumber.Text.Replace(',', '-') + "," + txtRam.Text.Replace(',', '-') + "," + txtProcessor.Text.Replace(',', '-') + "," + txtNoProcessors.Text.Replace(',', '-') + "," + txtHardDriveSize.Text.Replace(',', '-') + "," + txtFreeHardDrive.Text.Replace(',', '-') + "," + commentsString.Replace(',', '-'));

                    foreach (string ipAddressName in cbIPAddress.Items)
                    {
                        sw.WriteLine("$$$###*!!IPAddress!!**###$$$," + ipAddressName);
                    }

                    //Getting each Mac address and putting it into one line
                    foreach (string macAddressName in cbMacAddress.Items)
                    {
                        sw.WriteLine("$$$###**!!MACAddress!!**###$$$," + macAddressName);
                    }

                    //ADDING PERIPHERAL
                    foreach (string PeripheralItem in lbPeripherals.Items)
                    {
                        sw.WriteLine("$$$###**!!Peripherals!!**###$$$," + PeripheralItem);
                    }



                    //ADDING PRINTER
                    foreach (string PrinterItem in lbPrinters.Items)
                    {
                        sw.WriteLine("$$$###**!!Printers!!**###$$$," + PrinterItem);
                    }

                    sw.Flush();
                    sw.Close();
                    //ADDING SOFTWARE
                    if (dgSoftware.HasItems)
                    {
                        am.GetSoftwareInfoAndSaveCSV(filepath);
                    }
                }
            }
        }
开发者ID:CaptainLDawg,项目名称:PC-Audit-Project,代码行数:57,代码来源:MainWindow.xaml.cs


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