private void MoveAction(IPWEDoc activeDoc) { // Muoversi tra le righe activeDoc.MoveCursor(MoveCursorTarget.ToDocumentBegin); activeDoc.MoveCursor(MoveCursorTarget.PageDown); activeDoc.MoveCursor(MoveCursorTarget.PageUp); activeDoc.SetCursorPosition(1, 1); for (var i = 1; i <= activeDoc.LineCount; i++) { activeDoc.SetCursorPosition(i, 1); var line = activeDoc.GetLine(i); //... activeDoc.SetSelection(line.TextRange); } }
private void ReplaceAction(IPWEDoc activeDoc) { // Find & Replace if (activeDoc == null) { MessageBox.Show("Documento attivo non è di tipo testo"); return; } var profileName = this._PowerEDITApp.GetActiveProfileName(); if (profileName != "PWEBase") { return; } const string stringToReplace = "S"; const string replaceWith = "Raggio"; // Ricerca e sostituzione testo MODO 1 (Manuale) for (var i = 1; i <= activeDoc.LineCount; i++) { var line = activeDoc.GetLine(i); var newLine = line.Text.Replace(stringToReplace, replaceWith); line.ReplaceAllText(newLine); } // Ricerca e sostituzione testo MODO 2 (API) - solo find /* * var findResults = activeDoc.FindText(stringToReplace, SearchAction.SearchAll, SearchScope.All, * SearchType.Standard, SearchCasing.Any, * SearchWord.AnyText, string.Empty, true, * UiInteraction.None); */ // Ricerca e sostituzione testo MODO 3 (API) - replace diretto /* * var replaceResults = activeDoc.ReplaceText(stringToReplace, replaceWith, * SearchAction.SearchAll, SearchScope.All, * SearchType.Standard, SearchCasing.Any, * SearchWord.AnyText, string.Empty, * UiInteraction.None); */ }
private void AddDataAction(IPWEDoc activeDoc) { activeDoc.MoveCursor(MoveCursorTarget.ToDocumentEnd); activeDoc.AddLine("nuova riga"); //activeDoc.AddLineBefore(); }