private async void SelectButton_Click(object sender, RoutedEventArgs e) {
     selection = MediaList.SelectedItem;
     if (selection != null)
         this.Close();
     else
         await MediaList.ShowDetailsAsync();
 }
        public void SetStatus(VideoListItem item, VideoListItemStatusEnum status, string statusText) {
            item.Status = status;
            if (statusText != null)
                item.StatusText = statusText;

            // Store results in cache.
            scanResults[item.MediaId.Value] = new ScanResultItem(item.Status, item.StatusText);
        }
 public void SetStatus(VideoListItem item, VideoListItemStatusEnum status) {
     SetStatus(item, status, null);
 }
 private async Task DownloadFile(VideoListItem item, bool upgradeAudio) {
     if (DownloadManager != null && item != null && item.MediaId != null) {
         Media ItemData = PlayerAccess.GetVideoById(item.MediaId.Value);
         if (ItemData != null) {
             SetStatus(item, VideoListItemStatusEnum.Downloading, null);
             if (!upgradeAudio && ItemData.FileName != null && File.Exists(Settings.NaturalGroundingFolder + ItemData.FileName))
                 FileOperationAPIWrapper.MoveToRecycleBin(Settings.NaturalGroundingFolder + ItemData.FileName);
             await DownloadManager.DownloadVideoAsync(ItemData, -1, upgradeAudio,
                 (sender, e) => {
                     SetStatus(item, e.DownloadInfo.IsCompleted ? VideoListItemStatusEnum.Done : VideoListItemStatusEnum.Failed);
                 });
         }
     }
 }
 private void SelectButton_Click(object sender, RoutedEventArgs e) {
     selection = MediaList.SelectedItem;
     this.Close();
 }
 private void ShowEditFormPopup(VideoListItem item, UIElement target) {
     EditVideoWindow.InstancePopup(target, PlacementMode.Mouse, item.MediaId, item.FileName, player, EditForm_Closed);
 }
 private void ShowEditForm(VideoListItem item) {
     EditVideoWindow.Instance(item.MediaId, item.FileName, player, EditForm_Closed);
 }
 public bool UpdateFileName(VideoListItem item, string fileName) {
     EditVideoBusiness Business = new EditVideoBusiness();
     if (Business.GetVideoByFileName(fileName) == null) {
         // Update database.
         Media DbItem = Business.GetVideoById(item.MediaId.Value);
         DbItem.FileName = fileName;
         Business.Save();
         // Update in-memory list.
         if (!item.FileExists) {
             item.FileExists = true;
             item.FileName = fileName;
             playlist.RemoveAll(v => v.FileName == fileName && v.IsInDatabase == false);
         } else if (!item.IsInDatabase) {
             item.IsInDatabase = true;
             item.FileName = fileName;
             playlist.RemoveAll(v => v.FileName == fileName && v.FileExists == false);
         }
         return true;
     } else
         return false;
 }
 public bool UpdateFileName(Guid videoId, string fileName) {
     VideoListItem Item = playlist.Find(v => v.MediaId == videoId);
     if (Item == null)
         Item = new VideoListItem() { MediaId = videoId };
     return UpdateFileName(Item, fileName);
 }