private void addData() { S_BPair.Add(new Speed_breakMode() { Break = string.Empty, Speed = string.Empty }); }
private void newTrain() { TrainName = string.Empty; TotalLength = string.Empty; TotalWeightProperty = string.Empty; BasicalBreakFactors = string.Empty; CurrentFilePath = string.Empty; CanEdit = true; S_BPair.Clear(); }
private void deleteData() { if (CurrentIndex != -1) { S_BPair.RemoveAt(CurrentIndex); if (S_BPair.Count != 0) { CurrentIndex = 0; } } }
private void loadTrain() { string filename; string[] infos; string[] parts; string[] pairs; ofd = new OpenFileDialog(); ofd.Filter = "车辆文件|*.tr|全部文件|*.*"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { filename = ofd.FileName; CurrentFilePath = filename; infos = System.IO.File.ReadAllLines(filename); foreach (string info in infos) { switch (info.Split(':')[0]) { case "车辆名称": TrainName = info.Split(':')[1]; break; case "总长": TotalLength = info.Split(':')[1]; break; case "总重量": TotalWeightProperty = info.Split(':')[1]; break; case "基本摩擦系数": BasicalBreakFactors = info.Split(':')[1]; break; case "制动加速度表": parts = info.Split(':')[1].Split(','); foreach (string part in parts) { pairs = part.Split('|'); S_BPair.Add(new Models.Speed_breakMode() { Break = pairs[1], Speed = pairs[0] }); } break; case "转动惯量": YFactors = info.Split(':')[1]; break; default: break; } } CanEdit = false; } }