private void loadPreviewItems() { VideoPreview[] videoPreviews = workspaceManager.getPreviews(); ObservableCollection <VideoPreviewItemModel> videoPreviewItemModels = new ObservableCollection <VideoPreviewItemModel>(); foreach (VideoPreview currentPreview in videoPreviews) { VideoPreviewItemModel currentVideoPreviewItemModel = new VideoPreviewItemModel(); currentVideoPreviewItemModel.ownVideoPreviewInstance = currentPreview; System.Drawing.Image currentImage = currentPreview.previewImage; if (currentImage != null) { BitmapImage bitmapImage = new BitmapImage(); using (MemoryStream memory = new MemoryStream()) { currentImage.Save(memory, ImageFormat.Png); memory.Position = 0; bitmapImage.BeginInit(); bitmapImage.StreamSource = memory; bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.EndInit(); } currentVideoPreviewItemModel.PreviewImage = bitmapImage; currentVideoPreviewItemModel.PlayTime = currentPreview.playTime.getFormattedTime(); currentVideoPreviewItemModel.ForegroundColor = new SolidColorBrush(ColorUtilities.getTintByPercentage(currentPreview.recordingQuality)); currentVideoPreviewItemModel.RecordingQuality = (int)(currentPreview.recordingQuality * 100) + "%"; currentVideoPreviewItemModel.ParentWindow = this; videoPreviewItemModels.Add(currentVideoPreviewItemModel); } } listBoxGallery.ItemsSource = videoPreviewItemModels; }
private void deleteButton_Click(object sender, RoutedEventArgs e) { VideoPreviewItemModel itemModel = (VideoPreviewItemModel)(sender as Button).DataContext; DirectoryInfo directoryInfo = new DirectoryInfo(itemModel.ownVideoPreviewInstance.filePath); directoryInfo.Delete(true); itemModel.ParentWindow.refreseh(); }
private void exportButtonVP9_Click(object sender, RoutedEventArgs e) { VideoPreviewItemModel itemModel = (VideoPreviewItemModel)(sender as Button).DataContext; VideoFileReader videoFileReader = new VideoFileReader(WorkspaceManager.getWorkspacePathForGivenFile(itemModel.ownVideoPreviewInstance.fileName)); LoadingScreen loadingScreen = new LoadingScreen("Encoding as webm...", "Please, stand by!", new EncodingUtilities(videoFileReader.videoFileMetaData.filePath, 100)); loadingScreen.startEncodingAs(EncodingUtilities.EncodingType.VP9); videoFileReader.dispose(); videoFileReader = null; }