/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void ExportAnimationToFile(object sender, EventArgs args) { if (viewportPanel.LoadedScene == null) { MessageBox.Show("No scene is selected"); return; } SBAnimAttachment anim = viewportPanel.GetAttachment <SBAnimAttachment>(); SBAnimation animation; if (anim != null) { animation = anim.GetAnimation(); } else { MessageBox.Show("No animation is loaded in the scene"); return; } string Filter = ""; //Create filter Dictionary <string, IExportableAnimation> extensionToExporter = new Dictionary <string, IExportableAnimation>(); foreach (IExportableAnimation exporter in AnimationExporters) { string Extension = exporter.Extension; Filter += $"*{Extension};"; extensionToExporter.Add(Extension, exporter); } string FileName; if (Tools.FileTools.TrySaveFile(out FileName, "Supported Files|" + Filter)) { foreach (var extension in extensionToExporter.Keys) { if (FileName.ToLower().EndsWith(extension)) { DialogResult Result = DialogResult.OK; if (extensionToExporter[extension].Settings != null) { using (var dialog = new SBCustomDialog(extensionToExporter[extension].Settings)) Result = dialog.ShowDialog(); } if (Result == DialogResult.OK) { extensionToExporter[extension].ExportSBAnimation(FileName, animation, (SBSkeleton)viewportPanel.LoadedScene.Skeleton); } } } } }
/// <summary> /// Trys to open the file at specified path /// </summary> /// <param name="FilePath"></param> public void OpenFile(string FilePath) { // Attachments foreach (var attachment in AttachmentTypes) { if ((!attachment.OverlayScene() && viewportPanel.LoadedScene != null) || attachment.Extension() == null) { continue; } foreach (var extension in attachment.Extension()) { if (FilePath.ToLower().EndsWith(extension)) { attachment.Open(FilePath); viewportPanel.AddAttachment(attachment); return; } } } // Animation if (viewportPanel.Viewport.Scene != null) { var anim = LoadAnimation(FilePath, (SBSkeleton)viewportPanel.Viewport.Scene.Skeleton); if (anim != null) { var animattach = new SBAnimAttachment(anim); viewportPanel.AddAttachment(animattach); return; } } // Scenes var scene = LoadScene(FilePath); if (scene != null) { CloseWorkspace(null, null); viewportPanel.SetScene(scene); return; } }