// 复制 public object Clone() { ProblemRecord record = new ProblemRecord(); record.CreateTime = CreateTime; record.Name = (string)Name.Clone(); record.CarSpeed = CarSpeed; record.NodeStayTime = NodeStayTime; record.Cars = (CarCollection)Cars.Clone(); record.Nodes = (NodeCollection)Nodes.Clone(); // 复制路径 for (int i = 0; i < Paths.Count; ++i) { record.Paths.Add(new ObservableCollection <int>()); for (int j = 0; j < Paths[i].Count; ++j) { record.Paths[i].Add(Paths[i][j]); } } // 复制线条 for (int i = 0; i < Segments.Count; ++i) { record.Segments.Add((Segment)Segments[i].Clone()); } return(record); }
// 删除历史记录 public static void RemoveRecord(ProblemRecord record) { FileInfo file = new FileInfo(record.Filename); file.Delete(); Records.Remove(record); }
// 添加历史记录 public static void AddRecord(ProblemRecord rec) { ProblemRecord record = (ProblemRecord)rec.Clone(); record.GenerateAllInfo(); record.Filename = RecordPath + "/" + record.CreateTime.ToString("yyyy-MM-dd-HH-mm-ss") + ".rec"; Records.Insert(0, record); }
// 重命名历史记录 public static void RenameRecord(ProblemRecord record, string newName) { record.Name = newName; }