DocumentRange GetNewLineRange(DocumentPosition caret) { isSelectionLocked = true; DocumentPosition currentPosition = richEditControl1.Document.CaretPosition; StartOfLineCommand startOfLineCommand = new StartOfLineCommand(richEditControl1); EndOfLineCommand endOfLineCommand = new EndOfLineCommand(richEditControl1); startOfLineCommand.Execute(); int start = richEditControl1.Document.CaretPosition.ToInt(); endOfLineCommand.Execute(); int length = richEditControl1.Document.CaretPosition.ToInt() - start; DocumentRange range = richEditControl1.Document.CreateRange(start, length); DocumentRange range2 = richEditControl1.Document.CreateRange(start, length + 1); string text = richEditControl1.Document.GetText(range2); richEditControl1.Document.CaretPosition = currentPosition; isSelectionLocked = false; if (text.EndsWith(Environment.NewLine)) { return(range2); } else { return(range); } }
private void button1_Click(object sender, EventArgs e) { RichEditDocumentServer server = new RichEditDocumentServer(); server.LoadDocument("fish.rtf"); DocumentRange[] ranges = server.Document.FindAll(DevExpress.Office.Characters.PageBreak.ToString(), DevExpress.XtraRichEdit.API.Native.SearchOptions.None); DocumentPosition dp = server.Document.Paragraphs[0].Range.Start; List <MyRtfObject> collection = new List <MyRtfObject>(); foreach (DocumentRange dr in ranges) { DocumentRange tmpRange = server.Document.CreateRange(dp, dr.Start.ToInt() - dp.ToInt()); collection.Add(new MyRtfObject() { RtfSplitContent = server.Document.GetRtfText(tmpRange) }); dp = dr.End; } DocumentRange tmpRange2 = server.Document.CreateRange(dp, server.Document.Paragraphs[server.Document.Paragraphs.Count - 1].Range.End.ToInt() - dp.ToInt()); collection.Add(new MyRtfObject() { RtfSplitContent = server.Document.GetRtfText(tmpRange2) }); XtraReport1 report = new XtraReport1(); report.DataSource = collection; report.ShowPreviewDialog(); }
/// <summary> /// Метод, вызываемый вместе с сохранением документа /// </summary> private void SavePositionsCommonFolders(bool reloadPostions, List <DBCommand> cmds) { var positionCommonFolders0 = DocumentPosition <PositionCommonFolder> .LoadByDocId(int.Parse(Id)); positionCommonFolders0.ForEach(delegate(PositionCommonFolder p0) { var p = PositionCommonFolders.FirstOrDefault(x => x.Id == p0.Id); if (p == null) { p0.Delete(false); } }); PositionCommonFolders.ForEach(delegate(PositionCommonFolder p) { if (string.IsNullOrEmpty(p.Id)) { p.DocumentId = int.Parse(Id); p.Save(reloadPostions, cmds); return; } var p0 = positionCommonFolders0.FirstOrDefault(x => x.Id == p.Id && x.ChangedTime != p.ChangedTime); if (p0 != null) { p.Save(reloadPostions, cmds); } }); }
private void UpdateTextBoxText() { string textInRange; CustomRangeStart rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType<CustomRangeStart>().FirstOrDefault(); if (rangeStart != null) { CustomRangeEnd rangeEnd = (CustomRangeEnd)rangeStart.End; DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(rangeStart); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); end.MoveToInline(rangeEnd); DocumentSelection selection = new DocumentSelection(this.radRichTextBox.Document); selection.SetSelectionStart(start); selection.AddSelectionEnd(end); string text = selection.GetSelectedText(); textInRange = text; } else { textInRange = string.Empty; } this.suppressUpdate = true; this.textBox.Text = textInRange; this.suppressUpdate = false; }
private void richEditControl1_MouseClick(object sender, MouseEventArgs e) { PageLayoutPosition pageLayoutPosition = richEditControl1.ActiveView.GetDocumentLayoutPosition(e.Location); if (pageLayoutPosition == null) { return; } int pageIndex = pageLayoutPosition.PageIndex; Point point = pageLayoutPosition.Position; LayoutPage layoutPage = richEditControl1.DocumentLayout.GetPage(pageIndex); HitTestManager hitTest = new HitTestManager(richEditControl1.DocumentLayout); RichEditHitTestResult result = hitTest.HitTest(layoutPage, point); if (result.LayoutElement is CharacterBox && richEditControl1.Document.Selection.Length == 0) { CharacterBox character = (CharacterBox)result.LayoutElement; DocumentPosition caretPosition = richEditControl1.Document.CaretPosition; SubDocument document = caretPosition.BeginUpdateDocument(); if (document.GetSubDocumentType() == GetLocation(character.Parent)) { DocumentRange characterRange = document.CreateRange(character.Range.Start, 1); UpdateCheckState(document, characterRange, character.Text); } caretPosition.EndUpdateDocument(document); } }
public DocumentPosition Map(EditDocumentPositionRequest request) { if (request == null) { return(null); } DocumentPosition documentPosition = new DocumentPosition { Id = request.Id, PositionNumberText = request.PositionNumberText, ArticleNameExtern = request.ArticleNameExtern, Quantity = request.Quantity, ScaleUnitQty = request.ScaleUnitQty, ScaleUnitType = request.ScaleUnitType, ScaleUnit = request.ScaleUnit, DeliveryQty = request.DeliveryQty, IsPartialDelivered = request.IsPartialDelivered, PriceBase = request.PriceBase, PricePerUnit = request.PricePerUnit, PriceTotal = request.PricePerUnit, SalesTaxPercent = request.SalesTaxPercent, ParentId = request.ParentId, DocumentId = request.DocumentId, ArticleId = request.ArticleId, }; return(documentPosition); }
/// <summary> /// Default ctor /// </summary> public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry) : base(eventKind) { this.documentPosition = documentPosition; this.typeEntry = typeEntry; this.methodEntry = methodEntry; }
/// <summary> /// Record the mapping from .NET to Dex /// </summary> public void RecordMapping(TypeEntry typeEntry, MapFile mapFile) { var entry = RecordMapping(typeEntry, xMethod, method, dmethod, compiledMethod); if (cachedBody != null) { // take the mapping and debug info from the cached body. foreach (var v in cachedBody.MethodEntry.Variables) { entry.Variables.Add(v); } foreach (var p in cachedBody.MethodEntry.Parameters) { entry.Parameters.Add(p); } if (cachedBody.SourceCodePositions.Count > 0) { var doc = mapFile.GetOrCreateDocument(cachedBody.SourceCodePositions[0].Document.Path, true); foreach (var pos in cachedBody.SourceCodePositions.Select(p => p.Position)) { var newPos = new DocumentPosition(pos.Start.Line, pos.Start.Column, pos.End.Line, pos.End.Column, typeEntry.Id, dmethod.MapFileId, pos.MethodOffset) { AlwaysKeep = true }; doc.Positions.Add(newPos); } } } }
public DocumentPositionResponse Map(DocumentPosition documentPosition) { if (documentPosition == null) { return(null); } ; DocumentPositionResponse response = new DocumentPositionResponse { Id = documentPosition.Id, PositionNumberText = documentPosition.PositionNumberText, ArticleNameExtern = documentPosition.ArticleNameExtern, Quantity = documentPosition.Quantity, ScaleUnitQty = documentPosition.ScaleUnitQty, ScaleUnitType = documentPosition.ScaleUnitType, ScaleUnit = documentPosition.ScaleUnit, DeliveryQty = documentPosition.DeliveryQty, IsPartialDelivered = documentPosition.IsPartialDelivered, PriceBase = documentPosition.PriceBase, PricePerUnit = documentPosition.PricePerUnit, PriceTotal = documentPosition.PricePerUnit, SalesTaxPercent = documentPosition.SalesTaxPercent, ParentId = (Guid)documentPosition.ParentId, Parent = _documentPositionMapper.Map(documentPosition.Parent), DocumentId = documentPosition.DocumentId, Document = _documentMapper.Map(documentPosition.Document), ArticleId = documentPosition.ArticleId, Article = _articleMapper.Map(documentPosition.Article), }; return(response); }
static void FormatParagraph(RichEditDocumentServer wordProcessor) { #region #FormatParagraph Document document = wordProcessor.Document; document.BeginUpdate(); document.AppendText("Modified Paragraph\nNormal\nNormal"); document.EndUpdate(); DocumentPosition pos = document.Range.Start; DocumentRange range = document.CreateRange(pos, 0); ParagraphProperties pp = document.BeginUpdateParagraphs(range); // Center paragraph pp.Alignment = ParagraphAlignment.Center; // Set triple spacing pp.LineSpacingType = ParagraphLineSpacing.Multiple; pp.LineSpacingMultiplier = 3; // Set left indent at 0.5". // Default unit is 1/300 of an inch (a document unit). pp.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f); // Set tab stop at 1.5" TabInfoCollection tbiColl = pp.BeginUpdateTabs(true); TabInfo tbi = new DevExpress.XtraRichEdit.API.Native.TabInfo(); tbi.Alignment = TabAlignmentType.Center; tbi.Position = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f); tbiColl.Add(tbi); pp.EndUpdateTabs(tbiColl); document.EndUpdateParagraphs(pp); #endregion #FormatParagraph }
private void SelectCurrentWord(DocumentPosition position) { position.MoveToCurrentWordStart(); this.Document.Selection.SetSelectionStart(position); position.MoveToCurrentWordEnd(); this.Document.Selection.AddSelectionEnd(position); }
static void MakeTemplate(SnapList list, GridView grid, out Table table, out SnapDocument template) { template = list.RowTemplate; SnapDocument header = list.ListHeader; table = template.Tables.Create(template.Range.End, 1, grid.VisibleColumns.Count); Table caption = header.Tables.Create(header.Range.End, 1, grid.VisibleColumns.Count); AdjustSize(table); AdjustSize(caption); foreach (GridColumn col in grid.VisibleColumns) { header.InsertText(caption.Cell(0, col.VisibleIndex).Range.Start, col.FieldName); TableCell cell = table.Cell(0, col.VisibleIndex); DocumentPosition pos = cell.Range.Start; Type colType = GetColType(col); if (colType == typeof(byte[])) { template.CreateSnImage(pos, col.FieldName); } else if (colType == typeof(bool)) { template.CreateSnCheckBox(pos, col.FieldName); } else { template.CreateSnText(pos, col.FieldName); } } }
public void TestPutComment() { var localName = "test_multi_pages.docx"; var remoteName = "TestPutComment.docx"; var fullName = Path.Combine(this.dataFolder, remoteName); var nodeLink = new NodeLink { NodeId = "0.0.3" }; var documentPosition = new DocumentPosition { Node = nodeLink, Offset = 0 }; var body = new Comment { RangeStart = documentPosition, RangeEnd = documentPosition, Initial = "IA", Author = "Imran Anwar", Text = "A new Comment" }; this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName)); var request = new PutCommentRequest(remoteName, body, this.dataFolder); var actual = this.WordsApi.PutComment(request); Assert.AreEqual(200, actual.Code); }
static void ModifyFieldCode(Document document) { #region #ModifyFieldCode DocumentPosition caretPosition = document.CaretPosition; SubDocument currentDocument = caretPosition.BeginUpdateDocument(); //Create a DATE field at the caret position currentDocument.Fields.Create(caretPosition, "DATE"); currentDocument.EndUpdate(); for (int i = 0; i < currentDocument.Fields.Count; i++) { string fieldCode = document.GetText(currentDocument.Fields[i].CodeRange); if (fieldCode == "DATE") { //Retrieve the range obtained by the field code DocumentPosition position = currentDocument.Fields[i].CodeRange.End; //Insert the format switch to the end of the field code range currentDocument.InsertText(position, @"\@ ""M/d/yyyy h:mm am/pm"""); } } //Update all document fields currentDocument.Fields.Update(); #endregion #ModifyFieldCode }
static void ImageFromFile(Document document) { #region #ImageFromFile DocumentPosition pos = document.Range.Start; document.Images.Insert(pos, DocumentImageSource.FromFile("beverages.png")); #endregion #ImageFromFile }
private void btnFormatParagraph_Click(object sender, EventArgs e) { #region #formatparagraph Document doc = richEditControl1.Document; DocumentPosition pos = doc.Selection.Start; DocumentRange range = doc.CreateRange(pos, 0); ParagraphProperties pp = doc.BeginUpdateParagraphs(range); // Center paragraph pp.Alignment = ParagraphAlignment.Center; // Set triple spacing pp.LineSpacingType = ParagraphLineSpacing.Multiple; pp.LineSpacingMultiplier = 3; // Set left indent at 0.5". // Default unit is 1/300 of an inch (a document unit). pp.LeftIndent = Units.InchesToDocumentsF(0.5f); // Set tab stop at 1.5" TabInfoCollection tbiColl = pp.BeginUpdateTabs(true); TabInfo tbi = new TabInfo(); tbi.Alignment = TabAlignmentType.Center; tbi.Position = Units.InchesToDocumentsF(1.5f); tbiColl.Add(tbi); pp.EndUpdateTabs(tbiColl); doc.EndUpdateParagraphs(pp); #endregion #formatparagraph }
/// <summary> /// Add document and position data to the given map file. /// </summary> internal void AddDocumentMapping(MapFile mapFile) { var source = compiledMethod.DexMethod; if ((source == null) || (source.Body == null) || (source.Body.Instructions.Count == 0)) { return; } if (this.compiledMethod.DexMethod.Name == "testTryCatch") { } var sequencePointsInstr = source.Body.Instructions.Where(x => x.SequencePoint != null); foreach (var seqPointIns in sequencePointsInstr) { // Get document var seqPoint = (ISourceLocation)seqPointIns.SequencePoint; var doc = mapFile.GetOrCreateDocument(seqPoint.Document, true); // Add position var docPos = new DocumentPosition(seqPoint.StartLine, seqPoint.StartColumn, seqPoint.EndLine, seqPoint.EndColumn, compiledMethod.DexMethod.Owner.MapFileId, compiledMethod.DexMethod.MapFileId, seqPointIns.Offset) { AlwaysKeep = seqPointIns.OpCode.IsReturn() }; doc.Positions.Add(docPos); } }
void richEditControl1_SelectionChanged(object sender, EventArgs e) { if (isLocked) { return; } SyncronizeFilesCollection(); DocumentPosition pos = richEditControl1.Document.CaretPosition; foreach (KeyValuePair <string, FileFieldInfo> item in filesCollection) { DocumentRange fieldRange = item.Value.DocField.ResultRange; if (fieldRange.Contains(pos) && fieldRange.Start.ToInt() != pos.ToInt() && fieldRange.End.ToInt() != pos.ToInt()) { isLocked = true; int deltaFromStart = pos.ToInt() - fieldRange.Start.ToInt(); int deltaFromEnd = fieldRange.End.ToInt() - pos.ToInt(); if (deltaFromEnd > deltaFromStart) { richEditControl1.Document.CaretPosition = item.Value.DocField.Range.End; } else { richEditControl1.Document.CaretPosition = item.Value.DocField.Range.Start; } isLocked = false; break; } } }
/// <summary> /// Метод, вызываемый вместе с сохранением документа /// </summary> private void SavePositionsRoles(bool reloadPostions, List <DBCommand> cmds = null) { var positionRoles0 = DocumentPosition <PositionRole> .LoadByDocId(int.Parse(Id)); positionRoles0.ForEach(delegate(PositionRole p0) { var p = PositionRoles.FirstOrDefault(x => x.Id == p0.Id); if (p == null) { p0.Delete(false); } }); PositionRoles.ForEach(delegate(PositionRole p) { if (string.IsNullOrEmpty(p.Id)) { p.DocumentId = int.Parse(Id); p.Save(reloadPostions, cmds); return; } var p0 = positionRoles0.FirstOrDefault( x => x.Id == p.Id && (x.RoleId != p.RoleId || x.PersonId != p.PersonId)); if (p0 != null) { p.Save(reloadPostions, cmds); } }); }
/// <summary> /// Resolve the given dalvik location to a source location. /// </summary> private DocumentLocation DoResolve(Location location) { var refType = ReferenceTypeManager[location.Class]; DalvikMethod method = null; if (refType != null) { method = refType.GetMethodsAsync().Select(t => { DalvikMethod m; return(t.TryGetMember(location.Method, out m) ? m : null); }).Await(VmTimeout); } var typeName = (refType != null) ? refType.GetNameAsync().Await(VmTimeout) : null; var typeEntry = (typeName != null) ? mapFile.GetTypeByNewName(typeName) : null; var methodDexName = (method != null) ? method.Name : null; var methodDexSignature = (method != null) ? method.Signature : null; var methodEntry = ((typeEntry != null) && (method != null)) ? typeEntry.FindDexMethod(methodDexName, methodDexSignature) : null; Document document = null; DocumentPosition position = null; if (methodEntry != null) { mapFile.TryFindLocation(typeEntry, methodEntry, (int)location.Index, out document, out position); } return(new DocumentLocation(location, document, position, refType, method, typeEntry, methodEntry)); }
public void AppendChart(Document doc, string path, string filename) { float scaleX = 1.0f; float scaleY = 1.0f; string chartfile = String.Format("{0}{1}", path, filename); try { DocumentPosition pos = doc.Range.End; DocumentImageSource.FromFile(chartfile); doc.Images.Insert(pos, DocumentImageSource.FromFile(chartfile)); var size = doc.Images[doc.Images.Count - 1].Size; if (size.Width > 7.5) { scaleX = 7.5f / size.Width; scaleY = scaleX; } doc.Images[doc.Images.Count - 1].ScaleX = scaleX; doc.Images[doc.Images.Count - 1].ScaleY = scaleY; } catch (Exception ex) { } }
private void CreateShowDocument() { var document = new RadDocument(); document.LayoutMode = DocumentLayoutMode.Paged; RadDocumentEditor editor = new RadDocumentEditor(document); editor.Insert("Text Before Text Inside Text After"); DocumentPosition rangeStartPosition = new DocumentPosition(document); rangeStartPosition.MoveToNextWordStart(); rangeStartPosition.MoveToNextWordStart(); DocumentPosition rangeEndPosition = new DocumentPosition(rangeStartPosition); rangeEndPosition.MoveToNextWordStart(); rangeEndPosition.MoveToCurrentWordEnd(); document.Selection.SetSelectionStart(rangeStartPosition); document.Selection.AddSelectionEnd(rangeEndPosition); editor.InsertAnnotationRange(new CustomRangeStart(), new CustomRangeEnd()); this.radRichTextBox.Document = document; UpdateTextBoxText(); }
private Tuple <DocumentPosition, string> GetPreviousWord(RadDocument radDocument, DocumentPosition caretPosition) { DocumentPosition pos = new DocumentPosition(richTextBox.Document); pos.MoveToPosition(caretPosition); pos.MoveToPreviousWordStart(); radDocument.Selection.SetSelectionStart(pos); radDocument.Selection.AddSelectionEnd(caretPosition); // var text = pos.GetCurrentInlineBox().Text; string text = radDocument.Selection.GetSelectedText();; // pos.GetCurrentWord(); if (text.Contains("_")) { pos.MoveToPreviousWordStart(); radDocument.Selection.SetSelectionStart(pos); radDocument.Selection.AddSelectionEnd(caretPosition); text = radDocument.Selection.GetSelectedText(); } if (text != null && text != "" && text != ".") { if (text.EndsWith(".")) { text = text.Substring(0, text.Length - 1); } } var previousOfMainCaret = new DocumentPosition(pos); radDocument.Selection.Clear(); return(new Tuple <DocumentPosition, string>(previousOfMainCaret, text)); //////var word = GetText(previousOfMainCaret, caretPosition);// pos.Get //////return new Tuple<DocumentPosition, string>(previousOfMainCaret, word); }
private void richEditControl1_DragOver(object sender, DragEventArgs e) { if (!customDragDropTarget) { return; } Point docPoint = Units.PixelsToDocuments(richEditControl1.PointToClient(Form.MousePosition), richEditControl1.DpiX, richEditControl1.DpiY); DocumentPosition pos = richEditControl1.GetPositionFromPoint(docPoint); if (pos == null) { return; } Rectangle rect = Units.DocumentsToPixels(richEditControl1.GetBoundsFromPosition(pos), richEditControl1.DpiX, richEditControl1.DpiY); richEditControl1.Document.CaretPosition = pos; if (richEditGraphics == null) { richEditGraphics = richEditControl1.CreateGraphics(); } rect.Width = 2; richEditControl1.Refresh(); richEditGraphics.FillRectangle(Brushes.Blue, rect); richEditControl1.ScrollToCaret(); }
public static string GetInformationAboutRichEditDocumentLayout(Document currentDocument, DocumentLayout currentDocumentLayout) { SubDocument subDocument = currentDocument.CaretPosition.BeginUpdateDocument(); DocumentPosition docPosition = subDocument.CreatePosition(currentDocument.CaretPosition.ToInt() == 0 ? 0 : currentDocument.CaretPosition.ToInt() - 1); ReadOnlyShapeCollection shapes = subDocument.Shapes.Get(subDocument.CreateRange(docPosition, 1)); ReadOnlyDocumentImageCollection images = subDocument.Images.Get(subDocument.CreateRange(docPosition, 1)); if (shapes.Count == 0 && images.Count == 0) { docPosition = subDocument.CreatePosition(currentDocument.CaretPosition.ToInt()); } string returnedInformation = ""; // get infromation about a current document element returnedInformation += GetInformationAboutCurrentDocumentElement(currentDocument, currentDocumentLayout, subDocument, docPosition); // collect information about CURRENT PAGE RangedLayoutElement layoutPosition = currentDocumentLayout.GetElement <RangedLayoutElement>(docPosition); if (layoutPosition != null) { int currentPageIndex = currentDocumentLayout.GetPageIndex(layoutPosition); returnedInformation += PageLayoutHelper.GetInformationAboutCurrentPage(currentDocumentLayout, currentDocumentLayout.GetPage(currentPageIndex), docPosition); } currentDocument.CaretPosition.EndUpdateDocument(subDocument); return(returnedInformation); }
public void Can_Find_By_Prefixes_And_Suffixes() { const string document = "doc"; const string word = "te_st"; var invertedIndex = this.GetNewIndex(); var expectedResult = new DocumentPosition { RowNumber = 1, ColNumber = 1, Document = document }; invertedIndex.Add(new[] { word }, document); invertedIndex.Find("te_s").Should().BeEquivalentTo(expectedResult); invertedIndex.Find("te_").Should().BeEquivalentTo(expectedResult); invertedIndex.Find("te").Should().BeEquivalentTo(expectedResult); invertedIndex.Find("e_st").Should().BeEquivalentTo(new DocumentPosition { RowNumber = 1, ColNumber = 2, Document = document }); invertedIndex.Find("_st").Should().BeEquivalentTo(new DocumentPosition { RowNumber = 1, ColNumber = 3, Document = document }); invertedIndex.Find("st").Should().BeEquivalentTo(new DocumentPosition { RowNumber = 1, ColNumber = 4, Document = document }); invertedIndex.Find("t").Should().BeEquivalentTo(expectedResult, new DocumentPosition { RowNumber = 1, ColNumber = 5, Document = document }); }
private void ApplyRTFModification(RichEditDocumentServer server) { // Apply default formatting server.Document.DefaultCharacterProperties.FontName = "Arial"; server.Document.DefaultCharacterProperties.FontSize = 9; server.Document.DefaultCharacterProperties.ForeColor = Color.FromArgb(120, 120, 120); server.Document.DefaultParagraphProperties.Alignment = ParagraphAlignment.Center; // Remove whitespaces from the end of RTF content DocumentRange[] dots = server.Document.FindAll(".", SearchOptions.None); DocumentPosition lastDot = dots[dots.Length - 1].End; server.Document.Delete(server.Document.CreateRange(lastDot, server.Document.Range.End.ToInt() - lastDot.ToInt())); // Append formatted word DocumentRange range = server.Document.InsertText(server.Document.Range.End, " [Approved]"); CharacterProperties cp = server.Document.BeginUpdateCharacters(range); cp.FontName = "Courier New"; cp.FontSize = 10; cp.ForeColor = Color.Red; cp.Underline = UnderlineType.Single; cp.UnderlineColor = Color.Red; server.Document.EndUpdateCharacters(cp); }
private void textBox_TextChanged(object sender, TextChangedEventArgs e) { if (suppressUpdate) { return; } CustomRangeStart rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType <CustomRangeStart>().FirstOrDefault(); if (rangeStart != null) { CustomRangeEnd rangeEnd = (CustomRangeEnd)rangeStart.End; DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(rangeStart); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); end.MoveToInline(rangeEnd); DocumentSelection selection = this.radRichTextBox.Document.Selection;// new DocumentSelection(this.radRichTextBox.Document); selection.SetSelectionStart(start); selection.AddSelectionEnd(end); this.radRichTextBox.Insert(this.textBox.Text); } }
private List <Tuple <DocumentPosition, string> > GetPreviousWords(DocumentPosition caretPosition, List <Tuple <DocumentPosition, string> > result = null) { if (result == null) { result = new List <Tuple <DocumentPosition, string> >(); } DocumentPosition pos = new DocumentPosition(richTextBox.Document); pos.MoveToPosition(caretPosition); pos.MoveToPreviousWordStart(); var text = pos.GetCurrentInlineBox().Text; if (text.Contains("_")) { pos.MoveToPreviousWordStart(); } var previousOfMainCaret = new DocumentPosition(pos); if (previousOfMainCaret != caretPosition) { result.Add(new Tuple <DocumentPosition, string>(previousOfMainCaret, text)); GetPreviousWords(previousOfMainCaret, result); } return(result); //////var word = GetText(previousOfMainCaret, caretPosition);// pos.Get //////return new Tuple<DocumentPosition, string>(previousOfMainCaret, word); }
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { editor.Document.Selection.Clear(); var search = new DocumentTextSearch(editor.Document); var lastPosition = new DocumentPosition(editor.Document); bool endOfDocument = false; bool theFirstFinding = true; while (!endOfDocument) { TextRange range; range = search.Find("#break#", theFirstFinding ? new DocumentPosition(editor.Document) : lastPosition); if (range != null) { theFirstFinding = false; lastPosition = range.EndPosition; editor.Document.Selection.AddSelectionStart(range.StartPosition); editor.Document.Selection.AddSelectionEnd(range.EndPosition); var documentEditor = new RadDocumentEditor(editor.Document); documentEditor.InsertLineBreak(); } else { endOfDocument = true; } } }
public void Equals_Test() { var firstDocumentPosition = new DocumentPosition { Document = "Test", RowNumber = 10, ColNumber = 5 }; var secondDocumentPosition = new DocumentPosition { Document = "Test", RowNumber = 10, ColNumber = 5 }; firstDocumentPosition.Equals(secondDocumentPosition).Should().BeTrue(); secondDocumentPosition.Document = "New"; firstDocumentPosition.Equals(secondDocumentPosition).Should().BeFalse(); secondDocumentPosition.Document = firstDocumentPosition.Document; secondDocumentPosition.RowNumber = 25; firstDocumentPosition.Equals(secondDocumentPosition).Should().BeFalse(); secondDocumentPosition.RowNumber = firstDocumentPosition.RowNumber; secondDocumentPosition.ColNumber = 25; firstDocumentPosition.Equals(secondDocumentPosition).Should().BeFalse(); }
/// <summary> /// Default ctor /// </summary> public DocumentLocation(Location location, Document document, DocumentPosition position, DalvikReferenceType referenceType, DalvikMethod method, TypeEntry typeEntry, MethodEntry methodEntry) { if (location == null) throw new ArgumentNullException("location"); Location = location; Document = document; Position = position; ReferenceType = referenceType; Method = method; this.typeEntry = typeEntry; this.methodEntry = methodEntry; }
public void FindNext() { if (this.Document.Selection.IsEmpty) { this.FindNext(this.Document.CaretPosition); } else { DocumentPosition fromPosition = new DocumentPosition(this.Document.Selection.Ranges.Last.StartPosition); fromPosition.MoveToNext(); this.FindNext(fromPosition); } }
private void HighlightOccurrencesInVisibleBoxes(IEnumerable<SpanLayoutBox> spanList) { if (spanList.Count() == 0) { return; } SpanLayoutBox firstBox = spanList.First(); SpanLayoutBox lastBox = spanList.Last(); DocumentPosition searchStart = new DocumentPosition(this.Document); DocumentPosition searchEnd = new DocumentPosition(this.Document); searchStart.MoveToInline(firstBox, 0); searchEnd.MoveToInline(lastBox, lastBox.PositionsCountInBox - 1); DocumentTextSearch textSearch = new DocumentTextSearch(this.Document); TextRange textRange = textSearch.Find(word, searchStart, searchEnd); int count = 0; while (textRange != null) { count++; DocumentPosition lineStart = new DocumentPosition(textRange.StartPosition); DocumentPosition lineEnd = new DocumentPosition(lineStart); lineEnd.MoveToCurrentLineEnd(); while (lineEnd < textRange.EndPosition) { this.FlushBoxes(lineStart, lineEnd); lineStart.MoveToCurrentLineEnd(); lineStart.MoveToNext(); lineEnd.MoveToNext(); lineEnd.MoveToCurrentLineEnd(); } this.FlushBoxes(lineStart, textRange.EndPosition); searchStart.MoveToPosition(textRange.EndPosition); if (searchStart >= searchEnd) { break; } textRange = textSearch.Find(word, searchStart, searchEnd); } }
private void ShowDialog() { ImageInline imageInline = this.radRichTextBox.Document.EnumerateChildrenOfType<ImageInline>().FirstOrDefault(); if (imageInline != null) { DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(imageInline); end.MoveToPosition(start); end.MoveToNext(); this.radRichTextBox.Document.Selection.AddSelectionStart(start); this.radRichTextBox.Document.Selection.AddSelectionEnd(end); if (this.radRichTextBox.Document.Selection.GetSelectedSingleInline() is ImageInline) { this.radRichTextBox.ShowImageEditorDialog(); } } }
/// <summary> /// Default ctor /// </summary> public DebugLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, DebugBoundBreakpoint<DebugLocationBreakpoint> boundBreakpoint) : base(eventKind, documentPosition, typeEntry, methodEntry) { this.boundBreakpoint = boundBreakpoint; }
private void FlushBoxes(DocumentPosition startPosition, DocumentPosition endPosition) { if (startPosition == endPosition) { return; } RectangleF rect = new RectangleF(); rect.X = startPosition.Location.X; rect.Width = endPosition.Location.X - startPosition.Location.X; InlineLayoutBox startBox = startPosition.GetCurrentInlineBox(); InlineLayoutBox endBox = endPosition.GetCurrentInlineBox(); float top = startBox.ControlBoundingRectangle.Top; float bottom = startBox.ControlBoundingRectangle.Bottom; while (startBox != endBox) { startBox = DocumentStructureCollection.GetNextSiblingForDocumentElementOnSameLevel(startBox, startBox.AssociatedDocumentElement) as InlineLayoutBox; if (startBox == null) { break; } if (startBox.ControlBoundingRectangle.Top < top) { top = startBox.ControlBoundingRectangle.Top; } if (startBox.ControlBoundingRectangle.Bottom < bottom) { bottom = startBox.ClippedControlBoundingRectangle.Bottom; } } rect.Y = top; rect.Height = bottom - top; this.AddRectangle(rect); }
public TextRange GetTextRange(SourceRange sourceRange) { EnsureBound(); DocumentPosition startPosition = new DocumentPosition(sourceRange.StartLine, sourceRange.StartColumn); DocumentPosition endPosition = new DocumentPosition(sourceRange.EndLine, sourceRange.EndColumn); int startOffset = _syntaxEditor.Document.PositionToOffset(startPosition); int endOffset = _syntaxEditor.Document.PositionToOffset(endPosition) + 1; if (startOffset > _syntaxEditor.Document.Length) startOffset = _syntaxEditor.Document.Length - 1; if (endOffset > _syntaxEditor.Document.Length) endOffset = _syntaxEditor.Document.Length - 1; return new TextRange(startOffset, endOffset); }
private void ShowErrorQuickInfo(Exception exception) { // Calculate the point of the line above the current one and // display an info tip with the error message. DocumentPosition pos = _syntaxEditor.Caret.DocumentPosition; if (pos.Line > 0) pos = new DocumentPosition(pos.Line - 1, pos.Character); else pos = new DocumentPosition(pos.Line + 1, pos.Character); Point tipLocation; if (pos.Line >= 0 && pos.Line < _syntaxEditor.Document.Lines.Count) { int offset = _syntaxEditor.Document.PositionToOffset(pos); tipLocation = _syntaxEditor.SelectedView.GetCharacterBounds(offset).Location; } else { tipLocation = new Point(0, -20); } StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb, CultureInfo.CurrentCulture)) { XmlWriter writer = new XmlTextWriter(sw); writer.WriteStartElement("b"); writer.WriteString("Error: "); writer.WriteEndElement(); writer.WriteString(exception.Message); } string markup = sb.ToString(); _syntaxEditor.IntelliPrompt.QuickInfo.Hide(); _syntaxEditor.IntelliPrompt.QuickInfo.Show(tipLocation, markup); }
private void textBox_TextChanged(object sender, TextChangedEventArgs e) { if (suppressUpdate) { return; } CustomRangeStart rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType<CustomRangeStart>().FirstOrDefault(); if (rangeStart != null) { CustomRangeEnd rangeEnd = (CustomRangeEnd)rangeStart.End; DocumentPosition start = new DocumentPosition(this.radRichTextBox.Document); start.MoveToInline(rangeStart); DocumentPosition end = new DocumentPosition(this.radRichTextBox.Document); end.MoveToInline(rangeEnd); DocumentSelection selection = this.radRichTextBox.Document.Selection;// new DocumentSelection(this.radRichTextBox.Document); selection.SetSelectionStart(start); selection.AddSelectionEnd(end); this.radRichTextBox.Insert(this.textBox.Text); } }
/// <summary> /// Try to find the document location that belongs to the given method + offset. /// </summary> /// <returns>null, if not found. If we know the document, but the offset is marked to /// have no source code attached (compiler generated), the returned position will /// be marked as IsSpecial.</returns> public SourceCodePosition FindSourceCode(MethodEntry method, int methodOffset, bool allowSpecial = true) { var locs = GetSourceCodePositions(method); // perform a binary search int idx = locs.FindLastIndexSmallerThanOrEqualTo(methodOffset, p => p.Position.MethodOffset); if (idx != -1 && (allowSpecial || !locs[idx].IsSpecial)) return locs[idx]; if (allowSpecial && locs.Count > 0) { // this can only happen at the beginning of the method. // forge a special location. var pos = locs[0].Position; var forgedPos = new DocumentPosition(pos.Start.Line,pos.Start.Column, pos.End.Line, pos.End.Column, pos.TypeId, pos.MethodId, DocumentPosition.SpecialOffset); return new SourceCodePosition(locs[0].Document, forgedPos); } return null; }
private string ExportAnnotationRangeFragment(RadDocument document, string semanticRangeName) { RecipeRangeStart semanticRangestart = null; RecipeRangeEnd semanticRangeEnd = null; foreach (RecipeRangeStart rangeStart in document.GetAnnotationMarkersOfType<RecipeRangeStart>()) { if (rangeStart.Name == semanticRangeName) { semanticRangestart = rangeStart; semanticRangeEnd = (RecipeRangeEnd)rangeStart.End; } } if (semanticRangestart != null && semanticRangeEnd != null) { DocumentPosition startPosition = new DocumentPosition(document); startPosition.MoveToInline((InlineLayoutBox)semanticRangestart.FirstLayoutBox, 0); DocumentPosition endPosition = new DocumentPosition(document); endPosition.MoveToInline((InlineLayoutBox)semanticRangeEnd.FirstLayoutBox, 0); DocumentSelection selection = new DocumentSelection(document); selection.SetSelectionStart(startPosition); selection.AddSelectionEnd(endPosition); DocumentFragment fragment = new DocumentFragment(selection); RadDocument fragmentDocument = fragment.ToDocument(); HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider(); htmlFormatProvider.ExportSettings = new HtmlExportSettings(); htmlFormatProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment; htmlFormatProvider.ExportSettings.StylesExportMode = StylesExportMode.Inline; htmlFormatProvider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles; return htmlFormatProvider.Export(fragmentDocument); } return string.Empty; }
private void MarkErrorWord(SyntaxEditor editor, int lineNumber, int characterPos, string message) { string text = editor.Document.Lines[lineNumber].Text; string compileText = CompileHelper.ReplaceUserOptionCalls(text); string preceedingText = characterPos <= compileText.Length ? compileText.Substring(0, characterPos) : ""; #region Find all GetUserOption calls and discount them int index = preceedingText.LastIndexOf("GetUserOption"); int offsetUO = "GetUserOptionValue('')".Length - "UserOptions.".Length; int castEndPos = 0; int castStartPos = 0; while (index >= 0) { characterPos -= offsetUO; while (preceedingText[index] != ')') { castEndPos = index; index -= 1; } while (preceedingText[index] != '(') { castStartPos = index; index -= 1; } characterPos -= castEndPos - castStartPos + 1; index = preceedingText.LastIndexOf("GetUserOption", index); } #endregion DocumentPosition position = new DocumentPosition(lineNumber, characterPos); int offset = editor.Document.PositionToOffset(position); DynamicToken token = (DynamicToken)editor.Document.Tokens.GetTokenAtOffset(offset); SpanIndicator indicator = new WaveLineSpanIndicator("ErrorIndicator", Color.Red); indicator.Tag = message; SpanIndicatorLayer indicatorLayer = editor.Document.SpanIndicatorLayers[ErrorLayerKey]; if (indicatorLayer == null) { indicatorLayer = new SpanIndicatorLayer(ErrorLayerKey, 1); editor.Document.SpanIndicatorLayers.Add(indicatorLayer); } int startOffset = Math.Min(token.StartOffset, indicatorLayer.Document.Length - 1); int length = Math.Max(token.Length, 1); SpanIndicator[] indicators = indicatorLayer.GetIndicatorsForTextRange(new TextRange(startOffset, startOffset + length)); foreach (SpanIndicator i in indicators) { // If there is already an error indicator on that word, don't add another one. if (i.TextRange.StartOffset == startOffset && i.TextRange.Length == length) return; } indicatorLayer.Add(indicator, startOffset, length); }
//private void pReplaceDefaultTags() //{ // var oRanges = txtVerbale.Document.FindAll("$ordinegiorno", SearchOptions.None); // foreach (var oRange in oRanges) // { // DocumentPosition oPosition = oRange.Start; // txtVerbale.Document.Delete(oRange); // foreach (OrdineGiornoAssembleaDTO puntordinegiorno in ordineGiornoAssembleaDTOBindingSource) // { // string sText = puntordinegiorno.Descrizione.Trim(); // sText = "\\bullet " + sText + " "; // oPosition = pDocumentReplace(txtVerbale, oPosition, sText).End; // } // } //} #endregion private DocumentRange pDocumentReplace(RichControlEditorUC editor, DocumentPosition position, string text) { editor.Document.Replace(editor.Document.Selection, ""); text = text.Trim(); if (!text.StartsWith("{\\rtf")) { text = "{\\rtf " + text + "}"; } return editor.Document.InsertRtfText(position, text); }
/// <summary> /// Add document and position data to the given map file. /// </summary> internal void AddDocumentMapping(MapFile mapFile) { var source = compiledMethod.DexMethod; if ((source == null) || (source.Body == null) || (source.Body.Instructions.Count == 0)) return; if (this.compiledMethod.DexMethod.Name == "testTryCatch") { } var sequencePointsInstr = source.Body.Instructions.Where(x => x.SequencePoint != null); foreach (var seqPointIns in sequencePointsInstr) { // Get document var seqPoint = (ISourceLocation)seqPointIns.SequencePoint; var doc = mapFile.GetOrCreateDocument(seqPoint.Document, true); // Add position var docPos = new DocumentPosition(seqPoint.StartLine, seqPoint.StartColumn, seqPoint.EndLine, seqPoint.EndColumn, compiledMethod.DexMethod.Owner.MapFileId, compiledMethod.DexMethod.MapFileId, seqPointIns.Offset) { IsReturn = seqPointIns.OpCode.IsReturn() }; doc.Positions.Add(docPos); } }
internal static SourceCodePosition Create(Document document, DocumentPosition position) { return new SourceCodePosition(document, position); }
public SourceCodePosition(Document document, DocumentPosition position) { Document = document; Position = position; }
/// <summary> /// Determines whether the specified document has spelling errors. /// </summary> /// <param name="document"> /// The document. /// </param> /// <param name="culture"> /// The culture. /// </param> /// <returns> /// The asynchronous task. /// </returns> public async Task<bool> HasErrors(RadDocument document, CultureInfo culture) { if (document == null) throw new ArgumentNullException("document"); if (culture == null) throw new ArgumentNullException("culture"); var getUserDictionaryTask = GetUserDictionaryAsync(); var getDictionaryTask = GetDictionaryAsync(culture); var getIgnoredWordsTask = GetIgnoredWordsAsync(); await TaskEx.WhenAll(getUserDictionaryTask, getDictionaryTask, getIgnoredWordsTask); var userDictionary = getUserDictionaryTask.Result; var dictionary = getDictionaryTask.Result; var ignoredWords = getIgnoredWordsTask.Result; var spellChecker = new DocumentSpellChecker(userDictionary); try { if (dictionary != null) { spellChecker.AddDictionary(dictionary, culture); spellChecker.RemoveCustomDictionary(culture); } spellChecker.SpellCheckingCulture = culture; var proofingManager = new DocumentProofingManager(document, spellChecker, ignoredWords); using (var position = new DocumentPosition(document)) { var nextErrorWord = proofingManager.GetNextErrorWord(position); return nextErrorWord != null; } } finally { spellChecker.RemoveCustomDictionary(CultureInfo.InvariantCulture); } }
/// <summary> /// Default ctor /// </summary> public DebugLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, BreakpointBookmark bookmark) : base(eventKind, documentPosition, typeEntry, methodEntry) { this.bookmark = bookmark; InvalidateBookmark(); }
private string GetCurrentWord() { DocumentPosition pos = new DocumentPosition(this.Document.CaretPosition); pos.MoveToCurrentWordStart(); DocumentSelection selection = new DocumentSelection(this.Document); selection.AddSelectionStart(pos); pos.MoveToCurrentWordEnd(); selection.AddSelectionEnd(pos); return selection.GetSelectedText().Trim(); }
private void ReplaceSemanticRange(RadDocument document, string semanticRangeName, DocumentFragment replacement) { RecipeRangeStart start = null; RecipeRangeEnd end = null; foreach (RecipeRangeStart rangeStart in document.GetAnnotationMarkersOfType<RecipeRangeStart>()) { if (rangeStart.Name == semanticRangeName) { start = rangeStart; end = (RecipeRangeEnd)rangeStart.End; } } if (start != null && end != null) { DocumentPosition startPosition = new DocumentPosition(document); startPosition.MoveToInline((InlineLayoutBox)start.FirstLayoutBox, 0); startPosition.MoveToNext(); DocumentPosition endPosition = new DocumentPosition(document); endPosition.MoveToInline((InlineLayoutBox)end.FirstLayoutBox, 0); document.DeleteRange(startPosition, endPosition); document.CaretPosition.MoveToInline((InlineLayoutBox)start.FirstLayoutBox, 0); document.CaretPosition.MoveToNext(); document.InsertFragment(replacement); } }
/// <summary> /// Create custom breakpoint. /// </summary> protected override DalvikLocationBreakpoint CreateLocationBreakpoint(DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, object data) { return new DebugLocationBreakpoint(Jdwp.EventKind.BreakPoint, documentPosition, typeEntry, methodEntry, (BreakpointBookmark)data); }
public void FindNext(DocumentPosition fromPosition) { this.tbFindText.Focus(); this.tbFindText.SelectAll(); if (this.selectReplaceStateService.IsLastFoundSuccessful) { this.selectReplaceStateService.UnsubscribeFromDocumentEvents(); this.selectReplaceStateService.SubscribeForDocumentEvents(); } if (this.initialFindPosition == null) { this.initialFindPosition = new DocumentPosition(fromPosition); } DocumentTextSearch textSearch = new DocumentTextSearch(this.Document); TextRange find = textSearch.Find(this.GetSearchText(), fromPosition); if (find != null) { if (find.StartPosition >= this.initialFindPosition && !this.passedThroughEnd || find.StartPosition < this.initialFindPosition && this.passedThroughEnd) { this.selectReplaceStateService.SelectFoundRange(find); this.richTextBox.ActiveEditorPresenter.UpdateScrollOffsetFromDocumentPosition(find.StartPosition); this.RepositionDialog(find.StartPosition); } else { Dispatcher.BeginInvoke(new Action(() => { RadWindow.Alert(new DialogParameters() { Header = this.Header, Content = LocalizationManager.GetString("Documents_FindReplaceDialog_FinishedSearching") }); })); this.ResetFindDialog(); this.passedThroughEnd = false; this.Document.Selection.Clear(); } } else { if (!passedThroughEnd) { passedThroughEnd = true; this.FindNext(new DocumentPosition(this.Document)); } else { string content; if (this.selectReplaceStateService.IsLastFoundSuccessful) { content = LocalizationManager.GetString("Documents_FindReplaceDialog_FinishedSearching"); } else { content = string.Format(LocalizationManager.GetString("Documents_FindReplaceDialog_SearchedTextNotFound"), this.tbFindText.Text); } Dispatcher.BeginInvoke(new Action(() => RadWindow.Alert(new DialogParameters() { Header = this.Header, Content = content }))); this.Document.Selection.Clear(); this.ResetFindDialog(); } } }
/// <summary> /// Shows the dialog. /// </summary> /// <param name="richTextBox">The associated <see cref="RadRichTextBox"/>.</param> /// <param name="replaceCallback">The callback that will be invoked to perform replace.</param> /// <param name="textToFind">The text to initially set in the search field.</param> public void Show(RadRichTextBox richTextBox, Func<string, bool> replaceCallback, string textToFind) { this.richTextBox = richTextBox; this.replaceCallback = replaceCallback; this.initialCaretPosition = new DocumentPosition(this.richTextBox.Document.CaretPosition); this.initialCaretPosition.AnchorToNextFormattingSymbol(); if (!this.IsOpen && textToFind != null) { this.TextToFind = textToFind; } this.SetOwner(richTextBox); if (this.selectReplaceStateService != null) { this.selectReplaceStateService.UnsubscribeFromDocumentEvents(); } this.selectReplaceStateService = new DocumentSelectReplaceStateService(this.Document, this.ResetFindDialog); this.SetupUIAccordingToReadOnly(richTextBox); this.EnableButtonsAccordingToText(); if (!this.IsOpen) { this.ResetFindDialog(); this.Show(); this.Dispatcher.BeginInvoke(new Action(() => { this.tbFindText.Focus(); this.tbFindText.SelectAll(); })); } }
private void RepositionDialog(DocumentPosition targetPosition) { var targetLocation = new Point(); var point = this.richTextBox.ActiveEditorPresenter.GetViewPointFromDocumentPosition(targetPosition); targetLocation.X = point.X; targetLocation.Y = point.Y; #if WPF if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted) { targetLocation = this.richTextBox.TransformToVisual(Application.Current.MainWindow).Transform(targetLocation); } else { targetLocation = this.richTextBox.PointToScreen(targetLocation); } #else targetLocation = this.richTextBox.TransformToVisual(Application.Current.RootVisual).Transform(targetLocation); #endif Rect dialogRect = new Rect() { X = this.Left, Y = this.Top, Width = this.ActualWidth, Height = this.ActualHeight }; // TODO: smarter move if (dialogRect.Contains(targetLocation)) { this.Top = targetLocation.Y - this.ActualHeight - 5; if (this.Top < 0) { this.Top = targetLocation.Y + (targetPosition.GetCurrentInlineBox().ControlBoundingRectangle.Height * this.richTextBox.ScaleFactor.Height) + 5; } } }
public void ResetFindDialog() { this.passedThroughEnd = false; this.initialFindPosition = null; }
private void btnReplaceAll_Click(object sender, RoutedEventArgs e) { int foundCount = 0; this.richTextBox.SuspendUpdateLayout(); this.Document.BeginUpdate(); try { using (DocumentPosition startFindPosition = new DocumentPosition(this.Document.DocumentLayoutBox, true)) { var found = true; while (found) { DocumentTextSearch textSearch = new DocumentTextSearch(this.Document); TextRange find = textSearch.Find(this.GetSearchText(), startFindPosition); found = find != null; if (found) { startFindPosition.MoveToPosition(find.EndPosition); startFindPosition.AnchorToNextFormattingSymbol(); //This is needed to update the current style for editing this.Document.CaretPosition.MoveToPosition(find.StartPosition); find.SetSelection(this.Document); if (this.replaceCallback(this.tbReplaceText.Text)) { foundCount++; } startFindPosition.RemoveAnchorFromNextFormattingSymbol(); } } } } finally { this.Document.EndUpdate(); this.richTextBox.ResumeUpdateLayout(); } RadWindow.Alert(new DialogParameters() { Header = this.Header, Content = string.Format(LocalizationManager.GetString("Documents_FindReplaceDialog_MadeReplacements"), foundCount) }); }