Пример #1
0
 public void AddAnimationStep(AnimationStep animationStep)
 {
     if (animationStep == null)
     {
         throw new ArgumentNullException("animationStep");
     }
     this.animationSteps.Add(animationStep);
 }
Пример #2
0
 public void InsertAnimationStep(AnimationStep animationStep, int index)
 {
     if (animationStep == null)
     {
         throw new ArgumentNullException("animationStep");
     }
     this.animationSteps.Insert(index, animationStep);
 }
Пример #3
0
        private static Animation Load(string[] lines)
        {
            Animation animation = new Animation();

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i] == "END")
                {
                    break;
                }
                if (lines[i][0] != ';')
                {
                    string line = lines[i].Replace(" ", "");
                    if (line.StartsWith("xd=", StringComparison.Ordinal))
                    {
                        string[] s           = line.Split(',');
                        int      xDiff       = int.Parse(s[0].Substring(3), CultureInfo.InvariantCulture);
                        int      yDiff       = int.Parse(s[2].Substring(3), CultureInfo.InvariantCulture);
                        int      width       = int.Parse(s[1].Substring(2), CultureInfo.InvariantCulture);
                        int      height      = int.Parse(s[3].Substring(2), CultureInfo.InvariantCulture);
                        int      steps       = int.Parse(s[4].Substring(3), CultureInfo.InvariantCulture);
                        string   IDs         = s[5].Substring(4);
                        int      alternative = Constants.NoAlternative;
                        int      elementID;
                        if (Char.IsLetter(IDs, IDs.Length - 1))
                        {
                            switch (IDs[IDs.Length - 1])
                            {
                            case 'a':
                                alternative = 1;
                                break;

                            case 'b':
                                alternative = 2;
                                break;

                            case 'c':
                                alternative = 3;
                                break;

                            case 'd':
                                alternative = 4;
                                break;

                            default:
                                throw new InvalidDataException("Alternative");
                            }
                            elementID = int.Parse(IDs.Remove(IDs.Length - 1), CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            elementID = int.Parse(IDs, CultureInfo.InvariantCulture);
                        }
                        AnimationProgram AnimationProgram = new AnimationProgram(xDiff, yDiff, width, height);
                        for (int j = 0; j < steps; i++, j++)
                        {
                            string        step          = lines[i + 1].Replace(" ", "");
                            string[]      stepArray     = step.Split(',');
                            int           phase         = int.Parse(stepArray[0], CultureInfo.InvariantCulture);
                            int           minimumTime   = int.Parse(stepArray[1], CultureInfo.InvariantCulture);
                            int           maximumTime   = int.Parse(stepArray[2], CultureInfo.InvariantCulture);
                            int           sound         = int.Parse(stepArray[3], CultureInfo.InvariantCulture);
                            AnimationStep animationStep = new AnimationStep(phase, minimumTime, maximumTime, sound);
                            AnimationProgram.AddAnimationStep(animationStep);
                        }
                        animation.AddAnimationProgram(AnimationProgram, elementID, alternative);
                    }
                }
            }

            return(animation);
        }