public void OpenDocument <T>(object parameters) where T : EditorWindow
        {
            var existingDocument = _workspaceContainer.InnerRegions.OfType <T>().FirstOrDefault(x => x.Userdata == parameters);

            if (existingDocument != null)
            {
                // Focus on existing document.
                _workspaceContainer.ActivateWhere(x => x == existingDocument);
                return;
            }

            var child = _kernel.Get <T>();

            child.Userdata = parameters;
            _workspaceContainer.AddInnerRegion(child);
            _workspaceContainer.ActivateWhere(x => x == child);
        }
Ejemplo n.º 2
0
        private void SetupCanvas()
        {
            _canvas = new Canvas();

            var dockableLayoutContainer = new DockableLayoutContainer();

            dockableLayoutContainer.RightWidth   = 250;
            dockableLayoutContainer.BottomHeight = 250;

            var profilerDockableLayoutContainer = new DockableLayoutContainer();

            profilerDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateProfilerEditorWindow());

            var rightDockableLayoutContainer = new DockableLayoutContainer();

            rightDockableLayoutContainer.SetTopRegion(profilerDockableLayoutContainer);
            rightDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateInspectorEditorWindow());
            dockableLayoutContainer.SetRightRegion(rightDockableLayoutContainer);

            var bottomDockableLayoutContainer = new DockableLayoutContainer();

            bottomDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateProjectEditorWindow());
            bottomDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateConsoleEditorWindow());
            dockableLayoutContainer.SetBottomRegion(bottomDockableLayoutContainer);

            var workspaceDockableLayoutContainer = new DockableLayoutContainer();

            _workspaceContainer = new DockableLayoutContainer();
            workspaceDockableLayoutContainer.AddInnerRegion(_workspaceContainer);
            dockableLayoutContainer.AddInnerRegion(workspaceDockableLayoutContainer);

            var leftDockableLayoutContainer = new DockableLayoutContainer();

            leftDockableLayoutContainer.AddInnerRegion(_editorWindowFactory.CreateHierarchyEditorWindow());
            _workspaceContainer.SetLeftRegion(leftDockableLayoutContainer);

            _workspaceContainer.AddInnerRegion(_editorWindowFactory.CreateStartEditorWindow());
            _workspaceContainer.AddInnerRegion(_worldEditorWindow = _editorWindowFactory.CreateWorldEditorWindow());
            _workspaceContainer.AddInnerRegion(_gameEditorWindow  = _editorWindowFactory.CreateGameEditorWindow());

            var toolContainer = new RelativeContainer();

            /*var panButton = CreateToolButton("texture.IconToolPan", "pan");
             * panButton.Toggled = true;
             *
             * toolContainer.AddChild(panButton, new Rectangle(16, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolMove", "move"), new Rectangle(16 + 30 * 1, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolRotate", "rotate"), new Rectangle(16 + 30 * 2, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolResize", "resize"), new Rectangle(16 + 30 * 3, 8, 28, 28));
             * toolContainer.AddChild(CreateToolButton("texture.IconToolSelect", "select"), new Rectangle(16 + 30 * 4, 8, 28, 28));*/

            _gameControlContainer = new RelativeContainer();

            var unusedContainer = new RelativeContainer();

            _horizontalContainer = new HorizontalContainer();
            _horizontalContainer.AddChild(toolContainer, "*");
            _horizontalContainer.AddChild(_gameControlContainer, "0");
            _horizontalContainer.AddChild(unusedContainer, "*");

            var verticalContainer = new VerticalContainer();

            verticalContainer.AddChild(_horizontalContainer, "40");
            verticalContainer.AddChild(dockableLayoutContainer, "*");

            _canvas.SetChild(verticalContainer);

            _windowManagement.SetMainDocumentContainer(_workspaceContainer);
        }