回复 21楼wjy72的帖子
抱歉,由于不了解您的上下文环境所以给出的技术方案不符合。
通过21#代码添加注释需要通过以下代码进行修改文本:
- AnnTextObject AnnTxt;
- public void addTextToImage(string addText, LeadRect lr, double fontSize)
- {
- LeadRectD dest = new LeadRectD(this.imageViewer1.Image.Width - 120, this.imageViewer1.Image.Height - 80, 1000, 500);
- AnnTxt = new AnnTextObject();
- AnnTxt.Stroke = null;//没有边框
- AnnTxt.Text = addText;
- AnnTxt.Font = new AnnFont("Arial", fontSize);
- AnnTxt.Fill = null;
- AnnTxt.Rect = dest;
- AnnTxt.TextForeground = AnnSolidColorBrush.Create("Black");
- AnnTxt.IsSelected = true;
- Automation.Container.Children.Add(AnnTxt);
- Automation.Invalidate(LeadRectD.Empty);
- Automation.SelectObject(AnnTxt);
- Leadtools.Annotations.AnnPoint AnnPt = new Leadtools.Annotations.AnnPoint((float)(this.imageViewer1.Image.Width - 120), (float)(this.imageViewer1.Image.Height - 80), Leadtools.Annotations.AnnUnit.Pixel);
- TextBox txt = new TextBox();
- txt.Location = new Point(1000,500);
- txt.Leave += txt_Leave;
- txt.Multiline = true;
- txt.Parent = this.imageViewer1;
- txt.Text = AnnTxt.Text;
- txt.SetBounds((int)(AnnTxt.Bounds.X), (int)(AnnTxt.Bounds.Y), (int)(AnnTxt.Bounds.Width), (int)(AnnTxt.Bounds.Height));
- txt.Show();
- txt.Focus();
- }
- void txt_Leave(object sender, EventArgs e)
- {
- TextBox txt= sender as TextBox;
- AnnTxt.Text = txt.Text;
- txt.Dispose();
- }
复制代码
在 Viewer 中添加一个textbox,进行编辑。 |