private async void Window_Loaded(object sender, RoutedEventArgs e) { this.DataContext = settings; EditPlaylistBusiness business = new EditPlaylistBusiness(); RatingCategoryCombo.ItemsSource = await business.GetRatingCategoriesAsync(false); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { SaveButton.Focus(); string Errors = settings.Validate(); ErrorText.Text = Errors; if (Errors == null) { bool IsFirstRun = (Settings.SavedFile == null); Settings.SavedFile = settings; settings.Save(); SessionCore.Instance.Business.DownloadManager.Options = settings.Download; this.Close(); if (settings.MediaPlayerApp == MediaPlayerApplication.Mpc) { MpcConfigBusiness.ConfigureSettings(); SessionCore.Instance.Business.ConfigurePlayer(); } if (IsFirstRun || settings.MediaPlayerApp != currentPlayer) { SessionCore.Instance.Business.SetPlayer(SessionCore.Instance.GetNewPlayer()); } await EditPlaylistBusiness.AutoBindFilesAsync(); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { if (videoId != null) { video = business.GetVideoById(videoId.Value); if (video.MediaId == Guid.Empty) { throw new InvalidDataException("This Media information has an invalid empty GUID."); } } else { video = business.GetVideoByFileName(fileName); if (video == null) { video = business.NewVideo(); video.FileName = fileName; video.MediaTypeId = (int)EditVideoBusiness.GetFileType(fileName); video.DownloadName = System.IO.Path.GetFileNameWithoutExtension(fileName); isNew = true; } } this.DataContext = video; CategoryCombo.ItemsSource = business.GetCategories(video.MediaTypeId); Custom1Combo.ItemsSource = business.GetCustomRatingCategories(); Custom2Combo.ItemsSource = Custom1Combo.ItemsSource; ratingBusiness = business.GetRatings(video); RatingsGrid.DataContext = ratingBusiness; EditRating_LostFocus(null, null); if (video.FileName != null) { if (File.Exists(Settings.NaturalGroundingFolder + video.FileName)) { await LoadMediaInfoAsync(); } else { // Try to auto-attach same path with different extension. if (!EditPlaylistBusiness.AutoAttachFile(video, Path.ChangeExtension(video.FileName, null))) { fileNotFound = true; ErrorText.Text = "File not found."; } } } }
private async void ImportButton_Click(object sender, RoutedEventArgs e) { List <Guid> Selection = SelectedItems.Select(s => s.MediaId.Value).ToList(); if (Selection.Count > 0) { ImportButton.IsEnabled = false; Progress <int> progress = new Progress <int>(); progress.ProgressChanged += (psender, pe) => { ProgressText.Text = string.Format("{0}/{1}", pe, Selection.Count); }; await business.ImportToDatabase(Selection, progress); Task AutoBindTask = EditPlaylistBusiness.AutoBindFilesAsync(); MessageBox.Show("Import completed", "Result"); this.Close(); await AutoBindTask; } }