Ejemplo n.º 1
0
 /// <summary>
 /// Gets the length in characters (not including the null terminator) of the string with the specified index.
 /// </summary>
 /// <param name="index">Zero-based index of the string.</param>
 /// <returns>The length in characters, not including the null terminator.</returns>
 uint GetStringLength(uint index)
 {
     if (_localizedStrings == null)
     {
         return(0);
     }
     else
     {
         uint length = 0;
         length = _localizedStrings.GetStringLength(index);
         return(length);
     }
 }
Ejemplo n.º 2
0
        public static IReadOnlyList <DWriteLocalizedString> GetNames(this IDWriteLocalizedStrings strings)
        {
            if (strings == null)
            {
                throw new ArgumentNullException(nameof(strings));
            }

            var list = new List <DWriteLocalizedString>((int)strings.GetCount());

            for (var i = 0; i < list.Capacity; i++)
            {
                var name = new DWriteLocalizedString();
                strings.GetLocaleNameLength((uint)i, out var len).ThrowOnError();
                name.LocaleName = new string('\0', (int)len);
                strings.GetLocaleName((uint)i, name.LocaleName, len + 1);

                strings.GetStringLength((uint)i, out len).ThrowOnError();
                name.String = new string('\0', (int)len);
                strings.GetString((uint)i, name.String, len + 1);

                list.Add(name);
            }
            return(list);
        }