private void GetConfigHigh() { string file = System.IO.Directory.GetCurrentDirectory() + "\\ConfigHigh.txt"; if (File.Exists(file) == false) { return; } ConfigHighEntity cfg = Tool.Tools.JsonStingToObj <ConfigHighEntity>(File.ReadAllText(file)); tolTextBox.Text = cfg.ConnectTolerance.ToString(); rotTextBox.Text = cfg.PartRotateStep.ToString(); evalTextBox.Text = cfg.EvaluationFactor.ToString(); timeTextBox.Text = cfg.NestTime.ToString(); if (cfg.PartInPart == true) { partInPartCheckBox.Checked = true; } else { partInPartCheckBox.Checked = false; } if (cfg.Optimization == true) { optimizationCheckBox.Checked = true; } else { optimizationCheckBox.Checked = false; } }
private void SaveConfig(ConfigHighEntity config) { string file = System.IO.Directory.GetCurrentDirectory() + "\\ConfigHigh.txt"; using (StreamWriter sw = new StreamWriter(file, false)) { sw.Write(Tool.Tools.ObjToJsonString(config)); sw.Flush(); sw.Close(); } }
private void okBtn_Click(object sender, EventArgs e) { // verify input. try { Convert.ToDouble(tolTextBox.Text); Convert.ToDouble(rotTextBox.Text); Convert.ToInt32(evalTextBox.Text); Convert.ToInt32(timeTextBox.Text); } catch (FormatException exception) { MessageBox.Show("Incorrect input: " + exception.Message, "NestProfessor DEMO"); return; } // updating the nest param. m_nestParam.SetConTol(Convert.ToDouble(tolTextBox.Text)); m_nestParam.SetPartRotStep(Convert.ToDouble(rotTextBox.Text)); m_nestParam.SetEvalFactor(Convert.ToInt32(evalTextBox.Text)); m_iNestingTime = Convert.ToInt32(timeTextBox.Text); ConfigHighEntity cfg = new ConfigHighEntity(); cfg.ConnectTolerance = Convert.ToDouble(tolTextBox.Text); cfg.PartRotateStep = Convert.ToDouble(rotTextBox.Text); cfg.EvaluationFactor = Convert.ToInt32(evalTextBox.Text); cfg.NestTime = Convert.ToInt32(timeTextBox.Text); if (partInPartCheckBox.Checked) { m_nestParam.IsPartInPart(true); cfg.PartInPart = true; } else { m_nestParam.IsPartInPart(false); cfg.PartInPart = false; } if (optimizationCheckBox.Checked) { m_nestParam.EnableOptimization(true); cfg.Optimization = true; } else { m_nestParam.EnableOptimization(false); cfg.Optimization = false; } SaveConfig(cfg); this.DialogResult = DialogResult.OK; }
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); } } } } }