public void SetText(EditableFile SelectedItem, string param) { MyAvalonEditor TextEditor = SelectedItem.TextEditor; string[] tagStr = (param).Split('_'); if (tagStr.Length == 3) { if (tagStr[1].Equals("cursor")) { TextEditor.SelectionLength = 0; TextEditor.Document.Insert(TextEditor.CaretOffset, tagStr[0] + tagStr[2]); TextEditor.SelectionStart = TextEditor.SelectionStart - tagStr[2].Length; TextEditor.Focus(); } if (tagStr[1].Equals("cursorSelect")) { TextEditor.Document.Insert(TextEditor.SelectionStart, tagStr[0]); TextEditor.Document.Insert(TextEditor.SelectionStart + TextEditor.SelectionLength, tagStr[2]); if (TextEditor.SelectionLength == 0) { TextEditor.SelectionStart = TextEditor.SelectionStart - tagStr[2].Length; } TextEditor.Focus(); } } /*if (tagStr.Length == 2) * { * if (tagStr[1].Equals("cursor")) * { * TextEditor.Document.Insert(TextEditor.CaretOffset, tagStr[0]); * //TextEditor.SelectionLength = 0; * TextEditor.Focus(); * * /* SelectedItem.FastTextBox.SelectedText = tagStr[0]; * SelectedItem.FastTextBox.Focus(); * } * if (tagStr[0].Equals("cursor")) * { * TextEditor.Document.Insert(TextEditor.CaretOffset, tagStr[0]); * * TextEditor.CaretOffset -= tagStr[0].Length; * TextEditor.Focus(); * * /*SelectedItem.FastTextBox.SelectedText = tagStr[0]; * SelectedItem.FastTextBox.SelectionStart = SelectedItem.FastTextBox.SelectionStart - tagStr[0].Length; * SelectedItem.FastTextBox.Focus(); * } * }*/ if (tagStr.Length == 1) { TextEditor.Document.Insert(TextEditor.SelectionStart, tagStr[0]); TextEditor.SelectionLength = 0; TextEditor.Focus(); } }
public void findTag(TableRow SelectedRow) { //string opentg = selectedRowRegex(SelectedRow); string opentg = "<csn ind=\"" + SelectedRow.Ind + "\" item=\"" + SelectedRow.Item + "\">"; string closetg = opentg + "([\\s\\S]*?)</csn>"; TextEditor.Focus(); MatchCollection tag = Regex.Matches(TextEditor.Text, closetg); foreach (Match tg in tag) { TextEditor.SelectionStart = tg.Index; TextEditor.SelectionLength = tg.Length; TextLocation loc = TextEditor.TextArea.Document.GetLocation(TextEditor.SelectionStart); TextEditor.ScrollTo(loc.Line, loc.Column); // TextEditor.DoSelectionVisible(); break; } }