private async void RenderButton_Click(object sender, RoutedEventArgs e) { File.WriteAllText(System.IO.Path.Combine(ManimHelper.ManimDirectory, "interactive\\exported_scenes.py"), GenerateScene(SceneName)); //Common.RunCMD("cmd.exe", $@"py -3 extract_scene.py testing\exported_scenes.py {SceneName}", ProcessWindowStyle.Normal); Uri video = new Uri(await ManimHelper.RenderVideo(SceneName)); Player.Stop(); Player.Stretch = Stretch.Uniform; Player.MediaEnded += Player_LoopMedia; Player.Visibility = Visibility.Visible; Player.Source = video; IsPreviewing = true; Player.Play(); }
private async void PreviewButton_Click(object sender, RoutedEventArgs e) { if (IsPreviewing) { Player.Stop(); IsPreviewing = false; //Player.Source = null; PreviewButton.Icon = new Uri(@"pack://*****:*****@"pack://application:,,,/Assets/Icons/Run_32x.png"); PreviewButton.Header = "Start Preview"; PlaybackPlayButton.IsEnabled = false; PlaybackStopButton.IsEnabled = false; Player.Visibility = Visibility.Collapsed; DisplayCanvas.Visibility = Visibility.Visible; } else { try { File.WriteAllText(System.IO.Path.Combine(ManimHelper.InteractiveDirectory, "exported_scenes.py"), GenerateScene(SceneName)); //Common.RunCMD("cmd.exe", $@"py -3 extract_scene.py testing\exported_scenes.py {SceneName} -pmg", ProcessWindowStyle.Normal); string vpath = await ManimHelper.RenderVideo(SceneName, new ManimHelper.ExportOptions() { LowQuality = true, SavePNG = true }); Console.WriteLine(vpath); Player.Stretch = Stretch.Uniform; Player.Visibility = Visibility.Visible; Player.Source = new Uri(vpath, UriKind.Absolute); Player.Play(); } catch (DirectoryNotFoundException) { var result = MessageBox.Show("Manim not found on your system.\r\nSelect OK to locate manim manually.", "Manim Error", MessageBoxButton.OKCancel, MessageBoxImage.Error, MessageBoxResult.OK); if (result == MessageBoxResult.OK) { ShowManimLocator(); } } } }