当VectorDraw的cmdPolyline激活时如何使用撤销功能

如题所述

慧都专家答案当cmdPolyline激活时,ActionStart and ActionEnd事件要用来设置一个公共的flag,同时还需要一个vdKeyDown事件用于调用PostCommandActionString "U",请看下面的代码: vdDocument doc; // the vdDocument bool is_on_cmdPolyline = false; // a public on the form flag private void Form1_Load(object sender, EventArgs e) { doc = vdFramedControl1.BaseControl.ActiveDocument; //requireded events ! doc.ActionEnd+=new vdDocument.ActionEndEventHandler(doc_ActionEnd); doc.ActionStart +=new vdDocument.ActionStartEventHandler(doc_ActionStart); vdFramedControl1.BaseControl.vdKeyDown += new VectorDraw.Professional.Control.KeyDownEventHandler(BaseControl_vdKeyDown); } void BaseControl_vdKeyDown(KeyEventArgs e, ref bool cancel) { if (!is_on_cmdPolyline) return; // not in cmdPolyline, then retun if (e.Control && e.KeyCode == Keys.Z) { // do the Undo in the last segment doc.PostCommandActionString(vdFramedControl1.BaseControl, "U"); //this.Text = this.Text + " ctrl+z pressed "; // for debugging } } void doc_ActionStart(object sender, string actionName, ref bool cancel) { if (actionName == "CmdPolyLine") { is_on_cmdPolyline = true; // this.Text = " cmdPolyLine started "; // for debug reasons } } void doc_ActionEnd(object sender, string actionName) { if (actionName == "CmdPolyLine") { is_on_cmdPolyline=false; // this.Text = this.Text + "- cmdPolyLine finished"; // for debugging } } private void button1_Click(object sender, EventArgs e) { doc.CommandAction.CmdPolyLine(null); }
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