VDF常见问题整理(二十四):如何像插入块对话框中那样获得vdBlock的图像预览?

VectorDraw Developer Framework试用版下载


    点开本篇文章,是否对矢量图形工具感兴趣呢看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!

问:

    我如何像插入块对话框中那样获得vdBlock的图像预览/p>

答:

    vdBlocks内部不包含它们的预览,因此您需要使用vdRender快速创建一个。

    在表单中添加一个vdFramed / vdScrollable / vdBase控件,一个按钮和一个图片框,打开一个图形并尝试如下代码:

     private void button1_Click(object sender, EventArgs e)        {            doc = vdFramedControl1.BaseControl.ActiveDocument;            vdBlock blk = doc.Blocks.FindName("VDDIM_DEFAULT"); // try here some block names that exist in the drawing you opened            if (blk == null) return; // block not found             // imgblock is a picturebox  private System.Windows.Forms.PictureBox imgblock; added to the form            int blockwid = imgblock.Width;            int blockhei = imgblock.Height;            Bitmap image = new Bitmap(blockwid, blockhei);            VectorDraw.Render.vdRender rend = new VectorDraw.Render.GDIPlusRender(null);            rend.graphics = Graphics.FromImage(image);            rend.UpperLeft = new Point(0, 0);            rend.Width = blockwid;            rend.Height = blockhei;            rend.ViewSize = blockhei;            rend.ViewCenter = new VectorDraw.Geometry.gPoint((double)rend.Width / 2.0d, (double)rend.Height / 2.0d);            rend.Init();            rend.StartDraw(false);            rend.Clear(doc.Palette.Background);            VectorDraw.Render.vdGdiPenStyle ps = new VectorDraw.Render.vdGdiPenStyle();            ps.LineType = doc.LineTypes.Solid.GetgrLineType();            ps.color = Color.Black;            rend.PushPenstyle(ps);            vdInsert ins = new vdInsert();            ins.SetUnRegisterDocument(doc);            ins.setDocumentDefaults();            ins.Block = blk;            double hei = ins.BoundingBox.Height;            double wid = ins.BoundingBox.Width;            double max = Math.Max(hei, wid);            double min = Math.Min(hei, wid);            ins.InsertionPoint = new VectorDraw.Geometry.gPoint(0.0d, 0.0d, 0.0d);            rend.ViewSize = max * 5.0 / 4.0;            rend.ViewCenter = new VectorDraw.Geometry.gPoint(ins.BoundingBox.MidPoint);            ins.Update();            ins.Draw(rend);            rend.PopPenstyle();            rend.EndDraw();            rend.graphics.Dispose();            rend.graphics = null;            imgblock.Image = image;        }

    对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。

相关资料推荐:

  • 如何排除GroundSurface对象的三角形区域/strong>

  • 复杂自定义对象的入门指南

  • 点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!


    如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年9月8日
下一篇 2019年9月8日

相关推荐

发表回复

登录后才能评论