public void LibraryTracks()
        {
            Controller      controller = new Controller();
            TrackCollection tracks     = controller.LibraryPlaylist.Tracks;

            PersistentIDCollection pids = new PersistentIDCollection();

            //List<int> tids = new List<int>();

            watch.Start();

            foreach (Track track in tracks.Values)
            {
                if (track != null)
                {
                    pids.Add(track.PersistentID);
                    //tids.Add(track.trackID);
                    track.Dispose();
                }
            }

            watch.Stop();
            Console.WriteLine(String.Format("Found {0} tracks", pids.Count));
            Console.WriteLine(String.Format("Completed in {0} ms", watch.GetElapsedMilliseconds()));

            tracks.Dispose();
            tracks = null;

            controller.Dispose();
            controller = null;
        }
Beispiel #2
0
 public void AddTrack(List <MusicLibraryViewModel.TrackItem> tracks)
 {
     foreach (MusicLibraryViewModel.TrackItem track in tracks)
     {
         TrackCollection.Add(track);
     }
 }
        private TrackCollection LoadTracks()
        {
            TrackCollection tracks = new TrackCollection();

            Track track;
            for (int i = 0; i < 30; i++) {
                track = new Track() { StartTime = new DateTime(2012, 3, 1, 11, i, 0), EndTime = new DateTime(2012, 3, 1, 11, i, 59) };
                tracks.Add(track);
            }

            for (int i = 0; i < 20; i++) {
                track = new Track() { StartTime = new DateTime(2012, 3, 1, 12, 10 + i, 0), EndTime = new DateTime(2012, 3, 1, 12, 10 + i, 59) };
                tracks.Add(track);
            }

            for (int i = 0; i < 20; i++) {
                track = new Track() { StartTime = new DateTime(2012, 3, 1, 13, 11 + i, 0), EndTime = new DateTime(2012, 3, 1, 13, 11 + i, 59) };
                track.TrackType = TrackType.Event;
                tracks.Add(track);
            }

            for (int i = 0; i < 20; i++) {
                track = new Track() { StartTime = new DateTime(2012, 3, 1, 13, 31 + i, 0), EndTime = new DateTime(2012, 3, 1, 13, 31 + i, 59) };
                tracks.Add(track);
            }

            return tracks;
        }
        public void TestCopyFrom()
        {
            var originalCollection = new TrackCollection {
                _testTrack
            };
            var copiedCollection = TrackCollection.CopyFrom(originalCollection);

            Assert.AreNotSame(originalCollection, copiedCollection);

            var originalFirstTrack = originalCollection[0];
            var copiedFirstTrack   = copiedCollection[0];

            Assert.AreNotSame(originalFirstTrack, copiedFirstTrack);
            Assert.AreNotSame(originalFirstTrack.Beats, copiedFirstTrack.Beats);
            Assert.AreNotSame(originalFirstTrack.FadeIns, copiedFirstTrack.FadeIns);
            Assert.AreNotSame(originalFirstTrack.FadeOuts, copiedFirstTrack.FadeOuts);

            Assert.AreEqual(originalFirstTrack.Duration, copiedFirstTrack.Duration);
            Assert.AreEqual(originalFirstTrack.Bpm, copiedFirstTrack.Bpm);
            Assert.AreEqual(originalFirstTrack.Key, copiedFirstTrack.Key);
            Assert.AreEqual(originalFirstTrack.Samplerate, copiedFirstTrack.Samplerate);
            Assert.AreEqual(originalFirstTrack.Danceability, copiedFirstTrack.Danceability);

            for (var i = 0; i < 3; i++)
            {
                Assert.AreEqual(originalFirstTrack.Beats[i], copiedFirstTrack.Beats[i]);
                Assert.AreEqual(originalFirstTrack.FadeIns[i], copiedFirstTrack.FadeIns[i]);
                Assert.AreEqual(originalFirstTrack.FadeOuts[i], copiedFirstTrack.FadeOuts[i]);
            }
        }
        private static TrackCollection CreatePotentialTrackCollection(TrackCollection current)
        {
            var random = new Random();
            var track1 = random.Next(current.Count);
            var track2 = random.Next(current.Count);

            if (current[track1].IsFixed || current[track2].IsFixed)
            {
                return(current);
            }
            var newTrackCollection = new TrackCollection();

            for (var i = 0; i < current.Count; i++)
            {
                if (i == track1)
                {
                    newTrackCollection.Add(current[track2]);
                }
                else
                {
                    newTrackCollection.Add(i == track2 ? current[track1] : current[i]);
                }
            }
            return(newTrackCollection);
        }
