新手入门必看:VectorDraw 常见问题整理大全(三)
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。该库还支持许多矢量和栅格输入和输出格式,包括本地PDF和SVG导出。
【VectorDraw Developer Framework最新版下载】
VectorDraw web library (javascript)是一个矢量图形库。VectorDraw web library (javascript)不仅能打开CAD图纸,而且能显示任何支持HTML5标准平台上的通用矢量对象,如Windows,安卓,iOS和Linux。无需任何安装,VectorDraw web library (javascript)就可以运行在任何支持canvas标签和Javascript的主流浏览器(Chrome, Firefox, Safari, Opera, Dolphin, Boat等等)中。
【VectorDraw web library (javascript)最新版下载】
一. 使用vdScrolableControl获取实体并在vdPropertyGrid中显示其属性
问:如何使用vdScrolableControl获取实体并在vdPropertyGrid中显示其属性?
答:可以试试像这样的代码:
private void Form1_Load(object sender, EventArgs e)
{
AddLayoutEntities();
vdSC.BaseControl.vdMouseClick += new VectorDraw.Professional.Control.MouseClickEventHandler(BaseControl_vdMouseClick);
}
void BaseControl_vdMouseClick(MouseEventArgs e, ref bool cancel)
{
VectorDraw.Professional.vdPrimaries.vdFigure fig;
VectorDraw.Geometry.gPoint pt = vdSC.BaseControl.ActiveDocument.CursorPosCCS(e.Location);
VectorDraw.Geometry.gPoint p1 = vdSC.BaseControl.ActiveDocument.World2PixelMatrix.Transform(pt as VectorDraw.Geometry.gPoint);
Point location = new Point((int)p1.x, (int)p1.y);
fig = vdSC.BaseControl.ActiveDocument.ActiveLayOut.GetEntityFromPoint(location, vdSC.BaseControl.ActiveDocument.ActiveLayOut.Render.GlobalProperties.PickSize, false);
if (fig == null)
{
vdPGrid.SelectedObject = vdSC.BaseControl.ActiveDocument;
this.Text = "NO Entity clicked";
}
else
{
vdPGrid.SelectedObject = fig;
this.Text = "Entity clicked";
}
}
二. 读取附加到polyhatch对象的折线
问:如何读取附加到polyhatch对象的折线?
答:您可以从hatch(孵化)中获取vdCurves,如下所示。请注意,填充对象可能包含vdCircle,vdArc以及通常所有类型的vdCurves。孵化是vdPolyhatch对象。
foreach (VectorDraw.Professional.vdCollections.vdCurves var in hatch.PolyCurves)
{
foreach (VectorDraw.Professional.vdFigures.vdCurve var1 in var)
{
VectorDraw.Professional.vdFigures.vdPolyline poly1 = var1 as VectorDraw.Professional.vdFigures.vdPolyline;
if (poly1 != null) MessageBox.Show("Found Polyline");
}
}
三. 重写VectorDrawBaseControl的DrawBackground事件
问:如何重写VectorDrawBaseControl的DrawBackground事件,以便将Image绘制到Background?
答:以下示例覆盖VectorDrawBaseControl的DrawBackground和vdScroll事件,以便在rendermode is Wire2d时将图像绘制为背景。
Bitmap m_Bitmap;
private void Form1_Load(object sender, EventArgs e)
{
vdFramedControl.BaseControl.DrawBackground += new VectorDraw.Professional.Control.DrawBackgroundEventHandler(BaseControl_DrawBackground);
vdFramedControl.BaseControl.vdScroll += new VectorDraw.Professional.Control.ScrollEventHandler(BaseControl_vdScroll);
//create a bitmap object at runtime
m_Bitmap = new Bitmap(vdFramedControl.BaseControl.Size.Width, vdFramedControl.BaseControl.Size.Height);
Graphics g = Graphics.FromImage(m_Bitmap);
g.Clear(vdFramedControl.BaseControl.ActiveDocument.Palette.Background);
g.DrawString("VDraw", SystemFonts.DefaultFont, Brushes.Red, new PointF(vdFramedControl.BaseControl.Size.Width / 2, vdFramedControl.BaseControl.Size.Height/2));
g.Dispose();
}
//override the vdScroll event in order the pan and scroll draw the background properly.
void BaseControl_vdScroll(object sender, ref double cx, ref double cy, ref bool cancel)
{
vdRender render = sender as vdRender;
render.ViewCenter += new gPoint(cx, cy);
vdFramedControl.BaseControl.ActiveDocument.Redraw(false);
}
void BaseControl_DrawBackground(object sender, VectorDraw.Render.vdRender render, ref bool cancel)
{
System.Diagnostics.Debug.WriteLine("DrawBackground");
if (m_Bitmap == null) return;
if (!render.IsWire2d) return;//the following code is working only when 3d render is not active
render.UnLock();
Graphics g = render.graphics;
if (g == null) return;
g.Clear(render.BkColor);
g.DrawImage(m_Bitmap, new Point(0, 0));
g.DrawLine(Pens.Red, new Point(0, 0), new Point(render.Width, render.Height));
render.Lock();
cancel = true;
}

QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线