找回密码
 立即注册

QQ登录

只需一步,快速开始

13573156105

注册会员

6

主题

20

帖子

190

积分

注册会员

积分
190
13573156105
注册会员   /  发表于:2019-1-11 11:03  /   查看:3344  /  回复:8



我定义好private LeadRect myrect = new LeadRect();之后
想让画好的图形,自动赋予myrect
我试了一下
myrect = _automation.Container.Children[0].Bounds;  不可以


包括对图形大小的调整,都可以自动获取,并赋予myrect
使用的Leadtools19
不知道如何完成,请版主指教,非常感谢版主!!!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

8 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-1-11 18:19:07
沙发
myrect = _automation.Container.Children[0].Bounds;
按照您写的这句代码应该是可以获取到的,现在是获取到的值不对,还是说_automation.Container.Children就没有object对象呢

回复 使用道具 举报
13573156105
注册会员   /  发表于:2019-1-14 15:00:32
板凳
_automation.Container.Children[0].Bounds的定义属性是
public LeadRectD Bounds { get; }

我想获取的区域定义属性是
private LeadRect myrect = new LeadRect();

因此myrect = _automation.Container.Children[0].Bounds; 是错误的
            myrect.X = Convert.ToInt32(_automation.Container.Children[0].Bounds.X ); myrect.Y = Convert.ToInt32(_automation.Container.Children[0].Bounds.Y);
            myrect.Width = Convert.ToInt32(_automation.Container.Children[0].Bounds.Width); myrect.Height = Convert.ToInt32(_automation.Container.Children[0].Bounds.Height);

            automationImageViewer1.Image.AddRectangleToRegion(null, myrect, RasterRegionCombineMode.Set);

我这样获取的区域,和_automation.Container.Children[0].Bounds位置区域是有偏差的,不知道应该怎么样处理?请版主指教!!!非常感谢!!!
回复 使用道具 举报
13573156105
注册会员   /  发表于:2019-1-14 17:21:50
地板
Richard.Ma 发表于 2019-1-11 18:19
myrect = _automation.Container.Children[0].Bounds;
按照您写的这句代码应该是可以获取到的,现在是获 ...



            myrect.X = Convert.ToInt32(_automation.Container.Children[0].Bounds.X * 0.1 / automationImageViewer1.ScaleFactor); myrect.Y = Convert.ToInt32(_automation.Container.Children[0].Bounds.Y * 0.1 / automationImageViewer1.ScaleFactor);
            myrect.Width = Convert.ToInt32(_automation.Container.Children[0].Bounds.Width * 0.1 / automationImageViewer1.ScaleFactor); myrect.Height = Convert.ToInt32(_automation.Container.Children[0].Bounds.Height * 0.1 / automationImageViewer1.ScaleFactor);

这样处理已经快逼近了,还是不能重合,挺奇怪,到底如何才能一致呢???

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-1-14 18:40:04
5#
我测试了一下确实是不一样,LeadRectD 有提供一个ToLeadRect()方法,但是转换后还是和您的错误结果一样
明天我帮你看一下,是否是需要进行某种转换,我判断可能是由于单位不一样,需要进行转换
回复 使用道具 举报
13573156105
注册会员   /  发表于:2019-1-15 11:15:53
6#
Richard.Ma 发表于 2019-1-14 18:40
我测试了一下确实是不一样,LeadRectD 有提供一个ToLeadRect()方法,但是转换后还是和您的错误结果一样
明 ...

非常感谢版主,盼解决!!!
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-1-15 14:11:46
7#
请参考下面的代码,主要是用RectFromContainerCoordinates这个方法对坐标进行了转换,

  1.             LeadRectD rectd = ActiveAnnotationsForm.Automation.Container.Children[0].Bounds;
  2.             LeadRect rect = ActiveAnnotationsForm.Automation.Container.Mapper.RectFromContainerCoordinates(rectd,AnnFixedStateOperations.None).ToLeadRect();

  3.             ActiveAnnotationsForm.Viewer.Image.AddRectangleToRegion(null, rect, RasterRegionCombineMode.Set);
复制代码
回复 使用道具 举报
13573156105
注册会员   /  发表于:2019-1-15 15:57:39
8#
Richard.Ma 发表于 2019-1-15 14:11
请参考下面的代码,主要是用RectFromContainerCoordinates这个方法对坐标进行了转换,

非常感谢,祝您工作顺利!!!
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-1-15 16:20:45
9#
不客气,同祝工作顺利
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部