예제 #1
0
 public static float GetNearestKey(SvgElement element, float time, bool on)
 {
     float[] singleArray1 = AnimFunc.GetKeys(element);
     Array.Sort(singleArray1, (Array)null, (IComparer)null);
     for (int num1 = 0; num1 < singleArray1.Length; num1++)
     {
         float single1 = singleArray1[num1];
         if ((single1 > time) || (Math.Abs((float)(single1 - time)) <= Math.Pow(10, -2)))
         {
             if (on)
             {
                 if ((Math.Abs((float)(single1 - time)) <= Math.Pow(10, -2)) && ((num1 + 1) < singleArray1.Length))
                 {
                     return(singleArray1[num1 + 1]);
                 }
                 return(single1);
             }
             if ((num1 - 1) >= 0)
             {
                 return(singleArray1[num1 - 1]);
             }
             return(0f);
         }
     }
     return(singleArray1[singleArray1.Length - 1]);
 }
예제 #2
0
        public static Matrix GetMatrixForTime(ITransformBrush brush, int time)
        {
            int num1 = 0;
            int num2 = 0;

            ((SvgElement)brush).SvgAnimAttributes = (Hashtable)((SvgElement)brush).SvgAttributes.Clone();
            AnimFunc.CreateAnimateValues(brush, time, out num1, out num2);
            return(brush.Transform.Matrix.Clone());
        }
