Example #1
0
 private void SetIsPlayingIndicator(bool isPlaying)
 {
     if (isPlaying)
     {
         PlayIcon.Visibility  = Visibility.Collapsed;
         PauseIcon.Visibility = Visibility.Visible;
         ToolTipService.SetToolTip(PlayPauseButton, "Pause");
         PlayPauseButton.SetValue(AutomationProperties.NameProperty, "Pause");
     }
     else
     {
         PlayIcon.Visibility  = Visibility.Visible;
         PauseIcon.Visibility = Visibility.Collapsed;
         ToolTipService.SetToolTip(PlayPauseButton, "Play");
         PlayPauseButton.SetValue(AutomationProperties.NameProperty, "Play");
     }
 }
Example #2
0
        /// <summary>
        /// 点击视频画面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MediaContainer_Tapped(object sender, TappedRoutedEventArgs e)
        {
            PlayPauseButton.Focus(FocusState.Programmatic);
            var timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(200);
            timer.Tick    += ((s, ea) =>
            {
                if (isTapped)
                {
                    isTapped = false;
                    IsShowControlPanel = !IsShowControlPanel;
                }
                timer.Stop();
            });
            isTapped = true;
            timer.Start();
        }
Example #3
0
        void showMessageBox(string s)
        {
            timer.Stop();
            IsGamePaused            = true;
            PlayPauseButton.Content = "Play";

            MessageBoxResult result = MessageBox.Show($"{s} again?", "game over", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                EndAnimation();
            }
            else
            {
                InitBoardForNewGame();
                PlayPauseButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
        }
Example #4
0
        private void Media_CurrentStateChanged(object sender, RoutedEventArgs e)
        {
            var i = Media.CurrentState;

            switch (i)
            {
            case MediaElementState.Playing:
            {
                PlayPauseButton.Focus(FocusState.Programmatic);
                StatusText.Visibility          = Visibility.Collapsed;
                Status.Visibility              = Visibility.Collapsed;
                PlayPauseSymbol.Symbol         = Symbol.Pause;
                SettingHelper.IsScreenAlwaysOn = true;
                DanmakuManager.Resume();
                break;
            }

            case MediaElementState.Paused:
            {
                goto case MediaElementState.Closed;
            }

            case MediaElementState.Stopped:
            {
                goto case MediaElementState.Closed;
            }

            case MediaElementState.Closed:
            {
                //修改按钮图标
                PlayPauseSymbol.Symbol = Symbol.Play;
                //取消屏幕常亮
                SettingHelper.IsScreenAlwaysOn = false;
                DanmakuManager.Pause();
                break;
            }
            }
        }
        public void Initialize <TState>(ReduxStore <TState> store) where TState : class, new()
        {
            if (store.TimeTravelEnabled)
            {
                // TODO : Cannot activate History component
            }

            // Observe UI events
            UndoButton.Events().Click
            .Subscribe(_ => store.Undo());
            RedoButton.Events().Click
            .Subscribe(_ => store.Redo());
            ResetButton.Events().Click
            .Subscribe(_ => store.Reset());

            PlayPauseButton.Events().Click
            .Subscribe(_ => _internalStore.Dispatch(new TogglePlayPauseAction()));

            Slider.Events().ValueChanged
            .Where(_ => Slider.FocusState != FocusState.Unfocused)
            .Subscribe(e =>
            {
                int newPosition = (int)e.NewValue;
                _internalStore.Dispatch(new MoveToPositionAction {
                    Position = newPosition
                });
            });

            // Observe changes on internal state
            _internalStore.Select(state => state.MaxPosition)
            .Subscribe(maxPosition =>
            {
                Slider.Maximum = maxPosition;
            });

            Observable.CombineLatest(
                _internalStore.Select(state => state.CurrentPosition),
                _internalStore.Select(state => state.PlaySessionActive),
                _internalStore.Select(state => state.MaxPosition),
                store.ObserveCanUndo(),
                store.ObserveCanRedo(),
                Tuple.Create
                )
            .ObserveOnDispatcher()
            .Subscribe(x =>
            {
                var(currentPosition, playSessionActive, maxPosition, canUndo, canRedo) = x;

                Slider.Value = currentPosition;

                if (playSessionActive)
                {
                    UndoButton.IsEnabled      = false;
                    RedoButton.IsEnabled      = false;
                    ResetButton.IsEnabled     = false;
                    PlayPauseButton.IsEnabled = true;

                    Slider.IsEnabled = false;

                    PlayPauseButton.Content = "\xE769";
                }
                else
                {
                    UndoButton.IsEnabled      = canUndo;
                    RedoButton.IsEnabled      = canRedo;
                    ResetButton.IsEnabled     = canUndo || canRedo;
                    PlayPauseButton.IsEnabled = canRedo;

                    Slider.IsEnabled = maxPosition > 0;

                    PlayPauseButton.Content = "\xE768";
                }
            });

            _internalStore.ObserveAction <MoveToPositionAction>()
            .Subscribe(a =>
            {
                if (a.Position < _internalStore.State.CurrentPosition)
                {
                    for (int i = 0; i < _internalStore.State.CurrentPosition - a.Position; i++)
                    {
                        store.Undo();
                    }
                }
                if (a.Position > _internalStore.State.CurrentPosition)
                {
                    for (int i = 0; i < a.Position - _internalStore.State.CurrentPosition; i++)
                    {
                        store.Redo();
                    }
                }
            });

            // Observe changes on listened state
            var goForwardNormalActionOrigin = store.ObserveAction()
                                              .Select(action => new { Action = action, BreaksTimeline = true });
            var goForwardRedoneActionOrigin = store.ObserveAction(ActionOriginFilter.Redone)
                                              .Select(action => new { Action = action, BreaksTimeline = false });

            goForwardNormalActionOrigin.Merge(goForwardRedoneActionOrigin)
            .ObserveOnDispatcher()
            .Subscribe(x =>
            {
                _internalStore.Dispatch(new GoForwardAction {
                    Action = x.Action, BreaksTimeline = x.BreaksTimeline
                });
                if (_internalStore.State.PlaySessionActive && !store.CanRedo)
                {
                    _internalStore.Dispatch(new TogglePlayPauseAction());
                }
            });

            store.ObserveUndoneAction()
            .ObserveOnDispatcher()
            .Subscribe(_ => _internalStore.Dispatch(new GoBackAction()));

            store.ObserveReset()
            .ObserveOnDispatcher()
            .Subscribe(_ => _internalStore.Dispatch(new ResetAction()));

            _internalStore.Select(state => state.PlaySessionActive)
            .Select(playSessionActive =>
                    playSessionActive ? Observable.Interval(TimeSpan.FromSeconds(1)) : Observable.Empty <long>()
                    )
            .Switch()
            .ObserveOnDispatcher()
            .Subscribe(_ =>
            {
                bool canRedo = store.Redo();
                if (!canRedo)
                {
                    _internalStore.Dispatch(new TogglePlayPauseAction());
                }
            });

            // Track redux actions
            _internalStore.ObserveAction()
            .Subscribe(action =>
            {
                TrackReduxAction(action);
            });
        }
Example #6
0
        internal void Initialize <TState>(ReduxStore <TState> store) where TState : class, new()
        {
            // Observe UI events
            UndoButton.Events().Click
            .Subscribe(_ => store.Undo());
            RedoButton.Events().Click
            .Subscribe(_ => store.Redo());
            ResetButton.Events().Click
            .Subscribe(_ => store.Reset());

            PlayPauseButton.Events().Click
            .Subscribe(_ => _devToolsStore.Dispatch(new TogglePlayPauseAction()));

            Slider.Events().ValueChanged
            .Where(_ => Slider.FocusState != Windows.UI.Xaml.FocusState.Unfocused)
            .Select(e => (int)e.NewValue)
            .DistinctUntilChanged()
            .Subscribe(newPosition =>
            {
                _devToolsStore.Dispatch(new MoveToPositionAction {
                    Position = newPosition
                });
            });

            ReduxActionInfosListView.Events().ItemClick
            .Subscribe(e =>
            {
                int index = ReduxActionInfosListView.Items.IndexOf(e.ClickedItem);
                _devToolsStore.Dispatch(new SelectPositionAction {
                    Position = index
                });
            });

            // Observe changes on DevTools state
            Observable.CombineLatest(
                _devToolsStore.Select(SelectCurrentPosition),
                _devToolsStore.Select(SelectPlaySessionActive),
                _devToolsStore.Select(SelectMaxPosition),
                store.ObserveCanUndo(),
                store.ObserveCanRedo(),
                Tuple.Create
                )
            .Subscribe(x =>
            {
                var(currentPosition, playSessionActive, maxPosition, canUndo, canRedo) = x;

                Slider.Value   = currentPosition;
                Slider.Maximum = maxPosition;

                if (playSessionActive)
                {
                    UndoButton.IsEnabled      = false;
                    RedoButton.IsEnabled      = false;
                    ResetButton.IsEnabled     = false;
                    PlayPauseButton.IsEnabled = true;
                    Slider.IsEnabled          = false;
                    PlayPauseButton.Content   = "\xE769";
                }
                else
                {
                    UndoButton.IsEnabled      = canUndo;
                    RedoButton.IsEnabled      = canRedo;
                    ResetButton.IsEnabled     = canUndo || canRedo;
                    PlayPauseButton.IsEnabled = canRedo;
                    Slider.IsEnabled          = maxPosition > 0;
                    PlayPauseButton.Content   = "\xE768";
                }
            });

            _devToolsStore.Select(
                CombineSelectors(SelectCurrentActions, SelectSelectedActionPosition)
                )
            .Subscribe(x =>
            {
                var(actions, selectedPosition) = x;

                ReduxActionInfosListView.ItemsSource   = actions;
                ReduxActionInfosListView.SelectedIndex = Math.Clamp(selectedPosition, -1, actions.Count - 1);
            });

            _devToolsStore.Select(SelectSelectedReduxAction)
            .Subscribe(reduxActionOption =>
            {
                reduxActionOption.Match()
                .Some().Do(reduxAction =>
                {
                    var serializerSettings = new JsonSerializerSettings
                    {
                        ContractResolver      = SuccinctContractResolver.Instance,
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                        Formatting            = Formatting.Indented
                    };

                    SelectedReduxActionDataTextBlock.Text = JsonConvert.SerializeObject(
                        reduxAction.Data,
                        serializerSettings
                        );
                    SelectedStateTextBlock.Text = JsonConvert.SerializeObject(
                        reduxAction.NextState,
                        serializerSettings
                        );
                    SelectedDiffStateTextBlock.Text = "This feature will be available soon...";
                })
                .None().Do(() =>
                {
                    SelectedReduxActionDataTextBlock.Text = string.Empty;
                    SelectedStateTextBlock.Text           = string.Empty;
                    SelectedDiffStateTextBlock.Text       = string.Empty;
                })
                .Exec();
            });

            _devToolsStore.ObserveAction <MoveToPositionAction>()
            .WithLatestFrom(
                _devToolsStore.Select(SelectCurrentPosition),
                Tuple.Create
                )
            .Subscribe(x =>
            {
                var(action, currentPosition) = x;

                if (action.Position < currentPosition)
                {
                    for (int i = 0; i < currentPosition - action.Position; i++)
                    {
                        store.Undo();
                    }
                }
                if (action.Position > currentPosition)
                {
                    for (int i = 0; i < action.Position - currentPosition; i++)
                    {
                        store.Redo();
                    }
                }
            });

            _devToolsStore.Select(SelectPlaySessionActive)
            .Select(playSessionActive =>
                    playSessionActive ? Observable.Interval(TimeSpan.FromSeconds(1)) : Observable.Empty <long>()
                    )
            .Switch()
            .ObserveOnDispatcher()
            .Subscribe(_ =>
            {
                bool canRedo = store.Redo();
                if (!canRedo)
                {
                    _devToolsStore.Dispatch(new TogglePlayPauseAction());
                }
            });

            // Observe changes on listened state
            var storeHistoryAtInitialization = store.GetHistory();

            store.ObserveHistory()
            .StartWith(storeHistoryAtInitialization)
            .Subscribe(historyInfos =>
            {
                var mementosOrderedByDate = historyInfos.PreviousStates
                                            .OrderBy(reduxMemento => reduxMemento.Date)
                                            .ToList();

                // Set list of current actions
                // Set list of future (undone) actions
                _devToolsStore.Dispatch(new HistoryUpdated
                {
                    CurrentActions = mementosOrderedByDate
                                     .Select((reduxMemento, index) =>
                    {
                        int nextIndex = index + 1;
                        var nextState = nextIndex < mementosOrderedByDate.Count
                                    ? mementosOrderedByDate[nextIndex].PreviousState
                                    : store.State;

                        return(new ReduxActionInfo
                        {
                            Date = reduxMemento.Date,
                            Type = reduxMemento.Action.GetType(),
                            Data = reduxMemento.Action,
                            PreviousState = reduxMemento.PreviousState,
                            NextState = nextState
                        });
                    })
                                     .ToImmutableList(),
                    FutureActions = historyInfos.FutureActions
                                    .Select(action =>
                    {
                        return(new ReduxActionInfo
                        {
                            Type = action.GetType(),
                            Data = action
                        });
                    })
                                    .ToImmutableList()
                });
            });

            _devToolsStore.Dispatch(
                new SelectPositionAction {
                Position = storeHistoryAtInitialization.PreviousStates.Count - 1
            }
                );
        }
Example #7
0
    private void InitButtons()
    {
        PlayPauseButton button = new PlayPauseButton(
                                                     "Images/play_button.xpm", //play
                                                     "Images/pause_button.xpm"); //pause

        button.Clicked += delegate(object sender, PlayPauseButtonEventArgs e) {
            Console.WriteLine(_currentTreeIter.Stamp);

            if (_currentTreeIter.Stamp != 0) {
                if (!e.IsPaused)
                    PlayTrack(_currentTreeIter);
                else
                {
                    if (_streamer != null)
                        _streamer.Pause();
                }
            } else button.SwitchState();

        };

        XPMButton backButton = new XPMButton("Images/back_button.xpm",
                                             "Images/back_button_pushed.xpm");

        XPMButton forwardButton = new XPMButton("Images/forward_button.xpm",
                                             "Images/forward_button_pushed.xpm");

        forwardButton.Clicked+= delegate(object sender, ButtonReleaseEventArgs e) {
            NextTrack();
        };

        bottomBar.PackStart(backButton, false, false, 0);
        bottomBar.PackStart(button, false, false, 0);
        bottomBar.PackStart(forwardButton, false, false, 0);
    }
        void ReleaseDesignerOutlets()
        {
            if (BufferedProgressSlider != null)
            {
                BufferedProgressSlider.Dispose();
                BufferedProgressSlider = null;
            }

            if (NextButton != null)
            {
                NextButton.Dispose();
                NextButton = null;
            }

            if (PlayingProgressSlider != null)
            {
                PlayingProgressSlider.Dispose();
                PlayingProgressSlider = null;
            }

            if (PlayPauseButton != null)
            {
                PlayPauseButton.Dispose();
                PlayPauseButton = null;
            }

            if (PreviousButton != null)
            {
                PreviousButton.Dispose();
                PreviousButton = null;
            }

            if (QueueLabel != null)
            {
                QueueLabel.Dispose();
                QueueLabel = null;
            }

            if (RepeatButton != null)
            {
                RepeatButton.Dispose();
                RepeatButton = null;
            }

            if (ShuffleButton != null)
            {
                ShuffleButton.Dispose();
                ShuffleButton = null;
            }

            if (SubtitleLabel != null)
            {
                SubtitleLabel.Dispose();
                SubtitleLabel = null;
            }

            if (TimePlayedLabel != null)
            {
                TimePlayedLabel.Dispose();
                TimePlayedLabel = null;
            }

            if (TimeTotalLabel != null)
            {
                TimeTotalLabel.Dispose();
                TimeTotalLabel = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }

            if (TrackCoverImageView != null)
            {
                TrackCoverImageView.Dispose();
                TrackCoverImageView = null;
            }
        }
 void StopPlayback()
 {
     Player.Rate = 0;
     PlayPauseButton.SetImage(UIImage.FromBundle("PlayButton"), UIControlState.Normal);
 }
 void StartPlayback()
 {
     player.Rate = 1;
     PlayPauseButton.SetImage(UIImage.FromBundle("PauseButton"), UIControlState.Normal);
 }
Example #11
0
 /// <summary>
 /// 点击控制栏获取焦点以便进行键盘控制
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ControlPanel_Tapped(object sender, TappedRoutedEventArgs e)
 {
     PlayPauseButton.Focus(FocusState.Programmatic);
 }
            private Widget GetRightPane()
            {
                VBox vbox = new VBox ();

                // labels
                moveNumberLabel = new Label ();
                nagCommentLabel = new Label ();
                nagCommentLabel.Xalign = 0;
                HBox hbox = new HBox ();
                hbox.PackStart (moveNumberLabel, false, false,
                        2);
                hbox.PackStart (nagCommentLabel, false, false,
                        2);

                vbox.PackStart (hbox, false, false, 2);

                // board
                chessGameDetailsBox = new VBox ();
                chessGameDetailsBox.PackStart (gameView,
                                   true, true, 4);

                vbox.PackStart (chessGameDetailsBox, true,
                        true, 2);

                // buttons
                playButton = new PlayPauseButton ();
                playButton.PlayNextEvent +=
                    on_play_next_event;

                firstButton = new Button ();
                firstButton.Clicked += on_first_clicked;
                firstButton.Image =
                    new Image (Stock.GotoFirst,
                           IconSize.Button);
                prevButton = new Button ();
                prevButton.Clicked += on_prev_clicked;
                prevButton.Image =
                    new Image (Stock.GoBack,
                           IconSize.Button);
                nextButton = new Button ();
                nextButton.Clicked += on_next_clicked;
                nextButton.Image =
                    new Image (Stock.GoForward,
                           IconSize.Button);
                lastButton = new Button ();
                lastButton.Clicked += on_last_clicked;
                lastButton.Image =
                    new Image (Stock.GotoLast,
                           IconSize.Button);

                HBox bbox = new HBox ();
                bbox.PackStart (firstButton, false, false, 1);
                bbox.PackStart (prevButton, false, false, 1);
                bbox.PackStart (playButton, false, false, 1);
                bbox.PackStart (nextButton, false, false, 1);
                bbox.PackStart (lastButton, false, false, 1);
                Alignment alignment =
                    new Alignment (0.5f, 1, 0, 0);
                alignment.Add (bbox);
                alignment.Show ();

                vbox.PackStart (alignment, false, false, 2);
                book.AppendPage (gamesListWidget,
                         new Label (Catalog.
                                GetString
                                ("Games")));
                book.AppendPage (vbox,
                         new Label (Catalog.
                                GetString
                                ("Current Game")));

                return book;
            }
Example #13
0
        private void ClientOnStatusUpdated(object sender, VlcStatus vlcStatus)
        {
            var time = new TimeSpan(0, 0, 0, vlcStatus.Time);

            Task.Factory.StartNew(() =>
            {
                var currentLeaf = GetCurrentLeaf().Result;
                if (currentLeaf != null)
                {
                    RunOnUiThread(() => TimeTextView2.Text = TimeSpan.FromSeconds(currentLeaf.Duration).ToString());
                }
                else
                {
                    RunOnUiThread(() => TimeTextView2.SetText(Resource.String.app_unknown_duration));
                }
            });

            RunOnUiThread(() =>
            {
                TimeTextView.Text = time.ToString();

                var value = (int)Math.Round((decimal)(125.0 * vlcStatus.Volume / 320.0));

                if (CanProgressBeSet)
                {
                    VolumeSeekbar.SetProgress(value, true);
                }

                string title;
                try
                {
                    title = Path.GetFileNameWithoutExtension(vlcStatus.Information.Category.First().Info
                                                             .First(i => i.Name == "filename").Text);
                }
                catch
                {
                    try
                    {
                        title = Path.GetFileNameWithoutExtension(vlcStatus.Information.Category.First().Info
                                                                 .First(i => i.Name == "name").Text);
                    }
                    catch
                    {
                        title = "";
                    }
                }

                if (title != "")
                {
                    TitleTextView.Text = title;
                }
                else
                {
                    TitleTextView.SetText(Resource.String.app_unknown_title);
                }

                if (vlcStatus.State == VlcPlaybackState.Playing)
                {
                    if (PlayPauseButton.State != MorphButton.MorphState.Start)
                    {
                        PlayPauseButton.SetState(MorphButton.MorphState.Start, true);
                    }
                }
                else
                {
                    if (PlayPauseButton.State != MorphButton.MorphState.End)
                    {
                        PlayPauseButton.SetState(MorphButton.MorphState.End, true);
                    }
                }
            });
        }