private void _save_Click(object sender, RoutedEventArgs e) { StringBuilder sb = new StringBuilder(); List <string> letters = new List <string>(); letters.AddRange(MatrixLedCharacterDefinitions.CharacterDefinitions.Keys); foreach (string letter in letters) { sb.AppendFormat("{{ \"{0}\", new byte [] {{ {1},{2},{3},{4},{5},0}} }},", (letter != "\"") ? letter : "\\\"", MatrixLedCharacterDefinitions.GetDefinition(letter)[0], MatrixLedCharacterDefinitions.GetDefinition(letter)[1], MatrixLedCharacterDefinitions.GetDefinition(letter)[2], MatrixLedCharacterDefinitions.GetDefinition(letter)[3], MatrixLedCharacterDefinitions.GetDefinition(letter)[4] ); sb.AppendLine(); } _tb.Text = sb.ToString(); _codePopup.IsOpen = true; }
/// <summary> /// Initialize all columns from a definition in the Character defintion /// </summary> internal void SetLedsFromCharacter(string t, MatrixLedCharacter matrixLedCharacter) { byte[] bytes = MatrixLedCharacterDefinitions.GetDefinition(t); _matrixLedCharacter = matrixLedCharacter; columns.Clear(); for (int i = 0; i < bytes.Length - 1; i++) { List <bool> n = new List <bool> { (bytes[i] & 0x40) != 0, (bytes[i] & 0x20) != 0, (bytes[i] & 0x10) != 0, (bytes[i] & 0x08) != 0, (bytes[i] & 0x04) != 0, (bytes[i] & 0x02) != 0, (bytes[i] & 0x01) != 0, }; columns.Add(n); } SetLedsFromState(); }