Beispiel #6
0
        private TrackCollection CreateChildrenFromParents(TrackCollection parent1, TrackCollection parent2)
        {
            var children = new TrackCollection();

            for (var k = 0; k < (parent1.Count) / 2; k++)
            {
                children.Add(parent1[k]);
            }

            for (var i = (parent1.Count) / 2; i < parent1.Count; i++)
            {
                if (children.Contains(parent2[i]))
                {
                    foreach (var t in parent1)
                    {
                        if ((!children.Contains(t)) && (!parent2.GetRange((parent1.Count) / 2, (parent1.Count) / 2).Contains(t)))
                        {
                            children.Add(t);
                        }
                    }
                }
                else
                {
                    children.Add(parent2[i]);
                }
            }
            return(children);
        }
Beispiel #7
0
    public static TrackLayout CreateFromTrackCollection(TrackCollection tc)
    {
        HashSet <TrackSectionSerializer>  sectionList  = new HashSet <TrackSectionSerializer>();
        HashSet <TrackJunctionSerializer> junctionList = new HashSet <TrackJunctionSerializer>();

        for (int i = 0; i < tc.sections.Length; i++)
        {
            if (tc.sections[i] != null)
            {
                TrackJunction j = tc.sections[i] as TrackJunction;
                if (j != null)
                {
                    junctionList.Add(new TrackJunctionSerializer(j));
                }
                else
                {
                    sectionList.Add(new TrackSectionSerializer(tc.sections[i]));
                }
            }
        }

        TrackLayout layout = ScriptableObject.CreateInstance <TrackLayout>();

        layout.trackSections = new TrackSectionSerializer[sectionList.Count];
        sectionList.CopyTo(layout.trackSections);
        layout.trackJunctions = new TrackJunctionSerializer[junctionList.Count];
        junctionList.CopyTo(layout.trackJunctions);

        return(layout);
    }
Beispiel #8
0
        public TrackCollection GetPlaylistTracks(Playlist playlist, int revision)
        {
            DataSet ds = MakeDataSet("SELECT data FROM [playlist], [users] WHERE [users].[id] = [playlist].[user] AND [playlist].[identifier] = '" + playlist.Identifier + "' AND [users].[identifier] = '" + playlist.User.Identifier + "'");
            String  d  = "";

            try
            {
                d = (String)ds.Tables[0].Rows[0]["data"];
            }
            catch (Exception e)
            {
            }

            String[]        tracks = d.Split('&');
            TrackCollection tc     = new TrackCollection(this, playlist, new List <Track>());

            if (String.IsNullOrEmpty(d))
            {
                return(tc);
            }
            foreach (String strtrack in tracks)
            {
                if (String.IsNullOrEmpty(strtrack))
                {
                    continue;
                }
                Track pt = MakeUserTrackFromString(strtrack);
                tc.Add((Track)pt);
            }
            return(tc);
        }
Beispiel #9
0
        private void TrackRemoved(TrackCollection collection, TrackEventArgs e)
        {
            if (collection != Tracks)
                throw new InvalidOperationException("Album attempted to alter wrong trackcollection.");

            Artist temp = null;
            for (int i = 0; i < collection.Count; i++)
                if (temp == null)
                    temp = collection[i].Artist;
                else if (collection[i].Artist != null && collection[i].Artist != temp)
                {
                    if (Artist != null)
                        Artist.Albums.Remove(this);
                    Artist = null;
                    return;
                }

            // All track artist are the same (or null)
            if (Artist != null)
                Artist.Albums.Remove(this);

            Artist = temp;

            if (temp != null)
                Artist.Albums.Add(this);
        }
