Пример #1
0
        private void RegisterCommands()
        {
            //create commands
            OpenNowPlaying = new Command((parameter) =>
            {
                //display the Now Playing component
                Component = new NowPlayingUserControl();
            });

            //open collection view
            OpenCollection = new Command((parameter) =>
            {
                //display the collection component
                Component = new CollectionUserControl();
            });

            //create commands
            OpenEqualizer = new Command((parameter) =>
            {
                //display the equalizer component
                Component = new EqualizerUserControl();
            });

            //open visualizer
            OpenVisualizer = new Command((parameter) =>
            {
                //display the visualizer component
                Component = new VisualizerUserControl(this);
            });

            //play or pause
            Play = new Command((parameter) =>
            {
                //play or pause the song
                App.SoundEngine.PlayOrPause(null);
            });

            //stop
            Stop = new Command((parameter) =>
            {
                //cancel visualization task
                _visTimer.Stop();

                App.SoundEngine.Stop();
            });

            //prev
            Prev = new Command((parameter) =>
            {
                App.SoundEngine.PlayPrev();
            });

            //next
            Next = new Command((parameter) =>
            {
                App.SoundEngine.PlayNext();
            });
        }
Пример #2
0
        public MainWindowViewModel(MainWindow window)
        {
            Window = window;

            //set the initial component to be the collection
            Component = new CollectionUserControl();

            //create timer. we are using timer because it performs better than a thread in
            //in this case. uses less CPU.
            _visTimer          = new DispatcherTimer();
            _visTimer.Interval = new TimeSpan(0, 0, 0, 0, 25);
            _visTimer.Tick    += new EventHandler((sender, e) =>
            {
                RenderVisualization();
            });

            //hook up properties
            App.SoundEngine.PropertyChanged       += SoundEngine_PropertyChanged;
            App.SoundEngine.PlaybackStatusChanged += SoundEngine_PlaybackStatusChanged;

            //create commands
            RegisterCommands();
        }