新手入門必看:VectorDraw 常見問題整理大全(十九)
VectorDraw Developer Framework(VDF)是一個(gè)用于應(yīng)用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。該庫還支持許多矢量和柵格輸入和輸出格式,包括本地PDF和SVG導(dǎo)出。
【VectorDraw Developer Framework最新版下載】
VectorDraw web library (javascript)是一個(gè)矢量圖形庫。VectorDraw web library (javascript)不僅能打開CAD圖紙,而且能顯示任何支持HTML5標(biāo)準(zhǔn)平臺(tái)上的通用矢量對(duì)象,如Windows,安卓,iOS和Linux。無需任何安裝,VectorDraw web library (javascript)就可以運(yùn)行在任何支持canvas標(biāo)簽和Javascript的主流瀏覽器(Chrome, Firefox, Safari, Opera, Dolphin, Boat等等)中。
【VectorDraw web library (javascript)最新版下載】
一. 通過單擊一個(gè)來選擇多個(gè)連續(xù)實(shí)體的方法
問:請(qǐng)問可以通過單擊一個(gè)來選擇多個(gè)連續(xù)實(shí)體的方法是什么?
答:由于圖中的實(shí)體沒有完全相互持續(xù),并且其中一些實(shí)體存在一個(gè)小的“間隙”,因此你需要使用如下所示代碼:
vdFigure fig; gPoint pt; doc.Prompt("select a curve"); doc.ActionUtility.getUserEntity(out fig,out pt); doc.Prompt(null); vdCurve curve = fig as vdCurve; if(curve == null) return; gPoint sp = curve.getStartPoint(); gPoint ep = curve.getEndPoint(); vdSelection set = new vdSelection(); set.SetUnRegisterDocument(doc); set.AddItem(curve, true, vdSelection.AddItemCheck.RemoveInVisibleEntities); double equality = 0.01; int pos = 0; while (pos < set.Count && sp != null && ep != null) { gPoints pts = new gPoints(); pts.Add((sp - new gPoint(equality, equality))); pts.Add((sp + new gPoint(equality, equality))); set.Select(RenderSelect.SelectingMode.CrossingWindowRectangle, pts); pts = new gPoints(); pts.Add((ep - new gPoint(equality, equality))); pts.Add((ep + new gPoint(equality, equality))); set.Select(RenderSelect.SelectingMode.CrossingWindowRectangle, pts); pos++; sp = null; ep = null; for (int i = pos; i < set.Count; i++) { curve = set[i] as vdCurve; if (curve != null) { sp = curve.getStartPoint(); ep = curve.getEndPoint(); break; } pos++; } } doc.UndoHistory.StoreUndoGroup(true); foreach (vdFigure ent in set) { ent.PenColor = new vdColor(Color.Blue); ent.LineWeight = VectorDraw.Professional.Constants.VdConstLineWeight.LW_120; } doc.UndoHistory.StoreUndoGroup(false); set.Invalidate();
二. 使命令的行文本框接受空格鍵為enter
問:當(dāng)我按下回車鍵并按空格鍵時(shí),我想使命令行的行為相同。
答:你需要使用Command的行userText框事件KeyDown,并在按下空格時(shí)向其發(fā)送一條輸入消息,如下代碼所示:
void UserText_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) { VectorDraw.WinMessages.MessageManager.MSG m = new VectorDraw.WinMessages.MessageManager.MSG(); m.hwnd = vdFramedControl1.CommandLine.UserText.Handle; m.lParam = IntPtr.Zero; m.message = (int)VectorDraw.WinMessages.MessageManager.Messages.WM_KEYDOWN; m.wParam = (IntPtr)Keys.Enter; VectorDraw.WinMessages.MessageManager.TranslateMessage(ref m); VectorDraw.WinMessages.MessageManager.DispatchMessage(ref m); } } private void Form1_Load(object sender, EventArgs e) { vdFramedControl1.CommandLine.UserText.KeyDown += new KeyEventHandler(UserText_KeyDown); }
三. 在cmdText啟動(dòng)之前設(shè)置文本的高度
問:文檔的全局/默認(rèn)文本高度是否存在?我想要這個(gè),因?yàn)楫?dāng)我想從用戶輸入高度值時(shí),它在用戶創(chuàng)建此vdtext時(shí)不會(huì)影響當(dāng)前的vdtext。當(dāng)用戶按照你在先前郵件中的建議完成命令時(shí),高度會(huì)生效。但我希望用戶在撰寫文本時(shí)可以看到新的高度。
答:你可以在cmdText啟動(dòng)之前設(shè)置文本的高度。請(qǐng)參閱下面的代碼和備注:
private void button3_Click(object sender, EventArgs e) { vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument; doc.New(); cmdTextWithHeight(doc, null, null, null, 5.0); cmdTextWithHeight(doc, "VDF version6", new gPoint(30,30), null, 15.0); cmdTextWithHeight(doc, null, new gPoint(10,10), 0.0d, 25.0); cmdTextWithHeight(doc, "hi", null, 30.0, 35.0); } private bool cmdTextWithHeight(vdDocument document, object TextString, object InsertionPoint, object RotationAngle, double TextHeight) { bool ret = false; double oldheight = document.ActiveTextStyle.Height; // store the old value to set this back after this finishes document.ActiveTextStyle.Height = TextHeight;// set the Height that is needed to activetextstyle if (document.CommandAction.CmdText(TextString, InsertionPoint, RotationAngle)) { vdText txt = document.ActiveLayOut.Entities[document.ActiveLayOut.Entities.Count - 1] as vdText; // get the text that was just created if (txt != null) { //... do other things there with the just-created-vdText if you like !! txt.Height = TextHeight; // see it to the Height so evene if activeTextStyle changes this remains. ret = true; } } document.ActiveTextStyle.Height = oldheight; // set the original value back. return ret; }
未完待續(xù)~
熱門活動(dòng)
*點(diǎn)擊圖片查看活動(dòng)詳情*