private int TrimLog() { if (LogLines.Count > Settings.MaxDisplayLogLines) { var toDelete = new List <LogLine>(); var pinned = 0; for (var i = 0; LogLines.Count - toDelete.Count > Settings.MaxDisplayLogLines + pinned; i++) { if (LogLines[i].Pinned) { pinned++; continue; } toDelete.Add(LogLines[i]); } toDelete.ForEach(line => LogLines.Remove(line)); } return(LogLines.Count); }