// Token: 0x06004A31 RID: 18993 RVA: 0x0014F45C File Offset: 0x0014D65C internal static CultureInfo GetCulture(FrameworkElement element) { bool flag; CultureInfo result; if (element.GetValueSource(FrameworkElement.LanguageProperty, null, out flag) != BaseValueSourceInternal.Default) { result = DynamicPropertyReader.GetCultureInfo(element); } else { result = CultureInfo.CurrentCulture; } return(result); }
// Token: 0x06004132 RID: 16690 RVA: 0x0012A184 File Offset: 0x00128384 public override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int dcp) { CharacterBufferRange empty = CharacterBufferRange.Empty; CultureInfo culture = null; if (dcp > 0) { ITextPointer textPointer = this._owner.Host.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward); int num = Math.Min(128, textPointer.GetTextRunLength(LogicalDirection.Backward)); char[] array = new char[num]; textPointer.GetTextInRun(LogicalDirection.Backward, array, 0, num); empty = new CharacterBufferRange(array, 0, num); culture = DynamicPropertyReader.GetCultureInfo((Control)this._owner.Host); } return(new TextSpan <CultureSpecificCharacterBufferRange>(empty.Length, new CultureSpecificCharacterBufferRange(culture, empty))); }
/// <summary> /// Get text immediately before specified text source position. Return CharacterBufferRange /// containing this text. /// </summary> /// <param name="dcp"> /// dcp of position relative to start of line /// </param> internal override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int dcp) { // Parameter validation Invariant.Assert(dcp >= 0); int nonTextLength = 0; CharacterBufferRange precedingText = CharacterBufferRange.Empty; CultureInfo culture = null; if (dcp > 0) { // Create TextPointer at dcp, and pointer at paragraph start to compare ITextPointer startPosition = TextContainerHelper.GetTextPointerFromCP(_paraClient.Paragraph.StructuralCache.TextContainer, _cpPara, LogicalDirection.Forward); ITextPointer position = TextContainerHelper.GetTextPointerFromCP(_paraClient.Paragraph.StructuralCache.TextContainer, _cpPara + dcp, LogicalDirection.Forward); // Move backward until we find a position at the end of a text run, or reach start of TextContainer while (position.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text && position.CompareTo(startPosition) != 0) { position.MoveByOffset(-1); nonTextLength++; } // Return text in run. If it is at start of TextContainer this will return an empty string string precedingTextString = position.GetTextInRun(LogicalDirection.Backward); precedingText = new CharacterBufferRange(precedingTextString, 0, precedingTextString.Length); StaticTextPointer pointer = position.CreateStaticPointer(); DependencyObject element = (pointer.Parent != null) ? pointer.Parent : _paraClient.Paragraph.Element; culture = DynamicPropertyReader.GetCultureInfo(element); } return(new TextSpan <CultureSpecificCharacterBufferRange>( nonTextLength + precedingText.Length, new CultureSpecificCharacterBufferRange(culture, precedingText) )); }
/// <summary> /// Get text immediately before specified text source position. /// </summary> public override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int dcp) { CharacterBufferRange precedingText = CharacterBufferRange.Empty; CultureInfo culture = null; if (dcp > 0) { // Create TextPointer at dcp ITextPointer position = _owner.Host.TextContainer.CreatePointerAtOffset(dcp, LogicalDirection.Backward); // Return text in run. If it is at start of TextContainer this will return an empty string. // Typically the caller requires just the preceding character. Worst case is the entire // preceding sentence, which we approximate with a 128 char limit. int runLength = Math.Min(128, position.GetTextRunLength(LogicalDirection.Backward)); char [] text = new char[runLength]; position.GetTextInRun(LogicalDirection.Backward, text, 0, runLength); precedingText = new CharacterBufferRange(text, 0, runLength); culture = DynamicPropertyReader.GetCultureInfo((Control)_owner.Host); } return(new TextSpan <CultureSpecificCharacterBufferRange>( precedingText.Length, new CultureSpecificCharacterBufferRange(culture, precedingText))); }
// Token: 0x06006864 RID: 26724 RVA: 0x001D6C0C File Offset: 0x001D4E0C internal override TextSpan <CultureSpecificCharacterBufferRange> GetPrecedingText(int dcp) { Invariant.Assert(dcp >= 0); int num = 0; CharacterBufferRange empty = CharacterBufferRange.Empty; CultureInfo culture = null; if (dcp > 0) { ITextPointer textPointerFromCP = TextContainerHelper.GetTextPointerFromCP(this._paraClient.Paragraph.StructuralCache.TextContainer, this._cpPara, LogicalDirection.Forward); ITextPointer textPointerFromCP2 = TextContainerHelper.GetTextPointerFromCP(this._paraClient.Paragraph.StructuralCache.TextContainer, this._cpPara + dcp, LogicalDirection.Forward); while (textPointerFromCP2.GetPointerContext(LogicalDirection.Backward) != TextPointerContext.Text && textPointerFromCP2.CompareTo(textPointerFromCP) != 0) { textPointerFromCP2.MoveByOffset(-1); num++; } string textInRun = textPointerFromCP2.GetTextInRun(LogicalDirection.Backward); empty = new CharacterBufferRange(textInRun, 0, textInRun.Length); StaticTextPointer staticTextPointer = textPointerFromCP2.CreateStaticPointer(); DependencyObject element = (staticTextPointer.Parent != null) ? staticTextPointer.Parent : this._paraClient.Paragraph.Element; culture = DynamicPropertyReader.GetCultureInfo(element); } return(new TextSpan <CultureSpecificCharacterBufferRange>(num + empty.Length, new CultureSpecificCharacterBufferRange(culture, empty))); }
/// <summary> /// Returns FormattedText for the largets marker in a list /// </summary> /// <param name="list"> /// List element for which formatted marker is to be calculated /// </param> private static FormattedText GetFormattedMarker(List list) { string markerString = ""; FormattedText formattedMarker; if (IsKnownSymbolMarkerStyle(list.MarkerStyle)) { switch (list.MarkerStyle) { case TextMarkerStyle.Disc: markerString = "\x9f"; break; case TextMarkerStyle.Circle: markerString = "\xa1"; break; case TextMarkerStyle.Square: markerString = "\x71"; break; case TextMarkerStyle.Box: markerString = "\xa7"; break; } // Create new formatted text with typeface using a symbol font, e.g. Wingdings Typeface typeface = DynamicPropertyReader.GetModifiedTypeface(list, new FontFamily("Wingdings")); formattedMarker = new FormattedText(markerString, DynamicPropertyReader.GetCultureInfo(list), list.FlowDirection, typeface, list.FontSize, list.Foreground); } else if (IsKnownIndexMarkerStyle(list.MarkerStyle)) { // Assume at least one element will be added and format accordingly int startIndex = list.StartIndex; Invariant.Assert(startIndex > 0); int size = list.ListItems.Count; int highestIndex; if (int.MaxValue - size < startIndex) { // Highest index will exceed max value of int. Clamp to int.MaxValue highestIndex = int.MaxValue; } else { highestIndex = (size == 0) ? startIndex : startIndex + size - 1; } switch (list.MarkerStyle) { case TextMarkerStyle.Decimal: markerString = ConvertNumberToString(highestIndex, false, DecimalNumerics); break; case TextMarkerStyle.LowerLatin: markerString = ConvertNumberToString(highestIndex, true, LowerLatinNumerics); break; case TextMarkerStyle.UpperLatin: markerString = ConvertNumberToString(highestIndex, true, UpperLatinNumerics); break; case TextMarkerStyle.LowerRoman: markerString = GetStringForLargestRomanMarker(startIndex, highestIndex, false); break; case TextMarkerStyle.UpperRoman: markerString = GetStringForLargestRomanMarker(startIndex, highestIndex, true); break; } // Create new formatted text using List defaulls formattedMarker = new FormattedText(markerString, DynamicPropertyReader.GetCultureInfo(list), list.FlowDirection, DynamicPropertyReader.GetTypeface(list), list.FontSize, list.Foreground); } else { // Assume a disc markerString = "\x9f"; // Create new formatted text with typeface using a symbol font, e.g. Wingdings Typeface typeface = DynamicPropertyReader.GetModifiedTypeface(list, new FontFamily("Wingdings")); formattedMarker = new FormattedText(markerString, DynamicPropertyReader.GetCultureInfo(list), list.FlowDirection, typeface, list.FontSize, list.Foreground); } return(formattedMarker); }
// Token: 0x060068A3 RID: 26787 RVA: 0x001D8324 File Offset: 0x001D6524 private static FormattedText GetFormattedMarker(List list, double pixelsPerDip) { string textToFormat = ""; FormattedText result; if (ListMarkerSourceInfo.IsKnownSymbolMarkerStyle(list.MarkerStyle)) { switch (list.MarkerStyle) { case TextMarkerStyle.Disc: textToFormat = "\u009f"; break; case TextMarkerStyle.Circle: textToFormat = "¡"; break; case TextMarkerStyle.Square: textToFormat = "q"; break; case TextMarkerStyle.Box: textToFormat = "§"; break; } Typeface modifiedTypeface = DynamicPropertyReader.GetModifiedTypeface(list, new FontFamily("Wingdings")); result = new FormattedText(textToFormat, DynamicPropertyReader.GetCultureInfo(list), list.FlowDirection, modifiedTypeface, list.FontSize, list.Foreground, pixelsPerDip); } else if (ListMarkerSourceInfo.IsKnownIndexMarkerStyle(list.MarkerStyle)) { int startIndex = list.StartIndex; Invariant.Assert(startIndex > 0); int count = list.ListItems.Count; int num; if (2147483647 - count < startIndex) { num = int.MaxValue; } else { num = ((count == 0) ? startIndex : (startIndex + count - 1)); } switch (list.MarkerStyle) { case TextMarkerStyle.LowerRoman: textToFormat = ListMarkerSourceInfo.GetStringForLargestRomanMarker(startIndex, num, false); break; case TextMarkerStyle.UpperRoman: textToFormat = ListMarkerSourceInfo.GetStringForLargestRomanMarker(startIndex, num, true); break; case TextMarkerStyle.LowerLatin: textToFormat = ListMarkerSourceInfo.ConvertNumberToString(num, true, ListMarkerSourceInfo.LowerLatinNumerics); break; case TextMarkerStyle.UpperLatin: textToFormat = ListMarkerSourceInfo.ConvertNumberToString(num, true, ListMarkerSourceInfo.UpperLatinNumerics); break; case TextMarkerStyle.Decimal: textToFormat = ListMarkerSourceInfo.ConvertNumberToString(num, false, ListMarkerSourceInfo.DecimalNumerics); break; } result = new FormattedText(textToFormat, DynamicPropertyReader.GetCultureInfo(list), list.FlowDirection, DynamicPropertyReader.GetTypeface(list), list.FontSize, list.Foreground, pixelsPerDip); } else { textToFormat = "\u009f"; Typeface modifiedTypeface2 = DynamicPropertyReader.GetModifiedTypeface(list, new FontFamily("Wingdings")); result = new FormattedText(textToFormat, DynamicPropertyReader.GetCultureInfo(list), list.FlowDirection, modifiedTypeface2, list.FontSize, list.Foreground, pixelsPerDip); } return(result); }