private void frmChoice_KeyPress(object sender, KeyPressEventArgs e) { TagLib.IPicture picture = ChosenObject as TagLib.IPicture; if (e.KeyChar == 'r' && picture != null) { switch (imageRotation) { case RotateFlipType.RotateNoneFlipNone: imageRotation = RotateFlipType.Rotate90FlipNone; break; case RotateFlipType.Rotate90FlipNone: imageRotation = RotateFlipType.Rotate180FlipNone; break; case RotateFlipType.Rotate180FlipNone: imageRotation = RotateFlipType.Rotate270FlipNone; break; case RotateFlipType.Rotate270FlipNone: imageRotation = RotateFlipType.RotateNoneFlipNone; break; } ResetPictureBox(); e.Handled = true; return; } if (e.KeyChar == 'c' && picture != null) { switch (cropAlign) { case CropAlign.None: cropAlign = CropAlign.TopLeft; break; case CropAlign.TopLeft: cropAlign = CropAlign.BottomRight; break; case CropAlign.BottomRight: cropAlign = CropAlign.None; break; } ResetPictureBox(); e.Handled = true; return; } if (e.KeyChar == 't' && picture != null) { if (trimEdge == 0) { trimEdge = 1; } else { trimEdge <<= 1; } if (trimEdge > 1024) { trimEdge = 0; } ResetPictureBox(); e.Handled = true; return; } }
private void listChoices_SelectedIndexChanged(object sender, EventArgs e) { object item = ChosenObject; if (item != null && item is TagLib.IPicture) { imageRotation = RotateFlipType.RotateNoneFlipNone; cropAlign = CropAlign.None; trimEdge = 0; ResetPictureBox(); textBox1.Hide(); pictureBox1.Show(); tableLayoutPanelMeta.Hide(); tableLayoutPanel1.SetRowSpan(pictureBox1, 2); } else if (item != null && item is CUEToolsSourceFile) { textBox1.Text = (item as CUEToolsSourceFile).contents.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n"); } else if (item != null && item is CUEMetadataEntry) { CUEMetadataEntry r = (item as CUEMetadataEntry); dataGridViewTracks.SuspendLayout(); dataGridViewTracks.Rows.Clear(); foreach (CUETrackMetadata track in r.metadata.Tracks) { int no = dataGridViewTracks.Rows.Count; dataGridViewTracks.Rows.Add( (no + 1).ToString(), track.Title, r.TOC[no + r.TOC.FirstAudio].StartMSF, r.TOC[no + r.TOC.FirstAudio].LengthMSF ); } dataGridViewTracks.ResumeLayout(); dataGridViewMetadata.Rows.Clear(); dataGridViewMetadata.Rows.Add("Artist", r.metadata.Artist); dataGridViewMetadata.Rows.Add("Album", r.metadata.Title); dataGridViewMetadata.Rows.Add("Date", r.metadata.Year); dataGridViewMetadata.Rows.Add("Genre", r.metadata.Genre); dataGridViewMetadata.Rows.Add("Disc Number", r.metadata.DiscNumber); dataGridViewMetadata.Rows.Add("Total Discs", r.metadata.TotalDiscs); dataGridViewMetadata.Rows.Add("Disc Name", r.metadata.DiscName); dataGridViewMetadata.Rows.Add("Label", r.metadata.Label); dataGridViewMetadata.Rows.Add("Label#", r.metadata.LabelNo); dataGridViewMetadata.Rows.Add("Country", r.metadata.Country); dataGridViewMetadata.Rows.Add("Release Date", r.metadata.ReleaseDate); dataGridViewMetadata.Rows.Add("Barcode", r.metadata.Barcode); dataGridViewMetadata.Rows.Add("Comment", r.metadata.Comment); if (pictureBox1.ImageLocation == null) { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } pictureBox1.Image = null; } pictureBox1.ImageLocation = null; if (r.metadata.AlbumArt.Count > 0 || r.cover != null) { pictureBox1.Show(); if (r.cover != null) { using (MemoryStream imageStream = new MemoryStream(r.cover, 0, r.cover.Length)) try { pictureBox1.Image = Image.FromStream(imageStream); } catch { } } else if (config.advanced.coversSearch != CUEConfigAdvanced.CTDBCoversSearch.None) { var image = r.metadata.AlbumArt.Find(x => x.primary) ?? r.metadata.AlbumArt[0]; pictureBox1.ImageLocation = image.uri150; } } else { pictureBox1.Hide(); } } else { dataGridViewMetadata.Rows.Clear(); dataGridViewTracks.Rows.Clear(); textBox1.Text = ""; } }