Beispiel #10
0
        /// <summary>
        /// Gets the tracks by genre.
        /// </summary>
        /// <param name="genreId">The genre id.</param>
        /// <param name="musicSearchBy">The music search by.</param>
        /// <param name="marker">The next/previous marker to get next/previous items</param>
        /// <param name="locale">The locale.</param>
        /// <returns></returns>
        /// <exception cref="System.NullReferenceException">Genre Id cannot be null or empty</exception>
        public async Task <TrackCollection> GetTracksByGenreAsync(string genreId, MusicSearchBy musicSearchBy = MusicSearchBy.SalesRank, string marker = "afterMarker=CgAAAA%3d%3d", string locale = null)
        {
            if (string.IsNullOrEmpty(genreId))
            {
                throw new NullReferenceException("Genre Id cannot be null or empty");
            }

            locale = string.IsNullOrEmpty(locale) ? Locale : locale;

            var url = string.Format(Constants.ItemsByGenreUrlFormat, locale, genreId, "tracks", musicSearchBy.ToString(), marker);

            var xml = await HttpClient.GetStringAsync(url);

            var result = ParseXml <ZuneTrackSearch.feed>(xml);

            if (result.entry == null)
            {
                return(new TrackCollection(new List <Track>()));
            }

            var resultList = new TrackCollection(result.entry.Select(x => new Track(x)).ToList());

            resultList.ProcessLinks(result.link);

            return(resultList);
        }
        public static Season RunNewSeasonWizard()
        {
            Season ret = null;

            FrmNewSeason f = new FrmNewSeason();

            f.ShowDialog();
            var res = f.ResultData;

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

            ret         = new Season();
            ret.Name    = res.SeasonName;
            ret.Scoring = Activator.CreateInstance(res.ScoringType);

            if (res.TracksFolder != "")
            {
                TrackCollection trcks = TrackIniLoader.LoadTracksFrom(res.TracksFolder);
                ret.Tracks.AddRange(trcks);
            }

            return(ret);
        }
Beispiel #12
0
        public Library()
        {
            _artists = new ArtistCollection();
            _albums = new AlbumCollection();
            _tracks = new TrackCollection();

            _trackDict = new Dictionary<string, Track>();
        }
 public static TrackCollection GetInstance()
 {
     if (instance == null)
     {
         instance = new TrackCollection();
     }
     return(instance);
 }
        public void TestIsPresent()
        {
            var originalCollection = new TrackCollection();

            Assert.IsFalse(originalCollection.IsPresent(_testTrack));
            originalCollection.Add(_testTrack);
            Assert.IsTrue(originalCollection.IsPresent(_testTrack));
        }
 public object SortTrackCollection(BackgroundWorker backgroundWorker)
 {
     if (_trackCollection.Count > 1)
     {
         _trackCollection = _sortAlgorithm.Sort(backgroundWorker, _trackCollection);
     }
     return(_trackCollection);
 }
Beispiel #16
0
        public Album(string album, int albumYear)
        {
            Year = albumYear;
            Tracks = new TrackCollection(TrackAdded, TrackRemoved);
            Identifier = Guid.NewGuid();

            Title = album;
        }
Beispiel #17
0
        public Library()
        {
            _artists = new ArtistCollection();
            _albums  = new AlbumCollection();
            _tracks  = new TrackCollection();

            _trackDict = new Dictionary <string, Track>();
        }
Beispiel #18
0
        public Album(string album, int albumYear)
        {
            Year       = albumYear;
            Tracks     = new TrackCollection(TrackAdded, TrackRemoved);
            Identifier = Guid.NewGuid();

            Title = album;
        }
        public Presenter()
        {
            _views                = new List <IViewWithTrackCollection>();
            _trackCollection      = new TrackCollection();
            _dataExtractionEngine = new AudioDataExtractionProxy();
            _sortProfile          = new BasicProfile();

            _sortAlgorithm = new SimulatedAnnealingSortAlgorithm(new SimpleTracksDistance(_sortProfile));
        }
        public void TestRemove()
        {
            var myCollection = new TrackCollection {
                _testTrack
            };

            myCollection.Remove(_testTrack.Path);
            Assert.IsFalse(myCollection.IsPresent(_testTrack));
        }
        public void TestSearch()
        {
            var originalCollection = new TrackCollection {
                _testTrack
            };
            var extractedTrack = originalCollection.Search(_testTrack.Path);

            Assert.AreSame(_testTrack, extractedTrack);
        }
        private void FillTracks(TrackCollection trackCollection)
        {
            cmbTracks.Items.Clear();

            foreach (var item in trackCollection)
            {
                cmbTracks.Items.Add(item);
            }
        }
