Exemplo n.º 1
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }

            // sync device
            SyncingForm SF = new SyncingForm();
            Device      d  = ManagedDrives[listBox1.SelectedIndex];

            SF.setMax(d.iTunesPlaylist.Tracks.Count);
            SF.SetValue(0);
            SF.SetText("Syncing...");
            SF.Show();
            int v = 0;

            foreach (IITFileOrCDTrack track in d.iTunesPlaylist.Tracks)
            {
                SF.SetText("Syncing " + track.Name + "...");
                // check if empty track
                if (track.Location == "")
                {
                    continue;
                }
                try
                {
                    // format output path
                    string outputPath = d.Drive.Name + "\\Music\\" + CleanName(string.IsNullOrEmpty(track.Artist) ? "Unknown Artist" : track.Artist) + "\\" + CleanName(string.IsNullOrEmpty(track.Album) ? "Unknown Album" : track.Album) + "\\" +
                                        System.IO.Path.GetFileName(track.Location);
                    // write file to drive
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath));
                    if (System.IO.File.Exists(outputPath))           // check if it already exists
                    {
                        System.IO.File.Delete(outputPath);           // if so, delete it
                    }
                    System.IO.File.Copy(track.Location, outputPath); // copy the file over
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    SF.SetValue(++v); // increase the progress bar
                }
            }
            SF.Close();
        }
Exemplo n.º 2
0
        void timer_Tick(object sender, EventArgs e)
        {
            if (isSyncing)
            {
                return;
            }

            isSyncing = true;
            // sync device
            SyncingForm SF = new SyncingForm();

            SF.setMax(Device.iTunesPlaylist.Tracks.Count);
            SF.SetValue(0);
            SF.SetText("Syncing...");
            SF.Show();
            int v = 0;

            foreach (IITFileOrCDTrack track in Device.iTunesPlaylist.Tracks)
            {
                SF.SetText("Syncing " + track.Name + "...");
                // check if empty track
                if (track.Location == "")
                {
                    MessageBox.Show("Dead track: " + track.Name);
                    continue;
                }
                string outputPath = "";
                try
                {
                    // format output path
                    outputPath = Device.Drive.Name + "\\Music\\" + MainForm.CleanName(string.IsNullOrEmpty(track.Artist) ? "Unknown Artist" : track.Artist) + "\\" + MainForm.CleanName(string.IsNullOrEmpty(track.Album) ? "Unknown Album" : track.Album) + "\\" + System.IO.Path.GetFileName(track.Location);
                    // write file to drive
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath));
                    if (System.IO.File.Exists(outputPath))           // check if it already exists
                    {
                        System.IO.File.Delete(outputPath);           // if so, delete it
                    }
                    System.IO.File.Copy(track.Location, outputPath); // copy the file over
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\nOutput Path: " + outputPath);
                }
                SF.SetValue(++v); // increase the progress bar
            }
            SF.Close();
            isSyncing = false;
        }
Exemplo n.º 3
0
        void timer_Tick(object sender, EventArgs e)
        {
            if (isSyncing)
                return;

            isSyncing = true;
            // sync device
            SyncingForm SF = new SyncingForm();
            SF.setMax(Device.iTunesPlaylist.Tracks.Count);
            SF.SetValue(0);
            SF.SetText("Syncing...");
            SF.Show();
            int v = 0;
            foreach (IITFileOrCDTrack track in Device.iTunesPlaylist.Tracks)
            {
                SF.SetText("Syncing " + track.Name + "...");
                // check if empty track
                if (track.Location == "")
                {
                    MessageBox.Show("Dead track: " + track.Name);
                    continue;
                }
                string outputPath="";
                try
                {
                    // format output path
                    outputPath = Device.Drive.Name + "\\Music\\" + MainForm.CleanName(string.IsNullOrEmpty(track.Artist) ? "Unknown Artist" : track.Artist) + "\\" + MainForm.CleanName(string.IsNullOrEmpty(track.Album) ? "Unknown Album" : track.Album) + "\\" + System.IO.Path.GetFileName(track.Location);
                    // write file to drive
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath));
                    if (System.IO.File.Exists(outputPath)) // check if it already exists
                        System.IO.File.Delete(outputPath); // if so, delete it
                    System.IO.File.Copy(track.Location, outputPath); // copy the file over
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\nOutput Path: " + outputPath);
                }
                SF.SetValue(++v); // increase the progress bar
            }
            SF.Close();
            isSyncing = false;
        }
Exemplo n.º 4
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
                return;

            // sync device
            SyncingForm SF = new SyncingForm();
            Device d = ManagedDrives[listBox1.SelectedIndex];
            SF.setMax(d.iTunesPlaylist.Tracks.Count);
            SF.SetValue(0);
            SF.SetText("Syncing...");
            SF.Show();
            int v = 0;
            foreach (IITFileOrCDTrack track in d.iTunesPlaylist.Tracks)
            {
                SF.SetText("Syncing " + track.Name + "...");
                // check if empty track
                if (track.Location == "")
                    continue;
                try
                {
                    // format output path
                    string outputPath = d.Drive.Name + "\\Music\\" + CleanName(string.IsNullOrEmpty(track.Artist) ? "Unknown Artist" : track.Artist) + "\\" + CleanName(string.IsNullOrEmpty(track.Album) ? "Unknown Album" : track.Album) + "\\" +
                        System.IO.Path.GetFileName(track.Location);
                    // write file to drive
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath));
                    if (System.IO.File.Exists(outputPath)) // check if it already exists
                        System.IO.File.Delete(outputPath); // if so, delete it
                    System.IO.File.Copy(track.Location, outputPath); // copy the file over
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    SF.SetValue(++v); // increase the progress bar
                }
            }
            SF.Close();
        }