Get about version from metadata, refactoring
This commit is contained in:
Родитель
c101a0c3bd
Коммит
31c7533f86
|
@ -25,7 +25,10 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="12,0,12,0">
|
||||
<TextBlock Margin="12,0,12,0" Text="Version 0.0.0.1"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="12,0,12,0" Text="Version"/>
|
||||
<TextBlock x:Name="versionTextBox" Margin="12,0,12,0" Text="Version"/>
|
||||
</StackPanel>
|
||||
<TextBlock Margin="12,10,12,0" Text="Camera Explorer application is a Nokia Developer example demonstrating the use of the advanced camera APIs of Windows Phone 8." TextWrapping="Wrap"/>
|
||||
<TextBlock Margin="12,10,12,0" Text="Developed and published by Nokia. All rights reserved." TextWrapping="Wrap"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
|
|
@ -7,14 +7,18 @@ using System.Windows.Controls;
|
|||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace MapExplorer
|
||||
{
|
||||
public partial class AboutPage : PhoneApplicationPage
|
||||
{
|
||||
|
||||
public AboutPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
versionTextBox.Text = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -119,14 +119,7 @@ namespace CameraExplorer
|
|||
public ArrayParameter(PhotoCaptureDevice device, string name, bool overlay = false)
|
||||
: base(device, name, overlay)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetValues(ref _items, ref _selectedItem);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Getting " + Name.ToLower() + " failed");
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public ArrayParameter(PhotoCaptureDevice device, Guid guid, string name, bool overlay = false)
|
||||
|
@ -134,41 +127,59 @@ namespace CameraExplorer
|
|||
{
|
||||
_guid = guid;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
_items.Clear();
|
||||
|
||||
_selectedItem = null;
|
||||
|
||||
bool supported = false;
|
||||
|
||||
try
|
||||
{
|
||||
GetValues(ref _items, ref _selectedItem);
|
||||
|
||||
supported = _items.Count > 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Getting " + Name.ToLower() + " failed");
|
||||
}
|
||||
|
||||
Supported = _items.Count > 0;
|
||||
Supported = supported;
|
||||
Modifiable = Supported && _items.Count > 1;
|
||||
|
||||
if (supported)
|
||||
{
|
||||
NotifyPropertyChanged("Count");
|
||||
NotifyPropertyChanged("SelectedItem");
|
||||
NotifyPropertyChanged("ImageSource");
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void GetValues(ref List<ArrayParameterItem<T>> items, ref ArrayParameterItem<T> selectedItem)
|
||||
{
|
||||
object p = Device.GetProperty(_guid);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
SetDefault();
|
||||
|
||||
p = Device.GetProperty(_guid);
|
||||
}
|
||||
|
||||
foreach (object o in PhotoCaptureDevice.GetSupportedPropertyValues(Device.SensorLocation, _guid))
|
||||
{
|
||||
dynamic dynamic_o = o;
|
||||
|
||||
items.Add(CreateItemForValue((T)dynamic_o));
|
||||
ArrayParameterItem<T> item = CreateItemForValue((T)dynamic_o);
|
||||
|
||||
if (o.Equals(p))
|
||||
if (item != null)
|
||||
{
|
||||
selectedItem = items.Last();
|
||||
items.Add(item);
|
||||
|
||||
ImageSource = selectedItem.ImageSource;
|
||||
if (o.Equals(p))
|
||||
{
|
||||
selectedItem = items.Last();
|
||||
|
||||
ImageSource = selectedItem.ImageSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +216,7 @@ namespace CameraExplorer
|
|||
|
||||
_selectedItem = value;
|
||||
|
||||
ImageSource = value.ImageSource;
|
||||
ImageSource = _selectedItem.ImageSource;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -239,6 +250,8 @@ namespace CameraExplorer
|
|||
|
||||
public class PreviewResolutionParameter : ArrayParameter<Windows.Foundation.Size>
|
||||
{
|
||||
ArrayParameterItem<Windows.Foundation.Size> _defaultItem;
|
||||
|
||||
public PreviewResolutionParameter(PhotoCaptureDevice device)
|
||||
: base(device, "Preview resolution")
|
||||
{
|
||||
|
@ -257,6 +270,15 @@ namespace CameraExplorer
|
|||
selectedItem = items.Last();
|
||||
}
|
||||
}
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
_defaultItem = items.First();
|
||||
}
|
||||
else
|
||||
{
|
||||
_defaultItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected async override void SetValue(ArrayParameterItem<Windows.Foundation.Size> item)
|
||||
|
@ -271,6 +293,8 @@ namespace CameraExplorer
|
|||
|
||||
public class CaptureResolutionParameter : ArrayParameter<Windows.Foundation.Size>
|
||||
{
|
||||
ArrayParameterItem<Windows.Foundation.Size> _defaultItem;
|
||||
|
||||
public CaptureResolutionParameter(PhotoCaptureDevice device)
|
||||
: base(device, "Capture resolution")
|
||||
{
|
||||
|
@ -289,6 +313,15 @@ namespace CameraExplorer
|
|||
selectedItem = items.Last();
|
||||
}
|
||||
}
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
_defaultItem = items.First();
|
||||
}
|
||||
else
|
||||
{
|
||||
_defaultItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected async override void SetValue(ArrayParameterItem<Windows.Foundation.Size> item)
|
||||
|
@ -303,6 +336,8 @@ namespace CameraExplorer
|
|||
|
||||
public class ExposureTimeParameter : ArrayParameter<UInt32>
|
||||
{
|
||||
ArrayParameterItem<UInt32> _defaultItem;
|
||||
|
||||
public ExposureTimeParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraPhotoProperties.ExposureTime, "Exposure time", true)
|
||||
{
|
||||
|
@ -330,7 +365,7 @@ namespace CameraExplorer
|
|||
|
||||
for (int i = 0; i < list.Count;)
|
||||
{
|
||||
UInt32 o = list[i];
|
||||
UInt32 o = 1000000 / list[i];
|
||||
|
||||
if (o < min || o > max)
|
||||
{
|
||||
|
@ -353,37 +388,46 @@ namespace CameraExplorer
|
|||
|
||||
List<UInt32> array = ConvertRangeToArray((UInt32)range.Min, (UInt32)range.Max);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
p = array[0];
|
||||
|
||||
Device.SetProperty(Guid, (UInt32)p);
|
||||
}
|
||||
|
||||
foreach (UInt32 o in array)
|
||||
{
|
||||
items.Add(CreateItemForValue(o));
|
||||
ArrayParameterItem<UInt32> item = new ArrayParameterItem<UInt32>(
|
||||
1000000 / o,
|
||||
"1/" + o.ToString() + " s",
|
||||
"Assets/Icons/overlay.exposuretime." + o.ToString() + ".png");
|
||||
|
||||
if (o.Equals(p))
|
||||
if (item != null)
|
||||
{
|
||||
selectedItem = items.Last();
|
||||
items.Add(item);
|
||||
|
||||
ImageSource = selectedItem.ImageSource;
|
||||
if ((1000000 / o).Equals(p))
|
||||
{
|
||||
selectedItem = items.Last();
|
||||
|
||||
ImageSource = selectedItem.ImageSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
_defaultItem = items.Last();
|
||||
}
|
||||
else
|
||||
{
|
||||
_defaultItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override ArrayParameterItem<UInt32> CreateItemForValue(uint value)
|
||||
public override void SetDefault()
|
||||
{
|
||||
string name = "1/" + value.ToString() + " s";
|
||||
string imageSource = "Assets/Icons/overlay.exposuretime." + value.ToString() + ".png";
|
||||
|
||||
return new ArrayParameterItem<UInt32>(value, name, imageSource);
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class IsoParameter : ArrayParameter<UInt32>
|
||||
{
|
||||
ArrayParameterItem<UInt32> _defaultItem;
|
||||
|
||||
public IsoParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraPhotoProperties.Iso, "ISO", true)
|
||||
{
|
||||
|
@ -425,24 +469,31 @@ namespace CameraExplorer
|
|||
|
||||
IReadOnlyList<UInt32> array = ConvertRangeToArray((UInt32)range.Min, (UInt32)range.Max);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
p = array[0];
|
||||
|
||||
Device.SetProperty(Guid, (UInt32)p);
|
||||
}
|
||||
|
||||
foreach (UInt32 o in array)
|
||||
{
|
||||
items.Add(CreateItemForValue(o));
|
||||
ArrayParameterItem<UInt32> item = CreateItemForValue(o);
|
||||
|
||||
if (o.Equals(p))
|
||||
if (item != null)
|
||||
{
|
||||
selectedItem = items.Last();
|
||||
items.Add(item);
|
||||
|
||||
ImageSource = selectedItem.ImageSource;
|
||||
if (o.Equals(p))
|
||||
{
|
||||
selectedItem = items.Last();
|
||||
|
||||
ImageSource = selectedItem.ImageSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (items.Count > 0)
|
||||
{
|
||||
_defaultItem = items[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
_defaultItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override ArrayParameterItem<UInt32> CreateItemForValue(uint value)
|
||||
|
@ -452,10 +503,17 @@ namespace CameraExplorer
|
|||
|
||||
return new ArrayParameterItem<UInt32>(value, name, imageSource);
|
||||
}
|
||||
|
||||
public override void SetDefault()
|
||||
{
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class SceneModeParameter : ArrayParameter<CameraSceneMode> // todo CameraSceneMode
|
||||
public class SceneModeParameter : ArrayParameter<CameraSceneMode>
|
||||
{
|
||||
ArrayParameterItem<CameraSceneMode> _defaultItem;
|
||||
|
||||
public SceneModeParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraPhotoProperties.SceneMode, "Scene mode", true)
|
||||
{
|
||||
|
@ -513,22 +571,36 @@ namespace CameraExplorer
|
|||
imageSource = "Assets/Icons/overlay.scenemode.backlit.png";
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
name = null;
|
||||
imageSource = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ArrayParameterItem<CameraSceneMode>(value, name, imageSource);
|
||||
ArrayParameterItem<CameraSceneMode> item = null;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
item = new ArrayParameterItem<CameraSceneMode>(value, name, imageSource);
|
||||
|
||||
if (_defaultItem == null)
|
||||
{
|
||||
_defaultItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.SceneMode, CameraSceneMode.Auto);
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class FlashModeParameter : ArrayParameter<FlashMode>
|
||||
{
|
||||
ArrayParameterItem<FlashMode> _defaultItem;
|
||||
|
||||
public FlashModeParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraPhotoProperties.FlashMode, "Flash mode", true)
|
||||
{
|
||||
|
@ -558,22 +630,36 @@ namespace CameraExplorer
|
|||
imageSource = "Assets/Icons/overlay.flashmode.redeyereduction.png";
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
imageSource = "";
|
||||
name = null;
|
||||
imageSource = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ArrayParameterItem<FlashMode>(value, name, imageSource);
|
||||
ArrayParameterItem<FlashMode> item = null;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
item = new ArrayParameterItem<FlashMode>(value, name, imageSource);
|
||||
|
||||
if (_defaultItem == null)
|
||||
{
|
||||
_defaultItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.FlashMode, FlashMode.Auto);
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class FocusIlluminationModeParameter : ArrayParameter<FocusIlluminationMode>
|
||||
{
|
||||
ArrayParameterItem<FocusIlluminationMode> _defaultItem;
|
||||
|
||||
public FocusIlluminationModeParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraPhotoProperties.FocusIlluminationMode, "Focus illumination mode")
|
||||
{
|
||||
|
@ -595,21 +681,35 @@ namespace CameraExplorer
|
|||
name = "On";
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
name = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ArrayParameterItem<FocusIlluminationMode>(value, name);
|
||||
ArrayParameterItem<FocusIlluminationMode> item = null;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
item = new ArrayParameterItem<FocusIlluminationMode>(value, name);
|
||||
|
||||
if (_defaultItem == null)
|
||||
{
|
||||
_defaultItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.FocusIlluminationMode, FocusIlluminationMode.Auto);
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class WhiteBalancePresetParameter : ArrayParameter<WhiteBalancePreset>
|
||||
{
|
||||
ArrayParameterItem<WhiteBalancePreset> _defaultItem;
|
||||
|
||||
public WhiteBalancePresetParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraPhotoProperties.WhiteBalancePreset, "White balance preset")
|
||||
{
|
||||
|
@ -640,20 +740,35 @@ namespace CameraExplorer
|
|||
name = "Tungsten";
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
name = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ArrayParameterItem<WhiteBalancePreset>(value, name);
|
||||
ArrayParameterItem<WhiteBalancePreset> item = null;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
item = new ArrayParameterItem<WhiteBalancePreset>(value, name);
|
||||
|
||||
if (_defaultItem == null)
|
||||
{
|
||||
_defaultItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoFocusRangeParameter : ArrayParameter<AutoFocusRange>
|
||||
{
|
||||
ArrayParameterItem<AutoFocusRange> _defaultItem;
|
||||
|
||||
public AutoFocusRangeParameter(PhotoCaptureDevice device)
|
||||
: base(device, KnownCameraGeneralProperties.AutoFocusRange, "Auto focus range")
|
||||
{
|
||||
|
@ -681,15 +796,28 @@ namespace CameraExplorer
|
|||
name = "Normal";
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
name = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ArrayParameterItem<AutoFocusRange>(value, name);
|
||||
ArrayParameterItem<AutoFocusRange> item = null;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
item = new ArrayParameterItem<AutoFocusRange>(value, name);
|
||||
|
||||
if (_defaultItem == null)
|
||||
{
|
||||
_defaultItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
SelectedItem = _defaultItem;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ namespace CameraExplorer
|
|||
{
|
||||
_device = value;
|
||||
|
||||
Settings.Refresh();
|
||||
Settings.CreateParameters();
|
||||
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.PageTitle, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||
<TextBlock Text="CAMERA EXPLORER - VIEWFINDER" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
|
@ -59,8 +58,6 @@
|
|||
IconUri="Assets/Icons/appbar.sensor.png" Click="sensorButton_Click"/>
|
||||
<shell:ApplicationBarIconButton x:Name="settingsButton" Text="settings"
|
||||
IconUri="Assets/Icons/appbar.feature.settings.rest.png" Click="settingsButton_Click"/>
|
||||
<shell:ApplicationBarIconButton x:Name="aboutButton" Text="about"
|
||||
IconUri="Assets/Icons/questionmark.png" Click="aboutButton_Click"/>
|
||||
</shell:ApplicationBar>
|
||||
</phone:PhoneApplicationPage.ApplicationBar>
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ namespace CameraExplorer
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
ApplicationBarMenuItem menuItem = new ApplicationBarMenuItem();
|
||||
menuItem.Text = "about";
|
||||
ApplicationBar.MenuItems.Add(menuItem);
|
||||
menuItem.Click += new EventHandler(aboutMenuItem_Click);
|
||||
|
||||
DataContext = _dataContext;
|
||||
}
|
||||
|
||||
|
@ -107,7 +112,10 @@ namespace CameraExplorer
|
|||
{
|
||||
SetButtonsEnabled(false);
|
||||
|
||||
await _dataContext.Device.FocusAsync();
|
||||
if (PhotoCaptureDevice.IsFocusSupported(_dataContext.Device.SensorLocation))
|
||||
{
|
||||
await _dataContext.Device.FocusAsync();
|
||||
}
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
|
||||
|
@ -126,7 +134,7 @@ namespace CameraExplorer
|
|||
SetButtonsEnabled(true);
|
||||
}
|
||||
|
||||
private void aboutButton_Click(object sender, EventArgs e)
|
||||
private void aboutMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
NavigationService.Navigate(new Uri("/AboutPage.xaml", UriKind.Relative));
|
||||
}
|
||||
|
|
|
@ -120,7 +120,12 @@ namespace CameraExplorer
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual void SetDefault()
|
||||
public virtual void SetDefault()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void Refresh()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -20,20 +20,20 @@
|
|||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="12,17,0,28">
|
||||
<TextBlock Text="CAMERA EXPLORER" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
<TextBlock Text="preview" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||
<TextBlock Text="CAMERA EXPLORER - PREVIEW" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<Image x:Name="image"/>
|
||||
<Image x:Name="image" Stretch="UniformToFill"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- todo does not work
|
||||
<phone:PhoneApplicationPage.ApplicationBar>
|
||||
<shell:ApplicationBar IsVisible="True">
|
||||
<shell:ApplicationBarIconButton x:Name="saveButton" Text="save"
|
||||
IconUri="Assets/Icons/save.png" Click="saveButton_Click"/>
|
||||
</shell:ApplicationBar>
|
||||
</phone:PhoneApplicationPage.ApplicationBar>
|
||||
|
||||
-->
|
||||
</phone:PhoneApplicationPage>
|
|
@ -34,13 +34,6 @@ namespace CameraExplorer
|
|||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
_dataContext.ImageStream = null;
|
||||
|
||||
base.OnNavigatingFrom(e);
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -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.1" 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.2" 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" />
|
||||
|
|
|
@ -23,38 +23,49 @@ namespace CameraExplorer
|
|||
{
|
||||
_guid = guid;
|
||||
|
||||
try
|
||||
{
|
||||
_range = PhotoCaptureDevice.GetSupportedPropertyRange(device.SensorLocation, guid);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Getting supported range for " + Name.ToLower() + " failed");
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void GetRange(ref CameraCapturePropertyRange range)
|
||||
{
|
||||
_range = PhotoCaptureDevice.GetSupportedPropertyRange(Device.SensorLocation, _guid);
|
||||
}
|
||||
|
||||
void GetValue(ref T value)
|
||||
{
|
||||
_value = (T)Device.GetProperty(_guid);
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
bool supported = false;
|
||||
|
||||
try
|
||||
{
|
||||
_value = (T)device.GetProperty(guid);
|
||||
GetRange(ref _range);
|
||||
|
||||
supported = _range != null;
|
||||
|
||||
if (supported)
|
||||
{
|
||||
GetValue(ref _value);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Getting " + Name.ToLower() + " failed");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_value == null)
|
||||
{
|
||||
SetDefault();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Setting " + Name.ToLower() + " failed");
|
||||
}
|
||||
|
||||
Supported = _range != null;
|
||||
Supported = supported;
|
||||
Modifiable = Supported && !_range.Min.Equals(_range.Max);
|
||||
|
||||
if (supported)
|
||||
{
|
||||
NotifyPropertyChanged("Minimum");
|
||||
NotifyPropertyChanged("Maximum");
|
||||
NotifyPropertyChanged("Value");
|
||||
NotifyPropertyChanged("ImageSource");
|
||||
}
|
||||
}
|
||||
|
||||
public T Minimum
|
||||
|
@ -106,16 +117,9 @@ namespace CameraExplorer
|
|||
{
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
if (Minimum <= 0 && Maximum >= 0)
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.ExposureCompensation, (Int32)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.ExposureCompensation, Minimum);
|
||||
}
|
||||
Value = (Int32)Minimum + (Maximum - Minimum) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,9 +130,9 @@ namespace CameraExplorer
|
|||
{
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.ManualWhiteBalance, Minimum);
|
||||
Value = (UInt32)Minimum + (Maximum - Minimum) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,9 +143,9 @@ namespace CameraExplorer
|
|||
{
|
||||
}
|
||||
|
||||
protected override void SetDefault()
|
||||
public override void SetDefault()
|
||||
{
|
||||
Device.SetProperty(KnownCameraPhotoProperties.FlashPower, Minimum);
|
||||
Value = (UInt32)Minimum + (Maximum - Minimum) / 2;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using Windows.Phone.Media.Capture;
|
||||
|
||||
|
@ -26,29 +27,69 @@ namespace CameraExplorer
|
|||
}
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
public void CreateParameters()
|
||||
{
|
||||
_parameters.Clear();
|
||||
|
||||
if (_dataContext.Device != null)
|
||||
{
|
||||
_parameters.Add(new SceneModeParameter(_dataContext.Device));
|
||||
_parameters.Add(new WhiteBalancePresetParameter(_dataContext.Device));
|
||||
ObservableCollection<Parameter> ps = new ObservableCollection<Parameter>();
|
||||
|
||||
_parameters.Add(new PreviewResolutionParameter(_dataContext.Device));
|
||||
_parameters.Add(new CaptureResolutionParameter(_dataContext.Device));
|
||||
ps.Add(new SceneModeParameter(_dataContext.Device));
|
||||
ps.Add(new WhiteBalancePresetParameter(_dataContext.Device));
|
||||
|
||||
_parameters.Add(new FlashModeParameter(_dataContext.Device));
|
||||
_parameters.Add(new FlashPowerParameter(_dataContext.Device));
|
||||
_parameters.Add(new IsoParameter(_dataContext.Device));
|
||||
_parameters.Add(new ExposureCompensationParameter(_dataContext.Device));
|
||||
_parameters.Add(new ManualWhiteBalanceParameter(_dataContext.Device));
|
||||
_parameters.Add(new ExposureTimeParameter(_dataContext.Device));
|
||||
_parameters.Add(new AutoFocusRangeParameter(_dataContext.Device));
|
||||
_parameters.Add(new FocusIlluminationModeParameter(_dataContext.Device));
|
||||
// ps.Add(new PreviewResolutionParameter(_dataContext.Device)); // todo throws exception when setting this
|
||||
ps.Add(new CaptureResolutionParameter(_dataContext.Device));
|
||||
|
||||
//ps.Add(new FlashModeParameter(_dataContext.Device)); // todo does not capture after setting this
|
||||
ps.Add(new FlashPowerParameter(_dataContext.Device));
|
||||
ps.Add(new IsoParameter(_dataContext.Device));
|
||||
//ps.Add(new ExposureCompensationParameter(_dataContext.Device)); // todo does not work, does not capture after setting this
|
||||
//ps.Add(new ManualWhiteBalanceParameter(_dataContext.Device)); // todo dependency with wb preset
|
||||
ps.Add(new ExposureTimeParameter(_dataContext.Device));
|
||||
ps.Add(new AutoFocusRangeParameter(_dataContext.Device));
|
||||
ps.Add(new FocusIlluminationModeParameter(_dataContext.Device));
|
||||
|
||||
for (int i = 0; i < ps.Count;)
|
||||
{
|
||||
Parameter p = ps[i];
|
||||
|
||||
if (p.Supported && p.Modifiable)
|
||||
{
|
||||
try
|
||||
{
|
||||
p.SetDefault();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Setting default to " + p.Name.ToLower() + " failed");
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Parameter p in ps)
|
||||
{
|
||||
p.Refresh();
|
||||
}
|
||||
|
||||
_parameters = ps;
|
||||
}
|
||||
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Parameters"));
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
foreach (Parameter p in _parameters)
|
||||
{
|
||||
p.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<ListBox ItemsSource="{Binding Settings.Parameters}">
|
||||
<ListBox x:Name="listBox" ItemsSource="{Binding Settings.Parameters}" Tap="listBox_Tap">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<local:SettingsTemplateSelector Content="{Binding}">
|
||||
|
|
|
@ -30,5 +30,10 @@ namespace CameraExplorer
|
|||
{
|
||||
_dataContext.Settings.Refresh();
|
||||
}
|
||||
|
||||
private void listBox_Tap(object sender, GestureEventArgs e)
|
||||
{
|
||||
_dataContext.Settings.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче