public ReplacePlaceholderWithTextCommand(Placeholder placeholder, string substitutedText, GeProfile geProfile) : base(geProfile) { Placeholder = placeholder; SubstitutedText = substitutedText; SelectionStart = 0; SelectionEnd = SubstitutedText.Length; Id = new GenDataId { ClassName = Placeholder.Class, PropertyName = Placeholder.Property }; }
public ReplaceSelectionWithPlaceholderCommand(Text text, int selectionStart, int selectionEnd, GenDataId id, GeProfile geProfile) : base(geProfile) { Text = text; SelectionStart = selectionStart; SelectionEnd = selectionEnd; Id = id; Body = (FragmentBody)Text.Parent; FragmentIndex = Body.FragmentList.IndexOf(Text) + 1; Prefix = Text.TextValue.Substring(0, SelectionStart); Suffix = Text.TextValue.Substring(SelectionEnd); }
private void AddText(GenContainerFragmentBase parentContainer, ref GenTextBlock textBlock, GenDataId id, GenDataDef genDataDef, bool isPrimary) { if (id.ClassId == -1 || id.PropertyId == -1) { throw new GeneratorException(Scan.Buffer.ToString() + id, GenErrorType.ProfileError); } CheckTextBlock(parentContainer, ref textBlock, genDataDef, isPrimary); textBlock.Body.Add( new GenPlaceholderFragment(new GenPlaceholderFragmentParams(GenDataDef, textBlock, id))); }
private static void AddText(GenDataDef genDataDef, ref GenTextBlock textBlock, GenContainerFragmentBase classProfile, GenDataId id) { CheckTextBlock(genDataDef, ref textBlock, classProfile); textBlock.Body.Add(new GenPlaceholderFragment(new GenPlaceholderFragmentParams(genDataDef, textBlock, id))); }
public GenPlaceholderFragmentParams(GenDataDef genDataDef, GenContainerFragmentBase parentContainer, GenDataId id, bool isPrimary = true) : base(genDataDef, parentContainer, FragmentType.Placeholder, isPrimary: isPrimary) { Id = id; }
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(); }