public void SetEditorForm(IFileFormat fileFormat) { if (fileFormat == null) { GetActiveEditor <STUserControl>(); return; } //Todo find a way to handle file editors if (fileFormat is IModelFormat) { if (ParentObjectView.WorkspacePanel == null) { ParentObjectView.WorkspacePanel = new WorkspacePanel() { Dock = DockStyle.Fill } } ; WorkspacePanel workspace = GetActiveEditor <WorkspacePanel>(ParentObjectView.WorkspacePanel); workspace.LoadFileFormat((IModelFormat)fileFormat); workspace.UpdateViewport(); } //Todo find a way to handle file editors if (fileFormat is STGenericTexture) { ImageEditorBase editor = GetActiveEditor <ImageEditorBase>(); editor.LoadProperties(((STGenericTexture)fileFormat).DisplayProperties); editor.LoadImage((STGenericTexture)fileFormat); } }
private WorkspacePanel CreateWorkspacePanel() { var workspace = new WorkspacePanel() { Dock = DockStyle.Fill }; workspace.Viewport.ObjectSelected += Viewport_SelectionChanged; return(workspace); }
private void SelectionChanged(ObjectTreeNode obj) { obj.OnClick(); bool tryUpdateViewport = false; if (Runtime.SelectedBoneIndex != -1) { tryUpdateViewport = true; Runtime.SelectedBoneIndex = -1; } if (obj.Tag is ArchiveFileInfo) { var fileInfo = (ArchiveFileInfo)obj.Tag; if (fileInfo.OpenFileFormatOnLoad) { fileInfo.FileFormat = fileInfo.OpenFile(); } if (fileInfo.FileFormat != null) { var fileNode = ObjectListWrapperLoader.OpenFormat(imgList, fileInfo.FileFormat); obj.Tag = fileInfo.FileFormat; foreach (var child in fileNode.Children) { obj.AddChild(child); } SelectionChanged(obj); return; } ArchiveFilePanel hexEditor = GetActiveEditor <ArchiveFilePanel>(); hexEditor.LoadFile(this, fileInfo); } else if (obj.Tag is STGenericTexture) { var tex = (STGenericTexture)obj.Tag; ImageEditorBase editor = GetActiveEditor <ImageEditorBase>(); editor.LoadProperties(tex.DisplayProperties); editor.LoadImage(tex); } else if (obj.Tag is IPropertyDisplay) { var property = (IPropertyDisplay)obj.Tag; STPropertyGrid editor = GetActiveEditor <STPropertyGrid>(); editor.LoadProperty(property.PropertyDisplay); } else if (obj.Tag is IEditorDisplay) { var property = (IEditorDisplay)obj.Tag; Console.WriteLine($"IEditorDisplay {property}"); var gui = GUIGenerator.Generate(property); gui.Dock = DockStyle.Fill; STPanel editor = GetActiveEditor <STPanel>(); editor.Controls.Clear(); editor.Controls.Add(gui); } else if (obj.Tag is System.IO.Stream) { var stream = (System.IO.Stream)obj.Tag; HexEditor hexEditor = GetActiveEditor <HexEditor>(); hexEditor.LoadData(stream); } else if (obj.Tag is IVideoFormat) { VideoPlayer editor = GetActiveEditor <VideoPlayer>(); editor.LoadVideoFile((IVideoFormat)obj.Tag); } else if (obj.Tag is STGenericMesh) { var mesh = (STGenericMesh)obj.Tag; mesh.SelectMesh?.Invoke(mesh, EventArgs.Empty); if (WorkspacePanel == null) { WorkspacePanel = CreateWorkspacePanel(); } WorkspacePanel workspace = GetActiveEditor <WorkspacePanel>(WorkspacePanel); var meshEditor = workspace.GetActiveEditor <MeshEditor>(); meshEditor.LoadMesh(mesh); workspace.UpdateViewport(); ObjectHiearchy.Focus(); } else if (obj.Tag is STGenericMaterial) { var mat = (STGenericMaterial)obj.Tag; if (WorkspacePanel == null) { WorkspacePanel = CreateWorkspacePanel(); } WorkspacePanel workspace = GetActiveEditor <WorkspacePanel>(WorkspacePanel); var materialEditor = workspace.GetActiveEditor <MaterialEditor>(); materialEditor.LoadMaterial(mat); workspace.UpdateViewport(); } else if (obj.Tag is IModelFormat) { if (WorkspacePanel == null) { WorkspacePanel = CreateWorkspacePanel(); } WorkspacePanel workspace = GetActiveEditor <WorkspacePanel>(WorkspacePanel); workspace.LoadFileFormat((IModelFormat)(obj.Tag)); workspace.UpdateViewport(); } else if (obj.Tag is IModelSceneFormat) { if (WorkspacePanel == null) { WorkspacePanel = CreateWorkspacePanel(); } WorkspacePanel workspace = GetActiveEditor <WorkspacePanel>(WorkspacePanel); workspace.LoadFileFormat((IModelSceneFormat)(obj.Tag)); workspace.UpdateViewport(); } else if (obj.Tag is STAnimation) { if (WorkspacePanel == null) { WorkspacePanel = CreateWorkspacePanel(); } WorkspacePanel workspace = GetActiveEditor <WorkspacePanel>(WorkspacePanel); workspace.LoadFileFormat((STAnimation)(obj.Tag)); workspace.UpdateViewport(); } else if (obj.Tag is STBone) { var bone = (STBone)obj.Tag; Runtime.SelectedBoneIndex = bone.Index; WorkspacePanel.UpdateViewport(); } if (tryUpdateViewport && WorkspacePanel != null) { WorkspacePanel.UpdateViewport(); } // else // GetActiveEditor<STPanel>(); }