DCAgile 发表于 2015-9-22 17:05:00

TX Text Control添加图片间隔

使用如下代码实现图片添加:
      string FilePath1 = Application.StartupPath + "\\Image\\1.png";
      string FilePath2 = Application.StartupPath + "\\Image\\2.png";
      string FilePath3 = Application.StartupPath + "\\Image\\3.png";
      string FilePath4 = Application.StartupPath + "\\Image\\4.png";

private void AddImage()
      {
            System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath1);
            System.Drawing.Image img2 = System.Drawing.Image.FromFile(FilePath2);
            System.Drawing.Image img3 = System.Drawing.Image.FromFile(FilePath3);
            System.Drawing.Image img4 = System.Drawing.Image.FromFile(FilePath4);

            List<System.Drawing.Image> list = new List<System.Drawing.Image>();
            list.Add(img);
            list.Add(img2);
            list.Add(img3);
            list.Add(img4);

            for (int i = 0; i < list.Count; i++)
            {
                System.Drawing.Image thumbImage = list.GetThumbnailImage(200, 200, null, System.IntPtr.Zero);
                TXTextControl.Image image = new TXTextControl.Image(thumbImage);
                textControl1.Images.Add(image, textControl1.InputPosition.TextPosition);
            }
      }

问题:1.如何为每张图片添加间隔??效果如下所示:

iceman 发表于 2015-9-22 18:07:00

回复 1楼DCAgile的帖子

实现代码如下:

            System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath1);
            System.Drawing.Image img2 = System.Drawing.Image.FromFile(FilePath2);
            System.Drawing.Image img3 = System.Drawing.Image.FromFile(FilePath3);
            System.Drawing.Image img4 = System.Drawing.Image.FromFile(FilePath4);

            List<System.Drawing.Image> list = new List<System.Drawing.Image>();
            list.Add(img);
            list.Add(img2);
            list.Add(img3);
            list.Add(img4);

            for (int i = 0; i < list.Count; i++)
            {
                //System.Drawing.Image thumbImage = list.GetThumbnailImage(200, 200, null, System.IntPtr.Zero);
                TXTextControl.Image image = new TXTextControl.Image(list);
                textControl1.Images.Add(image, textControl1.InputPosition.TextPosition);
                this.textControl1.Select(this.textControl1.Text.Length, 0);
                this.textControl1.Selection.Text = "    ";
            }


为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
http://gcdn.gcpowertools.com.cn/attachment.aspx?attachmentid=10062

DCAgile 发表于 2015-9-24 09:59:00

如何控制Tx Control中一行(一个段落)中显示图片的个数以及对其方式

回复 2楼iceman的帖子

问题:

1.如何控制在Tx Control一行中加载图片的个数? (例如如下图中一行只能加载三张图片)
      
2.如何控制加载图片后的对其方式?(例如如下图中——居中对其)

iceman 发表于 2015-9-24 11:19:00

回复 3楼DCAgile的帖子

建议通过Table来布局,在单元格中插入图片。请您想尝试,有后续问题我们再讨论。

DCAgile 发表于 2015-9-25 11:22:00

回复 4楼iceman的帖子

问题:
1.TX Control中添加Table——Id设置是否有什么限制(设置为1、2出错)?

2.如何设置Table的边框、对其方式、单元格高度(通过编码的方式)?

iceman 发表于 2015-9-25 12:29:00

回复 5楼DCAgile的帖子

TableID从 11开始设置,需要大于10。
Table边框可以通过以下代码隐藏:

            this.textControl1.Tables.GridLines = false;


对齐方式需要单元格逐个设置:

private void setBorderToolStripMenuItem_Click(object sender, EventArgs e)
      {
            Table tb = this.textControl1.Tables.GetItem(12);
            

            foreach (TableCell cell in this.textControl1.Tables.GetItem(12).Cells)
            {
                cell.CellFormat.VerticalAlignment = VerticalAlignment.Top;
            }
      }


单元格左右对齐方式需要通过 ParagraphFormat.Alignment 属性来设置。

DCAgile 发表于 2015-9-25 14:14:00

回复 6楼iceman的帖子

问题:
1.单元格左右对齐方式需要通过 ParagraphFormat.Alignment 属性来设置。
和你电话沟通,说需通过Selection选中当前行,进行设置,还是不太清楚 怎么获取,,

具体应该怎么操作??

DCAgile 发表于 2015-9-25 14:55:00

回复 7楼DCAgile的帖子

不用回了 问题已解决

iceman 发表于 2015-9-25 15:17:00

回复 8楼DCAgile的帖子

设置Border测试代码如下:

      private void Form1_Load(object sender, EventArgs e)
      {
            this.textControl1.Tables.Add(10, 10, 11);
            this.textControl1.Selection.Text = &quot;\n\n\n\n&quot;;
            this.textControl1.Tables.Add(10, 10, 12);
            this.textControl1.Tables.GridLines = false;
      }

      private void setBorderToolStripMenuItem_Click(object sender, EventArgs e)
      {
            Table tb = this.textControl1.Tables.GetItem(11);
            

            foreach (TableCell cell in this.textControl1.Tables.GetItem(11).Cells)
            {
                cell.CellFormat.TopBorderWidth = 20;
                cell.CellFormat.LeftBorderWidth= 20;
                cell.CellFormat.RightBorderWidth = 20;
                cell.CellFormat.BottomBorderWidth = 20;
            }
      }

DCAgile 发表于 2015-9-25 16:14:00

回复 9楼iceman的帖子

这种方式只适用于使用代码添加的表格,对于创建模版添加的表格无法操作
页: [1] 2
查看完整版本: TX Text Control添加图片间隔