Beispiel #1
0
 internal static AnimationControler.AnimePacket AnimeMultiRectPropPacket(string queueName, string propName, object[] objects, Rectangle[] rects, int time, SpeedMode speedMode, bool queue, int queueLevel, object qOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     RectArrayThreadParam multiRectParam = new RectArrayThreadParam() { CompleteIfCancel = CompleteIfCancel };
     multiRectParam.rects = rects;
     multiRectParam.objects = objects;
     multiRectParam.time = time;
     multiRectParam.PropertyName = propName;
     multiRectParam.speedMode = speedMode;
     multiRectParam.QueueLevel = queueLevel;
     multiRectParam.finalCallback = finalCallback;
     multiRectParam.queueName = queueName;
     return new AnimationControler.AnimePacket() { isQueue = queue && queueLevel >= 0, queueOwner = qOwner, method = SetMultiRectProperty, threadParam = multiRectParam };
 }
Beispiel #2
0
        private static void SetMultiRectProperty(object rectArrayThreadParam)
        {
            RectArrayThreadParam td = (RectArrayThreadParam)rectArrayThreadParam;
            try
            {
                int iterations = AnimationControler.GetIterations(td.time);
                var calcList = new List<MultiRectCalcData>();
                for (int i = 0; i < td.objects.Length; i++)
                {
                    var calc = new MultiRectCalcData();
                    calcList.Add(calc);

                    calc.obj = td.objects[i];
                    calc.currRect = (Rectangle)td.objects[i].GetProperty(td.PropertyName);
                    calc.finalRect = td.rects[i];
                    calc.changeX = calc.finalRect.X - calc.currRect.X;
                    calc.changeY = calc.finalRect.Y - calc.currRect.Y;
                    calc.changeW = calc.finalRect.Width - calc.currRect.Width;
                    calc.changeH = calc.finalRect.Height - calc.currRect.Height;
                    calc.calcX = new SizeCalculator(calc.changeX, td.speedMode, iterations);
                    calc.calcY = new SizeCalculator(calc.changeY, td.speedMode, iterations);
                    calc.calcW = new SizeCalculator(calc.changeW, td.speedMode, iterations);
                    calc.calcH = new SizeCalculator(calc.changeH, td.speedMode, iterations);
                    calc.newRect = calc.currRect;
                    calc.prevRect = calc.currRect;
                }

                StepProcesor procesor = new StepProcesor(iterations, td.time);

                procesor.Start((d) =>
                {
                    List<object> objects = new List<object>();
                    List<object> newRects = new List<object>();
                    for (int i = 0; i < calcList.Count; i++)
                    {
                        var calc = calcList[i];
                        calc.newRect = new Rectangle(calc.currRect.X + calc.calcX.NextSize, calc.currRect.Y + calc.calcY.NextSize, calc.currRect.Width + calc.calcW.NextSize, calc.currRect.Height + calc.calcH.NextSize);
                        if (td.animatorState.Canceled)
                        {
                            d.Cancel = true;
                            return;
                        }
                        if (calc.newRect != calc.prevRect)
                        {
                            objects.Add(calc.obj);
                            newRects.Add(calc.newRect);
                        }
                        //SetObjectProperty(td.control, td.PropertyName, newRect);
                        calc.prevRect = calc.newRect;
                    }
                    if (objects.Count > 0) SetObjectsProperties(td.control, objects.ToArray(), td.PropertyName, newRects.ToArray());
                });

                if (td.animatorState.Canceled && !td.CompleteIfCancel) return;

                foreach (var calc in calcList)
                {
                    List<object> objects = new List<object>();
                    List<object> newRects = new List<object>();
                    if (calc.newRect != calc.finalRect)
                    {
                        objects.Add(calc.obj);
                        newRects.Add(calc.finalRect);
                    }

                    if (objects.Count > 0)
                        try
                        {
                            SetObjectsProperties(td.control, objects.ToArray(), td.PropertyName, newRects.ToArray());
                        }
                        catch (Exception e)
                        {
                        }
                }
            }
            finally
            {
                td.controlState.AnimatorEnd(td.animatorState);
            }
        }