// Transfers _KeyCode to label private void DrawKeycodeLabel() { if (KeyCode < 0) { Button.Content = ""; } else { Button.Content = AsciiConverter.KeycodeToAscii(KeyCode); } }
public void AsciiConverter_Works() { string input = "1,2,3"; var expected = new List <int> { 49, 44, 50, 44, 51 }; var actual = AsciiConverter.ConvertString(input); Assert.Equal(expected, actual); }
public void setChar(char c) { int index = AsciiConverter.charToByte(c); if (zeroAsBlank && index == asciiZero) { setSubdivision(columns - 1, rows - 1); return; } index -= asciiZero; if (index > 9) { index += blankSpacesNineToColon; } int column = Mathf.FloorToInt(index / (float)rows); int row = index % columns; setSubdivision(column, row); }
void ConverterForm_DragDrop(object sender, DragEventArgs e) { textBox1.Clear(); string[] file = (string[])e.Data.GetData(DataFormats.FileDrop); AsciiConverter reader = new AsciiConverter(); _frame = reader.ConvertToAscii(file[0]); int xLength = _frame.Location.GetLength(0); int yLength = _frame.Location.GetLength(1); const int spacing = 10; for (int y = 0; y < yLength; y += spacing * 2) { for (int x = 0; x < xLength; x += spacing) { textBox1.Text += _frame.Location[x, y]; } textBox1.Text += Environment.NewLine; } }
private void ExportAscii() { Stream stream; saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; saveFileDialog1.FileName = filename + ".txt"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if ((stream = saveFileDialog1.OpenFile()) != null) { int charW, charH; if (int.TryParse(txtBxCharH.Text, out charH) == false) { MessageBox.Show("The text boxes must contain numbers."); } if (int.TryParse(txtBxCharW.Text, out charW) == false) { MessageBox.Show("The text boxes must contain numbers."); } StreamWriter sw; // get the output string output = AsciiConverter.ConvertAscii(filename_full, txtBxScale.Text, charH, charW); sw = new StreamWriter(stream); // write output; sw.WriteLine(output); // close stream and stream writer sw.Close(); stream.Close(); } } MessageBox.Show("Successfully Exported!"); }
static void Main(string[] args) { string scale; int charH, charW; // TODO: the rest of the program if (args.Length == 0) { Console.WriteLine("Please enter filename"); return; } try { using (var bmp = new Bitmap(args[0])) { string outName; // argument syntax: /charw=5 var parsedArgs = args .Where(s => s[0] == '/') // gets items that start with / .Select(s => s.Substring(1).Split('=')) // splits into substring array using = as delimitor .ToDictionary(s => s[0], y => y[1]); // turns into dictionary #region Set Defaults if (!parsedArgs.ContainsKey("charw")) { charW = 5; } else { if (!int.TryParse(parsedArgs["charw"], out charW)) { Console.WriteLine("Error getting char width"); return; } } if (!parsedArgs.ContainsKey("charh")) { charH = 9; } else { if (!int.TryParse(parsedArgs["charh"], out charH)) { Console.WriteLine("Error getting char height"); return; } } if (!parsedArgs.ContainsKey("scale")) { scale = "@%#*+=-:. "; } else { scale = parsedArgs["scale"].Trim('"'); } if (!parsedArgs.ContainsKey("out")) { outName = Path.ChangeExtension(args[0], ".txt"); } else { outName = parsedArgs["out"]; } #endregion string output = AsciiConverter.ConvertAscii(args[0], scale, charH, charW); using (var sw = new StreamWriter(outName)) { sw.WriteLine(output); Console.WriteLine("Written to '" + outName + "' successfully."); } } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } }