Exemplo n.º 1
0
        public System.Drawing.PointF AbsUnTransformPoint(float x, float y)
        {
            SimpleRectangleTransform pre  = null;
            SimpleRectangleTransform next = null;
            SimpleRectangleTransform cur  = null;

            foreach (SimpleRectangleTransform item in this)
            {
                if (item.Enable == false)
                {
                    continue;
                }
                if (intLimitedPageIndex >= 0 && item.PageIndex != intLimitedPageIndex)
                {
                    continue;
                }
                if (item.DescRectF.Contains(x, y))
                {
                    return(item.UnTransformPointF(x, y));
                }

                if (y >= item.DescRectF.Top && y < item.DescRectF.Bottom)
                {
                    cur = item;
                    break;
                }
                if (y < item.DescRectF.Top)
                {
                    if (next == null || item.DescRectF.Top < next.DescRectF.Top)
                    {
                        next = item;
                    }
                }
                if (y > item.DescRectF.Bottom)
                {
                    if (pre == null || item.DescRectF.Bottom > pre.DescRectF.Bottom)
                    {
                        pre = item;
                    }
                }
            }//foreach
            if (cur == null)
            {
                if (pre != null)
                {
                    cur = pre;
                }
                else
                {
                    cur = next;
                }
            }
            if (cur == null)
            {
                return(System.Drawing.PointF.Empty);
            }
            System.Drawing.PointF p = new System.Drawing.PointF(x, y);
            p = RectangleCommon.MoveInto(p, cur.DescRectF);
            return(cur.UnTransformPointF(p));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将控件客户区域中的坐标转换为文档视图区中的坐标
        /// </summary>
        /// <param name="x">控件客户区坐标值</param>
        /// <param name="y">控件客户区坐标值</param>
        /// <param name="mode">转换模式</param>
        /// <returns>转换结果</returns>
        public PointF ClientPointToView(float x, float y, ViewTransformMode mode)
        {
            SimpleRectangleTransform item = GetTransformItem(x, y, mode);

            if (item != null)
            {
                return(item.UnTransformPointF(x, y));
            }
            else
            {
                return(new PointF(float.NaN, float.NaN));
            }
        }