Beispiel #1
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);
        }