Example #1
0
        private void LoadProjectTracks()
        {
            try
            {
                string newProjectPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/" + selectedTrack.Name;
                int    projectIndex   = LoadedTracks.IndexOf(selectedTrack) + 1;
                int    insTrackNumber = 0;

                int songcount = 0;

                foreach (string songFile in Directory.GetFiles(newProjectPath))
                {
                    int tracknum = PersistentData.GetTrackNumber(newProjectPath, Path.GetFileNameWithoutExtension(songFile));

                    var t = new Track
                    {
                        Name             = Path.GetFileNameWithoutExtension(songFile),
                        FullPath         = songFile,
                        isProject        = false,
                        ProjectPath      = newProjectPath,
                        OrderVal         = PlayListOrder.ContainsKey(songFile) ? PlayListOrder[songFile] : 0,
                        TrackNum         = tracknum,
                        LastModifiedDate = File.GetLastWriteTime(songFile),
                    };

                    if (tracknum != 0)
                    {
                        LoadedTracks.Insert(projectIndex + tracknum - 1, t);
                    }
                    else
                    {
                        LoadedTracks.Insert(projectIndex + insTrackNumber, t);
                    }

                    insTrackNumber++;
                    songcount++;
                }

                Dictionary <String, String> properties = new Dictionary <string, string>();

                properties["songcount"] = songcount.ToString();

                Analytics.TrackEvent("ExpandTracks", properties);
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }
Example #2
0
        private void RightSongPressed(object sender, EventArgs e)
        {
            PersistentData.SaveNotes(qt, snd.Notes);

            int i = tvm.Playlist.IndexOf(qt) + 1;

            if (i >= tvm.Playlist.Count)
            {
                i = 0;
            }

            qt = tvm.Playlist[i];

            SetSongInfo();
        }
Example #3
0
        private async void SelectPressed(object sender, EventArgs e)
        {
            if (FolderList.SelectedItem != null)
            {
                string         p  = string.IsNullOrEmpty(CurrentFolder) ? "" : (CurrentFolder + "/");
                DirectoryEntry de = (DirectoryEntry)FolderList.SelectedItem;

                // Only add it if it's not there already
                var previousLoc = PersistentData.MixLocationList.FirstOrDefault((el) => (el.Path == p + de.DirectoryName));
                if (previousLoc == null)
                {
                    PersistentData.MixLocationList.Insert(0, new MixLocation()
                    {
                        Path = p + de.DirectoryName, Provider = pi.CloudProvider
                    });
                    PersistentData.SaveMixLocations();
                }
            }
        }
Example #4
0
        private async Task ValidatePlayingTracks()
        {
            List <QueuedTrack> t_remove = new List <QueuedTrack>();

            foreach (QueuedTrack t in Playlist)
            {
                if (!File.Exists(t.FullPath))
                {
                    t_remove.Add(t);
                }
            }

            foreach (QueuedTrack t in t_remove)
            {
                Playlist.Remove(t);
            }

            playingListLoaded = false;

            await PersistentData.SaveQueuedTracksAsync(Playlist);
        }
Example #5
0
 private void OnDisapearing(object sender, EventArgs e)
 {
     PersistentData.SaveNotes(qt, snd.Notes);
     PersistentData.Save();
 }
Example #6
0
 private void LocationDeleted(object sender, EventArgs e)
 {
     PersistentData.MixLocationList.Remove(FindMixLocation((View)sender));
     PersistentData.SaveMixLocations();
 }
Example #7
0
#pragma warning restore AvoidAsyncVoid

        private void Notes_Clicked(object sender, EventArgs e)
        {
            PersistentData.Save();
            Navigation.PushAsync(new SongNotes(TransportVMInstance, QueuedTrack.FindQueuedTrack((View)sender)));
        }
Example #8
0
 private async void OnDisappearing(object sender, EventArgs e)
 {
     await PersistentData.SaveQueuedTracksAsync(TransportVMInstance.Playlist);
 }
Example #9
0
#pragma warning disable AvoidAsyncVoid
        private async void Add_Clicked(object sender, EventArgs e)
        {
            PersistentData.Save();
            await Navigation.PushAsync(new AddSongs(TransportVMInstance));
        }
Example #10
0
 private void Help_Clicked(object sender, EventArgs e)
 {
     PersistentData.Save();
     Navigation.PushAsync(new HelpMain());
 }
Example #11
0
        public async Task <List <string> > UpdateProjectAsync(string root, string project, UpdateStatus UpdateStatusRoutine)
        {
            List <string> UpdatedSongs = new List <string>();

            try
            {
                string projectPath      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), project);
                string remoteFolderName = "/" + root + "/" + project;

                // Is local folder created?
                var d = Directory.CreateDirectory(projectPath);
                if (d != null)
                {
                    var items = await cs.GetFolderListAsync(remoteFolderName);

                    foreach (var di in items)
                    {
                        if (isAudioFile(di))
                        {
                            UpdatedSongs.Add(di.name);

                            string   localFileName  = projectPath + "/" + di.name;
                            DateTime localWriteTime = File.GetLastWriteTimeUtc(localFileName);

                            if (Math.Abs((localWriteTime - di.modifiedDate).TotalSeconds) >= 1)
                            {
                                using (Stream s = new FileStream(localFileName, FileMode.OpenOrCreate))
                                {
                                    Debug.Print("downloading " + localFileName + "\n");
                                    UpdateStatusRoutine("downloading " + project + "/" + di.name);
                                    if (!await CloudStore.DownloadFileAsync(remoteFolderName + "/" + di.name, s))
                                    {
                                        Debug.Print("FAILED " + localFileName + "\n");
                                    }
                                    else
                                    {
                                        PersistentData.SetTrackNumber(projectPath, di.name, di.track);
                                    }

                                    s.Close();

                                    File.SetLastWriteTimeUtc(localFileName, di.modifiedDate);

                                    DateTime tempLastWriteTime = File.GetLastWriteTimeUtc(localFileName);
                                }
                            }
                        }
                    }

                    // Save provider
                    PersistentData.SetProvider(project, project, d.LastWriteTime.ToString(), CloudProvider);
                    PersistentData.SetCloudRoot(project, project, d.LastWriteTime.ToString(), root);
                }
            }
            catch (Exception ex)
            {
                Debug.Print("exception " + ex.Message);
                throw;
            }

            return(UpdatedSongs);
        }
