예제 #1
0
        /// <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);
        }
예제 #2
0
        // 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);
        }