Example #1
0
        public MainForm()
        {
            InitializeComponent();

            ApplicationSettings.Init();

            ApplicationSettings.SkinControl(this);

            // Editors that are forms
            ApplicationSettingsEditor = new SBRenderSettingsEditor();
            MaterialEditor            = new GenericMaterialEditor();

            projectTree      = new SBProjectTree();
            projectTree.Dock = DockStyle.Fill;

            LeftPane      = new SBPopoutPanel(PopoutSide.Left, ">", "<");
            LeftPane.Dock = DockStyle.Left;
            LeftPane.Contents.Add(projectTree);

            BottomPane      = new SBPopoutPanel(PopoutSide.Bottom, "Open Console", "Close Console");
            BottomPane.Dock = DockStyle.Bottom;
            BottomPane.Contents.Add(SBConsole.Console);

            MenuBar = new SBMenuBar();
            {
                var ts = new SBToolStripMenuItem("File");
                {
                    var open = new SBToolStripMenuItem("Open");
                    {
                        var folder = new SBToolStripMenuItem("Folder");
                        folder.Click       += projectTree.OpenFolder;
                        folder.ShortcutKeys = Keys.O | Keys.Control | Keys.Shift | Keys.Alt;
                        open.DropDownItems.Add(folder);

                        var scene = new SBToolStripMenuItem("Scene");
                        scene.Click       += OpenFile;
                        scene.ShortcutKeys = Keys.O | Keys.Control;
                        open.DropDownItems.Add(scene);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var open = new SBToolStripMenuItem("Import");
                    {
                        var scene = new SBToolStripMenuItem("Model");
                        scene.Click += ImportToScene;
                        open.DropDownItems.Add(scene);

                        var animimport = new SBToolStripMenuItem("Animation Into Scene");
                        animimport.Click += ImportAnimationToScene;
                        open.DropDownItems.Add(animimport);

                        var skeletonimport = new SBToolStripMenuItem("Skeleton To Model");
                        skeletonimport.Click += ImportSkeletonToScene;
                        open.DropDownItems.Add(skeletonimport);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var open = new SBToolStripMenuItem("Export");
                    {
                        var folder = new SBToolStripMenuItem("Scene to File(s)");
                        folder.Click += SaveScene;
                        open.DropDownItems.Add(folder);

                        var animexport = new SBToolStripMenuItem("Animation to File");
                        animexport.Click += ExportAnimationToFile;
                        open.DropDownItems.Add(animexport);

                        var skeletonexport = new SBToolStripMenuItem("Skeleton to File");
                        skeletonexport.Click += ExportSkeletonToFile;
                        open.DropDownItems.Add(skeletonexport);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var closeWkspc = new SBToolStripMenuItem("Clear Workspace");
                    closeWkspc.Click += CloseWorkspace;
                    ts.DropDownItems.Add(closeWkspc);
                }
                MenuBar.Items.Add(ts);

                var view = new SBToolStripMenuItem("View");
                {
                    var rsettings = new SBToolStripMenuItem("Application Settings");
                    rsettings.Click += OpenRenderSettings;
                    view.DropDownItems.Add(rsettings);

                    var meditor = new SBToolStripMenuItem("Material Editor");
                    meditor.Click += OpenMaterialEditor;
                    view.DropDownItems.Add(meditor);
                }
                MenuBar.Items.Add(view);

                var viewport = new SBToolStripMenuItem("Camera");
                {
                    var resetCamera = new SBToolStripMenuItem("Reset Camera Position");
                    resetCamera.Click += Viewport_ResetCameraPosition;
                    viewport.DropDownItems.Add(resetCamera);

                    var rsettings = new SBToolStripMenuItem("Render Viewport to File");
                    rsettings.Click += ExportRenderToFile;
                    viewport.DropDownItems.Add(rsettings);
                }
                MenuBar.Items.Add(viewport);
            }
            MenuBar.Dock = DockStyle.Top;

            viewportPanel      = new SBViewportPanel();
            viewportPanel.Dock = DockStyle.Fill;

            Controls.Add(viewportPanel);
            Controls.Add(BottomPane);
            Controls.Add(LeftPane);
            Controls.Add(MenuBar);

            FormClosing += MainForm_FormClosing;
            InitializeImportTypes();

            if (ApplicationSettings.LastOpenedPath != "")
            {
                projectTree.SetRoot(ApplicationSettings.LastOpenedPath);
            }

            OpenTKResources.Init();
        }
Example #2
0
        public MainForm()
        {
            InitializeComponent();

            ApplicationSettings.Init();

            ApplicationSettings.SkinControl(this);

            // Editors that are forms
            ApplicationSettingsEditor = new SBRenderSettingsEditor();
            MaterialEditor            = new GenericMaterialEditor();

            projectTree      = new SBProjectTree();
            projectTree.Dock = DockStyle.Fill;

            LeftPane      = new SBPopoutPanel(PopoutSide.Left, ">", "<");
            LeftPane.Dock = DockStyle.Left;
            LeftPane.Contents.Add(projectTree);

            BottomPane      = new SBPopoutPanel(PopoutSide.Bottom, "Open Console", "Close Console");
            BottomPane.Dock = DockStyle.Bottom;
            BottomPane.Contents.Add(SBConsole.Console);

            MenuBar = new SBMenuBar();
            {
                var ts = new SBToolStripMenuItem("File");
                {
                    var open = new SBToolStripMenuItem("Open");
                    {
                        var folder = new SBToolStripMenuItem("Folder");
                        folder.Click       += OpenFolder;
                        folder.ShortcutKeys = Keys.O | Keys.Control | Keys.Shift | Keys.Alt;
                        open.DropDownItems.Add(folder);

                        var scene = new SBToolStripMenuItem("Scene");
                        scene.Click       += OpenFile;
                        scene.ShortcutKeys = Keys.O | Keys.Control;
                        open.DropDownItems.Add(scene);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var open = new SBToolStripMenuItem("Import");
                    {
                        var scene = new SBToolStripMenuItem("Model Into Scene");
                        scene.Click += ImportToScene;
                        open.DropDownItems.Add(scene);

                        var animimport = new SBToolStripMenuItem("Animation Into Scene");
                        animimport.Click += ImportAnimationToScene;
                        open.DropDownItems.Add(animimport);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var open = new SBToolStripMenuItem("Export");
                    {
                        var folder = new SBToolStripMenuItem("Scene to File(s)");
                        folder.Click += SaveScene;
                        open.DropDownItems.Add(folder);

                        var animexport = new SBToolStripMenuItem("Animation to File");
                        animexport.Click += ExportAnimationToFile;
                        open.DropDownItems.Add(animexport);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var closeWkspc = new SBToolStripMenuItem("Clear Workspace");
                    closeWkspc.Click += CloseWorkspace;
                    ts.DropDownItems.Add(closeWkspc);
                }
                MenuBar.Items.Add(ts);

                var view = new SBToolStripMenuItem("View");
                {
                    var rsettings = new SBToolStripMenuItem("Render Settings");
                    rsettings.Click += OpenRenderSettings;
                    view.DropDownItems.Add(rsettings);

                    var meditor = new SBToolStripMenuItem("Material Editor");
                    meditor.Click += OpenMaterialEditor;
                    view.DropDownItems.Add(meditor);
                }
                MenuBar.Items.Add(view);

                var viewport = new SBToolStripMenuItem("Camera");
                {
                    var resetCamera = new SBToolStripMenuItem("Reset Camera Position");
                    resetCamera.Click += Viewport_ResetCameraPosition;
                    viewport.DropDownItems.Add(resetCamera);

                    var rsettings = new SBToolStripMenuItem("Render Viewport to File");
                    rsettings.Click += ExportRenderToFile;
                    viewport.DropDownItems.Add(rsettings);
                }
                MenuBar.Items.Add(viewport);
            }
            MenuBar.Dock = DockStyle.Top;

            Viewport      = new SBViewport();
            Viewport.Dock = DockStyle.Fill;

            BoneTree             = new SBBoneTree();
            BoneTree.MaximumSize = RightBarSize;
            BoneTree.Dock        = DockStyle.Top;

            MeshList             = new SBMeshList();
            MeshList.MaximumSize = RightBarSize;
            MeshList.Dock        = DockStyle.Top;

            BoneEditor      = new SBBoneEditor();
            BoneEditor.Dock = DockStyle.Fill;

            MeshPanel      = new SBMeshPanel();
            MeshPanel.Dock = DockStyle.Fill;

            RightPane      = new SBPopoutPanel(PopoutSide.Right, "<", ">");
            RightPane.Dock = DockStyle.Right;

            animationBar      = new SBAnimationBar();
            animationBar.Dock = DockStyle.Bottom;
            animationBar.Frame.Bind(Viewport, "Frame");
            animationBar.Visible = false;

            ResetControls();

            Controls.Add(Viewport);
            Controls.Add(animationBar);
            Controls.Add(BottomPane);
            Controls.Add(RightPane);
            Controls.Add(LeftPane);
            Controls.Add(MenuBar);

            RenderTimer          = new Timer();
            RenderTimer.Interval = 1000 / 120;
            RenderTimer.Tick    += new EventHandler(InvalidateRender);
            RenderTimer.Start();

            FormClosing += MainForm_FormClosing;
            InitializeImportTypes();

            if (ApplicationSettings.LastOpenedPath != "")
            {
                projectTree.SetRoot(ApplicationSettings.LastOpenedPath);
            }
        }