private void SetState(PlayButtonState newState) { string buttonText; bool buttonInteractable; switch (newState) { case PlayButtonState.ConnectingToMaster: buttonText = "Connecting..."; buttonInteractable = false; break; case PlayButtonState.JoiningRoom: buttonText = "Joining lobby..."; buttonInteractable = false; break; case PlayButtonState.ReadyToPlay: buttonText = "Play"; buttonInteractable = true; break; default: buttonText = "undefined"; buttonInteractable = false; break; } _playButtonText.SetText(buttonText); _playButton.interactable = buttonInteractable; _currentState = newState; }
/// <summary> /// 触发Play发出状态改变命令 /// </summary> /// <param name="yourState"></param> private void OnReportButtonState(PlayButtonState yourState) { if (ButtonStateChangedEvent != null) { this.ButtonStateChangedEvent(this, new PlayButtonEventArgs(yourState)); } }
private void play_song(object sender, EventArgs e) { if (State.AppState._FullName_file == null) { Toast.MakeText(this, "You do not select a file", ToastLength.Short).Show(); } else { if (position_play == PlayButtonState.Stop) { var songCover = Android.Net.Uri.Parse(State.AppState._FullName_file); song = MediaPlayer.Create(this, songCover); play.SetImageResource(Resource.Drawable.icon_pause); //play.SetBackgroundResource(Resource.Drawable.icon_pause); song.Start(); position_play = PlayButtonState.Play; timer_main.Start(); } else if (position_play == PlayButtonState.Play) { song.Pause(); position_play = PlayButtonState.Pause; play.SetImageResource(Resource.Drawable.icon_play); timer_main.Stop(); } else if (position_play == PlayButtonState.Pause) { song.Start(); play.SetImageResource(Resource.Drawable.icon_pause); position_play = PlayButtonState.Play; timer_main.Start(); } seek_bar.Max = song.Duration / 1000; with_a_folder.Text = "Folder: " + State.AppState._Folder_file; song_name.Text = State.AppState._Name_file; update_index_actial_song(); if (index_actual_song < State.AppState.name_file_list.Count - 1) { next_song.Text = "Next song: " + State.AppState.name_file_list[index_actual_song + 1]; } else { next_song.Text = "Next song: " + State.AppState.name_file_list[0]; } } }
private void Awake() { _playButton = GetComponent <Button>(); _playButtonText = _playButton.GetComponentInChildren <TMP_Text>(); _currentState = PlayButtonState.ConnectingToMaster; var alreadyConnected = PhotonNetwork.IsConnectedAndReady; SetState(alreadyConnected ? PlayButtonState.ReadyToPlay : PlayButtonState.ConnectingToMaster); _playButton.onClick.AddListener(OnPlayButtonClicked); }
/// <summary> /// Sets all states for the play button /// </summary> public void SetPlayButtonState(PlayButtonState state) { currentPlayButtonState = state; if (PlayButton != null) { trigger.triggers.Clear(); PlayButton.onClick.RemoveAllListeners(); switch (state) { case PlayButtonState.Placement: PlayButton.onClick.AddListener(() => OnSpawnBallClick(0)); PlayButton.image.sprite = PlayButtonPlacementSprite; break; case PlayButtonState.Play: PlayButton.onClick.AddListener(() => OnPlayClick()); PlayButton.image.sprite = PlayButtonPlaySprite; if (trigger != null) { var pointerDown = new EventTrigger.Entry(); pointerDown.eventID = EventTriggerType.PointerDown; pointerDown.callback.AddListener((e) => OnPlayDown()); trigger.triggers.Add(pointerDown); var pointerUP = new EventTrigger.Entry(); pointerUP.eventID = EventTriggerType.PointerUp; pointerUP.callback.AddListener((e) => OnPlayUp()); trigger.triggers.Add(pointerUP); } break; case PlayButtonState.Replay: PlayButton.onClick.AddListener(() => OnReplayClick()); PlayButton.image.sprite = PlayButtonReplaySprite; break; default: break; } } }
/// <summary> /// Sets the global <see cref="updateState"/> and then changes the state of <see cref="playButton"/> accordingly. /// </summary> /// <param name="state">The state that should be set to.</param> private void SetPlayButtonState(PlayButtonState state) { updateState = state; switch (updateState) { case PlayButtonState.Download: case PlayButtonState.Downloading: case PlayButtonState.Select11: case PlayButtonState.Install: case PlayButtonState.Play: playButton.Enabled = true; break; case PlayButtonState.Installing: case PlayButtonState.Playing: playButton.Enabled = false; break; } playButton.Text = GetPlayButtonText(); playButton.ToolTip = GetPlayButtonTooltip(); playButton.Invalidate(); UpdateModSettingsState(); }
/// <summary> /// 真正执行者完成命令后的返回确认信息 /// </summary> /// <param name="yourState">确认状态</param> public void OnChangeState(PlayButtonState yourState) { buttonState = yourState; switch (buttonState) { case PlayButtonState.Stop: pictureBox_Play.Image = imageList_ForPlayButton.Images[2]; pictureBox_Pause.Image = imageList_ForPlayButton.Images[1]; pictureBox_Set.Image = imageList_ForPlayButton.Images[8]; pictureBox_outReport.Image = imageList_ForPlayButton.Images[4]; pictureBox_Remove.Image = imageList_ForPlayButton.Images[6]; break; case PlayButtonState.Run: pictureBox_Play.Image = imageList_ForPlayButton.Images[3]; pictureBox_Pause.Image = imageList_ForPlayButton.Images[0]; pictureBox_Set.Image = imageList_ForPlayButton.Images[9]; pictureBox_outReport.Image = imageList_ForPlayButton.Images[5]; pictureBox_Remove.Image = imageList_ForPlayButton.Images[7]; break; case PlayButtonState.Pause: pictureBox_Play.Image = imageList_ForPlayButton.Images[2]; pictureBox_Pause.Image = imageList_ForPlayButton.Images[1]; pictureBox_Set.Image = imageList_ForPlayButton.Images[9]; pictureBox_outReport.Image = imageList_ForPlayButton.Images[5]; pictureBox_Remove.Image = imageList_ForPlayButton.Images[7]; break; default: break; } }
public override bool OnOptionsItemSelected(IMenuItem item) { if (item.ItemId == Resource.Id.a_list_of_songs_in_the_folder) { if (State.AppState._FullName_file == null) { Toast.MakeText(this, "This list is empty because you did not choose any folder with songs", ToastLength.Short).Show(); } else { StartActivity(typeof(ListSongActivity)); } } else if (item.ItemId == Resource.Id.information_about_aplication) { StartActivity(typeof(InfoAplicationActivity)); } else if (item.ItemId == Resource.Id.add_to_favorites) { if (State.AppState._FullName_file == null) { Toast.MakeText(this, "Ehh ... what do you want to add?", ToastLength.Short).Show(); } else { State.AppState.paths_favorite_file_list.Add(State.AppState._FullName_file); State.AppState.name_favorite_file_list.Add(State.AppState._FullName_file.Remove(0, State.AppState._Path_file.Length)); } } else if (item.ItemId == Resource.Id.a_list_of_songs_in_the_favorites) { if (State.AppState._FullName_file == null) { Toast.MakeText(this, "This list is empty :(", ToastLength.Short).Show(); StartActivity(typeof(ListFovoriteSongActivity)); } else { StartActivity(typeof(ListFovoriteSongActivity)); } } else if (item.ItemId == Resource.Id.play_A_favorites_song) { if (State.AppState._FullName_file == null) { Toast.MakeText(this, "TList of favorite songs is empty :(", ToastLength.Short).Show(); } else { State.AppState.paths_file_list = State.AppState.paths_favorite_file_list; State.AppState.name_file_list = State.AppState.name_favorite_file_list; State.AppState._Name_file = State.AppState.name_favorite_file_list[0]; if (position_play == PlayButtonState.Play) { song.Stop(); play.SetImageResource(Resource.Drawable.icon_play); } var songCover = Android.Net.Uri.Parse(State.AppState.paths_file_list[0]); song = MediaPlayer.Create(this, songCover); play.SetImageResource(Resource.Drawable.icon_pause); song.Start(); position_play = PlayButtonState.Play; song_name.Text = State.AppState._Name_file; next_song.Text = State.AppState.name_favorite_file_list[1]; } } return(base.OnOptionsItemSelected(item)); }
private void buttonPause_Click(object sender, RoutedEventArgs e) { State = PlayButtonState.Pause; if (PlayStateChanged != null) PlayStateChanged.Invoke(this, State); if (Click != null) Click.Invoke(this, new RoutedEventArgs()); }
public PlayButtonEventArgs(PlayButtonState yourState) { playState = yourState; }