Exemplo n.º 1
0
        public Chip8(byte[] rom, IScreen screen, ISoundHandler sound, IKeyboard keyboard)
        {
            registers.PC = 512; // Most chip-8 programs start at address 0x200 (512)
            rom.CopyTo(ram, 512);

            this.screen          = screen;
            this.sound           = sound;
            this.keyboard        = keyboard;
            this.registers.Stack = new Stack <ushort>();
            this.registers.V     = new byte[16];
            this.rng             = new Random();
        }
        public ChatPageViewModel(ISoundHandler soundHandler)
        {
            this.soundHandler = soundHandler;

            // load sound file
            this.soundHandler.Load();

            this.EndTime = this.soundHandler.Duration();

            this.playPauseCommand = new MvxCommand(() =>
            {
                // start/stop UI updates if the audio is not playing
                if (soundHandler.IsPlaying)
                {
                    this.updating = false;
                }
                else
                {
                    this.Load();
                }

                soundHandler.PlayPause();
            });

            this.rewindCommand = new MvxCommand(() =>
            {
                // set current time to the beginning
                this.CurrentTime = 0;
                this.soundHandler.Rewind();
                this.updating = false;
            });

            this.forwardCommand = new MvxCommand(() =>
            {
                // set current time to the end
                this.CurrentTime = this.soundHandler.Duration();
                this.soundHandler.Forward();
                this.updating = false;
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AudioPlayer.Portable.ViewModels.AudioPlayerPageViewModel"/> class.
        /// </summary>
        /// <param name="soundHandler">Sound handler.</param>
        public AudioPlayerPageViewModel(ISoundHandler soundHandler)
        {
            _soundHandler = soundHandler;

            // load sound file
            soundHandler.Load();

            EndTime = soundHandler.Duration();

            _playPauseCommand = new MvxCommand(() =>
            {
                // start/stop UI updates if the audio is not playing
                if (soundHandler.IsPlaying)
                {
                    _updating = false;
                }
                else
                {
                    Load();
                }

                soundHandler.PlayPause();
            });

            _rewindCommand = new MvxCommand(() =>
            {
                // set current time to the beginning
                CurrentTime = 0;
                soundHandler.Rewind();
                _updating = false;
            });

            _forwardCommand = new MvxCommand(() =>
            {
                // set current time to the end
                CurrentTime = soundHandler.Duration();
                soundHandler.Forward();
                _updating = false;
            });
        }