Uninitialize camera when application is deactivated
This commit is contained in:
Родитель
de6c834007
Коммит
1d19b5d188
|
@ -13,6 +13,7 @@ namespace MapExplorer
|
|||
{
|
||||
public partial class AboutPage : PhoneApplicationPage
|
||||
{
|
||||
CameraExplorer.DataContext _dataContext = CameraExplorer.DataContext.Singleton;
|
||||
|
||||
public AboutPage()
|
||||
{
|
||||
|
@ -20,5 +21,15 @@ namespace MapExplorer
|
|||
|
||||
versionTextBox.Text = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
if (_dataContext.Device == null)
|
||||
{
|
||||
NavigationService.GoBack();
|
||||
}
|
||||
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ namespace CameraExplorer
|
|||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
private CameraExplorer.DataContext _dataContext = CameraExplorer.DataContext.Singleton;
|
||||
|
||||
/// <summary>
|
||||
/// Provides easy access to the root frame of the Phone Application.
|
||||
/// </summary>
|
||||
|
@ -75,6 +77,7 @@ namespace CameraExplorer
|
|||
// This code will not execute when the application is closing
|
||||
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
_dataContext.UnitializeCamera();
|
||||
}
|
||||
|
||||
// Code to execute when the application is closing (eg, user hit Back)
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace CameraExplorer
|
|||
|
||||
ApplicationBarMenuItem menuItem = new ApplicationBarMenuItem();
|
||||
menuItem.Text = "about";
|
||||
menuItem.IsEnabled = false;
|
||||
ApplicationBar.MenuItems.Add(menuItem);
|
||||
menuItem.Click += new EventHandler(aboutMenuItem_Click);
|
||||
|
||||
|
@ -86,6 +87,11 @@ namespace CameraExplorer
|
|||
{
|
||||
b.IsEnabled = enabled;
|
||||
}
|
||||
|
||||
foreach (ApplicationBarMenuItem m in ApplicationBar.MenuItems)
|
||||
{
|
||||
m.IsEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCameraButtonsEnabled(bool enabled)
|
||||
|
|
|
@ -20,9 +20,16 @@ namespace CameraExplorer
|
|||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
_bitmap.SetSource(_dataContext.ImageStream);
|
||||
if (_dataContext.Device == null)
|
||||
{
|
||||
NavigationService.GoBack();
|
||||
}
|
||||
else
|
||||
{
|
||||
_bitmap.SetSource(_dataContext.ImageStream);
|
||||
|
||||
image.Source = _bitmap;
|
||||
image.Source = _bitmap;
|
||||
}
|
||||
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
|
||||
<DefaultLanguage xmlns="" code="en-US" />
|
||||
<App xmlns="" ProductID="{94f53777-5783-47b2-9bcb-ce46ccb0f219}" Title="Camera Explorer" RuntimeType="Silverlight" Version="0.0.0.4" Genre="apps.normal" Author="" Description="" Publisher="" PublisherID="{cc336b25-5e51-419a-8c64-3c4a7a4383f4}">
|
||||
<App xmlns="" ProductID="{94f53777-5783-47b2-9bcb-ce46ccb0f219}" Title="Camera Explorer" RuntimeType="Silverlight" Version="0.0.0.5" Genre="apps.normal" Author="" Description="" Publisher="" PublisherID="{cc336b25-5e51-419a-8c64-3c4a7a4383f4}">
|
||||
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_NETWORKING" />
|
||||
|
|
|
@ -27,6 +27,16 @@ namespace CameraExplorer
|
|||
DataContext = _dataContext;
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
if (_dataContext.Device == null)
|
||||
{
|
||||
NavigationService.GoBack();
|
||||
}
|
||||
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
private void resetButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetScreenButtonsEnabled(false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче