Пример #1
0
        public static void OnZValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VectorEditor control = d as VectorEditor;

            float newValue = (float)e.NewValue;
            float oldValue = (float)e.OldValue;

            if (control.VectorType == typeof(EngineNS.Vector3))
            {
                if (System.Math.Abs(newValue - oldValue) > 0.0001f)
                {
                    var vec = (EngineNS.Vector3)(control.VectorObject);
                    var obj = new EngineNS.Vector3();
                    obj.X = vec.X; //control.XValue;
                    obj.Y = vec.Y; //control.YValue;
                    obj.Z = newValue;
                    control.VectorObject = obj;
                }
            }
            else if (control.VectorType == typeof(EngineNS.Vector4))
            {
                if (System.Math.Abs(newValue - oldValue) > 0.0001f)
                {
                    var vec = (EngineNS.Vector4)(control.VectorObject);
                    var obj = new EngineNS.Vector4();
                    obj.X = vec.X; //control.XValue;
                    obj.Y = vec.Y; //control.YValue;
                    obj.Z = newValue;
                    obj.W = vec.W; //control.WValue;
                    control.VectorObject = obj;
                }
            }
        }
Пример #2
0
        public static void OnVectorObjectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VectorEditor control = d as VectorEditor;

            if (e.NewValue == null)
            {
                return;
            }

            control.VectorType = e.NewValue.GetType();

            if (control.VectorType == typeof(EngineNS.Vector2))
            {
                var newValue = (EngineNS.Vector2)e.NewValue;
                control.NE_Z.Visibility = Visibility.Collapsed;
                control.NE_W.Visibility = Visibility.Collapsed;

                control.XValue = newValue.X;
                control.YValue = newValue.Y;
            }
            else if (control.VectorType == typeof(EngineNS.Vector3))
            {
                var newValue = (EngineNS.Vector3)e.NewValue;
                control.NE_W.Visibility = Visibility.Collapsed;

                control.XValue = newValue.X;
                control.YValue = newValue.Y;
                control.ZValue = newValue.Z;
            }
            else if (control.VectorType == typeof(EngineNS.Vector4))
            {
                var newValue = (EngineNS.Vector4)e.NewValue;
                control.XValue = newValue.X;
                control.YValue = newValue.Y;
                control.ZValue = newValue.Z;
                control.WValue = newValue.W;
            }
        }