Beispiel #23
0
 public Chart()
 {
     TrackCollection collection = new TrackCollection();
     Tracks = collection.CurrentList;
     TrackCollection = collection;
     FormationCollection formationCollection = new FormationCollection();
     Formations = formationCollection.CurrentList;
     FormationCollection = formationCollection;
 }
        public override TrackCollection Sort(BackgroundWorker backgroundWorker, TrackCollection trackCollection)
        {
            var originalTrackCollection = trackCollection;
            var nbTracks = trackCollection.Count;
            var n        = (nbTracks / 2) * (nbTracks / 2);
            var result   = trackCollection;
            var random   = new Random();

            for (var k = 0; k < _numberOfIteration; k++)
            {
                if (backgroundWorker.CancellationPending)
                {
                    break;
                }

                var temperature = _beginTemperature;

                while (temperature > _stopTemperature)
                {
                    for (var i = 0; i < n; i++)
                    {
                        TrackCollection tempCollection = CreatePotentialTrackCollection(result);
                        for (var j = 0; j < temperature; j++)
                        {
                            tempCollection = CreatePotentialTrackCollection(tempCollection);
                            if (j > tempCollection.Count)
                            {
                                break;
                            }
                        }

                        var dE = ComputeIndividualEvaluation(tempCollection) - ComputeIndividualEvaluation(result);

                        if (dE < 0)
                        {
                            result = tempCollection;
                        }
                        else
                        {
                            if (random.Next(100) < (Math.Exp(-dE / temperature) * 100))
                            {
                                result = tempCollection;
                            }
                        }
                    }
                    temperature = temperature * _decayFactor;
                }
                if (ComputeIndividualEvaluation(result) < ComputeIndividualEvaluation(trackCollection))
                {
                    trackCollection = result;
                }
                backgroundWorker.ReportProgress(1000 * k / _numberOfIteration);
            }

            return(trackCollection);
        }
