コード例 #1
0
ファイル: GUISmartDJ.cs プロジェクト: andrewjswan/mvcentral
        /// <summary>
        /// Deal with user input
        /// </summary>
        /// <param name="controlId"></param>
        /// <param name="control"></param>
        /// <param name="actionType"></param>
        protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);
              FieldSetup result;

              switch (controlId)
              {
            case (int)GUIControls.SmartDJMode:
              if (matchingMode)
              {
            matchingMode = false;
            GUIControl.SetControlLabel(windowID, (int)GUIControls.SmartDJMode, Localization.ModeFilter);
            GUIPropertyManager.SetProperty("#mvCentral.SmartDJ.Mode", "Mode: Filter");
              }
              else
              {
            matchingMode = true;
            GUIControl.SetControlLabel(windowID, (int)GUIControls.SmartDJMode, Localization.ModeMatch);
            GUIPropertyManager.SetProperty("#mvCentral.SmartDJ.Mode", "Mode: Filter");
              }
              setDefaultValues();
              refreshValues();
              reCalculatePlaylist();
              setButtonControls();
              GUIControl.FocusControl(windowID, (int)GUIControls.FieldButton1);
              break;

            case (int)GUIControls.FieldButton1:
              if (matchingMode)
              {
            selectedGenre = selectGenre();
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton1, "Genre: " + selectedGenre);
            genPlaylist(fullArtistList);
              }
              else
              {
            result = getFieldAndSearchValue(ref fieldSelected1, ref customSearchStr1, GUIControls.FieldButton1);
            if (result == FieldSetup.Success)
              GUIControl.EnableControl(windowID, (int)GUIControls.FieldButton2);

            if (result == FieldSetup.Clear)
              cleanAndReset(GUIControls.FieldButton1);
              }
              break;
            case (int)GUIControls.FieldButton2:
              if (matchingMode)
              {
            selectedLastFMTag = selectLastFMTag();
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton2, "Last FM Tag: " + selectedLastFMTag);
            genPlaylist(fullArtistList);
              }
              else
              {
            result = getFieldAndSearchValue(ref fieldSelected2, ref customSearchStr2, GUIControls.FieldButton2);
            if (result == FieldSetup.Success)
              GUIControl.EnableControl(windowID, (int)GUIControls.FieldButton3);

            if (result == FieldSetup.Clear)
              cleanAndReset(GUIControls.FieldButton2);
              }
              break;
            case (int)GUIControls.FieldButton3:
              if (matchingMode)
              {
            selectedTone = selectTone();
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton3, "Tone: " + selectedTone);
            genPlaylist(fullArtistList);
              }
              else
              {
            result = getFieldAndSearchValue(ref fieldSelected3, ref customSearchStr3, GUIControls.FieldButton3);
            if (result == FieldSetup.Success)
              GUIControl.EnableControl(windowID, (int)GUIControls.FieldButton4);

            if (result == FieldSetup.Clear)
              cleanAndReset(GUIControls.FieldButton3);
              }
              break;
            case (int)GUIControls.FieldButton4:
              if (matchingMode)
              {
            selectedStyle = selectStyle();
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton4, "Style: " + selectedStyle);
            genPlaylist(fullArtistList);
              }
              else
              {
            result = getFieldAndSearchValue(ref fieldSelected4, ref customSearchStr4, GUIControls.FieldButton4);
            if (result == FieldSetup.Success)
              GUIControl.EnableControl(windowID, (int)GUIControls.FieldButton5);

            if (result == FieldSetup.Clear)
              cleanAndReset(GUIControls.FieldButton4);
              }
              break;
            case (int)GUIControls.FieldButton5:
              if (matchingMode)
              {
            selectedComposer = selectComposer();
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton5, "Composer: " + selectedComposer);
            genPlaylist(fullArtistList);
              }
              else
              {
            result = getFieldAndSearchValue(ref fieldSelected5, ref customSearchStr5, GUIControls.FieldButton5);
            if (result == FieldSetup.Success)
              GUIControl.EnableControl(windowID, (int)GUIControls.FieldButton6);

            if (result == FieldSetup.Clear)
              cleanAndReset(GUIControls.FieldButton5);

              }
              break;
            case (int)GUIControls.FieldButton6:
              if (matchingMode)
              {
            selectedKeyword = getKeyword();
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton6, "Keyword: " + selectedKeyword);
            genPlaylist(fullArtistList);
              }
              else
              {
            result = getFieldAndSearchValue(ref fieldSelected6, ref customSearchStr6, GUIControls.FieldButton6);

            if (result == FieldSetup.Clear)
              cleanAndReset(GUIControls.FieldButton6);
              }
              break;
            case (int)GUIControls.PlayPlaylist:
              if (facadeLayout.Count > 0)
            playSmartDJPlaylist();

              break;
            case (int)GUIControls.SavePlaylist:
              if (facadeLayout.Count > 0)
            saveSmartDJPlaylist();

              break;
            case (int)GUIControls.Playlist:
              if (!Player.playlistPlayer.mvPlayer.Playing)
              {
            videoList.Clear();
            for (int i = 0; i < facadeLayout.ListLayout.Count; i++)
            {
              GUIListItem trackItem = facadeLayout.ListLayout[i];
              if (!trackItem.IsFolder && trackItem.MusicTag != null)
                videoList.Add((DBTrackInfo)trackItem.MusicTag);
            }
            addToPlaylist(videoList, false, true, smartDJ_ShufflePlaylist.Selected);
              }
              GUIWindowManager.ActivateWindow(Player.GetWindowId());
              break;

            case (int)GUIControls.ShufflePlaylist:
              mvCentralCore.Settings.SmartDJPlaylistShuffle = smartDJ_ShufflePlaylist.Selected;
              break;

            case (int)GUIControls.Facade:
              //Clicked on something in the facade
              logger.Debug("Hit Key : " + actionType.ToString());
              switch (actionType)
              {
            case Action.ActionType.ACTION_PLAY:
            case Action.ActionType.ACTION_PAUSE:
            case Action.ActionType.ACTION_QUEUE_ITEM:
            case Action.ActionType.ACTION_MUSIC_PLAY:
            case Action.ActionType.ACTION_SELECT_ITEM:

              if (facadeLayout.SelectedListItem != null)
              {
                GUIListItem selectedItem = facadeLayout.SelectedListItem;
                videoList.Clear();
                if (!selectedItem.IsFolder && selectedItem.MusicTag != null)
                {
                  // we have a track selected so add any other tracks which are on showing on the facade
                  for (int i = 0; i < facadeLayout.ListLayout.Count; i++)
                  {
                    GUIListItem trackItem = facadeLayout.ListLayout[i];
                    if (!trackItem.IsFolder && trackItem.MusicTag != null)
                      videoList.Add((DBTrackInfo)trackItem.MusicTag);
                  }
                  // Now create a Playlist
                  addToPlaylist(videoList, false, true, false);
                  // And play it
                  Player.playlistPlayer.Play(videoList.IndexOf((DBTrackInfo)selectedItem.MusicTag));
                  if (mvCentralCore.Settings.AutoFullscreen)
                    g_Player.ShowFullScreenWindow();
                  break;
                }
              }
              break;
              }
              break;
              }
        }
