public void OnTwitterCommand(object arg) { TwitterService twitterService = new TwitterService(); if (twitterService.AuthenticationRequired()) { if (_windowService == null) { _windowService = new WindowService(); } _windowService.CreateWindow(new TwitterLoginVM()); } else { string message; if (_currentMedia.GetType() == typeof(Music)) { if ((_currentMedia as Music).Artists != null) { message = "Entrain d'écouter " + _currentMedia.Name + " de " + (_currentMedia as Music).Artists + " sur #MyWindowsMediaPlayer"; } else { message = "Entrain d'écouter " + _currentMedia.Name + " sur #MyWindowsMediaPlayer"; } } else if (_currentMedia.GetType() == typeof(Video)) { message = "Entrain de regarder " + _currentMedia.Name + " sur #MyWindowsMediaPlayer"; } else { message = "Entrain de lire le média " + _currentMedia.Name + " sur #MyWindowsMediaPlayer"; } if (twitterService.SendTweet(message) == false) { _twitterCommand.RaiseCanExecuteChanged(); _twitterPopup.Message = "Erreur : " + twitterService.LastError; _twitterPopup.Show(5); System.Diagnostics.Debug.WriteLine("Unable to send tweet: " + twitterService.LastError); } else { _currentMedia.Tweeted = true; _twitterCommand.RaiseCanExecuteChanged(); _twitterPopup.Message = "Votre tweet a bien été envoyé !"; _twitterPopup.Show(3); } } }