Beispiel #25
0
        public static async Task DeletePlaylist(TrackCollection trackCollection)
        {
            await Locator.MusicLibraryVM.TrackCollectionRepository.Remove(trackCollection);

            await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Locator.MusicLibraryVM.TrackCollections.Remove(trackCollection);
                Locator.MusicLibraryVM.CurrentTrackCollection = null;
            });
        }
        private double ComputeIndividualEvaluation(TrackCollection individual)
        {
            double result = 0;

            for (var k = 0; k < (individual.Count) - 1; k++)
            {
                result += Distance.Compute(individual[k], individual[k + 1]);
            }
            return(result);
        }
        public void TestSafeAdd()
        {
            var originalCollection = new TrackCollection();

            Assert.AreEqual(originalCollection.Count, 0);
            originalCollection.SafeAdd(_testTrack);
            Assert.AreEqual(originalCollection.Count, 1);
            originalCollection.SafeAdd(_testTrack);
            Assert.AreEqual(originalCollection.Count, 1);
        }
        private TrackCollection LoadTracks()
        {
            TrackCollection tracks = new TrackCollection();
            Track track = new Track() { StartTime = new DateTime(2012, 3, 1, 11, 11, 12), EndTime = new DateTime(2012, 3, 1, 11, 11, 59) };
            tracks.Add(track);

            track = new Track() { StartTime = new DateTime(2012, 3, 1, 11, 1, 0), EndTime = new DateTime(2012, 3, 1, 11, 1, 59) };
            tracks.Add(track);

            return tracks;
        }
        public override TrackCollection Sort(BackgroundWorker backgroundWorker, TrackCollection trackCollection, TrackCollection fixedTracks)
        {
            var nbCollections    = fixedTracks.Count;
            var resultCollection = new TrackCollection();
            var collections      = new List <TrackCollection>();
            int numCollection    = 0;

            fixedTracks.ForEach(delegate(Track track)
            {
                collections.Add(new TrackCollection());
                int pos = trackCollection.IndexOf(track);
                if (pos != -1)
                {
                    for (int i = 0; i < pos; i++)
                    {
                        collections[numCollection].Add(trackCollection[i]);
                    }
                    numCollection++;

                    collections.Add(new TrackCollection());
                    collections[numCollection].Add(trackCollection[pos]); // add the fixed Track
                    numCollection++;

                    trackCollection.RemoveRange(0, pos + 1);
                }
            });

            collections.Add(new TrackCollection());
            for (int i = 0; i < trackCollection.Count; i++)
            {
                collections[numCollection].Add(trackCollection[i]);
            }
            numCollection++;
            trackCollection.Clear();

            for (int i = 0; i < collections.Count; i++)
            {
                TrackCollection newCollection;
                newCollection = Sort(backgroundWorker, collections[i]);

                if (!newCollection.Equals(collections[i]))
                {
                    var pos = collections.IndexOf(collections[i]);
                    collections[pos] = newCollection;
                }
            }

            collections.ForEach(delegate(TrackCollection collection)
            {
                resultCollection.Concat(collection);
            });

            return(resultCollection);
        }
        public async Task Remove(TrackCollection trackCollection)
        {
            var connection = new SQLiteAsyncConnection(DbPath);
            var loadTracks = await Locator.MusicLibraryVM.TracklistItemRepository.LoadTracks(trackCollection);

            foreach (TracklistItem tracklistItem in loadTracks)
            {
                await Locator.MusicLibraryVM.TracklistItemRepository.Remove(tracklistItem);
            }
            await connection.DeleteAsync(trackCollection);
        }
        public RepositoryViewModelBase()
        {
            m_vehicles = new ListCollectionView(PersonalDomain.Domain.Vehicles);
            m_vehicles.CurrentChanged += new EventHandler(Vehicles_CurrentChanged);

            m_selectedTracks = new TrackCollection();

            SearchFrom = DateTime.Today;
            SearchTo = DateTime.Today + TimeSpan.FromMinutes(23 * 60 + 59);
            SearchAll = true;
            AutoPlay = true;
        }
Beispiel #32
0
    // parse the iTunes library and read the track data for a given list, returning a reference to the TrackCollection
    public bool LoadiTunesDataFile(string strDataFile, string strPlaylist, out TrackCollection tcOut)
    {
        tcOut = null;       // don't assume this was initialized

        PropertyList plistRoot = new PropertyList();
        plistRoot.ParseFile(strDataFile);

        foreach (PropertyList plistPlaylist in plistRoot.Value("Playlists"))
        {
            if (plistPlaylist.Value("Name") == strPlaylist)
            {
                tcOut = new TrackCollection()
                {
                    Name = plistPlaylist.Value("Name"),
                    PersistentKey = plistPlaylist.Value("Playlist Persistent ID"),
                };

                if (plistPlaylist.Contains("Playlist Items"))
                {
                    // itterate over all the items in the playlist and dereference the track information to get metadata on the song
                    // note - iTunes XML only contains those fields in the original file so we must handle the "optional" data...

                    foreach (PropertyList plistItem in plistPlaylist.Value("Playlist Items"))
                    {
                        PropertyList plistTrack = plistRoot.Value("Tracks").Value(string.Format("{0}", plistItem.Value("Track ID")));
                        if (plistTrack.Value("Track Type") == "File")
                        {
                            string strFile = _UriToFilePath(plistTrack.Value("Location"));
                            TrackReference tr = new TrackReference()
                            {
                                SourcePath = strFile,
                                Name = plistTrack.Value("Name"),
                                Size = plistTrack.Value("Size"),
                                Artist = plistTrack.Value("Artist", "Unknown Artist"),
                                Album = plistTrack.Value("Album", "Unknown Album"),
                                Compilation = plistTrack.Value("Compilation", false),
                                DiscNumber = plistTrack.Value("Disc Number", 1),
                                TrackNumber = plistTrack.Value("Track Number", 1),
                                Duration = plistTrack.Value("Total Time", 0),
                            };

                            tcOut.Tracks.Add(tr);
                        }
                    }
                }

                break;
            }
        }

        return (tcOut != null);
    }
