Пример #1
0
        static private NestParamEx LoadNestParam_V1(XmlNode paramNode, ref int iNestingTime)
        {
            NestParamEx nestParam = new NestParamEx();

            // MatLeftMargin.
            nestParam.SetMatLeftMargin(Convert.ToDouble(paramNode.SelectSingleNode("MatLeftMargin").InnerText));

            // MatRightMargin.
            nestParam.SetMatRightMargin(Convert.ToDouble(paramNode.SelectSingleNode("MatRightMargin").InnerText));

            // MatTopMargin.
            nestParam.SetMatTopMargin(Convert.ToDouble(paramNode.SelectSingleNode("MatTopMargin").InnerText));

            // MatBottomMargin.
            nestParam.SetMatBottomMargin(Convert.ToDouble(paramNode.SelectSingleNode("MatBottomMargin").InnerText));

            // MatBottomMargin.
            nestParam.SetMatMargin(Convert.ToDouble(paramNode.SelectSingleNode("MatMargin").InnerText));

            // PartDis.
            nestParam.SetPartDis(Convert.ToDouble(paramNode.SelectSingleNode("PartDis").InnerText));

            // ConTol.
            nestParam.SetConTol(Convert.ToDouble(paramNode.SelectSingleNode("ConTol").InnerText));

            // PartRotStep.
            nestParam.SetPartRotStep(Convert.ToDouble(paramNode.SelectSingleNode("PartRotStep").InnerText));

            // StartCorner.
            nestParam.SetStartCorner((RECT_CORNER_EX)Convert.ToInt32(paramNode.SelectSingleNode("StartCorner").InnerText));

            // NestDir.
            nestParam.SetNestDir((NEST_DIRECTION_EX)Convert.ToInt32(paramNode.SelectSingleNode("NestDir").InnerText));

            // PartInPart.
            if (Convert.ToInt32(paramNode.SelectSingleNode("PartInPart").InnerText) == 1)
            {
                nestParam.IsPartInPart(true);
            }
            else if (Convert.ToInt32(paramNode.SelectSingleNode("PartInPart").InnerText) == 0)
            {
                nestParam.IsPartInPart(false);
            }

            // EvalFactor.
            nestParam.SetEvalFactor(Convert.ToInt32(paramNode.SelectSingleNode("EvalFactor").InnerText));

            // nesting time.
            iNestingTime = Convert.ToInt32(paramNode.SelectSingleNode("NestingTime").InnerText);

            return(nestParam);
        }
Пример #2
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            // verify input.
            try
            {
                Convert.ToDouble(topTextBox.Text);
                Convert.ToDouble(bottomTextBox.Text);
                Convert.ToDouble(leftTextBox.Text);
                Convert.ToDouble(rightTextBox.Text);
                Convert.ToDouble(marginTextBox.Text);
                Convert.ToDouble(spaceTextBox.Text);
            }
            catch (FormatException exception)
            {
                MessageBox.Show("输入的参数不合法: " + exception.Message, "排版参数");
                return;
            }

            ConfigEntity config = new ConfigEntity();

            config.ConfigName = tbConfigName.Text;

            /************************************************************************/
            // update the nesting param.
            // the border margin of the material.
            m_nestParam.SetMatLeftMargin(Convert.ToDouble(leftTextBox.Text));
            m_nestParam.SetMatRightMargin(Convert.ToDouble(rightTextBox.Text));
            m_nestParam.SetMatTopMargin(Convert.ToDouble(topTextBox.Text));
            m_nestParam.SetMatBottomMargin(Convert.ToDouble(bottomTextBox.Text));
            m_nestParam.SetMatMargin(Convert.ToDouble(marginTextBox.Text));

            config.MatLeftMargin   = Convert.ToDouble(leftTextBox.Text);
            config.MatRightMargin  = Convert.ToDouble(rightTextBox.Text);
            config.MatTopMargin    = Convert.ToDouble(topTextBox.Text);
            config.MatBottomMargin = Convert.ToDouble(bottomTextBox.Text);
            config.MatMargin       = Convert.ToDouble(marginTextBox.Text);

            // the part spacing.
            m_nestParam.SetPartDis(Convert.ToDouble(spaceTextBox.Text));

            config.PartDis = Convert.ToDouble(spaceTextBox.Text);

            // the start nesting corner.
            if (ltRadioBtn.Checked)
            {
                m_nestParam.SetStartCorner(RECT_CORNER_EX.LEFT_TOP);
                config.StartCorner = Corner.LeftTop;
            }
            else if (lbRadioBtn.Checked)
            {
                m_nestParam.SetStartCorner(RECT_CORNER_EX.LEFT_BOTTOM);
                config.StartCorner = Corner.LeftBottom;
            }
            else if (rtRadioBtn.Checked)
            {
                m_nestParam.SetStartCorner(RECT_CORNER_EX.RIGHT_TOP);
                config.StartCorner = Corner.RightTop;
            }
            else if (rbRadioBtn.Checked)
            {
                m_nestParam.SetStartCorner(RECT_CORNER_EX.RIGHT_BOTTOM);
                config.StartCorner = Corner.RightBottom;
            }

            // the nesting direction.
            if (xRadioBtn.Checked)
            {
                m_nestParam.SetNestDir(NEST_DIRECTION_EX.NEST_DIR_X);
                config.DirValue = Dir.XDir;
            }
            else if (yRadioBtn.Checked)
            {
                m_nestParam.SetNestDir(NEST_DIRECTION_EX.NEST_DIR_Y);
                config.DirValue = Dir.YDir;
            }
            /************************************************************************/

            //保存参数到本地
            SaveConfig(config);

            this.DialogResult = DialogResult.OK;
        }
