Esempio n. 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);
        }
Esempio n. 2
0
        private void buttOk_Click(object sender, EventArgs e)
        {
            Part           workPart  = Session.GetSession().Parts.Work;
            PartPost       post      = new PartPost(workPart);
            List <NCGroup> postGroup = new List <NCGroup>();

            if (buttonShopdoc.Text.Equals("产生工单"))
            {
                CreatePostExcel excel = new CreatePostExcel(groups, workPart);
                excel.CreateExcel();
            }
            if (buttonPost.Text == "后处理")
            {
                for (int i = 0; i < listViewProgram.Items.Count; i++)
                {
                    if (listViewProgram.Items[i].Checked)
                    {
                        postGroup.Add(groups[i]);
                    }
                }

                if (this.listBoxPostName.SelectedItem.ToString().Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
                {
                    string[] name = post.GetElectrodePostName(groups);
                    foreach (string str in name)
                    {
                        post.Post(str, postGroup.ToArray());
                    }
                }
                else
                {
                    post.Post(this.listBoxPostName.SelectedItem.ToString(), postGroup.ToArray());
                }
            }

            this.Close();
        }