/// <summary> /// Adds a message to the InfoBox. /// </summary> /// <param name="message">Message to add.</param> /// <param name="color">Color of the message's text.</param> public void Add(string message, Color color) { ThreadAsserts.IsMainThread(); var newItem = new InfoBoxItem(TickCount.Now, message, color, _font); // If we are full, remove the old messages until we have room while (_items.Count >= _maxItems) { _items.RemoveAt(0); } // Add the new item to the list _items.Add(newItem); }
internal object UpdateInfoBox(string boxName, int reference, int partition, InfoBoxItemType type, int position) { using (var context = ApplicationDbContext.Create()) { var item = context.InfoBoxItems .Where(x => x.BoxName == boxName) .Where(x => x.Reference == reference) .Where(x => x.Type == type) .Where(x => x.Partition == partition) .FirstOrDefault(); var result = InitInfoBoxItemModelForBox(boxName); result.Reference = reference; result.Type = type; result.Partition = partition; result.BoxName = boxName; if (item == null) { item = new InfoBoxItem { Reference = reference, Type = type, Partition = partition, BoxName = boxName }; context.InfoBoxItems.Add(item); var existingItem = context.InfoBoxItems .Where(x => x.BoxName == boxName) .Where(x => x.Position == position) .Where(x => x.Partition == partition) .FirstOrDefault(); if (existingItem != null) { context.InfoBoxItems.Remove(existingItem); } } // This is the only value we are getting. result.Position = position; item.Position = position; context.SaveChanges(); return(result); } }