Example #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);
        }
Example #2
0
        // load nest task from task file.
        static public NestTaskEx LoadNestTask_from_taskFile(String strFilePath, List <KeyValuePair <long, string> > partDxfPath, List <KeyValuePair <long, string> > matDxfPath,
                                                            Dictionary <long, int> partColorConfig, ImpDataListEx impDataList, ref int iNestingTime)
        {
            NestTaskEx nestTask = new NestTaskEx();

            // load the task file.
            XmlDocument  xmlDocument = new XmlDocument();
            StreamReader reader      = new StreamReader(strFilePath, Encoding.UTF8);

            xmlDocument.Load(reader);

            // the version.
            XmlNode taskNode     = xmlDocument.SelectSingleNode("NestTask");
            int     iTaskVersion = Convert.ToInt32(taskNode.Attributes["taskVersion"].Value);

            if (iTaskVersion == TASK_VERSION_1)
            {
                // load param.
                XmlNode     paramNode = taskNode.SelectSingleNode("Param");
                NestParamEx nestParam = LoadNestParam_V1(paramNode, ref iNestingTime);
                nestTask.SetNestParam(nestParam);

                // load nest part info.
                XmlNode        partListNode = taskNode.SelectSingleNode("PartList");
                NestPartListEx nestParts    = LoadNestParts_V1(strFilePath, partListNode, partDxfPath, impDataList, partColorConfig);
                nestTask.SetNestPartList(nestParts);

                // load material info.
                XmlNode   matListNode = taskNode.SelectSingleNode("MaterialList");
                MatListEx mats        = LoadMats_V1(strFilePath, matListNode, matDxfPath, nestParam);
                nestTask.SetMatList(mats);
            }

            return(nestTask);
        }
Example #3
0
        private void saveTaskBtn_Click(object sender, EventArgs e)
        {
            // check.
            if (m_nestPartList.Size() == 0)
            {
                MessageBox.Show("No part will be nested.", "NestProfessor DEMO");
                return;
            }
            if (m_matList.Size() == 0)
            {
                MessageBox.Show("No material will be used for nesting.", "NestProfessor DEMO");
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "Task File|*.xml";
            saveFileDialog.RestoreDirectory = true;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                String     strFilePath = saveFileDialog.FileName;
                NestTaskEx nestTask    = new NestTaskEx(m_nestPartList, m_matList, m_nestParam);
                TaskStorage.SaveNestTask(strFilePath, nestTask, m_partDxfPath, m_partColorConfig, m_matDxfPath, m_iNestingTime);
            }
        }
Example #4
0
        private void executeBtn_Click(object sender, EventArgs e)
        {
            // check
            if (m_nestPartList.Size() == 0)
            {
                MessageBox.Show("没有需要排版的零件!!!");
                return;
            }
            if (m_matList.Size() == 0)
            {
                MessageBox.Show("没有需要排版的材料!!!");
                return;
            }

            // create nest task object and execute it.
            NestTaskEx      nestTask      = new NestTaskEx(m_nestPartList, m_matList, m_nestParam);
            NestProcessorEx nestProcessor = NestFacadeEx.StartNest(nestTask);

            if (nestProcessor == null)
            {
                //MessageBox.Show("Cannot start the nesting task, please contact TAOSoft and check your license.");
                MessageBox.Show("没有排版的结果,请联系技术人员!!!");
                return;
            }

            // display the nesting result.
            NestResultForm form = new NestResultForm(nestTask, m_nestParam, nestProcessor, m_iNestingTime, m_impDataList, m_partColorConfig);

            form.ShowDialog();
        }
Example #5
0
        public NestResultForm(NestTaskEx nestTask, NestParamEx nestParam, NestProcessorEx nestProcessor, int iNestingTime, ImpDataListEx impDataList, Dictionary <long, int> partColorConfig)
        {
            m_nestTask        = nestTask;
            m_nestParam       = nestParam;
            m_nestProcessor   = nestProcessor;
            m_iNestingTime    = iNestingTime;
            m_impDataList     = impDataList;
            m_partColorConfig = partColorConfig;

            InitializeComponent();
        }
Example #6
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();
            }
        }