public void AddLine(string _str) { if (Texts.Count >= LogLimit) { Texts.Dequeue(); } Texts.Enqueue(new Pair <string, int>(_str, System.Environment.TickCount)); }
public bool ScrollText(TextToScroll text) { if (Texts.Count > 0) { Texts.Enqueue(text); CurrentText = Texts.Dequeue(); if (IsScrolling) { return(true); } } else { CurrentText = text; } IsScrolling = true; _ledStripTranslation.Image.Clear(); _ledStripTranslation.Device.Update(); ColorGrid = new Color[_ledStripTranslation.Height, _ledStripTranslation.Width]; // adding letters one column at a time while (CurrentText.ScrollIterations > 0) { foreach (char c in CurrentText.Letters) { IEnumerable <string> currentLetter = Font[c]; foreach (string column in currentLetter) { ShiftColorGrid(); // add on new column for (int i = 0; i < column.Length; i++) { if (column[i].Equals('1')) { ColorGrid[i, ColorGrid.GetLength(1) - 1] = CurrentText.Color; } else { ColorGrid[i, ColorGrid.GetLength(1) - 1] = Color.Empty; } } _ledStripTranslation.Image.Clear(); _ledStripTranslation.ToImage(ColorGrid); _ledStripTranslation.Device.Update(); System.Threading.Thread.Sleep(100); } } // shift to clear scrolling text for (int i = 0; i < _ledStripTranslation.Width; i++) { ShiftColorGrid(); for (int j = 0; j < _ledStripTranslation.Height; j++) { ColorGrid[j, ColorGrid.GetLength(1) - 1] = Color.Empty; } _ledStripTranslation.Image.Clear(); _ledStripTranslation.ToImage(ColorGrid); _ledStripTranslation.Device.Update(); System.Threading.Thread.Sleep(100); } CurrentText.ScrollIterations--; if (Texts.Count > 0) { CurrentText = Texts.Dequeue(); } } IsScrolling = false; return(true); }