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


C# TextRange.EndsWith方法代码示例

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


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

示例1: FlowDocument2Text

 public static String FlowDocument2Text(FlowDocument doc)
 {
     String text = new TextRange(doc.ContentStart, doc.ContentEnd).Text;
     if (text.EndsWith("\r\n"))
     {
         text = text.Substring(0, text.Length - 2);
     }
     return text;
 }
开发者ID:andrey-kozyrev,项目名称:LinguaSpace,代码行数:9,代码来源:FlowDocumentUtils.cs

示例2: richTextBox1_PreviewKeyDown

        private void richTextBox1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (lstOptions.Visibility == Visibility.Visible)
            {
                lstOptions.Focus();
                return;
            }

            if (!IsCaretPositionValid())
            {
                this.richTextBox1.CaretPosition = this.richTextBox1.CaretPosition.DocumentEnd;
                return;
            }

            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;
            }

            if (e.Key == Key.Enter)
            {
                var command = GetCommand();
                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("", BRUSH_PROMPT);
                lstOptions.Visibility = Visibility.Collapsed;
            }
            else if (e.Key == Key.Back)
            {
                var text = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                    richTextBox1.CaretPosition).Text;
                if (text.EndsWith(">")) e.Handled = true;
            }
        }
开发者ID:Frrank1,项目名称:Git-Source-Control-Provider,代码行数:51,代码来源:GitConsole.xaml.cs

示例3: richTextBox1_PreviewKeyDown

        private void richTextBox1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (lstOptions.Visibility == Visibility.Visible)
            {
                if (e.Key == Key.Escape)
                {
                    this.HideOptions();
                }
                else
                {
                    lstOptions.Focus();
                }
                return;
            }

            if (!IsCaretPositionValid())
            {
                this.richTextBox1.CaretPosition = this.richTextBox1.CaretPosition.DocumentEnd;
                return;
            }

            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;
            }

            if (e.Key == Key.Enter)
            {
                var command = GetCommand();
                if (this.IsProcessRunning)
                {
                    this.WriteInput(command);
                }
                else
                {
                    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("", BRUSH_PROMPT);
                this.HideOptions();
            }
            else if (e.Key == Key.Back)
            {
                var text = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                    richTextBox1.CaretPosition).Text;
                if (text.EndsWith(">") && text.IndexOf(">") == text.Length - 1) e.Handled = true;
            }
            else if (e.Key == Key.C && Keyboard.Modifiers == ModifierKeys.Control)
            {
                if (IsProcessRunning)
                {
                    SendShutdownToConsole();
                    e.Handled = true;
                }
            }
            else if (lstOptions.Visibility == Visibility.Visible)
            {
                //lstOptions.KeyDown()
            }
        }
开发者ID:gencer,项目名称:git-tools,代码行数:77,代码来源:GitConsole.xaml.cs

示例4: DataObjectPastingHandler

 private void DataObjectPastingHandler(object sender, DataObjectPastingEventArgs e)
 {
     object data = e.DataObject.GetData(DataFormats.UnicodeText);
     if (data == null)
         return;
     string str1 = data.ToString();
     this.richTextBox.Selection.Text = string.Empty;
     string[] strArray = str1.Split(new char[1]
       {
     ' '
       });
     if (strArray != null && strArray.Length > 0)
     {
         for (int index = 0; index < strArray.Length; ++index)
         {
             string str2 = strArray[index];
             TextPointer positionAtOffset = this.richTextBox.CaretPosition.GetPositionAtOffset(0, LogicalDirection.Forward);
             if (positionAtOffset != null)
                 this.richTextBox.CaretPosition = positionAtOffset;
             string text = new TextRange(this.richTextBox.Document.ContentStart, this.richTextBox.CaretPosition).Text;
             if (this.richTextBox.CaretPosition != null)
             {
                 if (str2.Contains("http://") || str2.Contains("www.") || str2.Contains("https://"))
                 {
                     if (text.EndsWith(" "))
                         this.richTextBox.CaretPosition.InsertTextInRun(string.Format("{0} ", (object)str2));
                     else
                         this.richTextBox.CaretPosition.InsertTextInRun(string.Format(" {0} ", (object)str2));
                     this.performURLParsing = true;
                     this.adornedElement_PreviewKeyUp((object)this.richTextBox, (KeyEventArgs)null);
                 }
                 else if (index == strArray.Length - 1)
                     this.richTextBox.CaretPosition.InsertTextInRun(string.Format("{0}", (object)str2));
                 else
                     this.richTextBox.CaretPosition.InsertTextInRun(string.Format("{0} ", (object)str2));
             }
         }
     }
     e.CancelCommand();
 }
开发者ID:unbearab1e,项目名称:FlattyTweet,代码行数:40,代码来源:URLAdorner.cs

示例5: 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

示例6: RichTextBox_TextChanged

        private void RichTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (_isLoading)
                return;
            _isLoading = true;

            RichTextBox t = sender as RichTextBox;
            if (t == null)
                return;

            BlockCollection bc = t.Document.Blocks;
            foreach (Block b in bc)
            {
                if (b is Paragraph)
                {
                    var para = b as Paragraph;
                    string text = new TextRange(para.ContentStart, para.ContentEnd).Text;

                    bool isProject = text.EndsWith(":");
                    bool isTask = text.StartsWith("-") || text.StartsWith("*");
                    bool isNote = !isProject && !isTask;
                    bool isDone = text.Contains("@done");

                    para.Foreground = isNote ? Brushes.DimGray : Brushes.Black;
                    para.FontSize = isProject ? 16 : 12;
                    para.TextDecorations = isDone ? TextDecorations.Strikethrough : null;
                }
            }
            _isLoading = false;
        }
开发者ID:vijo,项目名称:taskpad,代码行数:30,代码来源:MainWindow.xaml.cs


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