Пример #3
0
        private void SetConfig()
        {
            string file = System.IO.Directory.GetCurrentDirectory() + "\\ConfigHigh.txt";

            if (File.Exists(file) == true)
            {
                CfgHigh = Tool.Tools.JsonStingToObj <ConfigHighEntity>(File.ReadAllText(file));

                if (CfgHigh != null && CfgHigh.NestTime > 0)
                {
                    m_iNestingTime = CfgHigh.NestTime;
                }
            }

            string path = Directory.GetCurrentDirectory() + "\\ConfigInfo";

            if (Directory.Exists(path) == true)
            {
                var dir   = new DirectoryInfo(path);
                var files = dir.GetFiles().OrderBy(q => q.CreationTime).ToList();
                if (files.Count > 0)
                {
                    var config = Tool.Tools.JsonStingToObj <ConfigEntity>(File.ReadAllText(files.Last().FullName));
                    if (config != null)
                    {
                        m_nestParam.SetMatLeftMargin(config.MatLeftMargin);
                        m_nestParam.SetMatRightMargin(config.MatRightMargin);
                        m_nestParam.SetMatTopMargin(config.MatTopMargin);
                        m_nestParam.SetMatBottomMargin(config.MatBottomMargin);
                        m_nestParam.SetMatMargin(config.MatMargin);
                        // the part spacing.
                        m_nestParam.SetPartDis(config.PartDis);

                        // the start nesting corner.
                        if (config.StartCorner == Corner.LeftTop)
                        {
                            m_nestParam.SetStartCorner(RECT_CORNER_EX.LEFT_TOP);
                        }
                        else if (config.StartCorner == Corner.LeftBottom)
                        {
                            m_nestParam.SetStartCorner(RECT_CORNER_EX.LEFT_BOTTOM);
                        }
                        else if (config.StartCorner == Corner.RightTop)
                        {
                            m_nestParam.SetStartCorner(RECT_CORNER_EX.RIGHT_TOP);
                        }
                        else if (config.StartCorner == Corner.RightBottom)
                        {
                            m_nestParam.SetStartCorner(RECT_CORNER_EX.RIGHT_BOTTOM);
                        }

                        // the nesting direction.
                        if (config.DirValue == Dir.XDir)
                        {
                            m_nestParam.SetNestDir(NEST_DIRECTION_EX.NEST_DIR_X);
                        }
                        else if (config.DirValue == Dir.YDir)
                        {
                            m_nestParam.SetNestDir(NEST_DIRECTION_EX.NEST_DIR_Y);
                        }
                    }
                }
            }
        }