/// <summary> /// Displays the 5 best scores and saves the scores to a file /// </summary> public void WriteScore() { List <UInt64> ScoreList; if (File.Exists("score.xml")) //check if file exists before trying to read { ScoreList = ListIO.ReadList <UInt64>("score.xml"); ScoreList.Add(Data.Score); ScoreList.Sort(); ScoreList.Reverse(); if (ScoreList.Count > 5) //remove the excess scores { ScoreList.RemoveAt(5); } } else //generate new file if it deos not exists { ScoreList = new List <UInt64> { Data.Score }; } byte Line = 3; foreach (UInt64 CurrScore in ScoreList) //write scores { Console.SetCursorPosition(56, Line); Console.Write(CurrScore.ToString()); Line += 1; } ListIO.WriteList <UInt64>("score.xml", ScoreList); ScoreList = null; }
private void handleDataFromEvent(PlcEventModel plcEventModel) { if (plcEventModel == null) { return; } var currentIO = ListIO.FirstOrDefault(io => io.Address.Equals(plcEventModel.Address)); if (currentIO != null) { currentIO.Value = plcEventModel.Data; } }