private void buttonAttachGraphics_Click(object sender, EventArgs e) { openFileDialog1.Title = LanguageSettings.Current.Main.Menu.File.Open.RemoveChar('&'); openFileDialog1.FileName = string.Empty; openFileDialog1.Filter = "Images|*" + string.Join(";*", _imageExtensions).TrimEnd('*'); openFileDialog1.FilterIndex = 0; openFileDialog1.Multiselect = true; var result = openFileDialog1.ShowDialog(this); if (result != DialogResult.OK || !File.Exists(openFileDialog1.FileName)) { return; } foreach (var fileName in openFileDialog1.FileNames) { var attachmentFileName = Path.GetFileName(fileName); var attachmentContent = UUEncoding.UUEncode(FileUtil.ReadAllBytesShared(fileName)); AddToListView(attachmentFileName, attachmentContent, "[Graphics]"); listViewAttachments.Items[listViewAttachments.Items.Count - 1].Selected = true; listViewAttachments.Items[listViewAttachments.Items.Count - 1].Focused = true; } UpdateAfterListViewChange(); }
public void ForwardAndBackAgain() { var byteArray = new byte[byte.MaxValue]; for (int i = byte.MinValue; i < byte.MaxValue; i++) { byteArray[i] = (byte)i; } var text = UUEncoding.UUEncode(byteArray); var newBytes = UUEncoding.UUDecode(text); Assert.AreEqual(byteArray.Length, newBytes.Length); for (int i = byte.MinValue; i < byte.MaxValue; i++) { Assert.AreEqual(byteArray[i], newBytes[i]); } }
private void buttonAttachFont_Click(object sender, EventArgs e) { openFileDialog1.Title = "Open..."; openFileDialog1.FileName = string.Empty; openFileDialog1.Filter = "Font|*.ttf"; openFileDialog1.FilterIndex = 0; openFileDialog1.Multiselect = true; var result = openFileDialog1.ShowDialog(this); if (result != DialogResult.OK || !File.Exists(openFileDialog1.FileName)) { return; } foreach (var fileName in openFileDialog1.FileNames) { var attachmentFileName = Path.GetFileName(fileName); var attachmentContent = UUEncoding.UUEncode(FileUtil.ReadAllBytesShared(fileName)); AddToListView(attachmentFileName, attachmentContent, "[Fonts]"); listViewAttachments.Items[listViewAttachments.Items.Count - 1].Selected = true; listViewAttachments.Items[listViewAttachments.Items.Count - 1].Focused = true; } UpdateAfterListViewChange(); }
private void buttonAttachFile_Click(object sender, EventArgs e) { openFileDialog1.Title = LanguageSettings.Current.Main.Menu.File.Open.RemoveChar('&'); openFileDialog1.FileName = string.Empty; openFileDialog1.Filter = $"{LanguageSettings.Current.AssaAttachments.FontsAndImages}|*.ttf;*{string.Join(";*", _imageExtensions).TrimEnd('*')}|{LanguageSettings.Current.General.Fonts}|*.ttf|{LanguageSettings.Current.General.Images}|*{string.Join(";*", _imageExtensions).TrimEnd('*')}"; openFileDialog1.FilterIndex = 0; openFileDialog1.Multiselect = true; var result = openFileDialog1.ShowDialog(this); if (result != DialogResult.OK || !File.Exists(openFileDialog1.FileName)) { return; } int skipCount = 0; var skipFiles = new List <string>(); var newAttachments = new List <AssaAttachment>(); foreach (var fileName in openFileDialog1.FileNames) { var attachmentFileName = Path.GetFileName(fileName); var attachmentContent = UUEncoding.UUEncode(FileUtil.ReadAllBytesShared(fileName)); var ext = Path.GetExtension(attachmentFileName)?.ToLowerInvariant(); if (ext == ".ttf") { AddToListIfNotEmpty(attachmentContent, attachmentFileName, newAttachments, GetType(attachmentFileName)); } else if (_imageExtensions.Contains(ext)) { AddToListIfNotEmpty(attachmentContent, attachmentFileName, newAttachments, GetType(attachmentFileName)); } else { skipFiles.Add(attachmentFileName); skipCount++; } } var first = true; foreach (var attachment in newAttachments) { _attachments.Add(attachment); AddToListView(attachment); var idx = listViewAttachments.Items.Count - 1; if (first) { listViewAttachments.SelectedIndices.Clear(); listViewAttachments.EnsureVisible(idx); listViewAttachments.Items[idx].Focused = true; first = false; } listViewAttachments.Items[idx].Selected = true; } UpdateAfterListViewChange(); if (skipCount > 0) { MessageBox.Show(string.Format(LanguageSettings.Current.AssaAttachments.FilesSkippedX, skipCount + Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, skipFiles))); } }