Beispiel #33
0
        /// <summary>
        /// Export a <c>TrackCollection</c> as text file containing all information
        /// </summary>
        /// <param name="trackCollection">The collection to export</param>
        /// <param name="outputFile">The path of the destination file</param>
        public static void TextExport(TrackCollection trackCollection, string outputFile)
        {
            var sw = new StreamWriter(outputFile);

            sw.WriteLine("Playlist created with Automix Software");
            foreach (var t in trackCollection)

            {
                sw.WriteLine(t.Name + " | " + t.DisplayDuration() + " | " + t.Bpm + " | " + t.Key);
            }
            sw.Flush();
            sw.Close();
        }
        public void TestSortByName()
        {
            var myCollection = new TrackCollection
            {
                new Track("test1.mp3", TestConstant.TestCheckSum),
                new Track("test3.mp3", TestConstant.TestCheckSum + "1"),
                new Track("test2.mp3", TestConstant.TestCheckSum + "2")
            };

            myCollection.SortByName();

            Assert.IsTrue(string.Compare(myCollection[0].Name, myCollection[1].Name, StringComparison.Ordinal) < 0);
            Assert.IsTrue(string.Compare(myCollection[1].Name, myCollection[2].Name, StringComparison.Ordinal) < 0);
        }
Beispiel #35
0
 public CDEntry(CDEntry src)
 {
     m_Discid       = src.m_Discid;
     m_Artist       = src.m_Artist;
     m_Title        = src.m_Title;
     m_Year         = src.m_Year;
     m_Genre        = src.m_Genre;
     m_ExtendedData = src.m_ExtendedData;
     m_PlayOrder    = src.m_PlayOrder;
     m_Tracks       = new TrackCollection();
     foreach (Track tr in src.m_Tracks)
     {
         m_Tracks.Add(new Track(tr));
     }
 }
        public void LengthTest()
        {
            TrackCollection target = new TrackCollection();
            Track track = new Track() { StartTime = new DateTime(2012, 3, 1, 0, 0, 0) };
            target.Add(track);

            long actual = target.Length;
            Assert.AreEqual(1, actual);

            track = new Track() { StartTime = new DateTime(2012, 3, 2, 3, 1, 0) };
            target.Add(track);

            actual = target.Length;
            Assert.AreEqual(24 * 60 + 3 * 60 + 2, actual);
        }
        public TracksView(TrackCollection tracks)
        {
            foreach (var item in tracks)
            {
                TracksViewItem i = new TracksViewItem();
                i.AdjustedLengthInFeet = item.AdjustedLengthInFeet;
                i.City          = item.City;
                i.LengthInFeet  = item.LengthInFeet;
                i.LengthInMiles = item.LengthInMiles;
                i.Name          = item.Name;
                i.State         = item.State;

                inner.Add(i);
            }
        }
Beispiel #38
0
        public TrackCollection LoadTracksForGivenRelease(Release release)
        {
            String sql = "SELECT * FROM track, release, artist WHERE (release.ID = track.album) AND (artist.ID = track.artist) AND (artist.ID = track.artist)  AND " +
                         "release.identifier = '" + release.Identifier + "' ORDER BY trackNumber ASC";
            DataSet         result = MakeDataSet(sql);
            TrackCollection tc     = new TrackCollection(this, release, new List <Track>());

            foreach (DataRow row in result.Tables[0].Rows)
            {
                Track t = TrackFromDataRow(row);
                tc.Add(t);
            }

            return(tc);
        }
