private void CMViewImage_Click(object sender, EventArgs e) { var message = GetMessage(Output_ChatText.SelectedItem.ToString()); if (message.Attachments.Count == 1) { IOF = new IOF(message.Attachments[0].Url, message.Attachments[0].FileName); Handles[AvailableSpace] = IOF.Handle; AvailableSpace++; IOF.Show(); } else { MessageBox.Show("Selected message has more than one attachment. Please select which attachments you would like to open.", "Multi-image message", MessageBoxButtons.OK, MessageBoxIcon.Information); for (int i = 0; i < message.Attachments.Count; i++) { switch (i + 1) { case 1: Multiple_ImagesLB.Items.Add($"1st file ({message.Attachments[i].FileName})"); break; case 2: Multiple_ImagesLB.Items.Add($"2nd file ({message.Attachments[i].FileName})"); break; case 3: Multiple_ImagesLB.Items.Add($"3rd file ({message.Attachments[i].FileName})"); break; default: Multiple_ImagesLB.Items.Add($"{i + 1}th file ({message.Attachments[i].FileName})"); break; } } Multiple_ImagesLB.BringToFront(); Multiple_ImagesLB.Visible = true; Multiple_ImagesOpen.BringToFront(); Multiple_ImagesOpen.Visible = true; Multiple_ImagesCancel.BringToFront(); Multiple_ImagesCancel.Visible = true; } CloseAllImages.Visible = true; }
private void Multiple_ImagesOpen_Click(object sender, EventArgs e) { bool allowFiles = false; bool allowFilesAnswered = false; for (int i = 0; i < Multiple_ImagesLB.SelectedIndices.Count; i++) { var attachment = GetMessage(Output_ChatText.SelectedItem.ToString()) .Attachments[Multiple_ImagesLB.SelectedIndices[i]]; // width == 0 means it's not an image if (attachment.Width != 0) { IOF = new IOF(attachment.Url, attachment.FileName); Handles[AvailableSpace] = IOF.Handle; AvailableSpace++; IOF.Show(); } else { if (!allowFilesAnswered) { if (MessageBox.Show( "One or more of the selected files is not an image.\n" + "Downloading/Viewing these files requires opening your browser; would you still like to open these files?", "Non-image in selection", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { allowFiles = true; allowFilesAnswered = true; } } if (allowFiles) { Process.Start(attachment.Url); } } } Multiple_ImagesLB.Visible = false; Multiple_ImagesOpen.Visible = false; Multiple_ImagesCancel.Visible = false; Multiple_ImagesLB.Items.Clear(); }