private string GenerateScene(string sceneName) { string pythonScene = ManimHelper.PythonSceneHeader + $"class {SceneName}(GraphScene):\r\n"; if (SceneGraph != null) { pythonScene += SceneGraph.GetPyInitializer(ManimHelper.PY_TAB); } pythonScene += $"{ManimHelper.PY_TAB}def construct(self):\r\n"; UIElementCollection elements = DisplayCanvas.Children; foreach (FrameworkElement item in elements) { var shape = item as ManimHelper.IMobject_Shape; if (shape != null && shape as ManimHelper.Mobject_Graph == null) { switch (shape.Visibility) { case Visibility.Visible: pythonScene += shape.GetPyInitializer(ManimHelper.PY_TAB + ManimHelper.PY_TAB); pythonScene += "\r\n\r\n"; break; case Visibility.Collapsed: DisplayCanvas.Children.Remove(item); break; } } } pythonScene += $"\r\n"; foreach (FrameworkElement item in elements) { var shape = item as ManimHelper.IMobject_Shape; if (shape != null) { if (shape.Visibility == Visibility.Visible) { if (shape.GetType() == typeof(ManimHelper.Mobject_Ellipse)) { var ellipseobj = shape as ManimHelper.Mobject_Ellipse; pythonScene += $"{ManimHelper.PY_TAB}{ManimHelper.PY_TAB}{ellipseobj.GetDrawBorderThenFillAnim()}\r\n"; } else if (shape.GetType() == typeof(ManimHelper.Mobject_Rectangle)) { var rectobj = shape as ManimHelper.Mobject_Rectangle; pythonScene += $"{ManimHelper.PY_TAB}{ManimHelper.PY_TAB}{rectobj.GetDrawBorderThenFillAnim()}\r\n"; } else if (shape.GetType() == typeof(ManimHelper.Mobject_Text)) { var textobj = shape as ManimHelper.Mobject_Text; pythonScene += $"{ManimHelper.PY_TAB}{ManimHelper.PY_TAB}{textobj.GetWriteAnim()}\r\n"; } else if (shape.GetType() == typeof(ManimHelper.Mobject_TeX)) { var texobj = shape as ManimHelper.Mobject_TeX; pythonScene += $"{ManimHelper.PY_TAB}{ManimHelper.PY_TAB}{texobj.GetWriteAnim()}\r\n"; } else if (shape.GetType() == typeof(ManimHelper.Mobject_PiCreature)) { var piobj = shape as ManimHelper.Mobject_PiCreature; pythonScene += $"{ManimHelper.PY_TAB}{ManimHelper.PY_TAB}{piobj.GetFadeInAnim()}\r\n"; } else if (shape.GetType() == typeof(ManimHelper.Mobject_Graph)) { var graphobj = shape as ManimHelper.Mobject_Graph; pythonScene += graphobj.GetShowCreationAnim($"{ManimHelper.PY_TAB}{ManimHelper.PY_TAB}"); pythonScene += "\r\n"; } } } } Console.Write(pythonScene); return(pythonScene); }