Beispiel #39
0
        private void LoadForm(object sender, EventArgs e)
        {
            var tracks = new TrackCollection <Track>();

            lnkTitle.Text = string.Format("Last {0} tracks played:", Channel.Tracks.Count);
            Text          = string.Format("{0} Playlist History", Channel.ChannelName);

            List <Track> list = Channel.Tracks.ConvertAll(TrackConverter);

            list.ForEach(tracks.Add);

            HistoryPanel.Controls.Clear();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            HistoryPanel.Controls.AddRange(tracks.ToArray());
        }
Beispiel #40
0
        private void TrackAdded(TrackCollection collection, TrackEventArgs e)
        {
            if (collection != Tracks)
                throw new InvalidOperationException("Album attempted to alter wrong trackcollection.");

            if (collection.Count == 1)
            {
                Artist = e.Track.Artist;
                Artist.Albums.Add(this);
            }
            //TODO: investigate maybe needed for some reason
            //else if (e.Track.Artist != null && e.Track.Artist != Artist)
            //{
            //    if (Artist != null)
            //        Artist.Albums.Remove(this);
            //    Artist = null;
            //}
        }
        private MusicSessionImpl(ISessionBuilder isb,IMainWindowHwndProvider mp)
        {
            _IMW = mp;
            _AllAlbums = new AlbumCollection(this);
            _AllArtists = new ArtistCollection(this);
            _AllTracks = new TrackCollection(this);
            _MusicFolderHelper = isb.Folders;
            _ISF = isb.GetNhibernateConfiguration(DBFactoryBuilder.GetConfiguration).BuildSessionFactory();
 
            _ISFact = isb.SettingFactory;
            _CleanOnOpen = isb.DBCleanOnOpen;
            _SessionCose = isb.OnSessionClose;
            this.Dependencies = isb.InfraTools;

            TraceListener = new ApplicationTraceListener();

            _MusicConverter = new Lazy<IMusicConverter>(isb.MusicConverterBuilder);

            Trace.Listeners.Add(TraceListener);
        }
        public RepositoryViewModel()
        {
            CommandBindings = new CommandBindingCollection();

            this.DriveManager = new DriveManager();
            m_deviceRepository = new DeviceRepository();

            m_vehicles = new ListCollectionView(PersonalDomain.Domain.Vehicles);
            m_vehicles.CurrentChanged += new EventHandler(Vehicles_CurrentChanged);

            m_selectedTracks = new TrackCollection();
            m_playbackManager = new PlaybackManager(m_selectedTracks);

            SearchFrom = DateTime.Today;
            SearchTo = DateTime.Today + TimeSpan.FromMinutes(23 * 60 + 59);
            SearchAll = true;
            SearchMode = SearchMode.Recent;
            AutoPlay = true;
            AllPlay = true;

            OpenCommand = new DelegateCommand<object>(DoOpen, CanOpen);
            SearchCommand = new DelegateCommand<object>(DoSearch, CanSearch);
            PlaybackCommand = new DelegateCommand<object>(DoPlayback, CanPlayback);
            SaveCommand = new DelegateCommand(DoSave, CanSave);
            ArrangeCommand = new DelegateCommand(DoArrange, CanArrange);

            DeleteCommand = new RoutedUICommand("삭제", "삭제", typeof(RepositoryViewModel));
            CommandBinding binding = new CommandBinding(DeleteCommand, DoDelete, CanDelete);
            CommandManager.RegisterClassCommandBinding(typeof(RepositoryViewModel), binding);
            CommandBindings.Add(binding);

            RegisterGlobalEvents();
        }
Beispiel #43
0
 /// <summary>
 /// Returns a collection containing the tracks with the specified text. 
 /// <para>
 /// If searchFields is ITPlaylistSearchFieldVisible , this is identical to the list of
 /// tracks displayed if the user enters the search text in the Search edit field in
 /// iTunes when this playlist is being displayed.
 /// </para>
 /// </summary>
 /// <param name="searchText">
 /// The text to search for. This string cannot be longer than 255 characters.
 /// </param>
 /// <param name="searchFields">
 /// Specifies which fields of each track should be searched for searchText.
 /// </param>
 /// <returns>
 /// Collection of Track objects. This will be empty if no tracks meet the search
 /// criteria.
 /// </returns>
 public TrackCollection Search(string searchText, ITPlaylistSearchField searchFields)
 {
     return Invoke((Func<TrackCollection>)delegate
     {
         TrackCollection collection = new TrackCollection();
         IITTrackCollection results = playlist.Search(searchText, searchFields);
         if (results != null)
         {
             foreach (IITTrack track in results)
             {
                 if (track != null)
                 {
                     collection.Add(new Track(track));
                 }
             }
         }
         return collection;
     });
 }
