Exemplo n.º 1
0
 public void AddKeyDirectly(FCurveKey <T> key)
 {
     if (keys.Contains(key))
     {
         return;
     }
     keys.Add(key);
     key.OnChangedKey += OnChangedKey;
     SortKeys(keys);
 }
Exemplo n.º 2
0
            public int Compare(FCurveKey <T> key1, FCurveKey <T> key2)
            {
                if (key1.Frame > key2.Frame)
                {
                    return(1);
                }
                else if (key1.Frame < key2.Frame)
                {
                    return(-1);
                }

                return(key1.Value.CompareTo(key2.Value));
            }
Exemplo n.º 3
0
        public void AddKey(FCurveKey <T> key)
        {
            if (keys.Contains(key))
            {
                return;
            }

            var old_value = keys;
            var new_value = new List <FCurveKey <T> >();

            new_value.AddRange(keys.Concat(new[] { key }));
            SortKeys(new_value);

            var cmd = new Command.DelegateCommand(
                () =>
            {
                keys              = new_value;
                key.OnChangedKey += OnChangedKey;

                if (OnChanged != null)
                {
                    OnChanged(this, new ChangedValueEventArgs(new_value, ChangedValueType.Execute));
                }
            },
                () =>
            {
                keys              = old_value;
                key.OnChangedKey -= OnChangedKey;

                if (OnChanged != null)
                {
                    OnChanged(this, new ChangedValueEventArgs(old_value, ChangedValueType.Unexecute));
                }
            });

            Command.CommandManager.Execute(cmd);
        }
Exemplo n.º 4
0
 void OnChangedKey(FCurveKey <T> key)
 {
     keys.Sort(new KeyComparer());
 }
Exemplo n.º 5
0
        public static void LoadFromElement(XmlElement e, Value.FCurveColorRGBA value, bool isClip)
        {
            Action <Data.Value.FCurve <byte>, XmlElement> import = (v_, e_) =>
            {
                foreach (XmlElement r in e_.ChildNodes)
                {
                    if (r.Name.StartsWith("Key"))
                    {
                        var f  = r.GetTextAsInt("Frame");
                        var v  = r.GetTextAsFloat("Value");
                        var lx = r.GetTextAsFloat("LeftX");
                        var ly = r.GetTextAsFloat("LeftY");
                        var rx = r.GetTextAsFloat("RightX");
                        var ry = r.GetTextAsFloat("RightY");
                        var i  = r.GetTextAsInt("InterpolationType");

                        var t = new Value.FCurveKey <byte>(f, (byte)v);
                        t.SetLeftDirectly(lx, ly);
                        t.SetRightDirectly(rx, ry);
                        t.InterpolationType.SetValue(i);

                        v_.AddKeyDirectly(t);
                    }
                    else if (r.Name.StartsWith("StartType"))
                    {
                        var v = r.GetTextAsInt();
                        v_.StartType.SetValue(v);
                    }
                    else if (r.Name.StartsWith("EndType"))
                    {
                        var v = r.GetTextAsInt();
                        v_.EndType.SetValue(v);
                    }
                    else if (r.Name.StartsWith("OffsetMax"))
                    {
                        var v = r.GetTextAsFloat();
                        v_.OffsetMax.SetValueDirectly(v);
                    }
                    else if (r.Name.StartsWith("OffsetMin"))
                    {
                        var v = r.GetTextAsFloat();
                        v_.OffsetMin.SetValueDirectly(v);
                    }
                    else if (r.Name.StartsWith("Sampling"))
                    {
                        var v = r.GetTextAsInt();
                        v_.Sampling.SetValueDirectly(v);
                    }
                }
            };


            var e_keys = e["Keys"] as XmlElement;

            if (e_keys == null)
            {
                return;
            }

            var e_r = e_keys["R"] as XmlElement;
            var e_g = e_keys["G"] as XmlElement;
            var e_b = e_keys["B"] as XmlElement;
            var e_a = e_keys["A"] as XmlElement;

            if (e_r != null)
            {
                import(value.R, e_r);
            }
            if (e_g != null)
            {
                import(value.G, e_g);
            }
            if (e_b != null)
            {
                import(value.B, e_b);
            }
            if (e_a != null)
            {
                import(value.A, e_a);
            }
        }
Exemplo n.º 6
0
        public static void LoadFromElement(XmlElement e, Value.FCurveVector3D value, bool isClip)
        {
            var e_keys = e["Keys"] as XmlElement;

            if (e_keys == null)
            {
                return;
            }

            var e_x = e_keys["X"] as XmlElement;
            var e_y = e_keys["Y"] as XmlElement;
            var e_z = e_keys["Z"] as XmlElement;

            Action <Data.Value.FCurve <float>, XmlElement> import = (v_, e_) =>
            {
                foreach (XmlElement r in e_.ChildNodes)
                {
                    if (r.Name.StartsWith("Key"))
                    {
                        var f  = r.GetTextAsInt("Frame");
                        var v  = r.GetTextAsFloat("Value");
                        var lx = r.GetTextAsFloat("LeftX");
                        var ly = r.GetTextAsFloat("LeftY");
                        var rx = r.GetTextAsFloat("RightX");
                        var ry = r.GetTextAsFloat("RightY");
                        var i  = r.GetTextAsInt("InterpolationType");

                        var t = new Value.FCurveKey <float>(f, v);
                        t.SetLeftDirectly(lx, ly);
                        t.SetRightDirectly(rx, ry);
                        t.InterpolationType.SetValue(i);

                        v_.AddKeyDirectly(t);
                    }
                    else if (r.Name.StartsWith("StartType"))
                    {
                        var v = r.GetTextAsInt();
                        v_.StartType.SetValue(v);
                    }
                    else if (r.Name.StartsWith("EndType"))
                    {
                        var v = r.GetTextAsInt();
                        v_.EndType.SetValue(v);
                    }
                    else if (r.Name.StartsWith("OffsetMax"))
                    {
                        var v = r.GetTextAsFloat();
                        v_.OffsetMax.SetValueDirectly(v);
                    }
                    else if (r.Name.StartsWith("OffsetMin"))
                    {
                        var v = r.GetTextAsFloat();
                        v_.OffsetMin.SetValueDirectly(v);
                    }
                    else if (r.Name.StartsWith("Sampling"))
                    {
                        var v = r.GetTextAsInt();
                        v_.Sampling.SetValueDirectly(v);
                    }
                }
            };

            if (e_x != null)
            {
                import(value.X, e_x);
            }
            if (e_y != null)
            {
                import(value.Y, e_y);
            }
            if (e_z != null)
            {
                import(value.Z, e_z);
            }
        }