Ejemplo n.º 1
0
        public void Execute(object parameter)
        {
            MediaItemsListModelItem mediaItem = parameter as MediaItemsListModelItem;

            switch (mediaItem.ItemState)
            {
            case MediaItemState.Local:
                // TEMPORARY: log media item playback
                App.Engine.StatisticsManager.LogMediaPlayback(mediaItem);
                if (mediaItem.IsChanged)
                {
                    mediaItem.IsChanged = false;
                    Library.markItemWatched(mediaItem.Id);
                }
                NedEngine.Utils.NavigateTo("/MediaItemsViewerPage.xaml?id=" + mediaItem.Id);
                break;

            case MediaItemState.Downloading:
                ToastPrompt toast = new ToastPrompt();
                toast.Message = String.Format("{0} is already queued for download", mediaItem.Title == String.Empty ? "Item" : mediaItem.Title);
                toast.Show();
                break;

            case MediaItemState.Remote:
                AddItemToQueueCommand.GetCommand().Execute(mediaItem);
                break;

            default:
                System.Diagnostics.Debug.Assert(false, "Unknown media item state when media item requested - unable to make decision what to do");
                break;
            }
        }
        private void OnMenuItemClicked(object sender, RoutedEventArgs args)
        {
            var menuItem = (MenuItem)sender;
            MediaItemsListModelItem mediaItem = (MediaItemsListModelItem)menuItem.CommandParameter;
            var tag = menuItem.Tag.ToString();

            switch (tag)
            {
            case DeleteTag:
                DeleteLibraryItemCommand.GetCommand().Execute(mediaItem);
                break;

            case AddToQueueTag:
                AddItemToQueueCommand.GetCommand().Execute(mediaItem);
                break;

            case DownloadNowTag:
                DownloadNowCommand.GetCommand().Execute(mediaItem);
                break;

            case ShowLinksTag:
                ShowLinksCommand.GetCommand().Execute(mediaItem);
                break;

            case ShowDescriptionTag:
                ShowDescriptionCommand.GetCommand().Execute(mediaItem);
                break;

            default:
                break;
            }
        }