Esempio n. 1
0
        public void SubstitutePlaceholder(TextBlock textBlock, string substitutedText, GenDataId id)
        {
            GenMultiUndoRedo multi = null;
            var body = textBlock.Body();
            var n    = body.FragmentList.Count;

            for (var i = n - 1; i >= 0; i--)
            {
                var text = body.FragmentList[i] as Text;
                if (text == null)
                {
                    continue;
                }

                var t = text.TextValue;
                var k = t.IndexOf(substitutedText, StringComparison.Ordinal);
                while (k != -1 && text != null)
                {
                    var command = new ReplaceSelectionWithPlaceholderCommand(text, k, k + substitutedText.Length, id, this);
                    command.Execute();
                    var undoCommand = new ReplacePlaceholderWithTextCommand(command.Placeholder, substitutedText, this);
                    (multi = multi ?? new GenMultiUndoRedo()).Add(new GenUndoRedo(undoCommand, command));
                    text = command.Text;
                    t    = command.Suffix;
                    k    = t.IndexOf(substitutedText, StringComparison.Ordinal);
                }
            }
            if (multi != null)
            {
                GeData.AddRedoUndo(multi);
            }
            GetNodeProfileText();
        }
Esempio n. 2
0
        private void AddRedoUndo(IGenCommand undoCommand, IGenCommand redoCommand)
        {
            var undoRedo = new GenUndoRedo(undoCommand, redoCommand);

            GeData.AddRedoUndo(undoRedo);
        }