Beispiel #1
0
        private void NoteContent_TextChanged(object sender, RoutedEventArgs e)
        {
            ITextDocument document = NoteContent.Document;
            string        documentContent;

            document.GetText(TextGetOptions.FormatRtf, out documentContent);
            mpd.ActiveContent = documentContent;
        }
        private void SaveText(ITextDocument document)
        {
            string text;

            document.GetText(TextGetOptions.AdjustCrlf, out text);
            _log?.AddLogStory(new LogStory()
            {
                Text = text
            });
            if (!string.IsNullOrEmpty(text))
            {
                SaveLog();
            }
        }
Beispiel #3
0
        public void AddMessageCore(AlertType at, string sMessage, params object[] rgo)
        {
            ITextDocument iDoc = m_rec.Document;

            string s2;

            string s = String.Format(sMessage, rgo);

            iDoc.GetText(TextGetOptions.None, out s2);
            s = s + "\r" + s2;

            iDoc.SetText(TextSetOptions.None, s);
            if (at != AlertType.None)
            {
                m_ia.DoAlert(at);
            }
        }
Beispiel #4
0
        public static void TrimTrailingWhiteSpace(this ITextDocument document, ISegment line)
        {
            var lineText = document.GetText(line);

            var index = lineText.Length;

            while (index > 0)
            {
                if (!char.IsWhiteSpace(lineText[index - 1]))
                {
                    break;
                }

                index--;
            }

            if (index != lineText.Length)
            {
                document.Replace(line.Offset + index, lineText.Length - index, "");
            }
        }
Beispiel #5
0
        public static string GetWordAtIndex(this ITextDocument document, int index)
        {
            var result = string.Empty;

            if (index >= 0 && document.TextLength > index)
            {
                var start = index;

                var currentChar = document.GetCharAt(index);
                var prevChar    = '\0';

                if (index > 0)
                {
                    prevChar = document.GetCharAt(index - 1);
                }

                var charClass = TextUtilities.GetCharacterClass(currentChar);

                if (charClass != CharacterClass.LineTerminator && prevChar != ' ' && TextUtilities.GetCharacterClass(prevChar) != CharacterClass.LineTerminator)
                {
                    start = TextUtilities.GetNextCaretPosition(document, index, LogicalDirection.Backward, CaretPositioningMode.WordStart);
                }

                var end = TextUtilities.GetNextCaretPosition(document, start, LogicalDirection.Forward, CaretPositioningMode.WordBorder);

                if (start != -1 && end != -1)
                {
                    var word = document.GetText(start, end - start).Trim();

                    if (word.IsSymbol())
                    {
                        result = word;
                    }
                }
            }

            return(result);
        }
Beispiel #6
0
 public static string GetText(this ITextDocument document, ISegment segment)
 {
     return(document.GetText(segment.Offset, segment.Length));
 }
Beispiel #7
0
 public static void TrimTrailingWhiteSpace(this ITextDocument document, ISegment line)
 {
     document.Replace(line, document.GetText(line).TrimEnd());
 }
Beispiel #8
0
        public bool FindCliches(ITextDocument doc)
        {
            if (doc != null)
            {
                doc.GetText(TextGetOptions.None, out myText);

                foreach (Cliche theCliche in myCliches)
                {
                    theCliche.Sum = new Regex(theCliche.Str.ToUpper()).Matches(myText.ToUpper()).Count;
                }

                return true;
            }
            else
            {
                return false;
            }
        }
        public static string GetText(this ITextDocument document)
        {
            document.GetText(TextGetOptions.None, out string text);

            return(text);
        }