Exemplo n.º 1
0
        public bool SaveToFile(string FilePath, bool RevertXAxis = false, bool RevertYAxis = false, bool ChangeAxis = false)
        {
            var indexEndDirectory = FilePath.LastIndexOf("\\");
            var filename          = FilePath.Substring(indexEndDirectory + 1, FilePath.Length - indexEndDirectory - 1);
            var directory         = FilePath.Substring(0, indexEndDirectory);

            foreach (var Group in GroupList)
            {
                var          path   = directory + "\\" + filename + Group.Name + ".pnt";
                StreamWriter stream = new StreamWriter(path);

                try
                {
                    stream.WriteLine("BEGIN " + filename.ToUpper() + Group.Name + ".PNT MM");
                    stream.WriteLine(ConstDefine.CNC_FILE_HEADER);
                    stream.Flush();
                    foreach (var LineData in Group.Data)
                    {
                        if (RevertXAxis)
                        {
                            LineData.RevertXAxis();
                        }
                        if (RevertYAxis)
                        {
                            LineData.RevertYAxis();
                        }
                        if (ChangeAxis)
                        {
                            LineData.ChangeAxis();
                        }
                        stream.WriteLine(LineData.ID + LineData.X + LineData.Y + LineData.Z + LineData.Fade + LineData.Clearance);
                        stream.Flush();
                    }
                    stream.WriteLine(ConstDefine.CNC_FILE_END);
                    stream.Flush();
                    stream.Dispose();
                }
                catch (Exception ex)
                {
                    return(false);
                }
                finally
                {
                    stream.Dispose();
                }
            }
            return(true);
        }