示例#1
0
        // save the nest task to file.
        static public void SaveNestTask(String strFilePath, NestTaskEx nestTask, List <KeyValuePair <long, string> > partDxfPath,
                                        Dictionary <long, int> partColorConfig, List <KeyValuePair <long, string> > matDxfPath, int iNestingTime)
        {
            XmlDocument xmlDoc = new XmlDocument();

            // the task node.
            XmlElement   taskNode         = xmlDoc.CreateElement("NestTask");
            XmlAttribute versionAttribute = xmlDoc.CreateAttribute("taskVersion");

            versionAttribute.Value = TASK_VERSION_1.ToString();
            taskNode.Attributes.Append(versionAttribute);
            xmlDoc.AppendChild(taskNode);

            // save part info.
            XmlElement partListNode = xmlDoc.CreateElement("PartList");

            taskNode.AppendChild(partListNode);
            SaveNestParts(xmlDoc, partListNode, nestTask.GetNestPartList(), partDxfPath, partColorConfig);

            // save material info.
            XmlElement matListNode = xmlDoc.CreateElement("MaterialList");

            taskNode.AppendChild(matListNode);
            SaveMats(xmlDoc, matListNode, nestTask.GetMatList(), matDxfPath);

            // save param info.
            XmlElement paramNode = xmlDoc.CreateElement("Param");

            taskNode.AppendChild(paramNode);
            SaveNestParam(xmlDoc, paramNode, nestTask.GetNestParam(), iNestingTime);

            xmlDoc.Save(strFilePath);
        }
示例#2
0
 private void remMatBtn_Click(object sender, EventArgs e)
 {
     ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
     if (selItems.Count != 1)
     {
         MessageBox.Show("Please select one sheet.", "NestProfessor DEMO");
         return;
     }
     else
     {
         ListViewItem item     = selItems[0];
         long         iSheetID = (long)item.Tag;
         SheetEx      sheet    = m_sheetList.GetSheetByID(iSheetID);
         if (sheet != null)
         {
             RemnantMatInfoForm form = new RemnantMatInfoForm(sheet, m_nestTask.GetNestParam().GetConTol());
             form.ShowDialog();
         }
     }
 }
示例#3
0
        private void loadTaskBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "Task Files|*.xml";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                String     strFilePath = openFileDialog.FileName;
                NestTaskEx nestTask    = TaskStorage.LoadNestTask_from_taskFile(strFilePath, m_partDxfPath, m_matDxfPath, m_partColorConfig, m_impDataList, ref m_iNestingTime);
                m_nestParam = nestTask.GetNestParam();

                // disable select-change event.
                m_bDisableSelChgEvent = true;

                // clean list.
                partListView.Items.Clear();
                matListView.Items.Clear();

                // init part list.
                {
                    m_nestPartList = nestTask.GetNestPartList();
                    for (int i = 0; i < m_nestPartList.Size(); i++)
                    {
                        AddPart_to_listCtrl(m_nestPartList.GetNestPartByIndex(i), "");
                    }

                    // select the last row.
                    if (partListView.Items.Count > 0)
                    {
                        partListView.SelectedItems.Clear();
                        partListView.Items[partListView.Items.Count - 1].Selected = true;
                        partListView.Items[partListView.Items.Count - 1].Focused  = true;
                        partListView.Items[partListView.Items.Count - 1].EnsureVisible();
                    }
                }

                // init material.
                {
                    m_matList = nestTask.GetMatList();
                    for (int i = 0; i < m_matList.Size(); i++)
                    {
                        AddMat(m_matList.GetMatByIndex(i));
                    }
                }

                // enable select-change event.
                m_bDisableSelChgEvent = false;

                Preview_selected_part();
                Preview_selected_material();
            }
        }