mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7087 from MSOpenTech/wp8-v3-template
Wp8 v3 template and missing texture after app switch fixes
This commit is contained in:
commit
a2a6a4e70a
|
@ -0,0 +1,63 @@
|
|||
set IN_DIR=.\..\..\..\angle\src\WP8\redist\vs2012\ARM\Release
|
||||
|
||||
set OUT_DIR=.\..\..\external\wp8-specific\angle\prebuilt\ARM\
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_phone\esUtil_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
|
||||
set IN_DIR=.\..\..\..\angle\src\WP8\redist\vs2012\Win32\Release
|
||||
|
||||
set OUT_DIR=.\..\..\external\wp8-specific\angle\prebuilt\Win32\
|
||||
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_phone\esUtil_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
|
||||
set IN_DIR=.\..\..\..\angle\src\WinRT\redist\vs2013\ARM\Release\
|
||||
set OUT_DIR=.\..\..\external\winrt-specific\angle\prebuilt\ARM\
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_winrt_2013\esUtil.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
set IN_DIR=.\..\..\..\angle\src\WinRT\redist\vs2013\Win32\Release\
|
||||
set OUT_DIR=.\..\..\external\winrt-specific\angle\prebuilt\Win32\
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_winrt_2013\esUtil.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
set OUT_DIR=.\..\..\external\winrt-specific\angle\include
|
||||
xcopy ".\..\..\..\angle\include" "%OUT_DIR%" /eiycq
|
||||
xcopy ".\..\..\..\angle\src\common\winrtangle.h" "%OUT_DIR%" /iycq
|
||||
xcopy ".\..\..\..\angle\samples\gles2_book\Common\esUtil.h" "%OUT_DIR%" /iycq
|
||||
|
|
@ -68,12 +68,12 @@
|
|||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>echo "Copying WP8-XAML CPP template files"
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -89,12 +89,12 @@ xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-x
|
|||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>echo "Copying WP8-XAML CPP template files"
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
|
@ -110,12 +110,12 @@ xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-x
|
|||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>echo "Copying WP8-XAML CPP template files"
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
|
@ -131,12 +131,12 @@ xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-x
|
|||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>echo "Copying WP8-XAML CPP template files"
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
|
||||
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
|
||||
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -64,13 +64,13 @@ void Cocos2dRenderer::CreateGLResources()
|
|||
else
|
||||
{
|
||||
cocos2d::GL::invalidateStateCache();
|
||||
cocos2d::ShaderCache::getInstance()->reloadDefaultShaders();
|
||||
cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
|
||||
cocos2d::DrawPrimitives::init();
|
||||
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
||||
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
|
||||
director->setGLDefaultValues();
|
||||
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
|
||||
cocos2d::Application::getInstance()->applicationWillEnterForeground();
|
||||
director->setGLDefaultValues();
|
||||
}
|
||||
|
||||
m_loadingComplete = true;
|
||||
|
@ -78,15 +78,15 @@ void Cocos2dRenderer::CreateGLResources()
|
|||
|
||||
void Cocos2dRenderer::Connect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// purge Cocos2d-x gl GL resourses since the DirectX/Angle Context has been lost
|
||||
void Cocos2dRenderer::Disconnect()
|
||||
{
|
||||
Application::getInstance()->applicationDidEnterBackground();
|
||||
EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND);
|
||||
Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent);
|
||||
Director::getInstance()->purgeCachedData();
|
||||
cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND);
|
||||
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent);
|
||||
CloseAngle();
|
||||
m_loadingComplete = false;
|
||||
}
|
||||
|
|
|
@ -56,13 +56,11 @@ IDrawingSurfaceBackgroundContentProvider^ Direct3DInterop::CreateContentProvider
|
|||
// Interface With Direct3DContentProvider
|
||||
HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
|
||||
{
|
||||
//m_renderer->SetDevice(device);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void Direct3DInterop::Disconnect()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mRenderingMutex);
|
||||
m_renderer->Disconnect();
|
||||
}
|
||||
|
||||
|
@ -143,8 +141,6 @@ HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTarge
|
|||
|
||||
HRESULT Direct3DInterop::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mRenderingMutex);
|
||||
|
||||
m_renderer->UpdateDevice(device, context, renderTargetView);
|
||||
#if 0
|
||||
if(mCurrentOrientation != WindowOrientation)
|
||||
|
|
|
@ -87,8 +87,6 @@ private:
|
|||
Windows::Graphics::Display::DisplayOrientations mCurrentOrientation;
|
||||
|
||||
|
||||
std::mutex mRenderingMutex;
|
||||
|
||||
Cocos2dEventDelegate^ m_delegate;
|
||||
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
|
||||
Cocos2dEditBoxDelegate^ m_editBoxDelegate;
|
||||
|
|
|
@ -24,6 +24,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "DirectXBase.h"
|
||||
#include "DirectXHelper.h"
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace Microsoft::WRL;
|
||||
|
@ -167,11 +168,11 @@ void DirectXBase::Render()
|
|||
|
||||
void DirectXBase::CloseAngle()
|
||||
{
|
||||
eglMakeCurrent(NULL, NULL, NULL, NULL);
|
||||
|
||||
if(m_eglDisplay && m_eglSurface)
|
||||
if(m_eglPhoneWindow != nullptr)
|
||||
{
|
||||
eglDestroySurface(m_eglDisplay, m_eglSurface);
|
||||
m_eglSurface = nullptr;
|
||||
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
if(m_eglDisplay && m_eglContext)
|
||||
|
@ -180,30 +181,26 @@ void DirectXBase::CloseAngle()
|
|||
m_eglContext = nullptr;
|
||||
}
|
||||
|
||||
if(m_eglDisplay && m_eglSurface)
|
||||
{
|
||||
eglDestroySurface(m_eglDisplay, m_eglSurface);
|
||||
m_eglSurface = nullptr;
|
||||
}
|
||||
|
||||
if(m_eglDisplay)
|
||||
{
|
||||
eglTerminate(m_eglDisplay);
|
||||
m_eglDisplay = nullptr;
|
||||
}
|
||||
|
||||
if(m_eglPhoneWindow != nullptr)
|
||||
{
|
||||
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
eglMakeCurrent(NULL, NULL, NULL, NULL);
|
||||
|
||||
if(m_device)
|
||||
{
|
||||
m_device->Release();
|
||||
m_device = nullptr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
m_eglPhoneWindow = nullptr;
|
||||
m_eglWindow = nullptr;
|
||||
#endif // 0
|
||||
|
||||
|
||||
m_bAngleInitialized = false;
|
||||
}
|
||||
|
@ -262,10 +259,12 @@ bool DirectXBase::InitializeAngle(ID3D11Device1* d3dDevice, ID3D11DeviceContext1
|
|||
|
||||
m_eglPhoneWindow->Update(d3dDevice, d3dContext, d3dRenderTargetView);
|
||||
|
||||
ComPtr<IUnknown> u;
|
||||
HRESULT r = m_eglPhoneWindow.As(&u);
|
||||
|
||||
if(m_eglWindow == nullptr)
|
||||
{ DX::ThrowIfFailed(
|
||||
CreateWinrtEglWindow(m_eglPhoneWindow.Get(), featureLevel, m_eglWindow.GetAddressOf())
|
||||
CreateWinrtEglWindow(u.Get(), featureLevel, m_eglWindow.GetAddressOf())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,12 @@ THE SOFTWARE.
|
|||
|
||||
#include <d3d11_1.h>
|
||||
#include <DirectXMath.h>
|
||||
#include "DirectXHelper.h"
|
||||
#include "CCGL.h"
|
||||
#include "EGL/egl.h"
|
||||
#include "EGL/eglext.h"
|
||||
#include "EGL/eglplatform.h"
|
||||
#include "GLES2/gl2.h"
|
||||
#include "GLES2/gl2ext.h"
|
||||
#include "winrtangle.h"
|
||||
|
||||
// Helper class that initializes DirectX APIs for 3D rendering.
|
||||
ref class DirectXBase abstract
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using System.Resources;
|
||||
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.Markup;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System.IO.IsolatedStorage;
|
||||
using PhoneDirect3DXamlAppInterop.Resources;
|
||||
|
||||
namespace PhoneDirect3DXamlAppInterop
|
||||
{
|
||||
|
@ -21,7 +17,28 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
/// Provides easy access to the root frame of the Phone Application.
|
||||
/// </summary>
|
||||
/// <returns>The root frame of the Phone Application.</returns>
|
||||
public PhoneApplicationFrame RootFrame { get; private set; }
|
||||
public static PhoneApplicationFrame RootFrame { get; private set; }
|
||||
|
||||
|
||||
enum SessionType
|
||||
{
|
||||
None,
|
||||
Home,
|
||||
DeepLink
|
||||
}
|
||||
|
||||
// Set to Home when the app is launched from Primary tile.
|
||||
// Set to DeepLink when the app is launched from Deep Link.
|
||||
private SessionType sessionType = SessionType.None;
|
||||
|
||||
// Set to true when the page navigation is being reset
|
||||
bool wasRelaunched = false;
|
||||
|
||||
// set to true when 5 min passed since the app was relaunched
|
||||
bool mustClearPagestack = false;
|
||||
|
||||
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
|
@ -31,14 +48,14 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard Silverlight initialization
|
||||
// Standard XAML initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = false;
|
||||
|
@ -50,8 +67,8 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// which shows areas of a page that are handed off to GPU with a colored overlay.
|
||||
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||
|
||||
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
|
||||
// application's PhoneApplicationService object to Disabled.
|
||||
// Prevent the screen from turning off while under the debugger by disabling
|
||||
// the application's idle detection.
|
||||
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
|
||||
// and consume battery power when the user is not using the phone.
|
||||
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
|
||||
|
@ -63,43 +80,63 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
|
||||
// When a new instance of the app is launched, clear all deactivation settings
|
||||
RemoveCurrentDeactivationSettings();
|
||||
}
|
||||
|
||||
// Code to execute when the application is activated (brought to foreground)
|
||||
// This code will not execute when the application is first launched
|
||||
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||
{
|
||||
// If some interval has passed since the app was deactivated (30 seconds in this example),
|
||||
// then remember to clear the back stack of pages
|
||||
mustClearPagestack = CheckDeactivationTimeStamp();
|
||||
|
||||
|
||||
// If IsApplicationInstancePreserved is not true, then set the session type to the value
|
||||
// saved in isolated storage. This will make sure the session type is correct for an
|
||||
// app that is being resumed after being tombstoned.
|
||||
if (!e.IsApplicationInstancePreserved)
|
||||
{
|
||||
RestoreSessionType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is deactivated (sent to background)
|
||||
// This code will not execute when the application is closing
|
||||
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
// When the applicaiton is deactivated, save the current deactivation settings to isolated storage
|
||||
SaveCurrentDeactivationSettings();
|
||||
}
|
||||
|
||||
// Code to execute when the application is closing (eg, user hit Back)
|
||||
// This code will not execute when the application is deactivated
|
||||
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||
{
|
||||
// When the application closes, delete any deactivation settings from isolated storage
|
||||
RemoveCurrentDeactivationSettings();
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,10 +162,80 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// Handle reset requests for clearing the backstack
|
||||
RootFrame.Navigated += CheckForResetNavigation;
|
||||
|
||||
// Monitor deep link launching
|
||||
RootFrame.Navigating += RootFrame_Navigating;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Event handler for the Navigating event of the root frame. Use this handler to modify
|
||||
// the default navigation behavior.
|
||||
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
|
||||
{
|
||||
|
||||
// If the session type is None or New, check the navigation Uri to determine if the
|
||||
// navigation is a deep link or if it points to the app's main page.
|
||||
if (sessionType == SessionType.None && e.NavigationMode == NavigationMode.New)
|
||||
{
|
||||
// This block will run if the current navigation is part of the app's intial launch
|
||||
|
||||
|
||||
// Keep track of Session Type
|
||||
if (e.Uri.ToString().Contains("DeepLink=true"))
|
||||
{
|
||||
sessionType = SessionType.DeepLink;
|
||||
}
|
||||
else if (e.Uri.ToString().Contains("/MainPage.xaml"))
|
||||
{
|
||||
sessionType = SessionType.Home;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e.NavigationMode == NavigationMode.Reset)
|
||||
{
|
||||
// This block will execute if the current navigation is a relaunch.
|
||||
// If so, another navigation will be coming, so this records that a relaunch just happened
|
||||
// so that the next navigation can use this info.
|
||||
wasRelaunched = true;
|
||||
}
|
||||
else if (e.NavigationMode == NavigationMode.New && wasRelaunched)
|
||||
{
|
||||
// This block will run if the previous navigation was a relaunch
|
||||
wasRelaunched = false;
|
||||
|
||||
if (e.Uri.ToString().Contains("DeepLink=true"))
|
||||
{
|
||||
// This block will run if the launch Uri contains "DeepLink=true" which
|
||||
// was specified when the secondary tile was created in MainPage.xaml.cs
|
||||
|
||||
sessionType = SessionType.DeepLink;
|
||||
// The app was relaunched via a Deep Link.
|
||||
// The page stack will be cleared.
|
||||
}
|
||||
else if (e.Uri.ToString().Contains("/MainPage.xaml"))
|
||||
{
|
||||
// This block will run if the navigation Uri is the main page
|
||||
if (sessionType == SessionType.DeepLink)
|
||||
{
|
||||
// When the app was previously launched via Deep Link and relaunched via Main Tile, we need to clear the page stack.
|
||||
sessionType = SessionType.Home;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mustClearPagestack)
|
||||
{
|
||||
//The app was previously launched via Main Tile and relaunched via Main Tile. Cancel the navigation to resume.
|
||||
e.Cancel = true;
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mustClearPagestack = false;
|
||||
}
|
||||
}
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
|
@ -153,7 +260,7 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// Unregister the event so it doesn't get called again
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
|
||||
// Only clear the stack for 'new' (forward) navigations
|
||||
// Only clear the stack for 'new' (forward) and 'refresh' navigations
|
||||
if (e.NavigationMode != NavigationMode.New)
|
||||
return;
|
||||
|
||||
|
@ -165,5 +272,92 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Helper method for adding or updating a key/value pair in isolated storage
|
||||
public bool AddOrUpdateValue(string Key, Object value)
|
||||
{
|
||||
bool valueChanged = false;
|
||||
|
||||
// If the key exists
|
||||
if (settings.Contains(Key))
|
||||
{
|
||||
// If the value has changed
|
||||
if (settings[Key] != value)
|
||||
{
|
||||
// Store the new value
|
||||
settings[Key] = value;
|
||||
valueChanged = true;
|
||||
}
|
||||
}
|
||||
// Otherwise create the key.
|
||||
else
|
||||
{
|
||||
settings.Add(Key, value);
|
||||
valueChanged = true;
|
||||
}
|
||||
return valueChanged;
|
||||
}
|
||||
|
||||
// Helper method for removing a key/value pair from isolated storage
|
||||
public void RemoveValue(string Key)
|
||||
{
|
||||
// If the key exists
|
||||
if (settings.Contains(Key))
|
||||
{
|
||||
settings.Remove(Key);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the app is deactivating. Saves the time of the deactivation and the
|
||||
// session type of the app instance to isolated storage.
|
||||
public void SaveCurrentDeactivationSettings()
|
||||
{
|
||||
if (AddOrUpdateValue("DeactivateTime", DateTimeOffset.Now))
|
||||
{
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
if (AddOrUpdateValue("SessionType", sessionType))
|
||||
{
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called when the app is launched or closed. Removes all deactivation settings from
|
||||
// isolated storage
|
||||
public void RemoveCurrentDeactivationSettings()
|
||||
{
|
||||
RemoveValue("DeactivateTime");
|
||||
RemoveValue("SessionType");
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
// Helper method to determine if the interval since the app was deactivated is
|
||||
// greater than 30 seconds
|
||||
bool CheckDeactivationTimeStamp()
|
||||
{
|
||||
DateTimeOffset lastDeactivated;
|
||||
|
||||
if (settings.Contains("DeactivateTime"))
|
||||
{
|
||||
lastDeactivated = (DateTimeOffset)settings["DeactivateTime"];
|
||||
}
|
||||
|
||||
var currentDuration = DateTimeOffset.Now.Subtract(lastDeactivated);
|
||||
|
||||
return TimeSpan.FromSeconds(currentDuration.TotalSeconds) > TimeSpan.FromSeconds(30);
|
||||
}
|
||||
|
||||
// Helper method to restore the session type from isolated storage.
|
||||
void RestoreSessionType()
|
||||
{
|
||||
if (settings.Contains("SessionType"))
|
||||
{
|
||||
sessionType = (SessionType)settings["SessionType"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -455,6 +455,16 @@ Texture2D::~Texture2D()
|
|||
}
|
||||
}
|
||||
|
||||
void Texture2D::releaseGLTexture()
|
||||
{
|
||||
if(_name)
|
||||
{
|
||||
GL::deleteTexture(_name);
|
||||
}
|
||||
_name = 0;
|
||||
}
|
||||
|
||||
|
||||
Texture2D::PixelFormat Texture2D::getPixelFormat() const
|
||||
{
|
||||
return _pixelFormat;
|
||||
|
@ -539,14 +549,7 @@ bool Texture2D::initWithData(const void *data, ssize_t dataLen, Texture2D::Pixel
|
|||
|
||||
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh)
|
||||
{
|
||||
// cocos2d-x is currently calling this multiple times on the same Texture2D
|
||||
// if the GL texture has already been created,it will be leaked in OpenGL
|
||||
// For now, call deleteTexture if the texture already exists
|
||||
if(_name)
|
||||
{
|
||||
GL::deleteTexture(_name);
|
||||
_name = 0;
|
||||
}
|
||||
|
||||
|
||||
//the pixelFormat must be a certain value
|
||||
CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
|
||||
|
@ -602,7 +605,11 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
|||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
}
|
||||
|
||||
|
||||
if(_name != 0)
|
||||
{
|
||||
GL::deleteTexture(_name);
|
||||
_name = 0;
|
||||
}
|
||||
|
||||
glGenTextures(1, &_name);
|
||||
GL::bindTexture2D(_name);
|
||||
|
|
|
@ -203,6 +203,12 @@ public:
|
|||
*/
|
||||
virtual std::string getDescription() const;
|
||||
|
||||
/** release only the gl texture.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void releaseGLTexture();
|
||||
|
||||
/** Initializes with a texture2d with data
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
|
|
@ -706,6 +706,12 @@ void VolatileTextureMgr::reloadAllTextures()
|
|||
{
|
||||
_isReloading = true;
|
||||
|
||||
// we need to release all of the glTextures to avoid collisions of texture id's when reloading the textures onto the GPU
|
||||
for(auto iter = _textures.begin(); iter != _textures.end(); ++iter)
|
||||
{
|
||||
(*iter)->_texture->releaseGLTexture();
|
||||
}
|
||||
|
||||
CCLOG("reload all texture");
|
||||
auto iter = _textures.begin();
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using System.Resources;
|
||||
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.Markup;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System.IO.IsolatedStorage;
|
||||
using PhoneDirect3DXamlAppInterop.Resources;
|
||||
|
||||
namespace PhoneDirect3DXamlAppInterop
|
||||
{
|
||||
|
@ -21,7 +17,28 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
/// Provides easy access to the root frame of the Phone Application.
|
||||
/// </summary>
|
||||
/// <returns>The root frame of the Phone Application.</returns>
|
||||
public PhoneApplicationFrame RootFrame { get; private set; }
|
||||
public static PhoneApplicationFrame RootFrame { get; private set; }
|
||||
|
||||
|
||||
enum SessionType
|
||||
{
|
||||
None,
|
||||
Home,
|
||||
DeepLink
|
||||
}
|
||||
|
||||
// Set to Home when the app is launched from Primary tile.
|
||||
// Set to DeepLink when the app is launched from Deep Link.
|
||||
private SessionType sessionType = SessionType.None;
|
||||
|
||||
// Set to true when the page navigation is being reset
|
||||
bool wasRelaunched = false;
|
||||
|
||||
// set to true when 5 min passed since the app was relaunched
|
||||
bool mustClearPagestack = false;
|
||||
|
||||
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
|
@ -31,14 +48,14 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard Silverlight initialization
|
||||
// Standard XAML initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = false;
|
||||
|
@ -50,8 +67,8 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// which shows areas of a page that are handed off to GPU with a colored overlay.
|
||||
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||
|
||||
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
|
||||
// application's PhoneApplicationService object to Disabled.
|
||||
// Prevent the screen from turning off while under the debugger by disabling
|
||||
// the application's idle detection.
|
||||
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
|
||||
// and consume battery power when the user is not using the phone.
|
||||
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
|
||||
|
@ -63,43 +80,63 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
|
||||
// When a new instance of the app is launched, clear all deactivation settings
|
||||
RemoveCurrentDeactivationSettings();
|
||||
}
|
||||
|
||||
// Code to execute when the application is activated (brought to foreground)
|
||||
// This code will not execute when the application is first launched
|
||||
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||
{
|
||||
// If some interval has passed since the app was deactivated (30 seconds in this example),
|
||||
// then remember to clear the back stack of pages
|
||||
mustClearPagestack = CheckDeactivationTimeStamp();
|
||||
|
||||
|
||||
// If IsApplicationInstancePreserved is not true, then set the session type to the value
|
||||
// saved in isolated storage. This will make sure the session type is correct for an
|
||||
// app that is being resumed after being tombstoned.
|
||||
if (!e.IsApplicationInstancePreserved)
|
||||
{
|
||||
RestoreSessionType();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is deactivated (sent to background)
|
||||
// This code will not execute when the application is closing
|
||||
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
// When the applicaiton is deactivated, save the current deactivation settings to isolated storage
|
||||
SaveCurrentDeactivationSettings();
|
||||
}
|
||||
|
||||
// Code to execute when the application is closing (eg, user hit Back)
|
||||
// This code will not execute when the application is deactivated
|
||||
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||
{
|
||||
// When the application closes, delete any deactivation settings from isolated storage
|
||||
RemoveCurrentDeactivationSettings();
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,10 +162,80 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
// Handle reset requests for clearing the backstack
|
||||
RootFrame.Navigated += CheckForResetNavigation;
|
||||
|
||||
// Monitor deep link launching
|
||||
RootFrame.Navigating += RootFrame_Navigating;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Event handler for the Navigating event of the root frame. Use this handler to modify
|
||||
// the default navigation behavior.
|
||||
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
|
||||
{
|
||||
|
||||
// If the session type is None or New, check the navigation Uri to determine if the
|
||||
// navigation is a deep link or if it points to the app's main page.
|
||||
if (sessionType == SessionType.None && e.NavigationMode == NavigationMode.New)
|
||||
{
|
||||
// This block will run if the current navigation is part of the app's intial launch
|
||||
|
||||
|
||||
// Keep track of Session Type
|
||||
if (e.Uri.ToString().Contains("DeepLink=true"))
|
||||
{
|
||||
sessionType = SessionType.DeepLink;
|
||||
}
|
||||
else if (e.Uri.ToString().Contains("/MainPage.xaml"))
|
||||
{
|
||||
sessionType = SessionType.Home;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e.NavigationMode == NavigationMode.Reset)
|
||||
{
|
||||
// This block will execute if the current navigation is a relaunch.
|
||||
// If so, another navigation will be coming, so this records that a relaunch just happened
|
||||
// so that the next navigation can use this info.
|
||||
wasRelaunched = true;
|
||||
}
|
||||
else if (e.NavigationMode == NavigationMode.New && wasRelaunched)
|
||||
{
|
||||
// This block will run if the previous navigation was a relaunch
|
||||
wasRelaunched = false;
|
||||
|
||||
if (e.Uri.ToString().Contains("DeepLink=true"))
|
||||
{
|
||||
// This block will run if the launch Uri contains "DeepLink=true" which
|
||||
// was specified when the secondary tile was created in MainPage.xaml.cs
|
||||
|
||||
sessionType = SessionType.DeepLink;
|
||||
// The app was relaunched via a Deep Link.
|
||||
// The page stack will be cleared.
|
||||
}
|
||||
else if (e.Uri.ToString().Contains("/MainPage.xaml"))
|
||||
{
|
||||
// This block will run if the navigation Uri is the main page
|
||||
if (sessionType == SessionType.DeepLink)
|
||||
{
|
||||
// When the app was previously launched via Deep Link and relaunched via Main Tile, we need to clear the page stack.
|
||||
sessionType = SessionType.Home;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mustClearPagestack)
|
||||
{
|
||||
//The app was previously launched via Main Tile and relaunched via Main Tile. Cancel the navigation to resume.
|
||||
e.Cancel = true;
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mustClearPagestack = false;
|
||||
}
|
||||
}
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
|
@ -140,44 +247,20 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
private bool _isResume = false;
|
||||
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// If the app has received a 'reset' navigation, then we need to check
|
||||
// on the next navigation to see if the page stack should be reset
|
||||
if (e.NavigationMode == NavigationMode.Reset)
|
||||
{
|
||||
RootFrame.Navigating += HandlerFotResetNavigating;
|
||||
_isResume = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isResume && e.NavigationMode == NavigationMode.Refresh)
|
||||
{
|
||||
RootFrame.Navigating -= HandlerFotResetNavigating;
|
||||
_isResume = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlerFotResetNavigating(object sender, NavigatingCancelEventArgs e)
|
||||
{
|
||||
RootFrame.Navigating -= HandlerFotResetNavigating;
|
||||
if (e.Uri.OriginalString.Contains("MainPage.xaml"))
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RootFrame.Navigated += ClearBackStackAfterReset;
|
||||
}
|
||||
_isResume = false;
|
||||
}
|
||||
|
||||
private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Unregister the event so it doesn't get called again
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
|
||||
// Only clear the stack for 'new' (forward) navigations
|
||||
// Only clear the stack for 'new' (forward) and 'refresh' navigations
|
||||
if (e.NavigationMode != NavigationMode.New)
|
||||
return;
|
||||
|
||||
|
@ -189,5 +272,92 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Helper method for adding or updating a key/value pair in isolated storage
|
||||
public bool AddOrUpdateValue(string Key, Object value)
|
||||
{
|
||||
bool valueChanged = false;
|
||||
|
||||
// If the key exists
|
||||
if (settings.Contains(Key))
|
||||
{
|
||||
// If the value has changed
|
||||
if (settings[Key] != value)
|
||||
{
|
||||
// Store the new value
|
||||
settings[Key] = value;
|
||||
valueChanged = true;
|
||||
}
|
||||
}
|
||||
// Otherwise create the key.
|
||||
else
|
||||
{
|
||||
settings.Add(Key, value);
|
||||
valueChanged = true;
|
||||
}
|
||||
return valueChanged;
|
||||
}
|
||||
|
||||
// Helper method for removing a key/value pair from isolated storage
|
||||
public void RemoveValue(string Key)
|
||||
{
|
||||
// If the key exists
|
||||
if (settings.Contains(Key))
|
||||
{
|
||||
settings.Remove(Key);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the app is deactivating. Saves the time of the deactivation and the
|
||||
// session type of the app instance to isolated storage.
|
||||
public void SaveCurrentDeactivationSettings()
|
||||
{
|
||||
if (AddOrUpdateValue("DeactivateTime", DateTimeOffset.Now))
|
||||
{
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
if (AddOrUpdateValue("SessionType", sessionType))
|
||||
{
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called when the app is launched or closed. Removes all deactivation settings from
|
||||
// isolated storage
|
||||
public void RemoveCurrentDeactivationSettings()
|
||||
{
|
||||
RemoveValue("DeactivateTime");
|
||||
RemoveValue("SessionType");
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
// Helper method to determine if the interval since the app was deactivated is
|
||||
// greater than 30 seconds
|
||||
bool CheckDeactivationTimeStamp()
|
||||
{
|
||||
DateTimeOffset lastDeactivated;
|
||||
|
||||
if (settings.Contains("DeactivateTime"))
|
||||
{
|
||||
lastDeactivated = (DateTimeOffset)settings["DeactivateTime"];
|
||||
}
|
||||
|
||||
var currentDuration = DateTimeOffset.Now.Subtract(lastDeactivated);
|
||||
|
||||
return TimeSpan.FromSeconds(currentDuration.TotalSeconds) > TimeSpan.FromSeconds(30);
|
||||
}
|
||||
|
||||
// Helper method to restore the session type from isolated storage.
|
||||
void RestoreSessionType()
|
||||
{
|
||||
if (settings.Contains("SessionType"))
|
||||
{
|
||||
sessionType = (SessionType)settings["SessionType"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,15 +1,14 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
// Runtime Version:4.0.30319.34014
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PhoneDirect3DXamlAppInterop.Resources
|
||||
{
|
||||
namespace PhoneDirect3DXamlAppInterop.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
|
@ -23,28 +22,23 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class AppResources
|
||||
{
|
||||
public class AppResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal AppResources()
|
||||
{
|
||||
internal AppResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PhoneDirect3DXamlAppInterop.Resources.AppResources", typeof(AppResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
|
@ -57,14 +51,11 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +63,28 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to MY APPLICATION.
|
||||
/// </summary>
|
||||
public static string ApplicationTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
public static string ApplicationTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LeftToRight.
|
||||
/// </summary>
|
||||
public static string ResourceFlowDirection {
|
||||
get {
|
||||
return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to en-US.
|
||||
/// </summary>
|
||||
public static string ResourceLanguage {
|
||||
get {
|
||||
return ResourceManager.GetString("ResourceLanguage", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,4 +120,12 @@
|
|||
<data name="ApplicationTitle" xml:space="preserve">
|
||||
<value>MY APPLICATION</value>
|
||||
</data>
|
||||
<data name="ResourceFlowDirection" xml:space="preserve">
|
||||
<value>LeftToRight</value>
|
||||
<comment>Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language</comment>
|
||||
</data>
|
||||
<data name="ResourceLanguage" xml:space="preserve">
|
||||
<value>en-US</value>
|
||||
<comment>Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.</comment>
|
||||
</data>
|
||||
</root>
|
|
@ -1,15 +1,14 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
// Runtime Version:4.0.30319.34014
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PhoneDirect3DXamlAppInterop.Resources
|
||||
{
|
||||
namespace PhoneDirect3DXamlAppInterop.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
|
@ -23,28 +22,23 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class AppResources
|
||||
{
|
||||
public class AppResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal AppResources()
|
||||
{
|
||||
internal AppResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PhoneDirect3DXamlAppInterop.Resources.AppResources", typeof(AppResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
|
@ -57,14 +51,11 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
@ -72,10 +63,8 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to MY APPLICATION.
|
||||
/// </summary>
|
||||
public static string ApplicationTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
public static string ApplicationTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
// Runtime Version:4.0.30319.34014
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PhoneDirect3DXamlAppInterop.Resources
|
||||
{
|
||||
namespace PhoneDirect3DXamlAppInterop.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
|
@ -23,28 +22,23 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class AppResources
|
||||
{
|
||||
public class AppResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal AppResources()
|
||||
{
|
||||
internal AppResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PhoneDirect3DXamlAppInterop.Resources.AppResources", typeof(AppResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
|
@ -57,14 +51,11 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
@ -72,10 +63,8 @@ namespace PhoneDirect3DXamlAppInterop.Resources
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to MY APPLICATION.
|
||||
/// </summary>
|
||||
public static string ApplicationTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
public static string ApplicationTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue