There's something about WPF

in

October 2007 - Posts

Iphone like unlock screen
 It feels good to be in the "elite" group  of bloggers. I really wanted to steal Josh Simmerman's title(Just want to fit in). Well this is my first post on Clarity blogs and let me tell you I am a WPF fan. (yet another!!). Frankly speaking since WPF was introduced every thing I do I feel its an animation!!
 I used Kevin's Kinetic scrolling in my card game to display player names which was cool. I also used similar model to create a iphone like slider(the one which is used to unlock iphone).
Following is an excerpt from the code. Other events are similar to Kevin's scrolling example.
Here the endposition is the x coordinate of the rectangle which contains the sliding canvas.

protected override void OnPreviewMouseMove(MouseEventArgs e)
 {
   if (slidecanvas.IsMouseCaptured)
    {                           
                end = e.GetPosition(this);
                if (end.X >= endposition)
                {
                    slidecanvas.ReleaseMouseCapture();
                    story1.Begin(this);
                    return;
                }

                double diff = end.X - start.X;
                if (diff > 0)
                {                  
                    TimeSpan time = etime - stime;
                    story = (Storyboard)FindResource("Timeline2");
                    DoubleAnimation anim = (DoubleAnimation)story.Children[0];
                    anim.To = start.X + diff;
                    anim.Duration = time;                   
                    story.Begin(this);
                }
       }
}