|
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 CanvasExpt
{
public partial class MainPage : UserControl
{
//http://localhost:2042/CanvasExptTestPage.aspx
public Dictionary<string, UserControl> pageCache;
UserControl curPage;
public delegate void _ONCLOSE_();
_ONCLOSE_ onClose;
public MainPage()
{
InitializeComponent();
pageCache = new Dictionary<string, UserControl>();
}
public void NavigateToCanvasPage()
{
string strPage = "CanvasExpt.CanvasPage";
if (curPage != null)
{
if (onClose != null)
{
onClose();
}
LayoutRoot.Children.Remove(curPage);
}
CanvasPage cnvPage;
if (pageCache.ContainsKey(strPage))
cnvPage = (CanvasPage)pageCache[strPage];
else
{
cnvPage = new CanvasPage();
pageCache.Add(strPage, cnvPage);
}
onClose += cnvPage.onClose;
LayoutRoot.Children.Add(cnvPage);
curPage = cnvPage;
Grid.SetRow(cnvPage, 2);
}
public void NavigateToBounceAnimationPage()
{
string strPage = "CanvasExpt.StringVibrationPage";
if (curPage != null)
{
if (onClose != null)
{
onClose();
}
LayoutRoot.Children.Remove(curPage);
}
BounceAnimationPage stringVibrationPage;
if (pageCache.ContainsKey(strPage))
stringVibrationPage = (BounceAnimationPage)pageCache[strPage];
else
{
stringVibrationPage = new BounceAnimationPage();
pageCache.Add(strPage, stringVibrationPage);
}
onClose += stringVibrationPage.onClose;
LayoutRoot.Children.Add(stringVibrationPage);
curPage = stringVibrationPage;
Grid.SetRow(stringVibrationPage, 2);
}
public void NavigateToCircleAnimationPage()
{
string strPage = "CanvasExpt.CircleAnimations";
if (curPage != null)
{
if (onClose != null)
{
onClose();
}
LayoutRoot.Children.Remove(curPage);
}
CircleAnimations circleAnimationPage;
if (pageCache.ContainsKey(strPage))
circleAnimationPage = (CircleAnimations)pageCache[strPage];
else
{
circleAnimationPage = new CircleAnimations();
pageCache.Add(strPage, circleAnimationPage);
}
onClose += circleAnimationPage.onClose;
LayoutRoot.Children.Add(circleAnimationPage);
curPage = circleAnimationPage;
Grid.SetRow(circleAnimationPage, 2);
}
public void NavigateToArcAnimationPage()
{
string strPage = "CanvasExpt.ArcAnimationPage";
if (curPage != null)
{
if (onClose != null)
{
onClose();
}
LayoutRoot.Children.Remove(curPage);
}
ArcAnimationPage circleAnimationPage;
if (pageCache.ContainsKey(strPage))
circleAnimationPage = (ArcAnimationPage)pageCache[strPage];
else
{
circleAnimationPage = new ArcAnimationPage();
pageCache.Add(strPage, circleAnimationPage);
}
onClose += circleAnimationPage.onClose;
LayoutRoot.Children.Add(circleAnimationPage);
curPage = circleAnimationPage;
Grid.SetRow(circleAnimationPage, 2);
}
private void button_Click_ShowCanvasPage(object sender, RoutedEventArgs e)
{
NavigateToCanvasPage();
}
private void ShowBounceAnimationPage_Click(object sender, RoutedEventArgs e)
{
NavigateToBounceAnimationPage();
}
private void ShowCircleAnimationPage_Click(object sender, RoutedEventArgs e)
{
NavigateToCircleAnimationPage();
}
private void ShowArcAnimationPage_Click(object sender, RoutedEventArgs e)
{
NavigateToArcAnimationPage();
}
}
}
|
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.
I have a PhD in pure mathematics from HCU. I have been programming in Microsoft technologies for more than a decade. My interests are C#, WPF Silverlight, MFC, COM.