Example #12
0
        private async Task SyncProjectsAsync()
        {
            Dictionary <string, List <string> > AllSongs = new Dictionary <string, List <string> >();

            foreach (MixLocation ml in PersistentData.MixLocationList)
            {
                UpdateStatus(ml.Provider.ToString() + " " + ml.Path);

                ProviderInfo pi = await ProviderInfo.GetCloudProviderAsync(ml.Provider);

                if (await pi.CheckAuthenitcationAsync())
                {
                    List <string> l = await pi.GetFoldersAsync(ml.Path);

                    if (l != null)
                    {
                        foreach (string f in l)
                        {
                            UpdateStatus(ml.Provider.ToString() + " " + ml.Path + " " + f);
                            var retList = await pi.UpdateProjectAsync(ml.Path, f, UpdateStatus);

                            if (AllSongs.ContainsKey(f))
                            {
                                AllSongs[f].AddRange(retList);
                            }
                            else
                            {
                                AllSongs[f] = retList;
                            }
                        }
                    }
                }
            }

            string rootPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            foreach (string p in Directory.GetDirectories(rootPath))
            {
                if (!AllSongs.ContainsKey(Path.GetFileName(p)))
                {
                    Debug.Print("Remove dir " + p + "\n");
                    UpdateStatus("Removing " + p);
                    Directory.Delete(p, true);
                }
                else
                {
                    foreach (string s in Directory.GetDirectories(p))
                    {
                        if (AllSongs[p].Contains(Path.GetFileName(s)))
                        {
                            UpdateStatus("Removing " + s);
                            Debug.Print("Remove file " + s + "\n");
                            File.Delete(s);
                        }
                    }
                }
            }

            foreach (string p in AllSongs.Keys)
            {
                foreach (string f in AllSongs[p])
                {
                    UpdateStatus(p + " " + f);
                }
            }

            PersistentData.Save();
        }