public ViewAudioVideoPageAppbarUpdater(IApplicationBar appbar, IAudioVideoPageVM viewmodel)
        {
            _appbar = appbar;
            _vm = viewmodel;

            if (_vm == null)
                return;


            _play = new ApplicationBarIconButton()
            {
                IconUri = new Uri("/Images/AudioIcons/play.png", UriKind.Relative),
                Text = "play",
                IsEnabled = true,
            };
            _play.Click += (s, args) => _vm.Play.Execute(null);
            _play.Click += (s, args) => this.adjustPlaying(true);

            _stop = new ApplicationBarIconButton()
            {
                IconUri = new Uri("/Images/AudioIcons/stop.png", UriKind.Relative),
                Text = "stop",
                IsEnabled = false,
            };
            _stop.Click += (s, args) => _vm.Stop.Execute(null);
            _stop.Click += (s, args) => this.adjustPlaying(false);


            _vm.ObservableForProperty(x => x.IsEditable)
                .Select(change => change.Value)
                .Subscribe(iseditable => adjustApplicationBar(iseditable));

            _edit = new ApplicationBarIconButton()
            {
                IconUri = new Uri("/Images/appbar.edit.rest.png", UriKind.Relative),
                Text = "edit",
                IsEnabled = true,
            };
            _edit.Click += (s, args) => _vm.ToggleEditable.Execute(null);
            _delete = new ApplicationBarIconButton()
            {
                IconUri = new Uri("/Images/appbar.delete.rest.png", UriKind.Relative),
                Text = "delete",
                IsEnabled = true,
            };
            _delete.Click += (s, args) => _vm.Delete.Execute(null);

            adjustApplicationBar(_vm.IsEditable);

        }
예제 #2
0
        public PlayStopButton(IApplicationBar appbar, IAudioVideoPageVM vm)
            : base(appbar)
        {
            PLAY = new ButtonState()
            {
                URI = new Uri("/Images/AudioIcons/play.png", UriKind.Relative),
                Text = DiversityResources.Button_Play,
                Command = vm.Play
            };

            STOP = new ButtonState()
            {
                URI = new Uri("/Images/AudioIcons/stop.png", UriKind.Relative),
                Text = DiversityResources.Button_Stop,
                Command = vm.Stop
            };

            _subscription =
            vm.ObservableForProperty(x => x.State)
            .Value()
            .StartWith(vm.State)
            .Select(state => (state == PlayStates.Idle) ? PLAY : STOP)
            .Subscribe(s => this.CurrentState = s);
        }