|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightFlipNavigation
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
Storyboard stb1 = new Storyboard();
stb1.Duration = new Duration(TimeSpan.FromSeconds(1));
stb1.SpeedRatio = 3;
DoubleAnimation daY1 = new DoubleAnimation { From = 0.00, To = 90.00 };
Storyboard.SetTargetName(daY1, "Projection");
Storyboard.SetTargetProperty(daY1, new PropertyPath("RotationX"));
stb1.Children.Add(daY1);
this.Resources.Add("EndOfPage", stb1);
Storyboard stb = new Storyboard();
stb.Duration = new Duration(TimeSpan.FromSeconds(1));
stb.SpeedRatio = 3;
DoubleAnimation daY = new DoubleAnimation { From = -90.00, To = 0.00 };
Storyboard.SetTargetName(daY, "Projection");
Storyboard.SetTargetProperty(daY, new PropertyPath("RotationX"));
stb.Children.Add(daY);
this.Resources.Add("StartOfPage", stb);
Page1 oPage1 = new Page1();
PageContainer.Children.Add(oPage1);
}
private UserControl currentPage;
public UserControl CurrentPage
{
get { return this.PageContainer.Children[0] as UserControl; }
set { currentPage = value; }
}
private UserControl nextPage;
public UserControl NextPage
{
get { return nextPage; }
set { nextPage = value; }
}
public void SwitchToPage(UserControl p)
{
NextPage = p;
//if (CurrentPage != p)
//{
Storyboard currStb = CurrentPage.Resources["EndOfPage"] as Storyboard;
currStb.Completed += new EventHandler(currStb_Completed);
currStb.Begin();
//}
}
void currStb_Completed(object sender, EventArgs e)
{
this.PageContainer.Children.RemoveAt(0);
this.PageContainer.Children.Add(NextPage);
Storyboard stb = NextPage.Resources["StartOfPage"] as Storyboard;
stb.Begin();
}
private void Button1_Click(object sender, RoutedEventArgs e)
{
Page1 oPage1 = new Page1();
SwitchToPage(oPage1);
}
private void Button2_Click(object sender, RoutedEventArgs e)
{
Page2 oPage2 = new Page2();
SwitchToPage(oPage2);
}
private void Button3_Click(object sender, RoutedEventArgs e)
{
Page3 oPage3 = new Page3();
SwitchToPage(oPage3);
}
private void Button4_Click(object sender, RoutedEventArgs e)
{
Page4 oPage4 = new Page4();
SwitchToPage(oPage4);
}
}
}
|
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.