private Window_Loaded ( object sender, |
||
sender | object | |
e | ||
return | void |
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 (player == null)
PlayButton.Visibility = System.Windows.Visibility.Hidden;
if (video.FileName != null) {
if (File.Exists(Settings.NaturalGroundingFolder + video.FileName))
await LoadMediaInfoAsync();
else {
fileNotFound = true;
ErrorText.Text = "File not found.";
}
}
}
/// <summary> /// Displays a popup containing the FileBinding menu features. /// </summary> public static EditVideoWindow InstancePopup(UIElement target, PlacementMode placement, Guid? videoId, string fileName, IMediaPlayerBusiness player, ClosingCallback callback) { EditVideoWindow NewForm = new EditVideoWindow(); NewForm.isPopup = true; NewForm.videoId = videoId; if (videoId != null && videoId != Guid.Empty) NewForm.videoId = videoId; else NewForm.fileName = fileName; NewForm.player = player; NewForm.callback = callback; WindowHelper.SetScale(NewForm.FileBindingButton.ContextMenu); NewForm.Window_Loaded(null, null); NewForm.ShowFileBindingMenu(target, placement); return NewForm; }