/// <summary> /// 将文档视图区域中的坐标转换为控件客户区中的坐标 /// </summary> /// <param name="x">视图坐标值</param> /// <param name="y">视图坐标值</param> /// <param name="mode">转换模式</param> /// <returns>转换结果</returns> public PointF ViewPointToClient(float x, float y, ViewTransformMode mode) { this.RefreshScaleTransform(); SimpleRectangleTransform item = null; switch (mode) { case ViewTransformMode.Normal: item = this.PagesTransform.GetBySourcePoint(x, y); break; case ViewTransformMode.Absolute: item = this.PagesTransform.GetBySourcePointAbsolute(x, y); break; case Printing.ViewTransformMode.LimitedCurrentItem: item = this.CurrentTransformItem; break; } if (item != null) { return(item.TransformPointF(x, y)); } else { return(new PointF(float.NaN, float.NaN)); } }
/// <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)); } }
/// <summary> /// 获得指定客户区坐标点所在的坐标转换对象 /// </summary> /// <param name="clientX">客户区X坐标</param> /// <param name="clientY">客户区Y坐标</param> /// <param name="mode">转换模式</param> /// <returns>获得的转换对象</returns> public SimpleRectangleTransform GetTransformItem( float clientX, float clientY, ViewTransformMode mode) { this.RefreshScaleTransform(); SimpleRectangleTransform item = null; switch (mode) { case ViewTransformMode.Normal: item = this.PagesTransform.GetByDescPoint(clientX, clientY); break; case ViewTransformMode.Absolute: item = this.PagesTransform.GetByDescPointAbsolute(clientX, clientY); break; case Printing.ViewTransformMode.LimitedCurrentItem: item = this.CurrentTransformItem; break; } return(item); }