//assigns the adhoc sort values, ran each time a sortup/down is clicked
 private void AssignSortVal()
 {
     for (int x = 0; x < dgvFiles.Rows.Count; x++)
     {
         FileEntryClass item = (FileEntryClass)dgvFiles.Rows[x].DataBoundItem;
         item.AdHocSort = x;
     }
 }
        private void DelItem(int RowIndex)
        {
            if (dgvRowSelected == -1)
            {
                return;
            }
            FileEntryClass removeitem = (FileEntryClass)dgvFiles.Rows[RowIndex].DataBoundItem;

            FileList.Remove(removeitem);
            dgvFiles.Refresh();
        }
 private void AddFiles()
 {
     if (ofdAdd.ShowDialog() == DialogResult.OK)
     {
         string[] files = ofdAdd.FileNames;
         foreach (string file in files)
         {
             FileEntryClass newfile = new FileEntryClass(file);
             FileList.Add(newfile);
         }
         GenDGV();
     }
 }
 private void ABC_DragDrop(object sender, DragEventArgs e)
 {
     //if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;
     try {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         foreach (string file in files)
         {
             FileEntryClass newfile = new FileEntryClass(file);
             FileList.Add(newfile);
         }
         GenDGV();
     }
     catch { return; }
 }
 private void CopyTagsFrom(FileEntryClass sourcefile)
 {
     if (sourcefile == null)
     {
         return;
     }
     txtAlbum.Text      = sourcefile.Tag.Album;
     txtArtist.Text     = sourcefile.Tag.FirstPerformer;
     txtDisc.Text       = sourcefile.Tag.Disc.ToString();
     txtDiscTotal.Text  = sourcefile.Tag.DiscCount.ToString();
     txtTitle.Text      = sourcefile.Tag.Title;
     txtTrack.Text      = sourcefile.Tag.Track.ToString();
     txtTrackTotal.Text = sourcefile.Tag.TrackCount.ToString();
     txtYear.Text       = sourcefile.Tag.Year.ToString();
 }
 public void MPlayerPlay(int row)
 {
     if (row < 0)
     {
         return;
     }
     if (PlayerUpdate != 2)
     {
         if (MediaPlayer != null)
         {
             MediaPlayer.Stop();
         }
         FileEntryClass RowFile = (FileEntryClass)dgvFiles.Rows[row].DataBoundItem;
         MediaPlayer = new PlayerClass(this, RowFile.FilePath);
     }
     MediaPlayer.play();
 }
        //up=0 moving down, up = 1 moving up
        private void ChangeSort(bool up, int RowIndex)
        {
            //escape out if its row 0 going up or last row going down
            if (RowIndex == 0 && up)
            {
                return;
            }
            if (RowIndex == dgvFiles.Rows.Count - 1 && !up)
            {
                return;
            }

            //setup the sort values
            AssignSortVal();



            int switchrow;

            if (up)
            {
                switchrow = RowIndex - 1;
            }
            else
            {
                switchrow = RowIndex + 1;
            }

            int thirdhand;

            FileEntryClass moving_row = (FileEntryClass)dgvFiles.Rows[RowIndex].DataBoundItem;
            FileEntryClass other_row  = (FileEntryClass)dgvFiles.Rows[switchrow].DataBoundItem;

            thirdhand            = moving_row.AdHocSort;
            moving_row.AdHocSort = other_row.AdHocSort;
            other_row.AdHocSort  = thirdhand;


            dgvFiles.Sort(dgvFiles.Columns["AdHocSort"], ListSortDirection.Ascending);
            dgvRowSelected = switchrow;
        }
Esempio n. 8
0
        public void Read(out SortableBindingList <FileEntryClass> FileEntries, out OutputMetadata OutputMetaData)
        {
            file_entries    = new SortableBindingList <FileEntryClass>();
            output_metadata = new OutputMetadata();

            XDocument doc = XDocument.Load(filename);

            var outputinfo = from outputdat in (doc.Descendants("OutputData"))
                             select new {
                OutputFile   = (string)outputdat.Element("OutputFile"),
                Album        = (string)outputdat.Element("Album"),
                AlbumSort    = (string)outputdat.Element("AlbumSort"),
                Artist       = (string)outputdat.Element("Artist"),
                ArtistSort   = (string)outputdat.Element("ArtistSort"),
                Comment      = (string)outputdat.Element("Comment"),
                Composer     = (string)outputdat.Element("Composer"),
                ComposerSort = (string)outputdat.Element("ComposerSort"),
                Disc         = outputdat.Element("Disc").Value,
                DiscTotal    = outputdat.Element("DiscTotal").Value,
                Title        = (string)outputdat.Element("Title"),
                TitleSort    = (string)outputdat.Element("TitleSort"),
                Track        = outputdat.Element("Track").Value,
                TrackTotal   = outputdat.Element("TrackTotal").Value,
                Year         = outputdat.Element("Year").Value,
                Artwork      = (string)outputdat.Element("Artwork")
            };
            var fileinfo = from filedat in (doc.Descendants("FileEntry"))
                           select new {
                AdHocSort    = filedat.Attribute("Index").Value,
                FileName     = (string)filedat.Element("FileName"),
                FilePath     = (string)filedat.Element("FilePath"),
                Chapter      = (bool)filedat.Element("Chapter"),
                ChapterTitle = (string)filedat.Element("ChapterTitle"),
                Title        = (string)filedat.Element("Title"),
                Duration     = filedat.Element("Duration").Value,
                TrackNum     = filedat.Element("TrackNum").Value
            };
            var output = outputinfo.First();

            output_metadata.Album        = output.Album;
            output_metadata.AlbumSort    = output.AlbumSort;
            output_metadata.Artist       = output.Artist;
            output_metadata.ArtistSort   = output.ArtistSort;
            output_metadata.Comment      = output.Comment;
            output_metadata.Composer     = output.Composer;
            output_metadata.ComposerSort = output.ComposerSort;
            output_metadata.Disc         = Convert.ToInt32(output.Disc);
            output_metadata.DiscTotal    = Convert.ToInt32(output.DiscTotal);
            output_metadata.OutputFile   = output.OutputFile;
            output_metadata.Title        = output.Title;
            output_metadata.TitleSort    = output.TitleSort;
            output_metadata.Track        = Convert.ToInt32(output.Track);
            output_metadata.TrackTotal   = Convert.ToInt32(output.TrackTotal);
            output_metadata.Year         = Convert.ToInt32(output.Year);
            if (output.Artwork != null)
            {
                output_metadata.Image = Convert.FromBase64String(output.Artwork);
            }
            foreach (var singlefile in fileinfo)
            {
                FileEntryClass listfile = new FileEntryClass(singlefile.FilePath);
                listfile.AdHocSort    = Convert.ToInt32(singlefile.AdHocSort);
                listfile.Chapter      = singlefile.Chapter;
                listfile.ChapterTitle = singlefile.ChapterTitle;
                listfile.Duration     = TimeSpan.FromMilliseconds(Convert.ToInt32(singlefile.Duration));
                listfile.FileName     = singlefile.FileName;
                listfile.FilePath     = singlefile.FilePath;
                listfile.Title        = singlefile.Title;
                listfile.TrackNum     = Convert.ToInt32(singlefile.TrackNum);
                file_entries.Add(listfile);
            }


            FileEntries    = file_entries;
            OutputMetaData = output_metadata;
        }