Example #1
0
        public VectorSlider(PropertyInfo prop, object owner, float min = 0, float max = 1, NodeType type = NodeType.Float4, bool isInt = false)
        {
            InitializeComponent();
            property      = prop;
            propertyOwner = owner;
            this.min      = min;
            this.max      = max;

            switch (type)
            {
            case NodeType.Float2:
                ZView.Visibility = Visibility.Collapsed;
                WView.Visibility = Visibility.Collapsed;
                break;

            case NodeType.Float3:
                ZView.Visibility = Visibility.Visible;
                WView.Visibility = Visibility.Collapsed;
                break;

            case NodeType.Float4:
                ZView.Visibility = Visibility.Visible;
                WView.Visibility = Visibility.Visible;
                break;
            }

            object b = prop.GetValue(owner);

            if (b == null)
            {
                pc = new VectorPropertyContainer(new MVector());
            }
            else
            {
                MVector vec = (MVector)b;
                pc = new VectorPropertyContainer(vec);
            }

            pc.OnUpdate += Pc_OnUpdate;

            var xprop = pc.GetType().GetProperty("XProp");
            var yprop = pc.GetType().GetProperty("YProp");
            var zprop = pc.GetType().GetProperty("ZProp");
            var wprop = pc.GetType().GetProperty("WProp");

            XValue.IsInt = isInt;
            YValue.IsInt = isInt;
            ZValue.IsInt = isInt;
            WValue.IsInt = isInt;

            XValue.Set(min, max, xprop, pc);
            YValue.Set(min, max, yprop, pc);
            ZValue.Set(min, max, zprop, pc);
            WValue.Set(min, max, wprop, pc);
        }
Example #2
0
        public VectorInput(PropertyInfo prop, object owner, NodeType type = NodeType.Float4, NumberInputType ntype = NumberInputType.Float)
        {
            InitializeComponent();
            property      = prop;
            propertyOwner = owner;

            switch (type)
            {
            case NodeType.Float2:
                ZPos.Visibility = Visibility.Collapsed;
                WPos.Visibility = Visibility.Collapsed;
                break;

            case NodeType.Float3:
                ZPos.Visibility = Visibility.Visible;
                WPos.Visibility = Visibility.Collapsed;
                break;

            case NodeType.Float4:
                ZPos.Visibility = Visibility.Visible;
                WPos.Visibility = Visibility.Visible;
                break;
            }

            object b = prop.GetValue(owner);

            if (b == null)
            {
                pc = new VectorPropertyContainer(new MVector());
            }
            else
            {
                MVector vec = (MVector)b;
                pc = new VectorPropertyContainer(vec);
            }

            pc.OnUpdate += Pc_OnUpdate;

            var xprop = pc.GetType().GetProperty("XProp");
            var yprop = pc.GetType().GetProperty("YProp");
            var zprop = pc.GetType().GetProperty("ZProp");
            var wprop = pc.GetType().GetProperty("WProp");

            XPos.Set(ntype, pc, xprop);
            YPos.Set(ntype, pc, yprop);
            ZPos.Set(ntype, pc, zprop);
            WPos.Set(ntype, pc, wprop);
        }