示例#1
0
        private static void DoHighlightForecolor(object higlightThreadParam)
        {
            HiglightThreadParam td = (HiglightThreadParam)higlightThreadParam;
            Color ctrlColor = (Color)td.control.GetProperty("ForeColor");
            try
            {
                SetObjectProperty(td.control, "ForeColor", ctrlColor.BrightColor(td.HiglightPercent));
            }
            catch (Exception)
            {
            }
            int iteration = AnimationControler.GetIterations(td.time);
            int t = td.time / iteration;

            for (int i = 0; i < iteration; i++)
            {
                if (td.animatorState.Canceled) break;
                Thread.Sleep(t);
            }

            try
            {
                SetObjectProperty(td.control, "ForeColor", ctrlColor);
            }
            catch (Exception)
            {
            }

            td.controlState.AnimatorEnd(td.animatorState);
        }
示例#2
0
        private static void Wait(object baseThreadParam)
        {
            AnimationControler.BaseThreadParam td = (AnimationControler.BaseThreadParam)baseThreadParam;
            StepProcesor procesor = new StepProcesor(AnimationControler.GetIterations(td.time), td.time);

            procesor.Start((d) => { if (td.animatorState.Canceled) d.Cancel = true; });

            td.controlState.AnimatorEnd(td.animatorState);
        }
示例#3
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);
            }
        }
示例#4
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);
            }
        }
示例#5
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);
            }
        }
示例#6
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);
            }
        }
示例#7
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);
            }
        }
示例#8
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);
            }
        }