Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added in the Barcode Scanning seminar
- Loading branch information
Showing
365 changed files
with
57,134 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
2012-11-29-BarcodeScanning/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BarcodeScanning.MonoAndroid", "BarcodeScanning.MonoAndroid\BarcodeScanning.MonoAndroid.csproj", "{D90477B7-1A10-41D7-9819-567B52488024}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zxing.monoandroid", "..\ZXing.Net.Mobile\src\ZXing.Net\zxing.monoandroid.csproj", "{8971B59D-78F1-49BA-808D-CBADB37F571F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZXing.Net.Mobile.MonoForAndroid", "..\ZXing.Net.Mobile\src\ZXing.Net.Mobile\ZXing.Net.Mobile.MonoForAndroid.csproj", "{D72228AC-C356-4E1A-B56F-91C9A25F7286}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8971B59D-78F1-49BA-808D-CBADB37F571F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8971B59D-78F1-49BA-808D-CBADB37F571F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8971B59D-78F1-49BA-808D-CBADB37F571F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8971B59D-78F1-49BA-808D-CBADB37F571F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{D72228AC-C356-4E1A-B56F-91C9A25F7286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D72228AC-C356-4E1A-B56F-91C9A25F7286}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D72228AC-C356-4E1A-B56F-91C9A25F7286}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D72228AC-C356-4E1A-B56F-91C9A25F7286}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{D90477B7-1A10-41D7-9819-567B52488024}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D90477B7-1A10-41D7-9819-567B52488024}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D90477B7-1A10-41D7-9819-567B52488024}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D90477B7-1A10-41D7-9819-567B52488024}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(MonoDevelopProperties) = preSolution | ||
StartupItem = BarcodeScanning.MonoAndroid\BarcodeScanning.MonoAndroid.csproj | ||
EndGlobalSection | ||
EndGlobal |
19 changes: 19 additions & 0 deletions
19
...deScanning/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid/Assets/AboutAssets.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Any raw assets you want to be deployed with your application can be placed in | ||
this directory (and child directories) and given a Build Action of "AndroidAsset". | ||
|
||
These files will be deployed with you package and will be accessible using Android's | ||
AssetManager, like this: | ||
|
||
public class ReadAsset : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
InputStream input = Assets.Open ("my_asset.txt"); | ||
} | ||
} | ||
|
||
Additionally, some Android functions will automatically load asset files: | ||
|
||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
74 changes: 74 additions & 0 deletions
74
...arcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>10.0.0</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{D90477B7-1A10-41D7-9819-567B52488024}</ProjectGuid> | ||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>BarcodeScanning.MonoAndroid</RootNamespace> | ||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> | ||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix> | ||
<AndroidResgenClass>Resource</AndroidResgenClass> | ||
<AndroidApplication>True</AndroidApplication> | ||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile> | ||
<AssemblyName>BarcodeScanning.MonoAndroid</AssemblyName> | ||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>True</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>False</Optimize> | ||
<OutputPath>bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>False</ConsolePause> | ||
<AndroidLinkMode>None</AndroidLinkMode> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>none</DebugType> | ||
<Optimize>True</Optimize> | ||
<OutputPath>bin\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>False</ConsolePause> | ||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> | ||
<AndroidLinkMode>SdkOnly</AndroidLinkMode> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Mono.Android" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Resources\Resource.designer.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="MainActivity.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Resources\AboutResources.txt" /> | ||
<None Include="Assets\AboutAssets.txt" /> | ||
<None Include="Properties\AndroidManifest.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidResource Include="Resources\layout\Main.axml" /> | ||
<AndroidResource Include="Resources\values\Strings.xml" /> | ||
<AndroidResource Include="Resources\drawable\Icon.png" /> | ||
<AndroidResource Include="Resources\layout\ScanOverlayLayout.axml" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\ZXing.Net.Mobile\src\ZXing.Net\zxing.monoandroid.csproj"> | ||
<Project>{8971B59D-78F1-49BA-808D-CBADB37F571F}</Project> | ||
<Name>zxing.monoandroid</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\ZXing.Net.Mobile\src\ZXing.Net.Mobile\ZXing.Net.Mobile.MonoForAndroid.csproj"> | ||
<Project>{D72228AC-C356-4E1A-B56F-91C9A25F7286}</Project> | ||
<Name>ZXing.Net.Mobile.MonoForAndroid</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
</Project> |
117 changes: 117 additions & 0 deletions
117
...9-BarcodeScanning/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid/MainActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Android.App; | ||
using Android.Content; | ||
using Android.Runtime; | ||
using Android.Views; | ||
using Android.Widget; | ||
using Android.OS; | ||
|
||
using ZXing; | ||
using ZXing.Mobile; | ||
|
||
namespace BarcodeScanning.MonoAndroid | ||
{ | ||
[Activity (Label = "Barcode Scanning", MainLauncher = true)] | ||
public class Activity1 : Activity | ||
{ | ||
#region UI Code | ||
Button buttonSample1; | ||
Button buttonSample2; | ||
Button buttonSample3; | ||
|
||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
// Set our view from the "main" layout resource | ||
SetContentView (Resource.Layout.Main); | ||
|
||
// Get our button from the layout resource, | ||
// and attach an event to it | ||
buttonSample1 = FindViewById<Button> (Resource.Id.buttonSample1); | ||
buttonSample2 = FindViewById<Button> (Resource.Id.buttonSample2); | ||
buttonSample3 = FindViewById<Button> (Resource.Id.buttonSample3); | ||
|
||
buttonSample1.Click += buttonSample1_Click; | ||
buttonSample2.Click += buttonSample2_Click; | ||
buttonSample3.Click += buttonSample3_Click; | ||
} | ||
|
||
void ShowMessage(string msg) | ||
{ | ||
this.RunOnUiThread(() => { | ||
AlertDialog ad = null; | ||
var adBuilder = new AlertDialog.Builder(this); | ||
adBuilder.SetTitle("Barcode"); | ||
adBuilder.SetMessage(msg); | ||
adBuilder.SetNegativeButton("OK",(s, e) => { | ||
ad.Dismiss(); | ||
ad.Cancel(); | ||
}); | ||
ad = adBuilder.Create(); | ||
ad.Show(); | ||
}); | ||
} | ||
#endregion | ||
|
||
void buttonSample1_Click (object sender, EventArgs e) | ||
{ | ||
var scanner = new MobileBarcodeScanner(this); | ||
scanner.Scan().ContinueWith((t) => { | ||
ShowMessage(t.Result != null ? "Scanned: " + t.Result.Text : "No Barcode Scanned"); | ||
}); | ||
} | ||
|
||
void buttonSample2_Click (object sender, EventArgs e) | ||
{ | ||
var scanner = new MobileBarcodeScanner(this); | ||
var options = new MobileBarcodeScanningOptions() | ||
{ | ||
PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.All_1D }, | ||
|
||
}; | ||
|
||
scanner.TopText = "Hold the barcode close to the camera"; | ||
scanner.BottomText = "Barcode will scan automatigically"; | ||
|
||
scanner.Scan(options).ContinueWith((t) => { | ||
ShowMessage(t.Result != null ? "Scanned: " + t.Result.Text : "No Barcode Scanned"); | ||
}); | ||
} | ||
|
||
void buttonSample3_Click (object sender, EventArgs e) | ||
{ | ||
var scanner = new MobileBarcodeScanner(this); | ||
|
||
var overlay = (LinearLayout)this.LayoutInflater.Inflate(Resource.Layout.ScanOverlayLayout, null, false); | ||
|
||
var buttonCancel = overlay.FindViewById<Button>(Resource.Id.buttonCancelScan); | ||
var buttonFlash = overlay.FindViewById<Button>(Resource.Id.buttonToggleFlash); | ||
|
||
buttonCancel.Click += (object sender2, EventArgs e2) => | ||
{ | ||
scanner.Cancel(); | ||
}; | ||
|
||
buttonFlash.Click += (object sender2, EventArgs e2) => | ||
{ | ||
scanner.ToggleTorch(); | ||
}; | ||
|
||
scanner.UseCustomOverlay = true; | ||
scanner.CustomOverlay = overlay; | ||
|
||
scanner.Scan().ContinueWith((t) => { | ||
ShowMessage(t.Result != null ? "Scanned: " + t.Result.Text : "No Barcode Scanned"); | ||
}); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
7 changes: 7 additions & 0 deletions
7
...ng/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="BarcodeScanning.MonoAndroid"> | ||
<uses-sdk /> | ||
<application android:label="BarcodeScanning.MonoAndroid"> | ||
</application> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
</manifest> |
28 changes: 28 additions & 0 deletions
28
...anning/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using Android.App; | ||
|
||
// Information about this assembly is defined by the following attributes. | ||
// Change them to the values specific to your project. | ||
|
||
[assembly: AssemblyTitle("BarcodeScanning.MonoAndroid")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("")] | ||
[assembly: AssemblyCopyright("jondick")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". | ||
// The form "{Major}.{Minor}.*" will automatically update the build and revision, | ||
// and "{Major}.{Minor}.{Build}.*" will update just the revision. | ||
|
||
[assembly: AssemblyVersion("1.0.0")] | ||
|
||
// The following attributes are used to specify the signing key for the assembly, | ||
// if desired. See the Mono documentation for more information about signing. | ||
|
||
//[assembly: AssemblyDelaySign(false)] | ||
//[assembly: AssemblyKeyFile("")] | ||
|
44 changes: 44 additions & 0 deletions
44
...ning/BarcodeScanning.MonoAndroid/BarcodeScanning.MonoAndroid/Resources/AboutResources.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Images, layout descriptions, binary blobs and string dictionaries can be included | ||
in your application as resource files. Various Android APIs are designed to | ||
operate on the resource IDs instead of dealing with images, strings or binary blobs | ||
directly. | ||
|
||
For example, a sample Android app that contains a user interface layout (main.axml), | ||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) | ||
would keep its resources in the "Resources" directory of the application: | ||
|
||
Resources/ | ||
drawable/ | ||
icon.png | ||
|
||
layout/ | ||
main.axml | ||
|
||
values/ | ||
strings.xml | ||
|
||
In order to get the build system to recognize Android resources, set the build action to | ||
"AndroidResource". The native Android APIs do not operate directly with filenames, but | ||
instead operate on resource IDs. When you compile an Android application that uses resources, | ||
the build system will package the resources for distribution and generate a class called "R" | ||
(this is an Android convention) that contains the tokens for each one of the resources | ||
included. For example, for the above Resources layout, this is what the R class would expose: | ||
|
||
public class R { | ||
public class drawable { | ||
public const int icon = 0x123; | ||
} | ||
|
||
public class layout { | ||
public const int main = 0x456; | ||
} | ||
|
||
public class strings { | ||
public const int first_string = 0xabc; | ||
public const int second_string = 0xbcd; | ||
} | ||
} | ||
|
||
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main | ||
to reference the layout/main.axml file, or R.strings.first_string to reference the first | ||
string in the dictionary file values/strings.xml. |
Oops, something went wrong.