private void selectButton_Click(object sender, EventArgs e) { if (xdata != null) { xdata.UpdateXData(); } //SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle); this.Visible = false; this.Hide();//先隐藏窗体 PromptEntityOptions prEnt = new PromptEntityOptions("\n请选择一个实体 "); PromptEntityResult prEntRes = Tools.Editor.GetEntity(prEnt); if (prEntRes.Status != PromptStatus.OK) { this.Visible = true; this.Show(); return; } if (xdata == null || xdata.Id != prEntRes.ObjectId) { xdata = new XData(prEntRes.ObjectId); updateData(); } this.Visible = true; this.Show(); //SetFocus(this.Handle); }
public xdataForm(XData xd) { InitializeComponent(); this.xdataListView.AddEditableCell(-1, 0); this.xdataListView.AddEditableCell(-1, 1); this.xdataListView.AddSubItem = true; xdata = xd; if (xdata != null) { updateData(); } }
public AddParamsForm(XData xdata)//必须保证xdata!=null(在外部保证) { this.xdata = xdata; InitializeComponent(); }
public addNewXDataForm(XData xdata) { this.xdata = xdata; InitializeComponent(); }
private void selectButton_Click(object sender, EventArgs e) { if (xdata != null) { if (xdata.HasXData()) { if (!xdata.IsXDataUpdate) { DialogResult res = MessageBox.Show("请确认是否保存数据?", "保存数据", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { checkChanged();//检查修改,并更新 xdata.UpdateXData(); appNamesComboBox.Items.Clear(); xdataListView.Items.Clear(); appNamesComboBox.Text = null; } } } //xdata.UpdateXData(); } //TestPalettes.SetPaletteFocus(false); SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle); PromptEntityOptions prEnt = new PromptEntityOptions("\n请选择一个实体 "); PromptEntityResult prEntRes = Tools.Editor.GetEntity(prEnt); if (prEntRes.Status != PromptStatus.OK) { return; } //TestPalettes.SetPaletteFocus(true); if (xdata == null || xdata.Id != prEntRes.ObjectId) { appNamesComboBox.Items.Clear(); xdataListView.Items.Clear(); appNamesComboBox.Text = null; xdata = new XData(prEntRes.ObjectId); updateData(); MessageBox.Show("该实体没有扩展数据,请注册应用程序名称"); } SetFocus(TestPalettes.ps.Handle); }
static public void createNewXData(string appName, ref XData xdata) { string param = null; string value = null; bool isUserCancel = false; Tools.WriteMessage("\n创建新的扩展数据!!!至少需要2个数据项\n"); isUserCancel = getParams(ref param, ref value); if (!isUserCancel) { Tools.WriteMessage("\n用户取消操作\n"); return; } xdata.CreateXData(appName, param, value);//创建一个新的扩展数据 }
static public void getxdata() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId id = SelectEntity();//选择实体 if (id == ObjectId.Null) { ed.WriteMessage("\n用户取消操作\n"); return; } XData xdata = new XData(id); if (!xdata.HasXData()) { Tools.WriteMessage("\n该实体不存在扩展数据\n"); return; } string appName = getAppName();//获取appname if (appName == null) { ed.WriteMessage("\n用户取消操作\n"); return; } if (!XData.IsAppExist(appName)) { Tools.WriteMessage("\n该应用程序名对应的扩展数据不存在\n"); return; } xdata.PrintXData(appName); }
static public void delallxdata() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId id = SelectEntity();//选择实体 if (id == ObjectId.Null) { ed.WriteMessage("\n用户取消操作\n"); return; } XData xdata = new XData(id); if (!xdata.HasXData()) { Tools.WriteMessage("\n该实体不存在扩展数据\n"); return; } xdata.ClearAllXData(); xdata.UpdateXData(); }
static public void addxdata() { bool isCreateNewXdata = false; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId id = SelectEntity();//选择实体 if (id == ObjectId.Null) { ed.WriteMessage("\n用户取消操作\n"); return; } XData xdata = new XData(id); if (!xdata.HasXData()) { Tools.WriteMessage("\n该实体不存在扩展数据\n"); isCreateNewXdata = AskForCreateXData(); if (!isCreateNewXdata) { Tools.WriteMessage("\n用户选择不创建新的扩展数据,程序结束\n"); return; } Tools.WriteMessage("\n下面的操作将会创建新的扩展数据\n"); } string appName = getAppName();//获取appname if (appName == null) { ed.WriteMessage("\n用户取消操作\n"); return; } string param = null; string value = null; bool isUserCancel = false; if (!XData.IsAppExist(appName)) { Tools.WriteMessage("\n该应用程序名对应的扩展数据不存在\n"); Tools.WriteMessage("\n下面的操作将会注册该应用程序名称,并添加一个新的扩展数据\n"); XData.RegisterApp(appName); } createNewXData(appName, ref xdata);//不管appname存在与否,调用cretaenewxdata都不会产生任何的问题 xdata.setCurrentAppName(appName);//设置当前appname //重复循环,让用户输入扩展数据的参数和值 Tools.WriteMessage("\n继续添加数据\n"); isUserCancel = true; param = null; value = null; while (isUserCancel) { isUserCancel = getParams(ref param, ref value); if (param != null && value != null) { xdata.AddXData(param, value);//添加扩展数据,成对添加 } } xdata.UpdateXData(); }
static public void printxdata() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId id = SelectEntity();//选择实体 if (id == ObjectId.Null) { ed.WriteMessage("\n用户取消操作\n"); return; } XData xdata = new XData(id); if (!xdata.HasXData()) { Tools.WriteMessage("\n该实体不存在扩展数据\n"); return; } bool isPrintAllXData = AskForPrintAllXData(); if (isPrintAllXData) { xdata.PrintXDataList(); } else { string appName = getAppName();//获取appname if (appName == null) { ed.WriteMessage("\n用户取消操作\n"); return; } xdata.PrintXData(appName); } }