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);
        }