Example #1
0
        /// <summary>
        /// 원본 문자열의 커서를 지정
        /// </summary>
        /// <param name="cursor">커서위치</param>
        public void SetOriginCursor(int cursor)
        {
            this.origin.SetCursor(cursor);

            int tempCursor  = cursor;
            int transCursor = 0;

            foreach (var token in trans.GetTokenList())
            {
                if (tempCursor <= 0)
                {
                    break;
                }


                int delta = 0;
                if (token is StringToken)
                {
                    if (tempCursor > token.ToString().Length)
                    {
                        delta = token.ToString().Length;
                    }
                    else
                    {
                        delta = tempCursor;
                    }

                    tempCursor -= delta;
                }
                else if (token is ChangeToken)
                {
                    ChangeToken temp = token as ChangeToken;
                    if (tempCursor > temp.GetOriginString().Length)
                    {
                        tempCursor -= temp.GetOriginString().Length;
                        delta       = temp.ToString().Length;
                    }
                    else
                    {
                        tempCursor -= tempCursor;
                        delta       = temp.ToString().Length;
                    }
                }
                else
                {
                    delta = token.ToString().Length;
                }
                transCursor += delta;
            }

            trans.SetCursor(transCursor);
        }