private void PlayFadeAnimation(PanelType newPanelType, PanelType lastPanelType, State newState)
{
PanelType panelToFade = PanelType.None;
if (newState == State.FadingIn)
{
// If we are fading in we know which panel we want to fade in.
panelToFade = newPanelType;
}
else
{
// Figure out what panel to fade out, if we are in single mode we want to fade out
// whatever was on the screen last.
if (m_screenMode == ScreenMode.Single)
{
panelToFade = lastPanelType;
}
// If we are in split mode we want to fade out which ever panel we are replacing.
else
{
panelToFade = newPanelType;
}
}
// Get the correct vars
Storyboard story = panelToFade == PanelType.SubredditList ? ui_storySubList : ui_storyContent;
DoubleAnimation anim = panelToFade == PanelType.SubredditList ? ui_animSubList : ui_animContent;
Grid root = panelToFade == PanelType.SubredditList ? ui_subListRoot : ui_contentRoot;
// Setup
anim.To = newState == State.FadingIn ? 1 : 0;
/// #todo, use the current opacity in the animation.
anim.From = newState == State.FadingIn ? 0 : 1;
/// #todo make this better, why do i have set set opacity?
root.Opacity = newState == State.FadingIn ? 0 : 1;
// Stop any existing animation
story.Stop();
// Set the new state
m_state = newState;
// Start a new one
story.Begin();
}