Click here to Skip to main content
15,892,737 members
Articles / Programming Languages / C#

Animation Along a Path for Silverlight

Rate me:
Please Sign up or sign in to vote.
4.89/5 (18 votes)
4 Mar 2009CPOL4 min read 146.4K   2.6K   69  
Animates an object along a geometric path
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MatrixMathHelpers
{
    public class PointHelper
    {
        Point _value;
        public Point Value
        {
            get { return _value; }
            set { _value = value; }
        }

        public PointHelper(Point Input)
        {
            _value = Input;
        }

        public PointHelper()
        {
        }

        //public static explicit operator Vector(PointHelper point)
        //{
        //    return (new Vector(point._value.X, point._value.Y));
        //}

        public static Vector operator -(PointHelper point1, PointHelper point2)
        {
            return new Vector(point1._value.X - point2._value.X, point1._value.Y - point2._value.Y);
        }

        //
        // Summary:
        //     Translates the specified System.Windows.Point by the specified System.Windows.Vector
        //     and returns the result.
        //
        // Parameters:
        //   point:
        //     The point to translate.
        //
        //   vector:
        //     The amount by which to translate point.
        //
        // Returns:
        //     The result of translating the specified point by the specified vector.
        
        public static PointHelper operator +(PointHelper point, Vector vector)
        {
            PointHelper result = new PointHelper();

            result._value.X = vector.X + point.Value.X;
            result._value.Y = vector.Y + point.Value.Y;

            return result;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I work in the Bay Area primarily developing software on the Windows platform using C++, .NET/C#, WPF, and Silverlight.

Comments and Discussions