Example #1
0
        private byte[] GetCoverFromTrack(CDQueryDataSet.TrackRow track)
        {
            byte[] imageArray = null;

            SoundFileInformation sfi = SoundFileInformation.GetSoundFileInformation(track.SoundFile);

            if (sfi.Images != null && sfi.Images.Count > 0)
            {
                imageArray = sfi.Images[0];
            }

            if (!string.IsNullOrEmpty(track.CDRow.FrontCover) && File.Exists(track.CDRow.FrontCover))
            {
                imageArray = File.ReadAllBytes(track.CDRow.FrontCover);
            }

            if (imageArray == null)
            {
                return(null);
            }

            // Thumbnail generieren
            MemoryStream m   = new MemoryStream(imageArray);
            Image        img = Image.FromStream(m);

            MemoryStream      msThumb = new MemoryStream();
            EncoderParameters e       = new EncoderParameters();
            Image             thumb   = img.GetThumbnailImage(128, 128, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

            thumb.Save(msThumb, ImageFormat.Jpeg);

            return(msThumb.ToArray());
        }
Example #2
0
        private void CopyDataToClipboard(FieldCollection selectedFields)
        {
            StringBuilder clipboardText = new StringBuilder();

            string fieldSeperator  = ((ComboBoxSeperator)comboBoxFieldSeperator.SelectedItem).Value;
            string recordSeperator = ((ComboBoxSeperator)comboBoxRecordSeperator.SelectedItem).Value;

            // Header-Zeile schreiben?
            if (checkBoxFieldsInFirstLine.Checked)
            {
                int iCount = 0;
                foreach (Field field in selectedFields)
                {
                    clipboardText.Append(dataBase.GetNameOfFieldFull(field));

                    if (iCount < selectedFields.Count - 1)
                    {
                        clipboardText.Append(fieldSeperator);
                    }

                    iCount++;
                }

                clipboardText.Append(recordSeperator);
            }

            progressBar.Maximum = records.Length;
            progressBar.Value   = 0;
            CDQueryDataSet cdQuery = null;

            if (copyTracks)
            {
                cdQuery = dataBase.ExecuteTrackQuery();
            }
            else
            {
                cdQuery = dataBase.ExecuteCDQuery();
            }

            foreach (int id in records)
            {
                if (copyTracks)
                {
                    string filter = string.Format("TrackID={0}", id);
                    CDQueryDataSet.TrackRow liedRow = (CDQueryDataSet.TrackRow)cdQuery.Track.Select(filter)[0];
                    int iCount = 0;
                    foreach (Field field in selectedFields)
                    {
                        object value = liedRow.GetValueByField(dataBase, field);
                        if (checkBoxQuoteTextFields.Checked && value is string)
                        {
                            clipboardText.Append("\"" + value + "\"");
                        }
                        else
                        {
                            clipboardText.Append(value);
                        }

                        if (iCount < selectedFields.Count - 1)
                        {
                            clipboardText.Append(fieldSeperator);
                        }

                        iCount++;
                    }
                }
                else
                {
                    string filter = string.Format("CDID={0}", id);
                    CDQueryDataSet.CDRow cdRow = (CDQueryDataSet.CDRow)cdQuery.CD.Select(filter)[0];
                    int iCount = 0;
                    foreach (Field field in selectedFields)
                    {
                        object value = cdRow.GetValueByField(field);
                        if (checkBoxQuoteTextFields.Checked && value is string)
                        {
                            clipboardText.Append("\"" + value + "\"");
                        }
                        else
                        {
                            clipboardText.Append(value);
                        }

                        if (iCount < selectedFields.Count - 1)
                        {
                            clipboardText.Append(fieldSeperator);
                        }

                        iCount++;
                    }
                }

                clipboardText.Append(recordSeperator);

                progressBar.Value++;
                progressBar.Update();
                Application.DoEvents();
            }

            Clipboard.SetText(clipboardText.ToString(), TextDataFormat.Text);
        }