예제 #1
0
        private XmlDisc GetDiscFromFolder(string dirPath)
        {
            List <XmlTrack> tracks = new List <XmlTrack>();

            foreach (string ext in Program.Config.SupportedFileTypes)
            {
                Directory.GetFiles(dirPath, string.Format("*.{0}", ext),
                                   SearchOption.TopDirectoryOnly).ToList().ForEach(delegate(string fp)
                {
                    tracks.Add(new XmlTrack(fp));
                });
            }

            string  dirName    = Path.GetFileName(dirPath);
            Regex   r          = new Regex(@"\d+");
            Match   discNumber = r.Match(dirName);
            XmlDisc tempDisc   = new XmlDisc(tracks);

            if (discNumber.Success)
            {
                tempDisc.DiscNumber = uint.Parse(discNumber.Value);
            }

            Discs.Add(tempDisc);
            Tracks.AddRange(tempDisc.Tracks.ToArray());

            if (tempDisc.DiscNumber > 0)
            {
                tracks.ToList().ForEach(x => x.DiscNumber = tempDisc.DiscNumber);
            }

            tracks.ToList().ForEach(x => x.AlbumArtist = tempDisc.AlbumArtist);

            return(tempDisc);
        }
예제 #2
0
 public Tower(int maxDick)
 {
     for (int i = maxDick; i > 0; i--)
     {
         Discs.Push(i);
     }
 }
예제 #3
0
파일: Album.cs 프로젝트: ffdd270/vocadb
        public virtual CollectionDiffWithValue <AlbumDiscProperties, AlbumDiscProperties> SyncDiscs(AlbumDiscPropertiesContract[] newDiscs)
        {
            for (var i = 0; i < newDiscs.Length; ++i)
            {
                newDiscs[i].DiscNumber = i + 1;
            }

            Func <AlbumDiscProperties, AlbumDiscPropertiesContract, bool> idEquality    = ((i1, i2) => i1.Id == i2.Id);
            Func <AlbumDiscProperties, AlbumDiscPropertiesContract, bool> valueEquality = ((i1, i2) => i1.DiscNumber.Equals(i2.DiscNumber) && string.Equals(i1.Name, i2.Name) && i1.MediaType.Equals(i2.MediaType));

            Func <AlbumDiscPropertiesContract, AlbumDiscProperties> create = (data => {
                var disc = new AlbumDiscProperties(this, data);
                Discs.Add(disc);
                return(disc);
            });

            Func <AlbumDiscProperties, AlbumDiscPropertiesContract, bool> update = ((disc, data) => {
                if (!valueEquality(disc, data))
                {
                    disc.CopyContentFrom(data);
                    return(true);
                }
                return(false);
            });

            Action <AlbumDiscProperties> remove = (disc => {
                Discs.Remove(disc);
            });

            var diff = CollectionHelper.SyncWithContent(Discs, newDiscs, idEquality, create, update, remove);

            return(diff);
        }
예제 #4
0
 private int GetTopValue()
 {
     if (Discs.Count == 0)
     {
         return(0);
     }
     return(Discs.Peek());
 }
예제 #5
0
 public void SetTower(Tower tower)
 {
     _tower = tower;
     Discs.Clear();
     foreach (var disc in tower.DiscsFromBottomToTop())
     {
         AddDisc(disc);
     }
 }
예제 #6
0
 public bool Give(Tower acceptor)
 {
     if (acceptor.Push(Discs.Peek()))
     {
         Discs.Pop();
         return(true);
     }
     return(false);
 }
예제 #7
0
 public bool Push(int income)
 {
     if (income < TopValue)
     {
         Discs.Push(income);
         return(true);
     }
     return(false);
 }
예제 #8
0
 public void InitializeParticles(int numberOfParticles)
 {
     for (int i = 0; i < numberOfParticles; i++)
     {
         Discs.Add(
             new Disc(
                 new Vector(Origin.X + i * 0.1f, Origin.Y),
                 new Vector((float)Math.Pow(-1, i) * _random.Next(-4, 4), (float)Math.Pow(-1, i) * _random.Next(-4, 4)),
                 _random.Next(1, 5),
                 _random.Next(1, 10),
                 GenerateColor(),
                 _random.Next(1, 3)
                 )
             );
     }
 }
예제 #9
0
        private XmlDisc GetDiscFromFolder(string dirPath)
        {
            List <XmlTrack> tracks = new List <XmlTrack>();

            foreach (string ext in Program.Config.SupportedFileTypes)
            {
                Directory.GetFiles(dirPath, string.Format("*.{0}", ext),
                                   SearchOption.TopDirectoryOnly).ToList().ForEach(delegate(string fp)
                {
                    tracks.Add(new XmlTrack(fp));
                });
            }

            XmlDisc tempDisc = new XmlDisc(tracks);

            Discs.Add(tempDisc);
            this.Tracks.AddRange(tempDisc.Tracks.ToArray());
            return(tempDisc);
        }
예제 #10
0
파일: XmlLibrary.cs 프로젝트: radtek/iTSfv
        /// <summary>
        /// Method to add a track to Player
        /// </summary>
        /// <param name="track"></param>
        private void AddTrack(XmlTrack track)
        {
            string albumName = track.AlbumArtist;

            if (string.IsNullOrEmpty(albumName))
            {
                albumName = Path.GetFileName(Path.GetDirectoryName(track.Location));
            }

            XmlAlbumArtist tempBand = GetBand(albumName);

            if (tempBand == null)
            {
                tempBand = new XmlAlbumArtist(albumName);
                Library.Add(tempBand.Name, tempBand);
                AlbumArtists.Add(tempBand);
            }

            XmlAlbum tempAlbum = tempBand.GetAlbum(track.GetAlbumKey());

            if (tempAlbum == null)
            {
                tempAlbum = new XmlAlbum(track.GetAlbumKey());
                Library[albumName].AddAlbum(tempAlbum);
                Albums.Add(tempAlbum);
            }

            XmlDisc tempDisc = tempAlbum.GetDisc(track.GetDiscKey());

            if (tempDisc == null)
            {
                tempDisc = new XmlDisc(track.GetDiscKey());
                Library[albumName].GetAlbum(track.GetAlbumKey()).AddDisc(tempDisc);
                Discs.Add(tempDisc);
            }

            if (Library[albumName].GetAlbum(track.GetAlbumKey()).GetDisc(track.GetDiscKey()).AddTrack(track))
            {
                Tracks.Add(track);
            }
        }
예제 #11
0
파일: Album.cs 프로젝트: ffdd270/vocadb
 public virtual AlbumDiscProperties GetDisc(int discNumber)
 {
     return(Discs.FirstOrDefault(d => d.DiscNumber == discNumber));
 }
예제 #12
0
 /// <summary>
 /// Adds a disc (from the model!!!) to the tower viewmodel
 /// </summary>
 /// <param name="disc">The disc from the model to add to the tower viewmodel.</param>
 private void AddDisc(Disc disc)
 {
     Discs.Add(new Disc_ViewModel(disc));
 }