예제 #3
0
        public static string[] Linear(string startvalue, float starttime, string endvalue, float endtime, DomType domtype, int time)
        {
            int num2;
            int num5;

            char[] chArray1 = new char[2] {
                ' ', ','
            };
            string[] textArray1 = startvalue.Split(chArray1);
            char[]   chArray2   = new char[2] {
                ' ', ','
            };
            string[] textArray2 = endvalue.Split(chArray2);
            string[] textArray3 = new string[Math.Min(textArray1.Length, textArray2.Length)];
            switch (domtype)
            {
            case DomType.SvgMatrix:
            case DomType.SvgNumber:
            {
                num2 = 0;
                goto Label_0217;
            }

            case DomType.SvgString:
            {
                goto Label_0762;
            }

            case DomType.SvgColor:
            {
                if ((!startvalue.Trim().StartsWith("url") && !endvalue.Trim().StartsWith("url")) && ((endvalue != "none") && (startvalue != "none")))
                {
                    Color    color1      = ColorFunc.ParseColor(startvalue.Trim());
                    Color    color2      = ColorFunc.ParseColor(endvalue.Trim());
                    float    single5     = (float)Math.Round((double)AnimFunc.Linear((float)color1.R, starttime, (float)color2.R, endtime, (float)time), 2);
                    float    single6     = (float)Math.Round((double)AnimFunc.Linear((float)color1.G, starttime, (float)color2.G, endtime, (float)time), 2);
                    float    single7     = (float)Math.Round((double)AnimFunc.Linear((float)color1.B, starttime, (float)color2.B, endtime, (float)time), 2);
                    string[] textArray11 = new string[1];
                    string[] textArray12 = new string[7] {
                        "rgb(", single5.ToString(), ",", single6.ToString(), ",", single7.ToString(), ")"
                    };
                    textArray11[0] = string.Concat(textArray12);
                    return(textArray11);
                }
                if (time < ((starttime / 2f) + (endtime / 2f)))
                {
                    return(new string[1] {
                            startvalue
                        });
                }
                return(new string[1] {
                        endvalue
                    });
            }

            case DomType.SvgPath:
            {
                PointInfoCollection collection1 = new PointInfoCollection();
                PointInfoCollection collection2 = new PointInfoCollection();
                GraphicsPath        path1       = PathFunc.PathDataParse(startvalue, collection1);
                GraphicsPath        path2       = PathFunc.PathDataParse(endvalue, collection2);
                if (collection1.Count == collection2.Count)
                {
                    string text4 = string.Empty;
                    for (int num3 = 0; num3 < collection1.Count; num3++)
                    {
                        PointInfo info1 = collection1[num3];
                        PointInfo info2 = collection2[num3];
                        if (((info1.Command.Trim().ToLower() != info2.Command.Trim().ToLower()) || (info1.IsStart != info2.IsStart)) || (info1.IsEnd != info2.IsEnd))
                        {
                            if ((time > ((starttime + endtime) / 2f)) && (time <= endtime))
                            {
                                return(new string[1] {
                                        endvalue
                                    });
                            }
                            if ((time <= ((starttime + endtime) / 2f)) && (time >= starttime))
                            {
                                return(new string[1] {
                                        startvalue
                                    });
                            }
                            return(new string[1] {
                                    string.Empty
                                });
                        }
                        text4 = text4 + info1.Command.Trim().ToUpper();
                        string text5 = info1.Command.Trim().ToUpper();
                        if (((text5 == "C") || (text5 == "Q")) || (((text5 == "A") || (text5 == "T")) || (text5 == "S")))
                        {
                            float    single8     = AnimFunc.Linear(info1.FirstControl.X, starttime, info2.FirstControl.X, endtime, (float)time);
                            float    single9     = AnimFunc.Linear(info1.FirstControl.Y, starttime, info2.FirstControl.Y, endtime, (float)time);
                            string   text8       = text4;
                            string[] textArray19 = new string[5] {
                                text8, single8.ToString(), " ", single9.ToString(), " "
                            };
                            text4   = string.Concat(textArray19);
                            single8 = AnimFunc.Linear(info1.SecondControl.X, starttime, info2.SecondControl.X, endtime, (float)time);
                            single9 = AnimFunc.Linear(info1.SecondControl.Y, starttime, info2.SecondControl.Y, endtime, (float)time);
                            string   text9       = text4;
                            string[] textArray20 = new string[5] {
                                text9, single8.ToString(), " ", single9.ToString(), " "
                            };
                            text4 = string.Concat(textArray20);
                        }
                        float    single10    = AnimFunc.Linear(info1.MiddlePoint.X, starttime, info2.MiddlePoint.X, endtime, (float)time);
                        float    single11    = AnimFunc.Linear(info1.MiddlePoint.Y, starttime, info2.MiddlePoint.Y, endtime, (float)time);
                        string   text10      = text4;
                        string[] textArray21 = new string[5] {
                            text10, single10.ToString(), " ", single11.ToString(), " "
                        };
                        text4 = string.Concat(textArray21);
                        if (info1.IsEnd)
                        {
                            text4 = text4 + "Z";
                        }
                    }
                    return(new string[1] {
                            text4
                        });
                }
                if ((time > ((starttime + endtime) / 2f)) && (time <= endtime))
                {
                    return(new string[1] {
                            endvalue
                        });
                }
                if ((time <= ((starttime + endtime) / 2f)) && (time >= starttime))
                {
                    return(new string[1] {
                            startvalue
                        });
                }
                return(new string[1] {
                        string.Empty
                    });
            }

            case DomType.SvgPoints:
            {
                PointF[] tfArray1 = PointsFunc.PointsParse(startvalue);
                PointF[] tfArray2 = PointsFunc.PointsParse(endvalue);
                if (tfArray1.Length == tfArray2.Length)
                {
                    string text1 = string.Empty;
                    for (int num1 = 0; num1 < tfArray1.Length; num1++)
                    {
                        PointF tf1     = tfArray1[num1];
                        PointF tf2     = tfArray2[num1];
                        float  single1 = AnimFunc.Linear(tf1.X, starttime, tf2.X, endtime, (float)time);
                        float  single2 = AnimFunc.Linear(tf1.Y, starttime, tf2.Y, endtime, (float)time);
                        text1 = text1 + single1.ToString() + " " + single2.ToString();
                        if (num1 < (tfArray1.Length - 1))
                        {
                            text1 = text1 + ",";
                        }
                    }
                    return(new string[1] {
                            text1
                        });
                }
                if ((time > ((starttime + endtime) / 2f)) && (time <= endtime))
                {
                    return(new string[1] {
                            endvalue
                        });
                }
                if ((time <= ((starttime + endtime) / 2f)) && (time >= starttime))
                {
                    return(new string[1] {
                            startvalue
                        });
                }
                return(new string[1] {
                        string.Empty
                    });
            }

            default:
            {
                goto Label_0762;
            }
            }
Label_0217:
            if (num2 >= textArray3.Length)
            {
                return(textArray3);
            }
            string text2   = textArray1[num2];
            string text3   = textArray2[num2];
            float  single3 = 0f;
            float  single4 = 0f;

            try
            {
                single3 = ItopVector.Core.Func.Number.ParseFloatStr(text2);
                single4 = ItopVector.Core.Func.Number.ParseFloatStr(text3);
                double num6 = Math.Round((double)AnimFunc.Linear(single3, starttime, single4, endtime, (float)time), 2);
                textArray3[num2] = num6.ToString();
            }
            catch (Exception)
            {
            }
            num2++;
            goto Label_0217;
Label_0762:
            num5 = 0;
            while (num5 < textArray3.Length)
            {
                string text6 = textArray1[num5];
                string text7 = textArray2[num5];
                if (time >= ((endtime / 2f) + (starttime / 2f)))
                {
                    textArray3[num5] = text7;
                }
                else if (time >= starttime)
                {
                    textArray3[num5] = text6;
                }
                else
                {
                    textArray3[num5] = string.Empty;
                }
                num5++;
            }
            return(textArray3);
        }