コード例 #2
0
ファイル: GUIMain.cs プロジェクト: andrewjswan/mvcentral
        /// <summary>
        /// Deal with user input
        /// </summary>
        /// <param name="controlId"></param>
        /// <param name="control"></param>
        /// <param name="actionType"></param>
        protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);

              if (control == btnLayouts)
              {
            mvCentralCore.Settings.DefaultView = ((int)CurrentLayout).ToString();
              }

              switch (controlId)
              {
            case (int)GuiControls.PlayAllRandom:
              playRandomAll();
              break;
            case (int)GuiControls.PlaySmart:
              playSmart(ChooseSmartPlay());
              break;
            case (int)GuiControls.PlayList:
              GUIWindowManager.ActivateWindow(Player.GetWindowId());
              break;
            case (int)GuiControls.StatsAndInfo:
              GUIWindowManager.ActivateWindow(GUImvStatsAndInfo.GetWindowId());
              break;
            case (int)GuiControls.GenreConfig:
              SetFavoriteTags();
              break;
            case (int)GuiControls.Search:
              DoSearch();
              break;
            case (int)GuiControls.Facade:
              //Clicked on something in the facade
              logger.Debug("Hit Key : " + actionType.ToString());
              switch (actionType)
              {
            case Action.ActionType.ACTION_PLAY:
            case Action.ActionType.ACTION_PAUSE:
            case Action.ActionType.ACTION_QUEUE_ITEM:
            case Action.ActionType.ACTION_MUSIC_PLAY:
            case Action.ActionType.ACTION_SELECT_ITEM:

              if (facadeLayout.SelectedListItem.IsFolder && ((actionType == Action.ActionType.ACTION_MUSIC_PLAY) || (actionType == Action.ActionType.ACTION_PLAY) || (actionType == Action.ActionType.ACTION_PAUSE)))
              {
                // Are we on an Artist or Album, if Artist add all tracks by artist to playlist else if album add all tracks on album to playlist
                if (facadeLayout.SelectedListItem.MusicTag != null && facadeLayout.SelectedListItem.MusicTag.GetType() == typeof(DBAlbumInfo))
                  AlbumActions(actionType);
                else if (facadeLayout.SelectedListItem.MusicTag != null && facadeLayout.SelectedListItem.MusicTag.GetType() == typeof(DBArtistInfo))
                  ArtistActions(actionType);
                else if (facadeLayout.SelectedListItem.MusicTag != null && facadeLayout.SelectedListItem.MusicTag.GetType() == typeof(DBGenres))
                  GenreActions(actionType);
              }
              else
              {

                GUIListItem selectedItem = facadeLayout.SelectedListItem;

                if (selectedItem.MusicTag.GetType() == typeof(DBGenres))
                {
                  DisplayByGenre(facadeLayout.SelectedListItem.Label);
                  break;
                }

                if (!selectedItem.IsFolder && selectedItem.MusicTag != null)
                {
                  // we have a track selected so add any other tracks which are on showing on the facade
                  List<DBTrackInfo> list1 = new List<DBTrackInfo>();
                  for (int i = 0; i < facadeLayout.ListLayout.Count; i++)
                  {
                    GUIListItem trackItem = facadeLayout.ListLayout[i];

                    if (!trackItem.IsFolder && trackItem.MusicTag != null)
                    {
                      list1.Add((DBTrackInfo)trackItem.MusicTag);
                    }
                  }
                  AddToPlaylist(list1, false, true, false);
                  Player.playlistPlayer.Play(list1.IndexOf((DBTrackInfo)selectedItem.MusicTag));
                  if (mvCentralCore.Settings.AutoFullscreen)
                    g_Player.ShowFullScreenWindow();
                  break;
                }
                //return to previous level
                if (facadeLayout.SelectedListItem.Label == "..")
                {
                  loadCurrent();
                }
                else
                {
                  artistID = facadeLayout.SelectedListItem.ItemId;
                  _currentView = MvView.Video;
                  addToStack(_currentView, false);
                  loadCurrent();
                }
              }
              break;
              }
              break;
              }
        }