Example #1
0
        private void ApplyAutoCorrection()
        {
            if (myAutoCorrectionTrigger == null || Document == null)
            {
                return;
            }

            TextChanged -= OnTextChanged;

            var start = Document.ContentStart.GetPositionAtOffset(mySelectionStartPosition);

            if (start == null)
            {
                start = Document.ContentEnd;
            }

            var input = new AutoCorrectionInput(new TextRange(start, CaretPosition), myAutoCorrectionTrigger.Value);

            input.Editor = this;
            var result = AutoCorrection.Apply(input);

            if (result.Success && result.CaretPosition != null)
            {
                CaretPosition = result.CaretPosition;
            }

            TextChanged += OnTextChanged;

            myAutoCorrectionTrigger = null;
        }
Example #2
0
        public AutoCorrectionResult TryApply(AutoCorrectionInput input)
        {
            bool success = false;

            foreach (var wordRange in DocumentOperations.GetWords(input.Range))
            {
                if (wordRange.Text == "(c)")
                {
                    wordRange.Text = CopyrightSymbol;

                    success = true;
                }
            }

            return(new AutoCorrectionResult(success));
        }
 public AutoCorrectionResult TryApply(AutoCorrectionInput input)
 {
     ApplyTriggered = true;
     return(new AutoCorrectionResult(false));
 }