private void add_file_to_grid(string path) { string originalName = Path.GetFileName(path); string outName = string.Empty; bool IsEncoded = StringCipher.IsEncoded(originalName); switch (IsEncoded) { case true: string decodedName = StringCipher.Decode(originalName); if (optRemove_ascii_rBtn.Checked) { if (decodedName.Contains("(ascii)")) { outName = decodedName.Replace("(ascii)", string.Empty); } } break; case false: if (optAppend_ascii_rBtn.Checked) { if (!originalName.Contains("(ascii)")) { outName = originalName.Insert(originalName.Length - 4, "(ascii)"); } } if (optRemove_ascii_rBtn.Checked) { outName = originalName.Replace("(ascii)", string.Empty); } break; } if (string.IsNullOrEmpty(outName)) { outName = originalName; } switch (IsEncoded) { case true: { originalName = StringCipher.Decode(outName); fileGrid.Rows.Add(outName, originalName, Path.GetDirectoryName(path), "Pending"); } break; case false: { string convertedName = StringCipher.IsEncoded(outName) ? StringCipher.Decode(outName) : StringCipher.Encode(outName); fileGrid.Rows.Add(outName, convertedName, Path.GetDirectoryName(path), "Pending"); } break; } }
private void input_TextChanged(object sender, EventArgs e) { if (input.Text.Length > 3) { output.Text = (StringCipher.IsEncoded(input.Text)) ? StringCipher.Decode(input.Text) : StringCipher.Encode(input.Text); } else if (input.Text.Length == 0) { output.ResetText(); } }
private void add_file_to_grid(string path) { string originalName = Path.GetFileName(path); if (opt_append_ascii.Checked) { if (!originalName.Contains("(ascii)")) { originalName = originalName.Insert(originalName.Length - 4, "(ascii)"); } } if (opt_remove_ascii.Checked) { originalName = originalName.Replace("(ascii)", string.Empty); } string convertedName = StringCipher.IsEncoded(originalName) ? StringCipher.Decode(originalName) : StringCipher.Encode(originalName); fileGrid.Rows.Add(originalName, convertedName, Path.GetDirectoryName(path), "Pending"); }
private string HandleAscii(string filename) { string convertedName = StringCipher.IsEncoded(filename) ? StringCipher.Decode(filename) : filename; string fileWithoutExt = Path.GetFileNameWithoutExtension(convertedName); string ext = Path.GetExtension(convertedName); if (optAppend_ascii_rBtn.Checked) { if (!convertedName.Contains("(ascii)")) { return($"{fileWithoutExt}(ascii){ext}"); } } if (optRemove_ascii_rBtn.Checked) { if (convertedName.Contains("(ascii)")) { return(fileWithoutExt.Replace("(ascii)", string.Empty) + ext); } } return(convertedName); }