/// <summary> /// UpdateAccessKey - Scans forward in the tree looking for the access key marker, replacing it with access key element. We only support one find. /// </summary> private void UpdateAccessKey() { TextPointer navigator = new TextPointer(TextContainer.Start); while (!_accessKeyLocated && navigator.CompareTo(TextContainer.End) < 0) { TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward); switch (symbolType) { case TextPointerContext.Text: string text = navigator.GetTextInRun(LogicalDirection.Forward); int index = FindAccessKeyMarker(text); if (index != -1 && index < text.Length - 1) { string keyText = StringInfo.GetNextTextElement(text, index + 1); TextPointer keyEnd = navigator.GetPositionAtOffset(index + 1 + keyText.Length); _accessKey = new Run(keyText); _accessKey.Style = AccessKeyStyle; RegisterAccessKey(); HasCustomSerializationStorage.SetValue(_accessKey, true); _accessKeyLocated = true; UninitializeTextContainerListener(); TextContainer.BeginChange(); try { TextPointer underlineStart = new TextPointer(navigator, index); TextRangeEdit.DeleteInlineContent(underlineStart, keyEnd); _accessKey.RepositionWithContent(underlineStart); } finally { TextContainer.EndChange(); InitializeTextContainerListener(); } } break; } navigator.MoveToNextContextPosition(LogicalDirection.Forward); } // Convert double _ to single _ navigator = new TextPointer(TextContainer.Start); string accessKeyMarker = AccessKeyMarker.ToString(); string doubleAccessKeyMarker = accessKeyMarker + accessKeyMarker; while (navigator.CompareTo(TextContainer.End) < 0) { TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward); switch (symbolType) { case TextPointerContext.Text: string text = navigator.GetTextInRun(LogicalDirection.Forward); string nexText = text.Replace(doubleAccessKeyMarker, accessKeyMarker); if (text != nexText) { TextPointer keyStart = new TextPointer(navigator, 0); TextPointer keyEnd = new TextPointer(navigator, text.Length); UninitializeTextContainerListener(); TextContainer.BeginChange(); try { keyEnd.InsertTextInRun(nexText); TextRangeEdit.DeleteInlineContent(keyStart, keyEnd); } finally { TextContainer.EndChange(); InitializeTextContainerListener(); } } break; } navigator.MoveToNextContextPosition(LogicalDirection.Forward); } }
// Token: 0x06004211 RID: 16913 RVA: 0x0012E228 File Offset: 0x0012C428 private void UpdateAccessKey() { TextPointer textPointer = new TextPointer(this.TextContainer.Start); while (!this._accessKeyLocated && textPointer.CompareTo(this.TextContainer.End) < 0) { TextPointerContext pointerContext = textPointer.GetPointerContext(LogicalDirection.Forward); if (pointerContext == TextPointerContext.Text) { string textInRun = textPointer.GetTextInRun(LogicalDirection.Forward); int num = AccessText.FindAccessKeyMarker(textInRun); if (num != -1 && num < textInRun.Length - 1) { string nextTextElement = StringInfo.GetNextTextElement(textInRun, num + 1); TextPointer positionAtOffset = textPointer.GetPositionAtOffset(num + 1 + nextTextElement.Length); this._accessKey = new Run(nextTextElement); this._accessKey.Style = AccessText.AccessKeyStyle; this.RegisterAccessKey(); AccessText.HasCustomSerializationStorage.SetValue(this._accessKey, true); this._accessKeyLocated = true; this.UninitializeTextContainerListener(); this.TextContainer.BeginChange(); try { TextPointer textPointer2 = new TextPointer(textPointer, num); TextRangeEdit.DeleteInlineContent(textPointer2, positionAtOffset); this._accessKey.RepositionWithContent(textPointer2); } finally { this.TextContainer.EndChange(); this.InitializeTextContainerListener(); } } } textPointer.MoveToNextContextPosition(LogicalDirection.Forward); } textPointer = new TextPointer(this.TextContainer.Start); string text = AccessText.AccessKeyMarker.ToString(); string oldValue = text + text; while (textPointer.CompareTo(this.TextContainer.End) < 0) { TextPointerContext pointerContext2 = textPointer.GetPointerContext(LogicalDirection.Forward); if (pointerContext2 == TextPointerContext.Text) { string textInRun2 = textPointer.GetTextInRun(LogicalDirection.Forward); string text2 = textInRun2.Replace(oldValue, text); if (textInRun2 != text2) { TextPointer start = new TextPointer(textPointer, 0); TextPointer textPointer3 = new TextPointer(textPointer, textInRun2.Length); this.UninitializeTextContainerListener(); this.TextContainer.BeginChange(); try { textPointer3.InsertTextInRun(text2); TextRangeEdit.DeleteInlineContent(start, textPointer3); } finally { this.TextContainer.EndChange(); this.InitializeTextContainerListener(); } } } textPointer.MoveToNextContextPosition(LogicalDirection.Forward); } }