Beispiel #44
0
        /// <summary>
        /// Get a lits of iTunes Tracks given a list of track IDs.
        /// </summary>
        /// <param name="trackIDs"></param>
        /// <returns></returns>
        protected TrackCollection GetTracks(PersistentIDCollection persistentIDs)
        {
            TrackCollection tracks = new TrackCollection();

            foreach (PersistentID persistentID in persistentIDs)
            {
                Track track = controller.LibraryPlaylist.GetTrack(persistentID);
                if (track != null)
                {
                    tracks.Add(track);
                }
            }

            return tracks;
        }
 public PlaybackManager(TrackCollection tracks)
 {
     m_tracks = new ListCollectionView(tracks);
     m_tracks.SortDescriptions.Add(new SortDescription("CreateDate", ListSortDirection.Ascending));
 }
 void Start()
 {
     trackCollectionScript =GameObject.Find ("GameController").GetComponent<TrackCollection> ();
 }
 public TrackCollection LoadTracksForPlaylist(Playlist playlist)
 {
     Thread.Sleep(1000);
     TrackCollection tc = new TrackCollection(this, playlist, new List<Track>());
     for (var i = 0; i < 3; i++)
     {
         Track track = new Track(this)
         {
             Identifier = "5124525ffs12",
             Name = "Test",
             Artists = new Artist[] { new Artist(this) { Name = "TestArtist", Identifier = "2FOU" } }
         };
         tc.Add(track);
     }
     return tc;
 }
        public TrackCollection LoadTracksForGivenRelease(Release release)
        {
            String sql = "SELECT * FROM track, release, artist WHERE (release.ID = track.album) AND (artist.ID = track.artist) AND (artist.ID = track.artist)  AND " +
                "release.identifier = '" + release.Identifier + "'";
            DataSet result = MakeDataSet(sql);
            TrackCollection tc = new TrackCollection(this, release, new List<Track>());
            foreach (DataRow row in result.Tables[0].Rows)
            {
                Track t = TrackFromDataRow(row);
                tc.Add(t);
            }

            return tc;
        }
        public TrackCollection GetPlaylistTracks(Playlist playlist, int revision)
        {
            DataSet ds = MakeDataSet("SELECT data FROM [playlist], [users] WHERE [users].[id] = [playlist].[user] AND [playlist].[identifier] = '" + playlist.Identifier + "' AND [users].[identifier] = '" + playlist.User.Identifier + "'");
            String d = "";
            try
            {
                d = (String)ds.Tables[0].Rows[0]["data"];
            }
            catch (Exception e)
            {
            }

            String[] tracks = d.Split('&');
            TrackCollection tc = new TrackCollection(this, playlist, new List<Track>());
            if (String.IsNullOrEmpty(d))
                return tc;
            foreach (String strtrack in tracks)
            {
                if (String.IsNullOrEmpty(strtrack))
                    continue;
                Track pt = MakeUserTrackFromString(strtrack);
                tc.Add((Track)pt);
            }
            return tc;
        }
        public TrackCollection GetCollection(string type, string identifier)
        {
            switch (type)
            {
                case "own":
                    TrackCollection TC = new TrackCollection(this, null, new List<Track>());
                    DataSet DS = MakeDataSet("SELECT * FROM track, artist, release, users WHERE release.id = track.album AND track.artist = artist.id AND users.artist = artist.id ORDER BY release.release_date DESC");
                    foreach (DataRow dr in DS.Tables[0].Rows)
                    {
                        Track t = TrackFromDataRow(dr);
                        TC.Add(t);
                    }
                    return TC;

            }
            return null;
        }