예제 #1
0
        public void Render()
        {
            _pane.Render(() =>
            {
                if (_accessor.Selected != null)
                {
                    NodeEditorModel.StartEditFields(_accessor.Selected);
                }
                if (_selectedToolElements != null)
                {
                    Engine.Tool.PushID("Selected".GetHashCode());
                    foreach (var toolElement in _selectedToolElements)
                    {
                        Engine.Tool.PushID(toolElement.GetHashCode());
                        toolElement.Update(_accessor.Selected);
                        Engine.Tool.PopID();
                    }
                    Engine.Tool.PopID();
                }

                if (_accessor.Selected != null)
                {
                    NodeEditorModel.EndEditFields(_accessor.Selected);
                }
            });
        }
예제 #2
0
        public void SaveLoad()
        {
            NodeEditorHost.Initialize("SaveLoad", 1500, 800, new Configuration()
            {
                ConsoleLoggingEnabled = true, IsResizable = true
            });

            var spriteID   = NodeEditorModel.AddNode <SpriteNode>();
            var textID     = NodeEditorModel.AddNode <TextNode>();
            var arcID      = NodeEditorModel.AddNode <ArcNode>();
            var circleID   = NodeEditorModel.AddNode <CircleNode>();
            var lineID     = NodeEditorModel.AddNode <LineNode>();
            var rectID     = NodeEditorModel.AddNode <RectangleNode>();
            var triangleID = NodeEditorModel.AddNode <TriangleNode>();

            if (Engine.DoEvents())
            {
                NodeEditorHost.Update();
            }

            var circle = NodeEditorModel.FindInstance(circleID) as CircleNode;

            NodeEditorModel.StartEditFields(circle);
            NodeEditorModel.NotifyEditFields(circle);
            circle.Radius   = 100;
            circle.Position = new Vector2F(500, 500);
            circle.Color    = new Color(255, 0, 100, 255);
            NodeEditorModel.EndEditFields(circle);
            while (Engine.DoEvents())
            {
                NodeEditorHost.Update();
            }
            NodeEditorModel.Save("TestData/Editor/SaveLoadTest");
            var before = NodeEditorModel.NodeTree;

            NodeEditorHost.Terminate();

            NodeEditorHost.Initialize("SaveLoad", 1500, 800, new Configuration()
            {
                ConsoleLoggingEnabled = true, IsResizable = true
            });
            NodeEditorModel.Load("TestData/Editor/SaveLoadTest.nodes");
            while (Engine.DoEvents())
            {
                NodeEditorHost.Update();
            }
            var after = NodeEditorModel.NodeTree;

            NodeEditorHost.Terminate();

            Assert.True(PartsTreeSystemTest.Helper.IsValueEqual(before, after));
        }