Example #1
0
        public void LoadPts(string file)
        {
            using (var fs = new FileStream(file, FileMode.Open))
            {
                using (var sr = new StreamReader(fs))
                {
                    //find platform pos start line
                    var line = sr.ReadLine();
                    if (line != null && line.StartsWith(Name))
                    {
                        var propCount = PosType.GetProperties().Length;

                        //start read pos lines
                        line = sr.ReadLine();
                        while (!string.IsNullOrEmpty(line))
                        {
                            var data = line.Split(',');
                            if (data.Length == propCount)
                            {
                                if (PosType == typeof(PosXYZ))
                                {
                                    Positions.Add(PosXYZ.Create(line));
                                }
                                else if (PosType == typeof(PosXYZU))
                                {
                                    Positions.Add(PosXYZU.Create(line));
                                }
                                else if (PosType == typeof(PosXYZUVW))
                                {
                                    Positions.Add(PosXYZUVW.Create(line));
                                }
                                else
                                {
                                    //pos type error
                                }
                            }
                            else
                            {
                                //pos prop length error
                                MessageBox.Show($"{line} Props Count Error");
                            }

                            line = sr.ReadLine();
                        }
                    }
                }
            }
        }