예제 #4
0
 public static Matrix GetMatrixForTime(IGraph graph, int time, int begin)
 {
     ((SvgElement)graph).SvgAnimAttributes = (Hashtable)((SvgElement)graph).SvgAttributes.Clone();
     AnimFunc.CreateAnimateValues(graph, time, begin);
     return(graph.Transform.Matrix.Clone());
 }
예제 #5
0
 public static void CreateAnimateValues(ISvgElement svgelement, int time, int maxbegin)
 {
     if (svgelement is SvgElement)
     {
         SvgElement element1 = (SvgElement)svgelement;
         element1.AnimateNameValues.Clear();
         Hashtable hashtable1 = new Hashtable(0x10);
         int       num1       = 0;
         int       num2       = 0;
         int       num3       = 0;
         SvgElementCollection.ISvgElementEnumerator enumerator1 = element1.AnimateList.GetEnumerator();
         while (enumerator1.MoveNext())
         {
             ItopVector.Core.Animate.Animate animate1 = (ItopVector.Core.Animate.Animate)enumerator1.Current;
             if (animate1.Begin < maxbegin)
             {
                 string text1 = animate1.GetAttribute("additive").Trim();
                 if (((text1 == null) || (text1 == string.Empty)) && (animate1 is MotionAnimate))
                 {
                     text1 = "sum";
                 }
                 bool    flag1 = text1 == "sum";
                 string  text2 = animate1.AttributeName;
                 int     num4  = animate1.Begin;
                 DomType type1 = DomTypeFunc.GetTypeOfAttributeName(text2);
                 object  obj1  = animate1.GetAnimateResult((float)time, type1);
                 if ((obj1 != null) && (obj1.ToString() != string.Empty))
                 {
                     if (element1.AnimateNameValues.ContainsKey(text2))
                     {
                         AnimateInfo info1 = (AnimateInfo)element1.AnimateNameValues[text2];
                         info1.Add(obj1, num4, flag1);
                     }
                     else
                     {
                         AnimateInfo info2 = new AnimateInfo();
                         info2.Add(obj1, num4, flag1);
                         element1.AnimateNameValues.Add(text2, info2);
                     }
                 }
                 if (num1 == 0)
                 {
                     num2 = num4;
                     num3 = num4 + animate1.Duration;
                     continue;
                 }
                 num2 = Math.Min(animate1.Begin, num2);
                 num3 = Math.Max((int)(num4 + animate1.Duration), num3);
             }
         }
         foreach (string text3 in element1.AnimateNameValues.Keys)
         {
             DomType type2 = DomTypeFunc.GetTypeOfAttributeName(text3);
             if (element1.SvgAttributes.ContainsKey(text3))
             {
                 object obj2 = element1.SvgAttributes[text3];
                 object obj3 = AnimFunc.GetAnimateValue(element1, text3, type2, obj2);
                 if (element1.SvgAnimAttributes.ContainsKey(text3))
                 {
                     element1.SvgAnimAttributes[text3] = obj3;
                 }
                 else
                 {
                     element1.SvgAnimAttributes.Add(text3, obj3);
                 }
                 continue;
             }
             object obj4 = null;
             object obj5 = AnimFunc.GetAnimateValue(element1, text3, type2, obj4);
             if (element1.SvgAnimAttributes.ContainsKey(text3))
             {
                 element1.SvgAnimAttributes[text3] = obj5;
                 continue;
             }
             element1.SvgAnimAttributes.Add(text3, obj5);
         }
     }
 }