Exemple #1
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);
            }
        }
Exemple #2
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);
            }
        }
Exemple #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);
            }
        }
Exemple #4
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);
            }
        }
Exemple #5
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);
            }
        }