diff --git a/Aurora/Aurora.csproj b/Aurora/Aurora.csproj index 122adea..51e70d9 100644 --- a/Aurora/Aurora.csproj +++ b/Aurora/Aurora.csproj @@ -33,6 +33,7 @@ + diff --git a/Aurora/Backend/Models/BaseSong.cs b/Aurora/Backend/Models/BaseSong.cs index ca2156d..935029a 100644 --- a/Aurora/Backend/Models/BaseSong.cs +++ b/Aurora/Backend/Models/BaseSong.cs @@ -1,10 +1,16 @@ using System; +using System.IO; + namespace Aurora.Backend.Models { public abstract class BaseSong { + private bool _loaded; + private Stream _stream; + public BaseSong() { + _loaded = false; Id = Guid.NewGuid().ToString(); } @@ -41,16 +47,41 @@ namespace Aurora.Backend.Models /// public object Metadata { get; set; } - #endregion Properties - #region Methods - /// - /// Play this instance. - /// - public abstract void Play(); + public virtual void Load() + { + _loaded = true; + } + + public virtual void Unload() + { + _loaded = false; + } + + /// + /// Gets or sets the data stream that holds the song. + /// + /// The data stream. + public Stream DataStream + { + get + { + //if (!_loaded) + //{ + // throw new InvalidOperationException("Must be loaded first"); + //} + return _stream; + } + protected set + { + if (value != _stream) + { + _stream = value; + } + } + } - #endregion } } diff --git a/Aurora/Backend/Models/LocalSong.cs b/Aurora/Backend/Models/LocalSong.cs index 21405bb..502344c 100644 --- a/Aurora/Backend/Models/LocalSong.cs +++ b/Aurora/Backend/Models/LocalSong.cs @@ -15,12 +15,25 @@ namespace Aurora.Backend.Models #endregion Properties - #region Methods - public override void Play() + public override void Load() { - throw new NotImplementedException(); + if (this.DataStream != null) + { + DataStream.Close(); + DataStream = null; + } + this.DataStream = System.IO.File.OpenRead(File.FullName); + base.Load(); } - #endregion Methods + public override void Unload() + { + if (this.DataStream != null) + { + DataStream.Close(); + DataStream = null; + } + base.Unload(); + } } } \ No newline at end of file diff --git a/Aurora/Frontend/Views/BaseViewModel.cs b/Aurora/Frontend/Views/BaseViewModel.cs index 76b6588..f30f12d 100644 --- a/Aurora/Frontend/Views/BaseViewModel.cs +++ b/Aurora/Frontend/Views/BaseViewModel.cs @@ -4,13 +4,23 @@ using System.Runtime.CompilerServices; namespace Aurora.Frontend.Views { - public class BaseViewModel + public class BaseViewModel : INotifyPropertyChanged { public BaseViewModel() { } #region INotifyPropertyChanged Implementation + public bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) + { + if (Object.Equals(storage, value)) + return false; + + storage = value; + OnPropertyChanged(propertyName); + return true; + } + public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged([CallerMemberName] string propertyName = "") { diff --git a/Aurora/Frontend/Views/Songs/SongsView.xaml b/Aurora/Frontend/Views/Songs/SongsView.xaml index 5a48407..ee475b6 100644 --- a/Aurora/Frontend/Views/Songs/SongsView.xaml +++ b/Aurora/Frontend/Views/Songs/SongsView.xaml @@ -1,11 +1,16 @@ + + + + + RowHeight="30" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8" > @@ -18,7 +23,14 @@ - + + + +