Merge branch 'release/#17' into develmaster
This commit is contained in:
@@ -248,6 +248,9 @@
|
||||
<Compile Include="Utility\Lui\Button\PhoneButton.cs" />
|
||||
<Compile Include="Utility\Lui\Button\LinkButton.cs" />
|
||||
<Compile Include="Utility\Lui\MessageBoxes\MessageBoxes.cs" />
|
||||
<Compile Include="Utility\QRScanner\QRScanner.xaml.cs">
|
||||
<DependentUpon>QRScanner.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utility\StringManager.cs" />
|
||||
<Compile Include="Utility\Utilities.cs">
|
||||
<SubType>Code</SubType>
|
||||
@@ -351,6 +354,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Utility\QRScanner\QRScanner.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Assets\psd\holo_optionsbuttons.psd" />
|
||||
@@ -457,6 +464,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\WPtoolkit.4.2013.08.16\lib\wp8\Microsoft.Phone.Controls.Toolkit.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="zxing.wp8.0">
|
||||
<HintPath>..\packages\ZXing.Net.0.11.0.1\lib\wp8\zxing.wp8.0.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<Capability Name="ID_CAP_LOCATION" />
|
||||
<Capability Name="ID_CAP_ISV_CAMERA" />
|
||||
<Capability Name="ID_CAP_PHONEDIALER" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
|
||||
<Capability Name="ID_CAP_MICROPHONE" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="Pages/StartPage.xaml" />
|
||||
|
||||
@@ -681,6 +681,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Die primäre Kamera steht nicht zur Verfügung. ähnelt.
|
||||
/// </summary>
|
||||
public static string PrimCamNotSupported {
|
||||
get {
|
||||
return ResourceManager.GetString("PrimCamNotSupported", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Lehrstühle ähnelt.
|
||||
/// </summary>
|
||||
@@ -690,6 +699,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die ... suche ähnelt.
|
||||
/// </summary>
|
||||
public static string QRReader_Search {
|
||||
get {
|
||||
return ResourceManager.GetString("QRReader_Search", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die LeftToRight ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -406,5 +406,10 @@
|
||||
</data>
|
||||
<data name="MsgBox_ErrorMainModelLoadWeb" xml:space="preserve">
|
||||
<value>Es konnte kein neuer Inhalt aus den Web geladen werden</value>
|
||||
<data name="PrimCamNotSupported" xml:space="preserve">
|
||||
<value>Die primäre Kamera steht nicht zur Verfügung.</value>
|
||||
</data>
|
||||
<data name="QRReader_Search" xml:space="preserve">
|
||||
<value>... suche</value>
|
||||
</data>
|
||||
</root>
|
||||
47
CampusAppWP8/CampusAppWP8/Utility/QRScanner/QRScanner.xaml
Normal file
47
CampusAppWP8/CampusAppWP8/Utility/QRScanner/QRScanner.xaml
Normal file
@@ -0,0 +1,47 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="CampusAppWP8.Utility.QRScanner.QRScanner"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="PortraitUp"
|
||||
mc:Ignorable="d"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
|
||||
<StackPanel Grid.Row="0" Margin="12,17,0,28">
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
<!--
|
||||
<TextBlock Text="Seitenname" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||
-->
|
||||
<TextBlock x:Name="scannText" Text="{Binding Path=LocalizedResources.QRReader_Search, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Height="68" />
|
||||
</StackPanel>
|
||||
|
||||
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<Canvas x:Name="camView" Grid.Row="0" Tap="CamView_Tap">
|
||||
<Canvas.Background>
|
||||
<VideoBrush x:Name="camViewBrush">
|
||||
<VideoBrush.RelativeTransform>
|
||||
<CompositeTransform x:Name="camViewBrushTransform" CenterX="0.5" CenterY="0.5" Rotation="90"/>
|
||||
</VideoBrush.RelativeTransform>
|
||||
</VideoBrush>
|
||||
</Canvas.Background>
|
||||
</Canvas>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</phone:PhoneApplicationPage>
|
||||
224
CampusAppWP8/CampusAppWP8/Utility/QRScanner/QRScanner.xaml.cs
Normal file
224
CampusAppWP8/CampusAppWP8/Utility/QRScanner/QRScanner.xaml.cs
Normal file
@@ -0,0 +1,224 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// <copyright file="QRScanner.xaml.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>fiedlchr</author>
|
||||
// <sience>15.08.2013</sience>
|
||||
// <remarks>
|
||||
// This Class uses the ZXing library, which is under the Apache License 2.0.
|
||||
//
|
||||
// Therefor, see:
|
||||
// http://zxingnet.codeplex.com/license
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// </remarks>
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.QRScanner
|
||||
{
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CampusAppWP8.Resources;
|
||||
using Microsoft.Devices;
|
||||
using Microsoft.Phone.Controls;
|
||||
using ZXing;
|
||||
|
||||
/// <summary>
|
||||
/// QR Code scanner.
|
||||
/// </summary>
|
||||
public partial class QRScanner : PhoneApplicationPage
|
||||
{
|
||||
/// <summary>The camera object.</summary>
|
||||
private PhotoCamera cam = null;
|
||||
|
||||
/// <summary>Thread for transfer the preview image to the reader.</summary>
|
||||
private Thread captureThread = null;
|
||||
|
||||
/// <summary>For ending the thread.</summary>
|
||||
private volatile bool captureThreadExit = false;
|
||||
|
||||
/// <summary>QR reader object.</summary>
|
||||
private IBarcodeReader barcodeReader = null;
|
||||
|
||||
/// <summary>Bitmap for transfer the camera image to the reader.</summary>
|
||||
private WriteableBitmap bit = null;
|
||||
|
||||
/// <summary>true if this object is in autofocus. </summary>
|
||||
private bool isInAutofocus = false;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="QRScanner" /> class. </summary>
|
||||
public QRScanner()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.barcodeReader = new BarcodeReader();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is called when this page will become the current page of a frame.
|
||||
/// </summary>
|
||||
/// <param name="e">event args.</param>
|
||||
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true)
|
||||
{
|
||||
this.cam = new PhotoCamera(CameraType.Primary);
|
||||
this.cam.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(this.Cam_Initialized);
|
||||
this.cam.AutoFocusCompleted += new EventHandler<CameraOperationCompletedEventArgs>(this.Cam_AutoFocusCompl);
|
||||
this.bit = new WriteableBitmap((int)this.cam.PreviewResolution.Width, (int)this.cam.PreviewResolution.Height);
|
||||
|
||||
this.camViewBrush.SetSource(this.cam);
|
||||
this.isInAutofocus = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(delegate
|
||||
{
|
||||
this.scannText.Text = AppResources.PrimCamNotSupported;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is called when this page will not be the current page of a frame.
|
||||
/// </summary>
|
||||
/// <param name="e">event args.</param>
|
||||
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
|
||||
{
|
||||
if (this.cam != null)
|
||||
{
|
||||
this.captureThreadExit = true;
|
||||
this.captureThread.Join();
|
||||
|
||||
this.cam.Dispose();
|
||||
|
||||
this.bit = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is called after the orientation has changed.
|
||||
/// </summary>
|
||||
/// <param name="e">event args.</param>
|
||||
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
|
||||
{
|
||||
base.OnOrientationChanged(e);
|
||||
|
||||
switch (e.Orientation)
|
||||
{
|
||||
case PageOrientation.Landscape:
|
||||
this.camViewBrushTransform.Rotation = 0;
|
||||
break;
|
||||
case PageOrientation.LandscapeLeft:
|
||||
this.camViewBrushTransform.Rotation = 0;
|
||||
break;
|
||||
case PageOrientation.LandscapeRight:
|
||||
this.camViewBrushTransform.Rotation = 180;
|
||||
break;
|
||||
case PageOrientation.Portrait:
|
||||
this.camViewBrushTransform.Rotation = 90;
|
||||
break;
|
||||
case PageOrientation.PortraitUp:
|
||||
this.camViewBrushTransform.Rotation = 90;
|
||||
break;
|
||||
case PageOrientation.PortraitDown:
|
||||
this.camViewBrushTransform.Rotation = 270;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler. Called by Cam for initialized events.
|
||||
/// </summary>
|
||||
/// <param name="sender">Source of the event.</param>
|
||||
/// <param name="e">Camera operation completed event information.</param>
|
||||
private void Cam_Initialized(object sender, Microsoft.Devices.CameraOperationCompletedEventArgs e)
|
||||
{
|
||||
if (e.Succeeded)
|
||||
{
|
||||
this.cam.Focus();
|
||||
|
||||
this.captureThreadExit = false;
|
||||
this.captureThread = new Thread(this.CaptureThreadFunc);
|
||||
this.captureThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler. Called by Cam for automatic focus completed events.
|
||||
/// </summary>
|
||||
/// <param name="sender">Source of the event.</param>
|
||||
/// <param name="e">Camera operation completed event information.</param>
|
||||
private void Cam_AutoFocusCompl(object sender, CameraOperationCompletedEventArgs e)
|
||||
{
|
||||
this.isInAutofocus = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler. Called by CamView for tap events.
|
||||
/// </summary>
|
||||
/// <param name="sender">Source of the event.</param>
|
||||
/// <param name="e">Gesture event information.</param>
|
||||
private void CamView_Tap(object sender, System.Windows.Input.GestureEventArgs e)
|
||||
{
|
||||
if (this.cam != null && this.isInAutofocus == false)
|
||||
{
|
||||
if (this.cam.IsFocusAtPointSupported == true)
|
||||
{
|
||||
Point pos = e.GetPosition(this.camView);
|
||||
|
||||
this.cam.FocusAtPoint(
|
||||
pos.Y / this.camView.ActualHeight,
|
||||
1.0 - (pos.X / this.camView.ActualWidth));
|
||||
|
||||
this.isInAutofocus = true;
|
||||
}
|
||||
else if (this.cam.IsFocusSupported == true)
|
||||
{
|
||||
this.cam.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the capture image action.
|
||||
/// </summary>
|
||||
/// <param name="img">The image.</param>
|
||||
/// <param name="width">The width.</param>
|
||||
/// <param name="height">The height.</param>
|
||||
private void OnCaptureImage(int[] img, int width, int height)
|
||||
{
|
||||
Array.Copy(img, this.bit.Pixels, img.Length);
|
||||
|
||||
var result = this.barcodeReader.Decode(this.bit);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
Dispatcher.BeginInvoke(delegate
|
||||
{
|
||||
this.scannText.Text = result.Text;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Capture thread function.
|
||||
/// </summary>
|
||||
private void CaptureThreadFunc()
|
||||
{
|
||||
Size resolution = this.cam.PreviewResolution;
|
||||
int[] buffer = new int[(int)(resolution.Height * resolution.Width)];
|
||||
|
||||
while (!this.captureThreadExit)
|
||||
{
|
||||
if (this.isInAutofocus == false)
|
||||
{
|
||||
this.cam.GetPreviewBufferArgb32(buffer);
|
||||
|
||||
this.OnCaptureImage(buffer, (int)resolution.Width, (int)resolution.Height);
|
||||
}
|
||||
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="WPtoolkit" version="4.2013.08.16" targetFramework="wp80" />
|
||||
<package id="WPToolkit" version="4.2013.06.11" targetFramework="wp80" />
|
||||
<package id="ZXing.Net" version="0.11.0.1" targetFramework="wp80" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user