Ejemplo n.º 1
0
 internal static AnimationControler.AnimePacket AnimeRectPropPacket(string queueName, string propName, Rectangle rect, int time, SpeedMode speedMode, bool queue, int queueLevel, object qOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     RectThreadParam sizeParam = new RectThreadParam() { CompleteIfCancel = CompleteIfCancel };
     sizeParam.rect = rect;
     sizeParam.time = time;
     sizeParam.PropertyName = propName;
     sizeParam.speedMode = speedMode;
     sizeParam.QueueLevel = queueLevel;
     sizeParam.finalCallback = finalCallback;
     sizeParam.queueName = queueName;
     return new AnimationControler.AnimePacket() { isQueue = queue && queueLevel >= 0, queueOwner = qOwner, method = SetRectProperty, threadParam = sizeParam };
 }
Ejemplo n.º 2
0
        private static void SetRectProperty(object rectThreadParam)
        {
            RectThreadParam td = (RectThreadParam)rectThreadParam;
            try
            {
                int iterations = AnimationControler.GetIterations(td.time);
                Rectangle currRect = (Rectangle)td.control.GetProperty(td.PropertyName);
                int changeX = td.rect.X - currRect.X;
                int changeY = td.rect.Y - currRect.Y;
                int changeW = td.rect.Width - currRect.Width;
                int changeH = td.rect.Height - currRect.Height;
                SizeCalculator calcX = new SizeCalculator(changeX, td.speedMode, iterations);
                SizeCalculator calcY = new SizeCalculator(changeY, td.speedMode, iterations);
                SizeCalculator calcW = new SizeCalculator(changeW, td.speedMode, iterations);
                SizeCalculator calcH = new SizeCalculator(changeH, td.speedMode, iterations);
                StepProcesor procesor = new StepProcesor(iterations, td.time);
                Rectangle newRect = currRect;
                Rectangle prevRect = currRect;

                procesor.Start((d) =>
                                   {
                                       newRect = new Rectangle(currRect.X + calcX.NextSize, currRect.Y + calcY.NextSize, currRect.Width + calcW.NextSize, currRect.Height + calcH.NextSize);
                                       if (td.animatorState.Canceled)
                                       {
                                           d.Cancel = true;
                                           return;
                                       }
                                       if (newRect != prevRect)
                                           SetObjectProperty(td.control, td.PropertyName, newRect);
                                       prevRect = newRect;
                                   });

                if (newRect != td.rect)
                {
                    try
                    {
                        if (td.animatorState.Canceled && !td.CompleteIfCancel) return;
                        SetObjectProperty(td.control, td.PropertyName, td.rect);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            finally
            {
                td.controlState.AnimatorEnd(td.animatorState);
            }
        }