Exemple #1
0
        /*
         * private void ContentPanel_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
         * {
         *      bool bNoChng = (m_sContentPanel.Width == e.NewSize.Width && m_sContentPanel.Height == e.NewSize.Height);
         *      m_sContentPanel = e.NewSize;
         *
         *      if( !bNoChng )
         *      {
         *              if( e.NewSize.Width < e.NewSize.Height )
         *                      imgBk.Source = m_AppFrame.Theme.GetImage("Images/Bk001_portrait.jpg");
         *              else
         *                      imgBk.Source = m_AppFrame.Theme.GetImage("Images/Bk001_landscape.jpg");
         *      }
         * }
         */

        private void Instance_PlayStateChanged(object sender, EventArgs e)
        {
            switch (BackgroundAudioPlayer.Instance.PlayerState)
            {
            case PlayState.Playing:
            {
                m_AppFrame.StatusText = "Playing...";

                m_currentPosition.Stop();

                m_txtSnd.Text  = BackgroundAudioPlayer.Instance.Track.Title;
                m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")";

                m_btnPlayPause.Image.Source = m_isPause;
                m_btnPlayPause.Visibility   = Rsc.Visible;

                m_btnExtOpen.Visibility = Rsc.Visible;
                m_btnStop.Visibility    = Rsc.Visible;

                string sTag = BackgroundAudioPlayer.Instance.Track.Tag;
                if (sTag.Length > 0)
                {
                    int iTag = 0;
                    if (Int32.TryParse(sTag, out iTag))
                    {
                        //ATT: Can happen...
                        if ((iTag >= 0) && (iTag < m_sounds.Count))
                        {
                            try
                            {
                                //m_txtSnd.Text += " " + iTag.ToString();

                                m_siInPlayer = m_sounds[iTag];

                                m_btnPrev.Visibility = Rsc.ConditionalVisibility(iTag > 0);
                                m_btnNext.Visibility = Rsc.Visible;                                         //Allowe to restart list... //Rsc.ConditionalVisibility( idx < (m_sounds.Count - 1) );

                                prsBarLen.Minimum = 0;
                                prsBarLen.Maximum = (int)BackgroundAudioPlayer.Instance.Track.Duration.TotalMilliseconds;

                                m_siInPlayer.sLen = RscUtils.toDurationStr(BackgroundAudioPlayer.Instance.Track.Duration);

                                //Refresh...
                                lbSounds.ItemsSource = null;
                                lbSounds.ItemsSource = m_sounds;

                                m_currentPosition.Start();
                            }
                            catch (Exception)
                            {
                                //NOP...
                            }
                        }
                    }
                }

                break;
            }

            case PlayState.Paused:
            {
                m_AppFrame.StatusText = "Paused...";

                m_currentPosition.Stop();

                m_txtSnd.Text  = BackgroundAudioPlayer.Instance.Track.Title;
                m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")";

                m_btnPlayPause.Image.Source = m_isPlay;
                m_btnPlayPause.Visibility   = Rsc.Visible;

                m_btnExtOpen.Visibility = Rsc.Visible;
                m_btnStop.Visibility    = Rsc.Visible;

                break;
            }

            case PlayState.Stopped:
            {
                m_AppFrame.StatusText = "Stopped...";

                m_currentPosition.Stop();

                m_txtSnd.Text  = BackgroundAudioPlayer.Instance.Track.Title;
                m_txtSnd.Text += " (" + BackgroundAudioPlayer.Instance.PlayerState.ToString() + ")";

                m_btnPlayPause.Image.Source = m_isPlay;
                m_btnPlayPause.Visibility   = Rsc.Visible;

                m_btnExtOpen.Visibility = Rsc.Collapsed;
                m_btnStop.Visibility    = Rsc.Collapsed;

                prsBarLen.Value = 0;

                break;
            }

            default:
            {
                m_txtSnd.Text = "Loading...";                         //BackgroundAudioPlayer.Instance.PlayerState.ToString();
                break;
            }
            }
        }