Exemplo n.º 1
0
            public CharacterPositionInfo GetX_AtCharacterIndex(int char_index, bool trailingEdge)
            {
                if (char_index > CharLength - 1)
                {
                    throw new ArgumentOutOfRangeException
                              ("char_index", char_index, "char_index greater than line length.");
                }
                CharacterPositionType pos_type = CharacterPositionType.LeadingEdge;

                if (trailingEdge)
                {
                    pos_type = CharacterPositionType.TrailingEdge;
                }
                return(CharacterPositionInfo.FromCharIndex(ssa_struct_ptr, char_index, pos_type));
            }
Exemplo n.º 2
0
        public static CharacterPositionInfo FromCharIndex(IntPtr ssa_struct, int char_index, CharacterPositionType pos_type)
        {
            if ((pos_type == CharacterPositionType.AfterEnd) ||
                (pos_type == CharacterPositionType.BeforeBeginning) ||
                (pos_type == CharacterPositionType.ClusterPart))
            {
                throw new ArgumentException("Illegal parameter.", "pos_type");
            }

            var trailing = (pos_type == CharacterPositionType.TrailingEdge);
            var x_offset = 0;
            var res      = NativeScript.ScriptStringCPtoX
                               (ssa_struct,
                               char_index,
                               trailing,
                               ref x_offset);

            if (res != NativeScript.S_OK)
            {
                Marshal.ThrowExceptionForHR(res);
            }

            var ret = new CharacterPositionInfo();

            ret.CharIndex    = char_index;
            ret.PositionType = pos_type;
            ret.Xoffset      = x_offset;

            return(ret);
        }