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); }
public Tower(int maxDick) { for (int i = maxDick; i > 0; i--) { Discs.Push(i); } }
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); }
private int GetTopValue() { if (Discs.Count == 0) { return(0); } return(Discs.Peek()); }
public void SetTower(Tower tower) { _tower = tower; Discs.Clear(); foreach (var disc in tower.DiscsFromBottomToTop()) { AddDisc(disc); } }
public bool Give(Tower acceptor) { if (acceptor.Push(Discs.Peek())) { Discs.Pop(); return(true); } return(false); }
public bool Push(int income) { if (income < TopValue) { Discs.Push(income); return(true); } return(false); }
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) ) ); } }
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); }
/// <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); } }
public virtual AlbumDiscProperties GetDisc(int discNumber) { return(Discs.FirstOrDefault(d => d.DiscNumber == discNumber)); }
/// <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)); }