Ejemplo n.º 1
0
        private ITreeStringNode addReadonlyNodeToTree(IProperty property, ITreeStringNode parent)
        {
            IInspectorPropertyEditor editor = new StringPropertyEditor(_factory, false, _actions, _model);
            ITreeStringNode          node   = new InspectorTreeNode(property, editor, _font);

            addToTree(node, parent);
            if (property.Object is INotifyPropertyChanged propertyChanged)
            {
                PropertyChangedEventHandler onPropertyChanged = (sender, e) =>
                {
                    if (e.PropertyName != property.Name)
                    {
                        return;
                    }
                    bool isExpanded = _treeView.IsCollapsed(node) == false;
                    if (isExpanded)
                    {
                        _treeView.Collapse(node);
                    }
                    ObjectTypeDescriptor.RefreshChildrenProperties(property);
                    node.TreeNode.Children.Clear();
                    addChildrenToTree(node, property);

                    //todo: we'd like to enable expanding a node that was previously expanded however there's a bug that needs to be investigated before that, to reproduce:
                    //In the demo game, show the inspector for the character and expand its current room. Then move to another room.
                    //For some reason this results in endless boundin box/matrix changes until stack overflow is reached.
                    //if (isExpanded)
                    //  _treeView.Expand(node);
                };
                propertyChanged.PropertyChanged += onPropertyChanged;
                _cleanup.Add(() => propertyChanged.PropertyChanged -= onPropertyChanged);
            }
            return(node);
        }
Ejemplo n.º 2
0
        private ITreeStringNode addToTree(IProperty property, ITreeStringNode parent)
        {
            if (property.IsReadonly)
            {
                return(addReadonlyNodeToTree(property, parent));
            }

            var propType = property.PropertyType;
            var editor   = _editorProvider.GetEditor(propType, _currentEntity);

            ITreeStringNode node = new InspectorTreeNode(property, editor, _font);

            return(addToTree(node, parent));
        }
Ejemplo n.º 3
0
        private ITreeStringNode addToTree(InspectorProperty property, ITreeStringNode parent)
        {
            if (property.IsReadonly)
            {
                return(addReadonlyNodeToTree(property, parent));
            }
            IInspectorPropertyEditor editor;

            var propType = property.Prop.PropertyType;

            if (propType == typeof(bool))
            {
                editor = new BoolPropertyEditor(_factory, _actions);
            }
            else if (propType == typeof(Color))
            {
                editor = new ColorPropertyEditor(_factory, _actions);
            }
            else if (propType == typeof(int))
            {
                editor = new NumberPropertyEditor(_actions, _state, _factory, true, false);
            }
            else if (propType == typeof(float))
            {
                editor = new NumberPropertyEditor(_actions, _state, _factory, false, false);
            }
            else if (propType == typeof(SizeF))
            {
                editor = new SizeFPropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(Size))
            {
                editor = new SizePropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(PointF))
            {
                editor = new PointFPropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(Point))
            {
                editor = new PointPropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(Vector2))
            {
                editor = new Vector2PropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(Vector3))
            {
                editor = new Vector3PropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(Vector4))
            {
                editor = new Vector4PropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(ILocation))
            {
                var entity   = _currentEntity;
                var drawable = entity == null ? null : entity.GetComponent <IDrawableInfoComponent>();
                editor = new LocationPropertyEditor(_actions, _state, _factory, false, _settings, drawable);
            }
            else if (propType == typeof(RectangleF))
            {
                editor = new RectangleFPropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(Rectangle))
            {
                editor = new RectanglePropertyEditor(_actions, _state, _factory, false);
            }
            else if (propType == typeof(int?))
            {
                editor = new NumberPropertyEditor(_actions, _state, _factory, true, true);
            }
            else if (propType == typeof(float?))
            {
                editor = new NumberPropertyEditor(_actions, _state, _factory, false, true);
            }
            else if (propType == typeof(SizeF?))
            {
                editor = new SizeFPropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(Size?))
            {
                editor = new SizePropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(PointF?))
            {
                editor = new PointFPropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(Point?))
            {
                editor = new PointPropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(Vector2?))
            {
                editor = new Vector2PropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(Vector3?))
            {
                editor = new Vector3PropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(Vector4?))
            {
                editor = new Vector4PropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(RectangleF?))
            {
                editor = new RectangleFPropertyEditor(_actions, _state, _factory, true);
            }
            else if (propType == typeof(Rectangle?))
            {
                editor = new RectanglePropertyEditor(_actions, _state, _factory, true);
            }
            else
            {
                var typeInfo = propType.GetTypeInfo();
                if (typeInfo.IsEnum)
                {
                    editor = new EnumPropertyEditor(_factory.UI, _actions);
                }
                else
                {
                    editor = new StringPropertyEditor(_factory, propType == typeof(string), _actions);
                }
            }

            ITreeStringNode node = new InspectorTreeNode(property, editor);

            return(addToTree(node, parent));
        }