예제 #1
0
        public MainPageViewModel(MediaElement me, IIsolatedStore isolatedStore)
        {
            isoStore = isolatedStore;

            this.me          = me;
            this.me.AutoPlay = false;
            this.me.BufferingProgressChanged += (s, e) => { this.BufferingProgress = me.BufferingProgress; RaisePropertyChanged("BufferingProgress"); };
            this.me.MediaFailed             += (s, e) => ShowError("Error loading " + me.Source.ToString()); // e.ErrorException.Message
            this.me.MediaOpened             += me_MediaOpened;
            this.me.MediaEnded              += (s, e) => { SelectedTrack.Listens++; Next(); };
            this.me.DownloadProgressChanged += (s, e) => { this.DownloadProgress = me.DownloadProgress * 100; RaisePropertyChanged("DownloadProgress"); };

            this.timer     = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(500);
            timer.Tick    += OnTimerTick;
            timer.Start();

            this.Tracks       = new ObservableCollection <TrackViewModel>();
            this.PlayCommand  = new RelayCommand(() => this.me.Play());
            this.PauseCommand = new RelayCommand(() => this.me.Pause());
            this.NextCommand  = new RelayCommand(() => Next());
            this.PrevCommand  = new RelayCommand(() => Prev());
            this.AnonCommand  = new AnonymiseCommand(Tracks);
            this.OpenCommand  = new RelayCommand(() => Open());

            var loader = new ContestLoader(knownContests.Last(), isoStore);

            loader.Loaded += OnContestLoaded;
            IsLoading      = true;
            loader.BeginLoad();
        }
        public OpenContestWindowViewModel(IIsolatedStore store, IEnumerable <ContestInfo> knownContests)
        {
            this.Contests = new ObservableCollection <ContestInfo>();

            var repo = new RatingsRepository(store);

            foreach (var fileName in store.GetFileNames("*.xml"))
            {
                var c = repo.Load(fileName);
                this.Contests.Add(new ContestInfo()
                {
                    IsoStoreFileName = fileName, Name = c.Name, TrackListUrl = c.TrackListUrl
                });
            }

            AddKnownContests(knownContests);
        }
예제 #3
0
 public ContestLoader(ContestInfo contestInfo, IIsolatedStore isoStore)
 {
     this.contestInfo = contestInfo;
     this.isoLoader   = new IsolatedStoreContestLoader(contestInfo.IsoStoreFileName, isoStore);
     this.kvrLoader   = new KvrTrackListLoader(contestInfo.TrackListUrl);
 }
예제 #4
0
 public IsolatedStoreContestLoader(string fileName, IIsolatedStore isoStore)
 {
     this.fileName = fileName;
     this.isoStore = isoStore;
 }
예제 #5
0
 public RatingsRepository(IIsolatedStore isolatedStore)
 {
     this.isolatedStore = isolatedStore;
 }