Example #1
0
        public void Execute(object control)
        {
            object owner = null;

            for (int i = 0; i < packetQueue.Count; i++)
            {
                var p = packetQueue[i];
                p.queueOwner = owner;
                control.AnimeCancel(p.threadParam.queueName);
                owner        = AnimationControler.ProcessPacket(control, p);
                p.queueOwner = null;
            }
        }
Example #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);
            }
        }
Example #3
0
        private static void SetSizeProperty(object sizeThreadParam)
        {
            SizeThreadParam td = (SizeThreadParam)sizeThreadParam;
            try
            {
                int iterations = AnimationControler.GetIterations(td.time);
                Size currSize = (Size)td.control.GetProperty(td.PropertyName);
                int changeX = td.size.Width - currSize.Width;
                int changeY = td.size.Height - currSize.Height;
                SizeCalculator calcX = new SizeCalculator(changeX, td.speedMode, iterations);
                SizeCalculator calcY = new SizeCalculator(changeY, td.speedMode, iterations);
                StepProcesor procesor = new StepProcesor(iterations, td.time);
                Size newSize = currSize;
                Size prevSize = currSize;

                procesor.Start((d) =>
                {
                    newSize = new Size(currSize.Width + calcX.NextSize, currSize.Height + calcY.NextSize);
                    if (td.animatorState.Canceled)
                    {
                        d.Cancel = true;
                        return;
                    }
                    if (newSize != prevSize)
                        SetObjectProperty(td.control, td.PropertyName, newSize);
                    prevSize = newSize;
                });

                if (newSize != td.size)
                {
                    try
                    {
                        if (td.animatorState.Canceled && !td.CompleteIfCancel) return;
                        SetObjectProperty(td.control, td.PropertyName, td.size);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            finally
            {
                td.controlState.AnimatorEnd(td.animatorState);
            }
        }
Example #4
0
        private static void SetPointProperty(object pointThreadParam)
        {
            LocationThreadParam td = (LocationThreadParam)pointThreadParam;
            try
            {
                int iterations = AnimationControler.GetIterations(td.time);
                Point currPos = (Point)td.control.GetProperty(td.PropertyName);
                int changeX = td.location.X - currPos.X;
                int changeY = td.location.Y - currPos.Y;
                SizeCalculator calcX = new SizeCalculator(changeX, td.speedMode, iterations);
                SizeCalculator calcY = new SizeCalculator(changeY, td.speedMode, iterations);
                StepProcesor procesor = new StepProcesor(iterations, td.time);
                Point newPos = currPos;
                Point prevPos = currPos;

                procesor.Start((d) =>
                {
                    newPos = new Point(currPos.X + calcX.NextSize, currPos.Y + calcY.NextSize);
                    if (td.animatorState.Canceled)
                    {
                        d.Cancel = true;
                        return;
                    }
                    if (newPos != prevPos)
                        SetObjectProperty(td.control, td.PropertyName, newPos);
                    prevPos = newPos;
                });

                if (newPos != td.location)
                {
                    try
                    {
                        if (td.animatorState.Canceled && !td.CompleteIfCancel) return;
                        SetObjectProperty(td.control, td.PropertyName, td.location);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            finally
            {
                td.controlState.AnimatorEnd(td.animatorState);
            }
        }
Example #5
0
        private static void SetIntProperty(object intThreadParam)
        {
            IntValueThreadParam td = (IntValueThreadParam)intThreadParam;
            try
            {
                int iterations = AnimationControler.GetIterations(td.time);
                int currHeight = (int)td.control.GetProperty(td.PropertyName);
                int changeSize = td.value - currHeight;
                SizeCalculator cacl = new SizeCalculator(changeSize, td.speedMode, iterations);
                StepProcesor procesor = new StepProcesor(iterations, td.time);
                bool up = changeSize > 0;
                int newHeight = currHeight;
                int prevHeight = currHeight;

                procesor.Start((d) =>
                {
                    newHeight = currHeight + cacl.NextSize;
                    if (up && newHeight > td.value || !up && newHeight < td.value) newHeight = td.value;
                    if (td.animatorState.Canceled)
                    {
                        d.Cancel = true;
                        return;
                    }
                    if (newHeight != prevHeight)
                        SetObjectProperty(td.control, td.PropertyName, newHeight);
                    prevHeight = newHeight;
                });

                if (newHeight != td.value)
                {
                    try
                    {
                        if (td.animatorState.Canceled && !td.CompleteIfCancel) return;
                        SetObjectProperty(td.control, td.PropertyName, td.value);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            finally
            {
                td.controlState.AnimatorEnd(td.animatorState);
            }
        }
Example #6
0
        private static void SetColorProperty(object colorThreadParam)
        {
            ColorThreadParam td = (ColorThreadParam)colorThreadParam;
            try
            {
                Color controlColor = (Color)td.control.GetProperty(td.PropertyName);
                int iterations = AnimationControler.GetIterations(td.time);
                SizeCalculator cacl = new SizeCalculator(100, td.speedMode, iterations);
                StepProcesor procesor = new StepProcesor(iterations, td.time);

                Color newColor = controlColor;
                Color prevColor = controlColor;
                procesor.Start((d) =>
                                   {
                                       if (td.animatorState.Canceled)
                                       {
                                           d.Cancel = true;
                                           return;
                                       }
                                       newColor = controlColor.MergeColor(td.color, cacl.NextSize);
                                       if (newColor != prevColor)
                                           SetObjectProperty(td.control, td.PropertyName, newColor);
                                       prevColor = newColor;
                                   });

                if (newColor != td.color)
                {
                    try
                    {
                        if (td.animatorState.Canceled && !td.CompleteIfCancel) return;
                        SetObjectProperty(td.control, td.PropertyName, td.color);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            finally
            {
                td.controlState.AnimatorEnd(td.animatorState);
            }
        }
Example #7
0
 public static void AnimeForce(object ctrl, string name)
 {
     AnimationControler.Cancel(ctrl, name, true);
 }
Example #8
0
 public static void AnimeCancel(object ctrl, string name)
 {
     AnimationControler.Cancel(ctrl, name, false);
 }
Example #9
0
 public static object AnimeHighlightForecolor(Control ctrl, string queueName, int highlightPercent, int time, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeHighlightForecolorPacket(queueName, highlightPercent, time, queue, queueLevel, queueOwner, finalCallback));
 }
Example #10
0
 public static object AnimeColorProp(object ctrl, string queueName, string propName, Color color, int time, SpeedMode speedMode, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeColorPropPacket(queueName, propName, color, time, speedMode, queue, queueLevel, queueOwner, finalCallback, CompleteIfCancel));
 }
Example #11
0
 public static object AnimeMultiRectProp(object ctrl, string queueName, string propName, object[] objects, Rectangle[] rects, int time, SpeedMode speedMode, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback, bool CompleteIfCancel)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeMultiRectPropPacket(queueName, propName, objects, rects, time, speedMode, queue, queueLevel, queueOwner, finalCallback, CompleteIfCancel));
 }
Example #12
0
 public static object AnimeWait(Control ctrl, string queueName, int time, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeWaitPacket(queueName, time, queue, queueLevel, queueOwner, finalCallback));
 }
Example #13
0
 public static object AnimeCustom(Control ctrl, string queueName, int sleepTime, CustomAnimeHandler method, int maxIteration, bool queue, int queueLevel, object queueOwner, AnimationControler.FinalCallback finalCallback)
 {
     return AnimationControler.ProcessPacket(ctrl, AnimeCustomPacket(queueName, sleepTime, method, maxIteration, queue, queueLevel, queueOwner, finalCallback));
 }
Example #14
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);
            }
        }