示例#1
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                List <string> newFileName = new List <string>();
                if (file.Path == "")
                {
                    theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请指定文件位置");
                    return(1);
                }
                foreach (Node node in treeElectrode.GetSelectedNodes())
                {
                    ElectrodeModel model = assemble.Electrodes.Find(a => node.Equals(a.Node));
                    if (model != null)
                    {
                        ExportFile path = new ExportFile(model);
                        string     temp = path.NewFile(file.Path);
                        newFileName.Add(temp);
                        model.PartTag.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null);
                        Part newPart = PartUtils.OpenPartFile(temp);
                        PartUtils.SetPartDisplay(newPart);
                        if (this.toggleShops.Value && IsPartProgram(newPart))
                        {
                            PartPost        elePost = new PartPost(newPart);
                            List <NCGroup>  groups  = elePost.GetGroup();
                            CreatePostExcel excel   = new CreatePostExcel(groups, newPart);
                            excel.CreateExcel();
                            string[] name = elePost.GetElectrodePostName(groups);
                            foreach (string str in name)
                            {
                                elePost.Post(str, groups.ToArray());
                            }
                        }
                        newPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False);
                    }
                }
                foreach (Part part in theSession.Parts)//关闭其他
                {
                    string type = AttributeUtils.GetAttrForString(part, "PartType");
                    if (!type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
                    {
                        part.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null);
                    }
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }