Inheritance: INotifyPropertyChanged
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var currentView = SystemNavigationManager.GetForCurrentView();

            displayRequest.RequestActive(); //to request keep display on

            currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            currentView.BackRequested += CurrentView_BackRequested;

            if (e.NavigationMode != NavigationMode.Back)
            {
                try
                {
                    _mainPageViewModel = MainPage.Current.MainPageViewModel;
                    LayoutRoot.DataContext = _mainPageViewModel;
                    _currentTrack = _mainPageViewModel.PlayingTrack;
                    _canvasControl = new CanvasControl();
                    _canvasControl.Draw += _canvasControl_Draw;
                    App.AudioPlayer.CurrentTrackChanged += AudioPlayer_CurrentTrackChanged;
                    ContentPresenter.Content = _canvasControl;
                    CreateWaveForm();
                }
                catch (Exception ex)
                {
                    ErrorLogProxy.LogError(ex.ToString());
                    ErrorLogProxy.NotifyErrorInDebug(ex.ToString());
                }
            }
        }
Ejemplo n.º 2
0
 public static XmlDocument CreateTiles(Track t)
 {
     XDocument xDoc = new XDocument(
         new XElement("tile", new XAttribute("version", 3),
             new XElement("visual",
                 // Medium Tile
                 new XElement("binding",
                     new XAttribute("branding", "name"),
                     new XAttribute("displayName", "10Sound"),
                     new XAttribute("template", "TileMedium"),
                     new XElement("group",
                         new XElement("subgroup",
                             new XElement("text", t.User.Username,
                                 new XAttribute("hint-style", "caption"),
                                 new XAttribute("hint-wrap", true),
                                 new XAttribute("hint-maxLines", 3)
                             ),
                             new XElement("text", t.Title,
                                 new XAttribute("hint-style", "captionsubtle"),
                                 new XAttribute("hint-wrap", true),
                                 new XAttribute("hint-maxLines", 3)
                             )
                         )
                     )
                 ),
                 // Wide Tile
                 new XElement("binding",
                     new XAttribute("branding", "name"),
                     new XAttribute("displayName", "10Sound"),
                     new XAttribute("template", "TileWide"),
                     new XElement("group",
                         new XElement("subgroup",
                             new XElement("text", t.User.Username,
                                 new XAttribute("hint-style", "caption"),
                                 new XAttribute("hint-wrap", true),
                                 new XAttribute("hint-maxLines", 3)
                             ),
                             new XElement("text", t.Title,
                                 new XAttribute("hint-style", "captionsubtle"),
                                 new XAttribute("hint-wrap", true),
                                 new XAttribute("hint-maxLines", 3)
                             )
                         )
                     )
                 )
             )
         )
     );
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.LoadXml(xDoc.ToString());
     return xmlDoc;
 }
 private void AudioPlayer_CurrentTrackChanged(object sender, EventArgs e)
 {
     List<Track> playlist = App.AudioPlayer.PlayList;
     Track track = App.AudioPlayer.CurrentTrack;
     int index;
     for (index = 0; index < playlist.Count; index++)
     {
         if (track.Id.Equals(playlist[index].Id))
         {
             try
             {
                 PlayListView.SelectedIndex = index;
                 _currentTrack = track;
                 _canvasControl.Invalidate();
                 return;
             }
             catch (Exception ex)
             {
                 ErrorLogProxy.LogError(ex.ToString());
                 ErrorLogProxy.NotifyErrorInDebug(ex.ToString());
             }
         }
     }
 }
Ejemplo n.º 4
0
        public void PlayTrack(List<Track> playList, Track track)
        {
            var oldPlaylist = PlayList;
            PlayList = playList;
            MainPage.Current.MainPageViewModel.PlayingList = PlayList;
            MainPage.Current.MainPageViewModel.PlayingTrack = track;
            bool liveTile = (bool)ApplicationSettingsHelper.ReadRoamingSettingsValue<bool>("LiveTilesEnabled");
            if (liveTile)
            {
                UpdateLiveTile(track);
            }
            bool toast = (bool)ApplicationSettingsHelper.ReadRoamingSettingsValue<bool>("ToastsEnabled");
            if (toast)
            {
                UpdateToastMessage(track);
            }
            Debug.WriteLine("Clicked item from App: " + track.Id);
            // Start the background task if it wasn't running
            if (!IsMyBackgroundTaskRunning)// || MediaPlayerState.Closed == CurrentPlayer.CurrentState)
            {
                // First update the persisted start track
                ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.TrackId, track.Id);
                ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.Position, new TimeSpan().ToString());

                StartBackgroundAudioTask();
            }
            else
            {

                if (oldPlaylist == null || !oldPlaylist.Equals(playList))
                {
                    MessageService.SendMessageToBackground(new UpdatePlaylistMessage(playList));
                }
                MessageService.SendMessageToBackground(new TrackChangedMessage(track.Id));
            }

            if (MediaPlayerState.Paused == CurrentPlayer.CurrentState)
            {
                CurrentPlayer.Play();
            }
        }
Ejemplo n.º 5
0
        void UpdateToastMessage(Track t)
        {
            var template = ToastTemplateType.ToastImageAndText02;
            var xml = ToastNotificationManager.GetTemplateContent(template);
            xml.DocumentElement.SetAttribute("launch", "Args");

            var title = xml.CreateTextNode(t.Title);
            var artist = xml.CreateTextNode(t.User.Username);
            var elements = xml.GetElementsByTagName("text");
            elements[0].AppendChild(artist);
            elements[1].AppendChild(title);

            var imageElement = xml.GetElementsByTagName("image");
            imageElement[0].Attributes[1].NodeValue = t.ArtworkUrl;

            var toast = new ToastNotification(xml);
            var notifier = ToastNotificationManager.CreateToastNotifier();
            notifier.Show(toast);
        }
Ejemplo n.º 6
0
 void UpdateLiveTile(Track t)
 {
     try
     {
         var xmlDoc = TileService.CreateTiles(t);
         var updater = TileUpdateManager.CreateTileUpdaterForApplication();
         TileNotification notification = new TileNotification(xmlDoc); updater.Update(notification);
     }
     catch (Exception ex)
     {
         ErrorLogProxy.LogError(ex.ToString());
         ErrorLogProxy.NotifyErrorInDebug(ex.ToString());
     }
 }
 private void ListViewBase_OnItemClick(object sender, ItemClickEventArgs e)
 {
     _currentTrack = _mainPageViewModel.PlayingTrack = (Track)e.ClickedItem;
     App.AudioPlayer.PlayTrack(MainPage.Current.MainPageViewModel.PlayingList, _currentTrack);
     _canvasControl.Invalidate();
 }