init
40
.gitignore
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#Autosave files
|
||||
*~
|
||||
|
||||
#build
|
||||
[Oo]bj/
|
||||
[Bb]in/
|
||||
packages/
|
||||
TestResults/
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.DS_Store
|
||||
*.sln.cache
|
||||
*.suo
|
||||
*.cache
|
||||
*.pidb
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.log
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.user
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
Thumbs.db
|
||||
|
||||
#Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
#resharper
|
||||
*_Resharper.*
|
||||
*.Resharper
|
||||
|
||||
#dotCover
|
||||
*.dotCover
|
||||
1
Components/xamarin.mobile-0.7.7.info
Normal file
BIN
Components/xamarin.mobile-0.7.7.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
107
Components/xamarin.mobile-0.7.7/component/Details.md
Normal file
@@ -0,0 +1,107 @@
|
||||
Xamarin.Mobile is an API for accessing common platform features, such as
|
||||
reading the user's address book and using the camera, across iOS,
|
||||
Android, and Windows Phone.
|
||||
|
||||
The goal of Xamarin.Mobile is to decrease the amount of
|
||||
platform-specific code needed to perform common tasks in multiplatform
|
||||
apps, making development simpler and faster.
|
||||
|
||||
Xamarin.Mobile is currently a preview release and is subject to API
|
||||
changes.
|
||||
|
||||
**Note:** The Windows Phone 7.1 version of the library requires the
|
||||
Microsoft.Bcl.Async NuGet package. You'll need to restore this package
|
||||
to use the samples or download this package to any WP7 app using
|
||||
Xamarin.Mobile.
|
||||
|
||||
## Examples
|
||||
|
||||
To access the address book (requires `READ_CONTACTS` permissions
|
||||
on Android):
|
||||
|
||||
```csharp
|
||||
using Xamarin.Contacts;
|
||||
// ...
|
||||
|
||||
var book = new Xamarin.Contacts.AddressBook ();
|
||||
// new AddressBook (this); on Android
|
||||
if (!await book.RequestPermission()) {
|
||||
Console.WriteLine ("Permission denied by user or manifest");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Contact contact in book.OrderBy (c => c.LastName)) {
|
||||
Console.WriteLine ("{0} {1}", contact.FirstName, contact.LastName);
|
||||
}
|
||||
```
|
||||
|
||||
To get the user's location (requires `ACCESS_COARSE_LOCATION` and
|
||||
`ACCESS_FINE_LOCATION` permissions on Android):
|
||||
|
||||
```csharp
|
||||
using Xamarin.Geolocation;
|
||||
// ...
|
||||
|
||||
var locator = new Geolocator { DesiredAccuracy = 50 };
|
||||
// new Geolocator (this) { ... }; on Android
|
||||
|
||||
Position position = await locator.GetPositionAsync (timeout: 10000);
|
||||
|
||||
Console.WriteLine ("Position Status: {0}", position.Timestamp);
|
||||
Console.WriteLine ("Position Latitude: {0}", position.Latitude);
|
||||
Console.WriteLine ("Position Longitude: {0}", position.Longitude);
|
||||
```
|
||||
|
||||
To take a photo:
|
||||
|
||||
```csharp
|
||||
using Xamarin.Media;
|
||||
// ...
|
||||
|
||||
var picker = new MediaPicker ();
|
||||
if (!picker.IsCameraAvailable)
|
||||
Console.WriteLine ("No camera!");
|
||||
else {
|
||||
try {
|
||||
MediaFile file = await picker.TakePhotoAsync (new StoreCameraMediaOptions {
|
||||
Name = "test.jpg",
|
||||
Directory = "MediaPickerSample"
|
||||
});
|
||||
|
||||
Console.WriteLine (file.Path);
|
||||
} catch (OperationCanceledException) {
|
||||
Console.WriteLine ("Canceled");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
On Android (requires `WRITE_EXTERNAL_STORAGE` permissions):
|
||||
|
||||
```csharp
|
||||
using Xamarin.Media;
|
||||
// ...
|
||||
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
var picker = new MediaPicker (this);
|
||||
if (!picker.IsCameraAvailable)
|
||||
Console.WriteLine ("No camera!");
|
||||
else {
|
||||
var intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
|
||||
Name = "test.jpg",
|
||||
Directory = "MediaPickerSample"
|
||||
});
|
||||
StartActivityForResult (intent, 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async void OnActivityResult (int requestCode, Result resultCode, Intent data)
|
||||
{
|
||||
// User canceled
|
||||
if (resultCode == Result.Canceled)
|
||||
return;
|
||||
|
||||
MediaFile file = await data.GetMediaFileExtraAsync (this);
|
||||
Console.WriteLine (file.Path);
|
||||
}
|
||||
```
|
||||
123
Components/xamarin.mobile-0.7.7/component/GettingStarted.md
Normal file
@@ -0,0 +1,123 @@
|
||||
## Examples
|
||||
|
||||
### Contacts
|
||||
To access the address book (requires `READ_CONTACTS` permissions
|
||||
on Android):
|
||||
|
||||
```csharp
|
||||
using Xamarin.Contacts;
|
||||
// ...
|
||||
|
||||
var book = new Xamarin.Contacts.AddressBook ();
|
||||
book.RequestPermission().ContinueWith (t => {
|
||||
if (!t.Result) {
|
||||
Console.WriteLine ("Permission denied by user or manifest");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Contact contact in book.OrderBy (c => c.LastName)) {
|
||||
Console.WriteLine ("{0} {1}", contact.FirstName, contact.LastName);
|
||||
}
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
```
|
||||
|
||||
### Geolocation
|
||||
|
||||
To get the user's location (requires `ACCESS_COARSE_LOCATION` and
|
||||
`ACCESS_FINE_LOCATION` permissions on Android):
|
||||
|
||||
```csharp
|
||||
using Xamarin.Geolocation;
|
||||
// ...
|
||||
|
||||
var locator = new Geolocator { DesiredAccuracy = 50 };
|
||||
// new Geolocator (this) { ... }; on Android
|
||||
locator.GetPositionAsync (timeout: 10000).ContinueWith (t => {
|
||||
Console.WriteLine ("Position Status: {0}", t.Result.Timestamp);
|
||||
Console.WriteLine ("Position Latitude: {0}", t.Result.Latitude);
|
||||
Console.WriteLine ("Position Longitude: {0}", t.Result.Longitude);
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
```
|
||||
|
||||
NOTE: On iOS 8.0+ you must set either `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` in your `Info.plist` file so that Xamarin.Mobile will request the appropriate permission from the user.
|
||||
|
||||
### Media
|
||||
|
||||
`MediaPicker` allows you to invoke the native UI to take or select photos or video. Given
|
||||
that there is this UI interaction, the code (while simpler than doing it manually) will not
|
||||
be completely cross-platform.
|
||||
|
||||
To take a photo on iOS, Windows Phone or WinRT:
|
||||
|
||||
```csharp
|
||||
using Xamarin.Media;
|
||||
// ...
|
||||
|
||||
var picker = new MediaPicker();
|
||||
picker.PickPhotoAsync().ContinueWith (t => {
|
||||
MediaFile file = t.Result;
|
||||
Console.WriteLine (file.Path);
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
```
|
||||
|
||||
On Android and optionally on iOS, you control the UI.
|
||||
|
||||
To take a photo on Android (requires `WRITE_EXTERNAL_STORAGE` permissions):
|
||||
|
||||
```csharp
|
||||
using Xamarin.Media;
|
||||
// ...
|
||||
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
var picker = new MediaPicker (this);
|
||||
if (!picker.IsCameraAvailable)
|
||||
Console.WriteLine ("No camera!");
|
||||
else {
|
||||
var intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
|
||||
Name = "test.jpg",
|
||||
Directory = "MediaPickerSample"
|
||||
});
|
||||
StartActivityForResult (intent, 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
|
||||
{
|
||||
// User canceled
|
||||
if (resultCode == Result.Canceled)
|
||||
return;
|
||||
|
||||
data.GetMediaFileExtraAsync (this).ContinueWith (t => {
|
||||
Console.WriteLine (t.Result.Path);
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
```
|
||||
|
||||
To take a photo on iOS controlling the UI:
|
||||
|
||||
```csharp
|
||||
using Xamarin.Media;
|
||||
// ...
|
||||
|
||||
var picker = new MediaPicker();
|
||||
MediaPickerController controller = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
|
||||
Name = "test.jpg",
|
||||
Directory = "MediaPickerSample"
|
||||
});
|
||||
|
||||
// On iPad, you'll use UIPopoverController to present the controller
|
||||
PresentViewController (controller, true, null);
|
||||
|
||||
controller.GetResultAsync().ContinueWith (t => {
|
||||
// Dismiss the UI yourself
|
||||
controller.DismissViewController (true, () => {
|
||||
MediaFile file = t.Result;
|
||||
});
|
||||
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
```
|
||||
#####Note to iOS 8 Developers
|
||||
Showing a `MediaPicker` in response to a `UIActionSheet.Clicked` event will cause unexpected behavior on iOS 8. Apps should be updated to conditionally use an `UIAlertController` with a style of `UIAlertControllerStyle.ActionSheet.` See the iOS sample for more info.
|
||||
|
||||
|
||||
174
Components/xamarin.mobile-0.7.7/component/License.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Apache License
|
||||
Version 2.0, January 2004<br />
|
||||
[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
25
Components/xamarin.mobile-0.7.7/component/Manifest.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component format="1" id="xamarin.mobile">
|
||||
<name>Xamarin.Mobile</name>
|
||||
<publisher>Xamarin Inc.</publisher>
|
||||
<publisher-url>http://xamarin.com/</publisher-url>
|
||||
<version>0.7.7</version>
|
||||
<summary>Xamarin.Mobile is a library that exposes a single set of APIs for accessing common mobile device functionality across iOS, Android and Windows platforms.</summary>
|
||||
<screenshots>
|
||||
<img src="screenshots/screenshot1.jpg" title="screenshot1" />
|
||||
</screenshots>
|
||||
<samples>
|
||||
<sample id="Xamarin.Mobile.Android.Samples">
|
||||
<name>Android Samples</name>
|
||||
<summary>Android Samples</summary>
|
||||
</sample>
|
||||
<sample id="Xamarin.Mobile.iOS-Classic.Samples">
|
||||
<name>iOS Classic API Samples</name>
|
||||
<summary>iOS Classic API Samples</summary>
|
||||
</sample>
|
||||
<sample id="Xamarin.Mobile.iOS.Samples">
|
||||
<name>iOS Unified API Samples</name>
|
||||
<summary>iOS Unified API Samples</summary>
|
||||
</sample>
|
||||
</samples>
|
||||
</component>
|
||||
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 20 KiB |
BIN
Components/xamarin.mobile-0.7.7/lib/android/Xamarin.Mobile.dll
Normal file
BIN
Components/xamarin.mobile-0.7.7/lib/ios/Xamarin.Mobile.dll
Normal file
BIN
Components/xamarin.mobile-0.7.7/lib/winrt/Xamarin.Mobile.dll
Normal file
BIN
Components/xamarin.mobile-0.7.7/lib/wp8/Xamarin.Mobile.dll
Normal file
@@ -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");
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Xamarin.Contacts;
|
||||
|
||||
namespace ContactsSample
|
||||
{
|
||||
[Activity (Label = "ContactActivity")]
|
||||
public class ContactActivity : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
//
|
||||
// Get the contact ID that is passed in
|
||||
// from the main activity
|
||||
//
|
||||
String contactID = String.Empty;
|
||||
if(bundle != null)
|
||||
{
|
||||
contactID = bundle.GetString("contactID");
|
||||
}
|
||||
else
|
||||
{
|
||||
contactID = Intent.GetStringExtra("contactID");
|
||||
}
|
||||
|
||||
Contact contact = MainActivity.AddressBook.Load (contactID);
|
||||
|
||||
//
|
||||
// If the contact is empty, we'll
|
||||
// display a 'not found' error
|
||||
//
|
||||
String displayName = "Contact Not Found";
|
||||
String mobilePhone = String.Empty;
|
||||
|
||||
//
|
||||
// Set the displayName variable to the contact's
|
||||
// DisplayName property
|
||||
//
|
||||
if(contact != null)
|
||||
{
|
||||
displayName = contact.DisplayName;
|
||||
var phone = contact.Phones.FirstOrDefault (p => p.Type == PhoneType.Mobile);
|
||||
if(phone != null)
|
||||
{
|
||||
mobilePhone = phone.Number;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Show the contacts display name and mobile phone
|
||||
//
|
||||
SetContentView (Resource.Layout.contact_view);
|
||||
var fullNameTextView = FindViewById<TextView> (Resource.Id.full_name);
|
||||
fullNameTextView.Text = displayName;
|
||||
var mobilePhoneTextView = FindViewById<TextView> (Resource.Id.mobile_phone);
|
||||
mobilePhoneTextView.Text = mobilePhone;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ContactsSample</RootNamespace>
|
||||
<AssemblyName>ContactsSample</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidApplication>true</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<TargetFrameworkVersion>v2.3</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Xamarin.Mobile">
|
||||
<HintPath>../../../lib\/android/Xamarin.Mobile.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="ContactActivity.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Assets\AboutAssets.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Layout\list_item.xml" />
|
||||
<AndroidResource Include="Resources\Layout\contact_view.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Values\Strings.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Drawable\Icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Database;
|
||||
using Android.Net;
|
||||
using Android.OS;
|
||||
using Android.Provider;
|
||||
using Android.Widget;
|
||||
using Xamarin.Contacts;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ContactsSample
|
||||
{
|
||||
[Activity(Label = "ContactsSample", MainLauncher = true, Icon = "@drawable/icon")]
|
||||
public class MainActivity : ListActivity
|
||||
{
|
||||
List<String> contacts = new List<String>();
|
||||
List<String> contactIDs = new List<String>();
|
||||
|
||||
public static readonly AddressBook AddressBook = new AddressBook (Application.Context) { PreferContactAggregation = true };
|
||||
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
base.OnCreate(bundle);
|
||||
|
||||
// We must request permission to access the user's address book
|
||||
// This will prompt the user on platforms that ask, or it will validate
|
||||
// manifest permissions on platforms that declare their required permissions.
|
||||
AddressBook.RequestPermission().ContinueWith (t =>
|
||||
{
|
||||
if (!t.Result) {
|
||||
Toast.MakeText (this, "Permission denied, check your manifest", ToastLength.Long).Show();
|
||||
return;
|
||||
}
|
||||
|
||||
// Contacts can be selected and sorted using LINQ!
|
||||
//
|
||||
// In this sample, we'll just use LINQ to sort contacts by
|
||||
// their last name in reverse order.
|
||||
foreach (Contact contact in AddressBook.Where (c => c.FirstName != null).OrderBy (c => c.FirstName)) {
|
||||
contacts.Add (contact.DisplayName);
|
||||
contactIDs.Add (contact.Id); // Save the ID in a parallel list
|
||||
}
|
||||
|
||||
ListAdapter = new ArrayAdapter<string> (this, Resource.Layout.list_item, contacts.ToArray());
|
||||
ListView.TextFilterEnabled = true;
|
||||
|
||||
// When clicked, start a new activity to display more contact details
|
||||
ListView.ItemClick += delegate (object sender, AdapterView.ItemClickEventArgs args) {
|
||||
|
||||
// To show the contact on the details activity, we
|
||||
// need to send that activity the contacts ID
|
||||
string contactId = contactIDs[args.Position];
|
||||
Intent showContactDetails = new Intent (this, typeof(ContactActivity));
|
||||
showContactDetails.PutExtra ("contactID", contactId);
|
||||
StartActivity (showContactDetails);
|
||||
|
||||
// Alternatively, show a toast with the name of the contact selected
|
||||
//
|
||||
//Toast.MakeText (Application, ((TextView)args.View).Text, ToastLength.Short).Show ();
|
||||
};
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly">
|
||||
<application>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
</manifest>
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ContactsSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xamarin Inc.")]
|
||||
[assembly: AssemblyProduct("ContactsSample")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2011-2012 Xamarin Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
// This app uses the internet, this can be removed if not needed
|
||||
[assembly: UsesPermission("android.permission.INTERNET")]
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/full_name"
|
||||
android:layout_margin="10dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="">
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/mobile_phone"
|
||||
android:layout_margin="10dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="10dp"
|
||||
android:textSize="16sp">
|
||||
</TextView>
|
||||
@@ -0,0 +1,118 @@
|
||||
#pragma warning disable 1591
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.17020
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
[assembly: Android.Runtime.ResourceDesignerAttribute("ContactsSample.Resource", IsApplication=true)]
|
||||
|
||||
namespace ContactsSample
|
||||
{
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
static Resource()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
public static void UpdateIdValues()
|
||||
{
|
||||
}
|
||||
|
||||
public partial class Attribute
|
||||
{
|
||||
|
||||
static Attribute()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Attribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Drawable
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f020000
|
||||
public const int Icon = 2130837504;
|
||||
|
||||
static Drawable()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Drawable()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Id
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f050000
|
||||
public const int full_name = 2131034112;
|
||||
|
||||
// aapt resource value: 0x7f050001
|
||||
public const int mobile_phone = 2131034113;
|
||||
|
||||
static Id()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Id()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Layout
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f030000
|
||||
public const int contact_view = 2130903040;
|
||||
|
||||
// aapt resource value: 0x7f030001
|
||||
public const int list_item = 2130903041;
|
||||
|
||||
static Layout()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Layout()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class String
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f040001
|
||||
public const int ApplicationName = 2130968577;
|
||||
|
||||
// aapt resource value: 0x7f040000
|
||||
public const int Hello = 2130968576;
|
||||
|
||||
static String()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private String()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="Hello">Hello World, Click Me!</string>
|
||||
<string name="ApplicationName">ContactsSample</string>
|
||||
</resources>
|
||||
@@ -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");
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{82254F3E-647E-4F4A-AA4F-008A614C4B02}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>GeolocationSample</RootNamespace>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<AndroidApplication>True</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AssemblyName>GeolocationSample</AssemblyName>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<DeployExternal>False</DeployExternal>
|
||||
<AndroidSupportedAbis>armeabi</AndroidSupportedAbis>
|
||||
<AndroidStoreUncompressedFileExtensions />
|
||||
<MandroidI18n />
|
||||
<TargetFrameworkVersion>v2.3</TargetFrameworkVersion>
|
||||
</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>
|
||||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="Xamarin.Mobile">
|
||||
<HintPath>../../../lib\/android/Xamarin.Mobile.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Widget;
|
||||
using Android.OS;
|
||||
using System.Threading;
|
||||
using Xamarin.Geolocation;
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
[Activity (Label = "GeolocationSample", MainLauncher = true)]
|
||||
public class MainActivity : Activity
|
||||
{
|
||||
private Button toggleListenButton, cancelPositionButton;
|
||||
|
||||
private TextView positionStatus, positionLatitude, positionLongitude, positionAccuracy,
|
||||
listenStatus, listenLatitude, listenLongitude, listenAccuracy;
|
||||
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
// Set our view from the "main" layout resource
|
||||
SetContentView (Resource.Layout.Main);
|
||||
|
||||
FindViewById<Button> (Resource.Id.getPositionButton)
|
||||
.Click += OnGetPosition;
|
||||
|
||||
this.cancelPositionButton = FindViewById<Button> (Resource.Id.cancelPositionButton);
|
||||
this.cancelPositionButton.Click += OnCancelPosition;
|
||||
|
||||
this.toggleListenButton = FindViewById<Button> (Resource.Id.toggleListeningButton);
|
||||
this.toggleListenButton.Click += OnToggleListening;
|
||||
|
||||
this.positionStatus = FindViewById<TextView> (Resource.Id.status);
|
||||
this.positionAccuracy = FindViewById<TextView> (Resource.Id.pAccuracy);
|
||||
this.positionLatitude = FindViewById<TextView> (Resource.Id.pLatitude);
|
||||
this.positionLongitude = FindViewById<TextView> (Resource.Id.pLongitude);
|
||||
|
||||
this.listenStatus = FindViewById<TextView> (Resource.Id.listenStatus);
|
||||
this.listenAccuracy = FindViewById<TextView> (Resource.Id.lAccuracy);
|
||||
this.listenLatitude = FindViewById<TextView> (Resource.Id.lLatitude);
|
||||
this.listenLongitude = FindViewById<TextView> (Resource.Id.lLongitude);
|
||||
}
|
||||
|
||||
private Geolocator geolocator;
|
||||
private CancellationTokenSource cancelSource;
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
if (this.geolocator != null)
|
||||
return;
|
||||
|
||||
this.geolocator = new Geolocator (this) { DesiredAccuracy = 50 };
|
||||
this.geolocator.PositionError += OnListeningError;
|
||||
this.geolocator.PositionChanged += OnPositionChanged;
|
||||
}
|
||||
|
||||
private void OnGetPosition (object sender, EventArgs e)
|
||||
{
|
||||
Setup();
|
||||
|
||||
if (!this.geolocator.IsGeolocationAvailable || !this.geolocator.IsGeolocationEnabled)
|
||||
{
|
||||
Toast.MakeText (this, "Geolocation is unavailable", ToastLength.Long).Show();
|
||||
return;
|
||||
}
|
||||
|
||||
this.cancelSource = new CancellationTokenSource();
|
||||
|
||||
this.positionStatus.Text = String.Empty;
|
||||
this.positionAccuracy.Text = String.Empty;
|
||||
this.positionLatitude.Text = String.Empty;
|
||||
this.positionLongitude.Text = String.Empty;
|
||||
|
||||
this.geolocator.GetPositionAsync (timeout: 10000, cancelToken: this.cancelSource.Token)
|
||||
.ContinueWith (t => RunOnUiThread (() =>
|
||||
{
|
||||
if (t.IsFaulted)
|
||||
this.positionStatus.Text = ((GeolocationException)t.Exception.InnerException).Error.ToString();
|
||||
else if (t.IsCanceled)
|
||||
this.positionStatus.Text = "Canceled";
|
||||
else
|
||||
{
|
||||
this.positionStatus.Text = t.Result.Timestamp.ToString("G");
|
||||
this.positionAccuracy.Text = t.Result.Accuracy + "m";
|
||||
this.positionLatitude.Text = "La: " + t.Result.Latitude.ToString("N4");
|
||||
this.positionLongitude.Text = "Lo: " + t.Result.Longitude.ToString("N4");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void OnCancelPosition (object sender, EventArgs e)
|
||||
{
|
||||
CancellationTokenSource cancel = this.cancelSource;
|
||||
if (cancel != null)
|
||||
cancel.Cancel();
|
||||
}
|
||||
|
||||
private void OnToggleListening (object sender, EventArgs e)
|
||||
{
|
||||
Setup();
|
||||
|
||||
if (!this.geolocator.IsListening)
|
||||
{
|
||||
if (!this.geolocator.IsGeolocationAvailable || !this.geolocator.IsGeolocationEnabled)
|
||||
{
|
||||
Toast.MakeText (this, "Geolocation is unavailable", ToastLength.Long).Show();
|
||||
return;
|
||||
}
|
||||
|
||||
this.toggleListenButton.SetText (Resource.String.stopListening);
|
||||
this.geolocator.StartListening (minTime: 30000, minDistance: 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.toggleListenButton.SetText (Resource.String.startListening);
|
||||
this.geolocator.StopListening();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnListeningError (object sender, PositionErrorEventArgs e)
|
||||
{
|
||||
RunOnUiThread (() => {
|
||||
this.listenStatus.Text = e.Error.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
private void OnPositionChanged (object sender, PositionEventArgs e)
|
||||
{
|
||||
RunOnUiThread (() => {
|
||||
this.listenStatus.Text = e.Position.Timestamp.ToString("G");
|
||||
this.listenAccuracy.Text = e.Position.Accuracy + "m";
|
||||
this.listenLatitude.Text = "La: " + e.Position.Latitude.ToString("N4");
|
||||
this.listenLongitude.Text = "Lo: " + e.Position.Longitude.ToString("N4");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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="GeolocationSample.GeolocationSample" android:installLocation="internalOnly">
|
||||
<application android:label="GeolocationSample" android:debuggable="true">
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
</manifest>
|
||||
@@ -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("GeolocationSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xamarin Inc.")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2011-2012 Xamarin Inc.")]
|
||||
[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.*")]
|
||||
|
||||
// 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("")]
|
||||
|
||||
@@ -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.
|
||||
@@ -0,0 +1,151 @@
|
||||
#pragma warning disable 1591
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.17020
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
[assembly: Android.Runtime.ResourceDesignerAttribute("GeolocationSample.Resource", IsApplication=true)]
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
static Resource()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
public static void UpdateIdValues()
|
||||
{
|
||||
}
|
||||
|
||||
public partial class Attribute
|
||||
{
|
||||
|
||||
static Attribute()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Attribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Drawable
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f020000
|
||||
public const int Icon = 2130837504;
|
||||
|
||||
static Drawable()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Drawable()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Id
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f050001
|
||||
public const int cancelPositionButton = 2131034113;
|
||||
|
||||
// aapt resource value: 0x7f050000
|
||||
public const int getPositionButton = 2131034112;
|
||||
|
||||
// aapt resource value: 0x7f050008
|
||||
public const int lAccuracy = 2131034120;
|
||||
|
||||
// aapt resource value: 0x7f05000a
|
||||
public const int lLatitude = 2131034122;
|
||||
|
||||
// aapt resource value: 0x7f050009
|
||||
public const int lLongitude = 2131034121;
|
||||
|
||||
// aapt resource value: 0x7f050007
|
||||
public const int listenStatus = 2131034119;
|
||||
|
||||
// aapt resource value: 0x7f050003
|
||||
public const int pAccuracy = 2131034115;
|
||||
|
||||
// aapt resource value: 0x7f050005
|
||||
public const int pLatitude = 2131034117;
|
||||
|
||||
// aapt resource value: 0x7f050004
|
||||
public const int pLongitude = 2131034116;
|
||||
|
||||
// aapt resource value: 0x7f050002
|
||||
public const int status = 2131034114;
|
||||
|
||||
// aapt resource value: 0x7f050006
|
||||
public const int toggleListeningButton = 2131034118;
|
||||
|
||||
static Id()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Id()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Layout
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f030000
|
||||
public const int Main = 2130903040;
|
||||
|
||||
static Layout()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Layout()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class String
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f040004
|
||||
public const int app_name = 2130968580;
|
||||
|
||||
// aapt resource value: 0x7f040001
|
||||
public const int cancelPosition = 2130968577;
|
||||
|
||||
// aapt resource value: 0x7f040000
|
||||
public const int getPosition = 2130968576;
|
||||
|
||||
// aapt resource value: 0x7f040002
|
||||
public const int startListening = 2130968578;
|
||||
|
||||
// aapt resource value: 0x7f040003
|
||||
public const int stopListening = 2130968579;
|
||||
|
||||
static String()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private String()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
|
||||
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/getPositionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/getPosition" />
|
||||
<Button android:id="@+id/cancelPositionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/cancelPosition" />
|
||||
</LinearLayout>
|
||||
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/status" android:text=" " />
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pAccuracy" android:text=" " />
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pLongitude" android:text=" " />
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pLatitude" android:text=" " />
|
||||
</LinearLayout>
|
||||
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/toggleListeningButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/startListening" />
|
||||
</LinearLayout>
|
||||
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listenStatus" android:text=" " />
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lAccuracy" android:text=" " />
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lLongitude" android:text=" " />
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lLatitude" android:text=" " />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="getPosition">Get position</string>
|
||||
<string name="cancelPosition">Cancel position</string>
|
||||
<string name="startListening">Start listening</string>
|
||||
<string name="stopListening">Stop listening</string>
|
||||
<string name="app_name">GeolocationSample</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Android.App;
|
||||
using Android.Graphics;
|
||||
using Android.OS;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
[Activity]
|
||||
public class ImageActivity
|
||||
: Activity
|
||||
{
|
||||
private string path;
|
||||
private ImageView image;
|
||||
protected override void OnCreate (Bundle savedInstanceState)
|
||||
{
|
||||
base.OnCreate (savedInstanceState);
|
||||
this.image = new ImageView (this);
|
||||
this.image.SetScaleType (ImageView.ScaleType.CenterInside);
|
||||
SetContentView (this.image, new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
|
||||
|
||||
this.path = (savedInstanceState ?? Intent.Extras).GetString ("path");
|
||||
Title = System.IO.Path.GetFileName (this.path);
|
||||
|
||||
Cleanup();
|
||||
DecodeBitmapAsync (path, 400, 400).ContinueWith (t => {
|
||||
this.image.SetImageBitmap (this.bitmap = t.Result);
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
|
||||
protected override void OnSaveInstanceState (Bundle outState)
|
||||
{
|
||||
outState.PutString ("path", this.path);
|
||||
base.OnSaveInstanceState (outState);
|
||||
}
|
||||
|
||||
private static Task<Bitmap> DecodeBitmapAsync (string path, int desiredWidth, int desiredHeight)
|
||||
{
|
||||
return Task.Factory.StartNew (() => {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.InJustDecodeBounds = true;
|
||||
BitmapFactory.DecodeFile (path, options);
|
||||
|
||||
int height = options.OutHeight;
|
||||
int width = options.OutWidth;
|
||||
|
||||
int sampleSize = 1;
|
||||
if (height > desiredHeight || width > desiredWidth) {
|
||||
int heightRatio = (int)Math.Round ((float)height / (float)desiredHeight);
|
||||
int widthRatio = (int)Math.Round ((float)width / (float)desiredWidth);
|
||||
sampleSize = Math.Min (heightRatio, widthRatio);
|
||||
}
|
||||
|
||||
options = new BitmapFactory.Options();
|
||||
options.InSampleSize = sampleSize;
|
||||
|
||||
return BitmapFactory.DecodeFile (path, options);
|
||||
});
|
||||
}
|
||||
|
||||
private Bitmap bitmap;
|
||||
private void Cleanup()
|
||||
{
|
||||
if (this.bitmap == null)
|
||||
return;
|
||||
|
||||
this.image.SetImageBitmap (null);
|
||||
this.bitmap.Dispose();
|
||||
this.bitmap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
using Android.Widget;
|
||||
using Android.OS;
|
||||
using Xamarin.Media;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
[Activity (Label = "MediaPickerSample", MainLauncher = true, Icon = "@drawable/icon", ConfigurationChanges = ConfigChanges.Orientation)]
|
||||
public class MainActivity : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
SetContentView (Resource.Layout.Main);
|
||||
|
||||
Button videoButton = FindViewById<Button> (Resource.Id.takeVideoButton);
|
||||
videoButton.Click += delegate {
|
||||
// MediaPicker is the class used to invoke the
|
||||
// camera and gallery picker for selecting and
|
||||
// taking photos and videos
|
||||
var picker = new MediaPicker (this);
|
||||
|
||||
// We can check to make sure the device has a camera
|
||||
// and supports dealing with video.
|
||||
if (!picker.IsCameraAvailable || !picker.VideosSupported) {
|
||||
ShowUnsupported();
|
||||
return;
|
||||
}
|
||||
|
||||
// The GetTakeVideoUI method returns an Intent to start
|
||||
// the native camera app to record a video.
|
||||
Intent intent = picker.GetTakeVideoUI (new StoreVideoOptions {
|
||||
Name = "MyVideo",
|
||||
Directory = "MyVideos",
|
||||
DesiredLength = TimeSpan.FromSeconds (10)
|
||||
});
|
||||
|
||||
StartActivityForResult (intent, 1);
|
||||
};
|
||||
|
||||
Button photoButton = FindViewById<Button> (Resource.Id.takePhotoButton);
|
||||
photoButton.Click += delegate {
|
||||
var picker = new MediaPicker (this);
|
||||
|
||||
if (!picker.IsCameraAvailable || !picker.PhotosSupported) {
|
||||
ShowUnsupported();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
|
||||
Name = "test.jpg",
|
||||
Directory = "MediaPickerSample"
|
||||
});
|
||||
|
||||
StartActivityForResult (intent, 2);
|
||||
};
|
||||
|
||||
Button pickVideoButton = FindViewById<Button> (Resource.Id.pickVideoButton);
|
||||
pickVideoButton.Click += delegate {
|
||||
var picker = new MediaPicker (this);
|
||||
|
||||
if (!picker.VideosSupported) {
|
||||
ShowUnsupported();
|
||||
return;
|
||||
}
|
||||
|
||||
// The GetPickVideoUI() method returns an Intent to start
|
||||
// the native gallery app to select a video.
|
||||
Intent intent = picker.GetPickVideoUI();
|
||||
StartActivityForResult (intent, 1);
|
||||
};
|
||||
|
||||
Button pickPhotoButton = FindViewById<Button> (Resource.Id.pickPhotoButton);
|
||||
pickPhotoButton.Click += delegate {
|
||||
var picker = new MediaPicker (this);
|
||||
|
||||
if (!picker.PhotosSupported) {
|
||||
ShowUnsupported();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = picker.GetPickPhotoUI();
|
||||
StartActivityForResult (intent, 2);
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
|
||||
{
|
||||
// User canceled
|
||||
if (resultCode == Result.Canceled)
|
||||
return;
|
||||
|
||||
data.GetMediaFileExtraAsync (this).ContinueWith (t => {
|
||||
if (requestCode == 1) { // Video request
|
||||
ShowVideo (t.Result.Path);
|
||||
} else if (requestCode == 2) { // Image request
|
||||
ShowImage (t.Result.Path);
|
||||
}
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
|
||||
private void ShowVideo (string path)
|
||||
{
|
||||
Intent videoIntent = new Intent (this, typeof (VideoActivity));
|
||||
videoIntent.PutExtra ("path", path);
|
||||
StartActivity (videoIntent);
|
||||
}
|
||||
|
||||
private void ShowImage (string path)
|
||||
{
|
||||
Intent imageIntent = new Intent (this, typeof (ImageActivity));
|
||||
imageIntent.PutExtra ("path", path);
|
||||
StartActivity (imageIntent);
|
||||
}
|
||||
|
||||
private Toast unsupportedToast;
|
||||
private void ShowUnsupported()
|
||||
{
|
||||
if (this.unsupportedToast != null) {
|
||||
this.unsupportedToast.Cancel();
|
||||
this.unsupportedToast.Dispose();
|
||||
}
|
||||
|
||||
this.unsupportedToast = Toast.MakeText (this, "Your device does not support this feature", ToastLength.Long);
|
||||
this.unsupportedToast.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{35CF5239-F77C-40B0-B3A7-14AF989A19C8}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MediaPickerSample</RootNamespace>
|
||||
<AssemblyName>MediaPickerSample</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidApplication>true</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<DeployExternal>False</DeployExternal>
|
||||
<AndroidSupportedAbis>armeabi</AndroidSupportedAbis>
|
||||
<AndroidStoreUncompressedFileExtensions />
|
||||
<MandroidI18n />
|
||||
<TargetFrameworkVersion>v2.3</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
|
||||
<AndroidSupportedAbis>armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Xamarin.Mobile">
|
||||
<HintPath>../../../lib\/android/Xamarin.Mobile.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ImageActivity.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="VideoActivity.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Layout\Main.axml">
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Values\Strings.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\Drawable\Icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Assets\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly">
|
||||
<application>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" />
|
||||
</manifest>
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MediaPickerSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xamarin Inc.")]
|
||||
[assembly: AssemblyProduct("MediaPickerSample")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2011-2012 Xamarin Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
// Add some common permissions, these can be removed if not needed
|
||||
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
|
||||
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
|
||||
@@ -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.xml),
|
||||
an internationalization string table (Strings.xml) and some icons (drawable/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, the build action should be set
|
||||
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
|
||||
"Resource" that contains the tokens for each one of the resources included. For example,
|
||||
for the above Resources layout, this is what the Resource class would expose:
|
||||
|
||||
public class Resource {
|
||||
public class Drawable {
|
||||
public const int Icon = 0x123;
|
||||
}
|
||||
|
||||
public class Layout {
|
||||
public const int Main = 0x456;
|
||||
}
|
||||
|
||||
public class String {
|
||||
public const int FirstString = 0xabc;
|
||||
public const int SecondString = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use Resource.Drawable.Icon to reference the Drawable/Icon.png file, or
|
||||
Resource.Layout.Main to reference the Layout/Main.axml file, or Resource.String.FirstString
|
||||
to reference the first string in the dictionary file Values/Strings.xml.
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<Button
|
||||
android:id="@+id/takePhotoButton"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Take Photo" />
|
||||
<Button
|
||||
android:id="@+id/takeVideoButton"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Take Video" />
|
||||
<Button
|
||||
android:id="@+id/pickPhotoButton"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Pick Photo" />
|
||||
<Button
|
||||
android:id="@+id/pickVideoButton"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Pick Video" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,121 @@
|
||||
#pragma warning disable 1591
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.17020
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
[assembly: Android.Runtime.ResourceDesignerAttribute("MediaPickerSample.Resource", IsApplication=true)]
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
static Resource()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
public static void UpdateIdValues()
|
||||
{
|
||||
}
|
||||
|
||||
public partial class Attribute
|
||||
{
|
||||
|
||||
static Attribute()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Attribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Drawable
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f020000
|
||||
public const int Icon = 2130837504;
|
||||
|
||||
static Drawable()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Drawable()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Id
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f050002
|
||||
public const int pickPhotoButton = 2131034114;
|
||||
|
||||
// aapt resource value: 0x7f050003
|
||||
public const int pickVideoButton = 2131034115;
|
||||
|
||||
// aapt resource value: 0x7f050000
|
||||
public const int takePhotoButton = 2131034112;
|
||||
|
||||
// aapt resource value: 0x7f050001
|
||||
public const int takeVideoButton = 2131034113;
|
||||
|
||||
static Id()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Id()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Layout
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f030000
|
||||
public const int Main = 2130903040;
|
||||
|
||||
static Layout()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private Layout()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class String
|
||||
{
|
||||
|
||||
// aapt resource value: 0x7f040001
|
||||
public const int ApplicationName = 2130968577;
|
||||
|
||||
// aapt resource value: 0x7f040000
|
||||
public const int Hello = 2130968576;
|
||||
|
||||
static String()
|
||||
{
|
||||
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||
}
|
||||
|
||||
private String()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="Hello">Hello World, Click Me!</string>
|
||||
<string name="ApplicationName">MediaPickerSample</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,34 @@
|
||||
using Android.App;
|
||||
using Android.OS;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
[Activity]
|
||||
public class VideoActivity
|
||||
: Activity
|
||||
{
|
||||
private VideoView video;
|
||||
private string path;
|
||||
|
||||
protected override void OnCreate (Bundle savedInstanceState)
|
||||
{
|
||||
base.OnCreate (savedInstanceState);
|
||||
this.video = new VideoView (this);
|
||||
SetContentView (this.video, new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
|
||||
|
||||
this.path = (savedInstanceState ?? Intent.Extras).GetString ("path");
|
||||
Title = System.IO.Path.GetFileName (this.path);
|
||||
|
||||
this.video.SetVideoPath (this.path);
|
||||
this.video.Start();
|
||||
}
|
||||
|
||||
protected override void OnSaveInstanceState (Bundle outState)
|
||||
{
|
||||
outState.PutString ("path", this.path);
|
||||
base.OnSaveInstanceState (outState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contacts Sample", "ContactsSample\Contacts Sample.csproj", "{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geolocation Sample", "GeolocationSample\Geolocation Sample.csproj", "{82254F3E-647E-4F4A-AA4F-008A614C4B02}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaPicker Sample", "MediaPickerSample\MediaPicker Sample.csproj", "{35CF5239-F77C-40B0-B3A7-14AF989A19C8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{32E5FA7A-4754-49C6-BA09-2E262BEDC4CE}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{82254F3E-647E-4F4A-AA4F-008A614C4B02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{82254F3E-647E-4F4A-AA4F-008A614C4B02}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{82254F3E-647E-4F4A-AA4F-008A614C4B02}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{82254F3E-647E-4F4A-AA4F-008A614C4B02}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{82254F3E-647E-4F4A-AA4F-008A614C4B02}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{82254F3E-647E-4F4A-AA4F-008A614C4B02}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{35CF5239-F77C-40B0-B3A7-14AF989A19C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{35CF5239-F77C-40B0-B3A7-14AF989A19C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{35CF5239-F77C-40B0-B3A7-14AF989A19C8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{35CF5239-F77C-40B0-B3A7-14AF989A19C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{35CF5239-F77C-40B0-B3A7-14AF989A19C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{35CF5239-F77C-40B0-B3A7-14AF989A19C8}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = ContactsSample\Contacts Sample.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,19 @@
|
||||
<Application
|
||||
x:Class="ContactsSample.App"
|
||||
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">
|
||||
|
||||
<!--Application Resources-->
|
||||
<Application.Resources>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.ApplicationLifetimeObjects>
|
||||
<!--Required object that handles lifetime events for the application-->
|
||||
<shell:PhoneApplicationService
|
||||
Launching="Application_Launching" Closing="Application_Closing"
|
||||
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||
</Application.ApplicationLifetimeObjects>
|
||||
|
||||
</Application>
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
|
||||
namespace ContactsSample
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// 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; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard Silverlight initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||
|
||||
// Show the areas of the app that are being redrawn in each frame.
|
||||
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||
|
||||
// Enable non-production analysis visualization mode,
|
||||
// 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.
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is launching (eg, from Start)
|
||||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
// Avoid double-initialization
|
||||
private bool phoneApplicationInitialized = false;
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void InitializePhoneApplication()
|
||||
{
|
||||
if (phoneApplicationInitialized)
|
||||
return;
|
||||
|
||||
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||
// screen to remain active until the application is ready to render.
|
||||
RootFrame = new PhoneApplicationFrame();
|
||||
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||
|
||||
// Handle navigation failures
|
||||
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Set the root visual to allow the application to render
|
||||
if (RootVisual != RootFrame)
|
||||
RootVisual = RootFrame;
|
||||
|
||||
// Remove this handler since it is no longer needed
|
||||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EC845FCE-D9B8-408B-BCF6-53CFC95F289C}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ContactsSample</RootNamespace>
|
||||
<AssemblyName>ContactsSample</AssemblyName>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>
|
||||
</SilverlightVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<SilverlightApplication>true</SilverlightApplication>
|
||||
<SupportedCultures>
|
||||
</SupportedCultures>
|
||||
<XapOutputs>true</XapOutputs>
|
||||
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||
<XapFilename>ContactsSample_$(Configuration)_$(Platform).xap</XapFilename>
|
||||
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||
<SilverlightAppEntry>ContactsSample.App</SilverlightAppEntry>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPageViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AppManifest.xml" />
|
||||
<None Include="Properties\WMAppManifest.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Background.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SplashScreenImage.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Phone.Controls, Version=8.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Xamarin.Mobile\Xamarin.Mobile.csproj">
|
||||
<Project>{2F184B4A-9A80-4097-92C4-2F93DCB0D6E4}</Project>
|
||||
<Name>Xamarin.Mobile %28Windows Phone 8\Xamarin.Mobile%29</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ProjectExtensions />
|
||||
</Project>
|
||||
@@ -0,0 +1,79 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="ContactsSample.MainPage"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<shell:SystemTray.ProgressIndicator>
|
||||
<shell:ProgressIndicator x:Name="indicator" IsVisible="{Binding ShowProgress}" IsIndeterminate="true" />
|
||||
</shell:SystemTray.ProgressIndicator>
|
||||
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<phone:Pivot Name="pivot" Title="Xamarin Mobile API Preview Contacts Sample">
|
||||
<phone:PivotItem Header="contacts">
|
||||
<ListBox Grid.Row="1" ItemsSource="{Binding Contacts}" SelectedItem="{Binding Contact,Mode=TwoWay}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</phone:PivotItem>
|
||||
|
||||
<phone:PivotItem Header="details">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80*" />
|
||||
<ColumnDefinition Width="20*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="{Binding Contact.DisplayName}" />
|
||||
<Image Grid.Column="1" Source="{Binding Thumbnail}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="1">Phones:</TextBlock>
|
||||
<ListBox Grid.Row="2" ItemsSource="{Binding Contact.Phones}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
<TextBlock Text="{Binding Number}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<TextBlock Grid.Row="3">Emails:</TextBlock>
|
||||
<ListBox Grid.Row="4" ItemsSource="{Binding Contact.Emails}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
<TextBlock Text="{Binding Address}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</phone:PivotItem>
|
||||
</phone:Pivot>
|
||||
</Grid>
|
||||
</phone:PhoneApplicationPage>
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Phone.Controls;
|
||||
|
||||
namespace ContactsSample
|
||||
{
|
||||
public partial class MainPage : PhoneApplicationPage
|
||||
{
|
||||
// Constructor
|
||||
public MainPage()
|
||||
{
|
||||
var vm = new MainPageViewModel();
|
||||
vm.SelectedContact += OnSelectedContact;
|
||||
DataContext = vm;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnSelectedContact (object sender, EventArgs eventArgs)
|
||||
{
|
||||
this.pivot.SelectedIndex = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Xamarin.Contacts;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ContactsSample
|
||||
{
|
||||
public class MainPageViewModel
|
||||
: INotifyPropertyChanged
|
||||
{
|
||||
public MainPageViewModel()
|
||||
{
|
||||
Setup();
|
||||
}
|
||||
|
||||
private async Task Setup()
|
||||
{
|
||||
if (!await this.addressBook.RequestPermission())
|
||||
this.addressBook = null;
|
||||
}
|
||||
|
||||
public event EventHandler SelectedContact;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private bool showProgress = true;
|
||||
public bool ShowProgress
|
||||
{
|
||||
get { return this.showProgress; }
|
||||
set
|
||||
{
|
||||
if (this.showProgress == value)
|
||||
return;
|
||||
|
||||
this.showProgress = value;
|
||||
OnPropertyChanged("ShowProgress");
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Contact> Contacts
|
||||
{
|
||||
get { return FinishWhenIterated (this.addressBook ?? Enumerable.Empty<Contact>()); }
|
||||
}
|
||||
|
||||
private BitmapImage thumb;
|
||||
public BitmapImage Thumbnail
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.thumb == null && this.contact != null)
|
||||
this.thumb = this.contact.GetThumbnail();
|
||||
|
||||
return this.thumb;
|
||||
}
|
||||
}
|
||||
|
||||
private Contact contact;
|
||||
public Contact Contact
|
||||
{
|
||||
get { return this.contact; }
|
||||
set
|
||||
{
|
||||
if (this.contact == value)
|
||||
return;
|
||||
|
||||
this.contact = value;
|
||||
this.thumb = null;
|
||||
OnPropertyChanged ("Contact");
|
||||
OnPropertyChanged ("Thumbnail");
|
||||
|
||||
if (value != null)
|
||||
OnSelectedContact (EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private AddressBook addressBook = new AddressBook();
|
||||
|
||||
private IEnumerable<Contact> FinishWhenIterated (IEnumerable<Contact> contacts)
|
||||
{
|
||||
foreach (var contact in contacts)
|
||||
yield return contact;
|
||||
|
||||
ShowProgress = false;
|
||||
}
|
||||
|
||||
private void OnPropertyChanged (string name)
|
||||
{
|
||||
var changed = PropertyChanged;
|
||||
if (changed != null)
|
||||
changed (this, new PropertyChangedEventArgs (name));
|
||||
}
|
||||
|
||||
private void OnSelectedContact (EventArgs e)
|
||||
{
|
||||
var selected = SelectedContact;
|
||||
if (selected != null)
|
||||
selected (this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
<Deployment.Parts>
|
||||
</Deployment.Parts>
|
||||
</Deployment>
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ContactsSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xamarin Inc.")]
|
||||
[assembly: AssemblyProduct("ContactsSample")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 Xamarin Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("7d434c9a-beec-461a-a8ce-592231394f82")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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="{371cc2ba-d085-4d08-aef6-c84a5af37f38}" Title="ContactsSample" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="ContactsSample author" Description="Sample description" Publisher="ContactsSample" PublisherID="{e9593c76-a6d9-48cd-9294-7d5928d8323d}">
|
||||
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_GAMERSERVICES" />
|
||||
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
|
||||
<Capability Name="ID_CAP_IDENTITY_USER" />
|
||||
<Capability Name="ID_CAP_LOCATION" />
|
||||
<Capability Name="ID_CAP_MICROPHONE" />
|
||||
<Capability Name="ID_CAP_NETWORKING" />
|
||||
<Capability Name="ID_CAP_PHONEDIALER" />
|
||||
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
|
||||
<Capability Name="ID_CAP_SENSORS" />
|
||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
||||
<Capability Name="ID_CAP_ISV_CAMERA" />
|
||||
<Capability Name="ID_CAP_CONTACTS" />
|
||||
<Capability Name="ID_CAP_APPOINTMENTS" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="ContactsSampleToken" TaskName="_default">
|
||||
<TemplateFlip>
|
||||
<SmallImageURI IsResource="false" IsRelative="true">Background.png</SmallImageURI>
|
||||
<Count>0</Count>
|
||||
<BackgroundImageURI IsResource="false" IsRelative="true">Background.png</BackgroundImageURI>
|
||||
<Title>ContactsSample</Title>
|
||||
<BackContent></BackContent>
|
||||
<BackBackgroundImageURI></BackBackgroundImageURI>
|
||||
<BackTitle></BackTitle>
|
||||
<LargeBackgroundImageURI></LargeBackgroundImageURI>
|
||||
<LargeBackContent></LargeBackContent>
|
||||
<LargeBackBackgroundImageURI></LargeBackBackgroundImageURI>
|
||||
<DeviceLockImageURI></DeviceLockImageURI>
|
||||
<HasLarge>false</HasLarge>
|
||||
</TemplateFlip>
|
||||
</PrimaryToken>
|
||||
</Tokens>
|
||||
<ScreenResolutions>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
|
||||
</ScreenResolutions>
|
||||
</App>
|
||||
</Deployment>
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,9 @@
|
||||
<MarketplaceDetails>
|
||||
<SmallAppTile>
|
||||
</SmallAppTile>
|
||||
<LargeAppTile>
|
||||
</LargeAppTile>
|
||||
<PCAppTile>
|
||||
</PCAppTile>
|
||||
<ScreenShots>;;;;;;;;</ScreenShots>
|
||||
</MarketplaceDetails>
|
||||
@@ -0,0 +1,19 @@
|
||||
<Application
|
||||
x:Class="GeolocationSample.App"
|
||||
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">
|
||||
|
||||
<!--Application Resources-->
|
||||
<Application.Resources>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.ApplicationLifetimeObjects>
|
||||
<!--Required object that handles lifetime events for the application-->
|
||||
<shell:PhoneApplicationService
|
||||
Launching="Application_Launching" Closing="Application_Closing"
|
||||
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||
</Application.ApplicationLifetimeObjects>
|
||||
|
||||
</Application>
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// 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; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard Silverlight initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||
|
||||
// Show the areas of the app that are being redrawn in each frame.
|
||||
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||
|
||||
// Enable non-production analysis visualization mode,
|
||||
// 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.
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is launching (eg, from Start)
|
||||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
// Avoid double-initialization
|
||||
private bool phoneApplicationInitialized = false;
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void InitializePhoneApplication()
|
||||
{
|
||||
if (phoneApplicationInitialized)
|
||||
return;
|
||||
|
||||
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||
// screen to remain active until the application is ready to render.
|
||||
RootFrame = new PhoneApplicationFrame();
|
||||
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||
|
||||
// Handle navigation failures
|
||||
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Set the root visual to allow the application to render
|
||||
if (RootVisual != RootFrame)
|
||||
RootVisual = RootFrame;
|
||||
|
||||
// Remove this handler since it is no longer needed
|
||||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
public class DelegatedCommand
|
||||
: ICommand
|
||||
{
|
||||
public DelegatedCommand (Action<object> execute, Func<object, bool> canExecute)
|
||||
{
|
||||
if (execute == null)
|
||||
throw new ArgumentNullException ("execute");
|
||||
if (canExecute == null)
|
||||
throw new ArgumentNullException ("canExecute");
|
||||
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public void ChangeCanExecute()
|
||||
{
|
||||
var changed = CanExecuteChanged;
|
||||
if (changed != null)
|
||||
changed (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public bool CanExecute (object parameter)
|
||||
{
|
||||
return this.canExecute (parameter);
|
||||
}
|
||||
|
||||
public void Execute (object parameter)
|
||||
{
|
||||
this.execute (parameter);
|
||||
}
|
||||
|
||||
private readonly Action<object> execute;
|
||||
private readonly Func<object, bool> canExecute;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0FBF47C0-7858-4BBA-9C12-FBFE70D6F719}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>GeolocationSample</RootNamespace>
|
||||
<AssemblyName>GeolocationSample</AssemblyName>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>
|
||||
</SilverlightVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<SilverlightApplication>true</SilverlightApplication>
|
||||
<SupportedCultures>
|
||||
</SupportedCultures>
|
||||
<XapOutputs>true</XapOutputs>
|
||||
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||
<XapFilename>GeolocationSample_$(Configuration)_$(Platform).xap</XapFilename>
|
||||
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||
<SilverlightAppEntry>GeolocationSample.App</SilverlightAppEntry>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DelegatedCommand.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPageViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AppManifest.xml" />
|
||||
<None Include="Properties\WMAppManifest.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Background.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SplashScreenImage.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Xamarin.Mobile\Xamarin.Mobile.csproj">
|
||||
<Project>{2F184B4A-9A80-4097-92C4-2F93DCB0D6E4}</Project>
|
||||
<Name>Xamarin.Mobile %28Windows Phone 8\Xamarin.Mobile%29</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ProjectExtensions />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -0,0 +1,84 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="GeolocationSample.MainPage"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<shell:SystemTray.ProgressIndicator>
|
||||
<shell:ProgressIndicator x:Name="indicator" IsVisible="{Binding ShowProgress}" IsIndeterminate="true" />
|
||||
</shell:SystemTray.ProgressIndicator>
|
||||
|
||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--TitlePanel contains the name of the application and page title-->
|
||||
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
||||
<TextBlock x:Name="ApplicationTitle" Text="Xamarin Mobile API Preview Geolocation Sample" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
<TextBlock x:Name="PageTitle" Text="geolocation" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40*" />
|
||||
<ColumnDefinition Width="60*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Command="{Binding GetPosition}">Get Location</Button>
|
||||
<Button Command="{Binding ToggleListening}">Toggle Listening</Button>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0">Status:</TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Status}" />
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0">Time:</TextBlock>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CurrentPosition.Timestamp}" />
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0">Latitude:</TextBlock>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CurrentPosition.Latitude}" />
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0">Longitude:</TextBlock>
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding CurrentPosition.Longitude}" />
|
||||
|
||||
<TextBlock Grid.Row="5" Grid.Column="0">Accuracy:</TextBlock>
|
||||
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding CurrentPosition.Accuracy}" />
|
||||
|
||||
<TextBlock Grid.Row="6" Grid.Column="0">Heading:</TextBlock>
|
||||
<TextBlock Grid.Row="6" Grid.Column="1" Text="{Binding CurrentPosition.Heading}" />
|
||||
|
||||
<TextBlock Grid.Row="7" Grid.Column="0">Altitude:</TextBlock>
|
||||
<TextBlock Grid.Row="7" Grid.Column="1" Text="{Binding CurrentPosition.Altitude}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Grid.Column="0">Altitude Accuracy:</TextBlock>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Text="{Binding CurrentPosition.AltitudeAccuracy}" />
|
||||
|
||||
<TextBlock Grid.Row="9" Grid.Column="0">Speed:</TextBlock>
|
||||
<TextBlock Grid.Row="9" Grid.Column="1" Text="{Binding CurrentPosition.Speed}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</phone:PhoneApplicationPage>
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
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.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Xamarin.Geolocation;
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
public partial class MainPage : PhoneApplicationPage
|
||||
{
|
||||
// Constructor
|
||||
public MainPage()
|
||||
{
|
||||
DataContext = new MainPageViewModel (new Geolocator(), SynchronizationContext.Current);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Geolocation;
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
public class MainPageViewModel
|
||||
: INotifyPropertyChanged
|
||||
{
|
||||
public MainPageViewModel (Geolocator geolocator, SynchronizationContext syncContext)
|
||||
{
|
||||
if (geolocator == null)
|
||||
throw new ArgumentNullException ("geolocator");
|
||||
if (syncContext == null)
|
||||
throw new ArgumentNullException ("syncContext");
|
||||
|
||||
this.sync = syncContext;
|
||||
this.geolocator = geolocator;
|
||||
this.geolocator.DesiredAccuracy = 50;
|
||||
this.geolocator.PositionError += GeolocatorOnPositionError;
|
||||
this.geolocator.PositionChanged += GeolocatorOnPositionChanged;
|
||||
this.getPosition = new DelegatedCommand (GetPositionHandler, s => true);
|
||||
this.toggleListening = new DelegatedCommand (ToggleListeningHandler, s => true);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private bool showProgress;
|
||||
public bool ShowProgress
|
||||
{
|
||||
get { return this.showProgress; }
|
||||
set
|
||||
{
|
||||
if (this.showProgress == value)
|
||||
return;
|
||||
|
||||
this.showProgress = value;
|
||||
OnPropertyChanged ("ShowProgress");
|
||||
}
|
||||
}
|
||||
|
||||
private string status;
|
||||
public string Status
|
||||
{
|
||||
get { return this.status; }
|
||||
private set
|
||||
{
|
||||
if (this.status == value)
|
||||
return;
|
||||
|
||||
this.status = value;
|
||||
OnPropertyChanged ("Status");
|
||||
}
|
||||
}
|
||||
|
||||
private readonly DelegatedCommand getPosition;
|
||||
public ICommand GetPosition
|
||||
{
|
||||
get { return this.getPosition; }
|
||||
}
|
||||
|
||||
private readonly DelegatedCommand toggleListening;
|
||||
public ICommand ToggleListening
|
||||
{
|
||||
get { return this.toggleListening; }
|
||||
}
|
||||
|
||||
private Position currentPosition;
|
||||
public Position CurrentPosition
|
||||
{
|
||||
get { return this.currentPosition; }
|
||||
private set
|
||||
{
|
||||
if (this.currentPosition == value)
|
||||
return;
|
||||
|
||||
this.currentPosition = value;
|
||||
OnPropertyChanged ("CurrentPosition");
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Geolocator geolocator;
|
||||
private readonly SynchronizationContext sync;
|
||||
|
||||
private async void GetPositionHandler (object state)
|
||||
{
|
||||
ShowProgress = true;
|
||||
Status = "Getting location..";
|
||||
|
||||
if (!this.geolocator.IsGeolocationEnabled)
|
||||
{
|
||||
Status = "Location disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Position p = await this.geolocator.GetPositionAsync (10000, includeHeading: true);
|
||||
CurrentPosition = p;
|
||||
Status = "Success";
|
||||
}
|
||||
catch (GeolocationException ex)
|
||||
{
|
||||
Status = "Error: (" + ex.Error + ") " + ex.Message;
|
||||
}
|
||||
catch (TaskCanceledException cex)
|
||||
{
|
||||
Status = "Canceled";
|
||||
}
|
||||
|
||||
ShowProgress = false;
|
||||
}
|
||||
|
||||
private void ToggleListeningHandler (object o)
|
||||
{
|
||||
if (!this.geolocator.IsGeolocationEnabled)
|
||||
{
|
||||
Status = "Location disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.geolocator.IsListening)
|
||||
{
|
||||
Status = "Listening";
|
||||
this.geolocator.StartListening (0, 0, includeHeading: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = "Stopped listening";
|
||||
this.geolocator.StopListening();
|
||||
}
|
||||
}
|
||||
|
||||
private void GeolocatorOnPositionError (object sender, PositionErrorEventArgs e)
|
||||
{
|
||||
Status = e.Error.ToString();
|
||||
}
|
||||
|
||||
private void GeolocatorOnPositionChanged (object sender, PositionEventArgs e)
|
||||
{
|
||||
CurrentPosition = e.Position;
|
||||
}
|
||||
|
||||
private void OnPropertyChanged (string name)
|
||||
{
|
||||
var changed = PropertyChanged;
|
||||
if (changed != null)
|
||||
this.sync.Post (n => changed (this, new PropertyChangedEventArgs ((string)n)), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
<Deployment.Parts>
|
||||
</Deployment.Parts>
|
||||
</Deployment>
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("GeolocationSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xamarin Inc.")]
|
||||
[assembly: AssemblyProduct("GeolocationSample")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 Xamarin Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("19e9580f-b4c2-40e5-b602-f569f113b8da")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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="{5f957bd6-24ad-4af6-a9c3-dd92c3fbb38b}" Title="GeolocationSample" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="GeolocationSample author" Description="Sample description" Publisher="GeolocationSample" PublisherID="{b9d70cd1-1ed9-42ef-bc64-d81c1761adf3}">
|
||||
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_GAMERSERVICES" />
|
||||
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
|
||||
<Capability Name="ID_CAP_IDENTITY_USER" />
|
||||
<Capability Name="ID_CAP_LOCATION" />
|
||||
<Capability Name="ID_CAP_MICROPHONE" />
|
||||
<Capability Name="ID_CAP_NETWORKING" />
|
||||
<Capability Name="ID_CAP_PHONEDIALER" />
|
||||
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
|
||||
<Capability Name="ID_CAP_SENSORS" />
|
||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
||||
<Capability Name="ID_CAP_ISV_CAMERA" />
|
||||
<Capability Name="ID_CAP_CONTACTS" />
|
||||
<Capability Name="ID_CAP_APPOINTMENTS" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="GeolocationSampleToken" TaskName="_default">
|
||||
<TemplateFlip>
|
||||
<SmallImageURI IsResource="false" IsRelative="true">Background.png</SmallImageURI>
|
||||
<Count>0</Count>
|
||||
<BackgroundImageURI IsResource="false" IsRelative="true">Background.png</BackgroundImageURI>
|
||||
<Title>GeolocationSample</Title>
|
||||
<BackContent></BackContent>
|
||||
<BackBackgroundImageURI></BackBackgroundImageURI>
|
||||
<BackTitle></BackTitle>
|
||||
<LargeBackgroundImageURI></LargeBackgroundImageURI>
|
||||
<LargeBackContent></LargeBackContent>
|
||||
<LargeBackBackgroundImageURI></LargeBackBackgroundImageURI>
|
||||
<DeviceLockImageURI></DeviceLockImageURI>
|
||||
<HasLarge>false</HasLarge>
|
||||
</TemplateFlip>
|
||||
</PrimaryToken>
|
||||
</Tokens>
|
||||
<ScreenResolutions>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
|
||||
</ScreenResolutions>
|
||||
</App>
|
||||
</Deployment>
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,9 @@
|
||||
<MarketplaceDetails>
|
||||
<SmallAppTile>
|
||||
</SmallAppTile>
|
||||
<LargeAppTile>
|
||||
</LargeAppTile>
|
||||
<PCAppTile>
|
||||
</PCAppTile>
|
||||
<ScreenShots>;;;;;;;;</ScreenShots>
|
||||
</MarketplaceDetails>
|
||||
@@ -0,0 +1,19 @@
|
||||
<Application
|
||||
x:Class="MediaPickerSample.App"
|
||||
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">
|
||||
|
||||
<!--Application Resources-->
|
||||
<Application.Resources>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.ApplicationLifetimeObjects>
|
||||
<!--Required object that handles lifetime events for the application-->
|
||||
<shell:PhoneApplicationService
|
||||
Launching="Application_Launching" Closing="Application_Closing"
|
||||
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||
</Application.ApplicationLifetimeObjects>
|
||||
|
||||
</Application>
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// 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; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard Silverlight initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||
|
||||
// Show the areas of the app that are being redrawn in each frame.
|
||||
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||
|
||||
// Enable non-production analysis visualization mode,
|
||||
// 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.
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is launching (eg, from Start)
|
||||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
// Avoid double-initialization
|
||||
private bool phoneApplicationInitialized = false;
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void InitializePhoneApplication()
|
||||
{
|
||||
if (phoneApplicationInitialized)
|
||||
return;
|
||||
|
||||
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||
// screen to remain active until the application is ready to render.
|
||||
RootFrame = new PhoneApplicationFrame();
|
||||
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||
|
||||
// Handle navigation failures
|
||||
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Set the root visual to allow the application to render
|
||||
if (RootVisual != RootFrame)
|
||||
RootVisual = RootFrame;
|
||||
|
||||
// Remove this handler since it is no longer needed
|
||||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
public class DelegatedCommand
|
||||
: ICommand
|
||||
{
|
||||
public DelegatedCommand (Action<object> execute, Func<object, bool> canExecute)
|
||||
{
|
||||
if (execute == null)
|
||||
throw new ArgumentNullException ("execute");
|
||||
if (canExecute == null)
|
||||
throw new ArgumentNullException ("canExecute");
|
||||
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public void ChangeCanExecute()
|
||||
{
|
||||
var changed = CanExecuteChanged;
|
||||
if (changed != null)
|
||||
changed (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public bool CanExecute (object parameter)
|
||||
{
|
||||
return this.canExecute (parameter);
|
||||
}
|
||||
|
||||
public void Execute (object parameter)
|
||||
{
|
||||
this.execute (parameter);
|
||||
}
|
||||
|
||||
private readonly Action<object> execute;
|
||||
private readonly Func<object, bool> canExecute;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="MediaPickerSample.MainPage"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--TitlePanel contains the name of the application and page title-->
|
||||
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,10">
|
||||
<TextBlock x:Name="ApplicationTitle" Text="Xamarin Mobile API Preview MediaPicker Sample" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
<TextBlock Text="{Binding State}" />
|
||||
</StackPanel>
|
||||
|
||||
<!--ContentPanel - place additional content here-->
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="72" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" >
|
||||
<Button Content="Pick Photo" Width="187" Command="{Binding PickPhoto}" />
|
||||
<Button Content="Take Photo" Width="187" Command="{Binding TakePhoto}" />
|
||||
</StackPanel>
|
||||
|
||||
<Image Grid.Row="1" Name="image" Source="{Binding Image}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</phone:PhoneApplicationPage>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Microsoft.Phone.Controls;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
public partial class MainPage : PhoneApplicationPage
|
||||
{
|
||||
public MainPage()
|
||||
{
|
||||
DataContext = new MainPageViewModel();
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Xamarin.Media;
|
||||
|
||||
namespace MediaPickerSample
|
||||
{
|
||||
public class MainPageViewModel
|
||||
: INotifyPropertyChanged
|
||||
{
|
||||
public MainPageViewModel()
|
||||
{
|
||||
TakePhoto = new DelegatedCommand (TakePhotoHandler, s => this.picker.PhotosSupported && this.picker.IsCameraAvailable);
|
||||
PickPhoto = new DelegatedCommand (PickPhotoHandler, s => this.picker.PhotosSupported);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private string state;
|
||||
public string State
|
||||
{
|
||||
get { return this.state; }
|
||||
private set
|
||||
{
|
||||
if (this.state == value)
|
||||
return;
|
||||
|
||||
this.state = value;
|
||||
OnPropertyChanged ("State");
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand TakePhoto
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand PickPhoto
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private BitmapImage image;
|
||||
public BitmapImage Image
|
||||
{
|
||||
get { return this.image; }
|
||||
private set
|
||||
{
|
||||
if (this.image == value)
|
||||
return;
|
||||
|
||||
this.image = value;
|
||||
OnPropertyChanged ("Image");
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaPicker picker = new MediaPicker();
|
||||
|
||||
private async void TakePhotoHandler (object state)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MediaFile file = await this.picker.TakePhotoAsync (new StoreCameraMediaOptions()))
|
||||
{
|
||||
State = file.Path;
|
||||
Image = new BitmapImage();
|
||||
Image.SetSource (file.GetStream());
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
State = "Canceled";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
State = "Error: " + ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private async void PickPhotoHandler (object state)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MediaFile file = await this.picker.PickPhotoAsync())
|
||||
{
|
||||
State = file.Path;
|
||||
Image = new BitmapImage();
|
||||
Image.SetSource (file.GetStream());
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
State = "Canceled";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
State = "Error: " + ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged (string name)
|
||||
{
|
||||
var changed = PropertyChanged;
|
||||
if (changed != null)
|
||||
changed (this, new PropertyChangedEventArgs (name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{3CA309F2-2454-4944-B13F-A5EB549A7636}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MediaPickerSample</RootNamespace>
|
||||
<AssemblyName>MediaPickerSample</AssemblyName>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>
|
||||
</SilverlightVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<SilverlightApplication>true</SilverlightApplication>
|
||||
<SupportedCultures>
|
||||
</SupportedCultures>
|
||||
<XapOutputs>true</XapOutputs>
|
||||
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||
<XapFilename>MediaPickerSample_$(Configuration)_$(Platform).xap</XapFilename>
|
||||
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||
<SilverlightAppEntry>MediaPickerSample.App</SilverlightAppEntry>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>
|
||||
</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DelegatedCommand.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPageViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AppManifest.xml" />
|
||||
<None Include="Properties\WMAppManifest.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Background.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SplashScreenImage.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Xamarin.Mobile\Xamarin.Mobile.csproj">
|
||||
<Project>{2F184B4A-9A80-4097-92C4-2F93DCB0D6E4}</Project>
|
||||
<Name>Xamarin.Mobile %28Windows Phone 8\Xamarin.Mobile%29</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ProjectExtensions />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
<Deployment.Parts>
|
||||
</Deployment.Parts>
|
||||
</Deployment>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MediaPickerSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Xamarin Inc.")]
|
||||
[assembly: AssemblyProduct("MediaPickerSample")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 Xamarin Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("201b5694-2200-409f-8fb0-29217df53f30")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
|
||||
<DefaultLanguage xmlns="" code="" />
|
||||
<App xmlns="" ProductID="{3104558f-49da-4a99-8e00-e1492915df05}" Title="MediaPickerSample" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="MediaPickerSample author" Description="Sample description" Publisher="MediaPickerSample" PublisherID="{6ea44473-9fb0-4593-960b-ea21024a7387}">
|
||||
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_GAMERSERVICES" />
|
||||
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
|
||||
<Capability Name="ID_CAP_IDENTITY_USER" />
|
||||
<Capability Name="ID_CAP_LOCATION" />
|
||||
<Capability Name="ID_CAP_MICROPHONE" />
|
||||
<Capability Name="ID_CAP_NETWORKING" />
|
||||
<Capability Name="ID_CAP_PHONEDIALER" />
|
||||
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
|
||||
<Capability Name="ID_CAP_SENSORS" />
|
||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
||||
<Capability Name="ID_CAP_ISV_CAMERA" />
|
||||
<Capability Name="ID_CAP_CONTACTS" />
|
||||
<Capability Name="ID_CAP_APPOINTMENTS" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="MediaPickerSampleToken" TaskName="_default">
|
||||
<TemplateFlip>
|
||||
<SmallImageURI IsResource="false" IsRelative="true">Background.png</SmallImageURI>
|
||||
<Count>0</Count>
|
||||
<BackgroundImageURI IsResource="false" IsRelative="true">Background.png</BackgroundImageURI>
|
||||
<Title>MediaPickerSample</Title>
|
||||
<BackContent></BackContent>
|
||||
<BackBackgroundImageURI></BackBackgroundImageURI>
|
||||
<BackTitle></BackTitle>
|
||||
<LargeBackgroundImageURI></LargeBackgroundImageURI>
|
||||
<LargeBackContent></LargeBackContent>
|
||||
<LargeBackBackgroundImageURI></LargeBackBackgroundImageURI>
|
||||
<DeviceLockImageURI></DeviceLockImageURI>
|
||||
<HasLarge>false</HasLarge>
|
||||
</TemplateFlip>
|
||||
</PrimaryToken>
|
||||
</Tokens>
|
||||
<ScreenResolutions>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
|
||||
</ScreenResolutions>
|
||||
</App>
|
||||
</Deployment>
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,38 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContactsSample", "ContactsSample\ContactsSample.csproj", "{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeolocationSample", "GeolocationSample\GeolocationSample.csproj", "{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaPickerSample", "MediaPickerSample\MediaPickerSample.csproj", "{B945D6E7-2A66-446A-A8DB-1673D90D74B0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B1C0A14A-7709-4FE7-B049-1B2AEB25E737}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F63C9A93-F120-4418-AB30-BCB3FA6E57BA}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{B945D6E7-2A66-446A-A8DB-1673D90D74B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B945D6E7-2A66-446A-A8DB-1673D90D74B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B945D6E7-2A66-446A-A8DB-1673D90D74B0}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{B945D6E7-2A66-446A-A8DB-1673D90D74B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B945D6E7-2A66-446A-A8DB-1673D90D74B0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B945D6E7-2A66-446A-A8DB-1673D90D74B0}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,20 @@
|
||||
<Application
|
||||
x:Class="GeolocationSample.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:GeolocationSample">
|
||||
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!--
|
||||
Styles that define common aspects of the platform look and feel
|
||||
Required by Visual Studio project and item templates
|
||||
-->
|
||||
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used when the application is launched to open a specific file, to display
|
||||
/// search results, and so forth.
|
||||
/// </summary>
|
||||
/// <param name="args">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
// Do not repeat app initialization when already running, just ensure that
|
||||
// the window is active
|
||||
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
|
||||
{
|
||||
Window.Current.Activate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Create a Frame to act navigation context and navigate to the first page
|
||||
var rootFrame = new Frame();
|
||||
if (!rootFrame.Navigate(typeof(MainPage)))
|
||||
{
|
||||
throw new Exception("Failed to create initial page");
|
||||
}
|
||||
|
||||
// Place the frame in the current Window and ensure that it is active
|
||||
Window.Current.Content = rootFrame;
|
||||
Window.Current.Activate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 801 B |
|
After Width: | Height: | Size: 329 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 429 B |
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GeolocationSample
|
||||
{
|
||||
public class DelegatedCommand
|
||||
: ICommand
|
||||
{
|
||||
public DelegatedCommand (Action<object> execute, Func<object, bool> canExecute)
|
||||
{
|
||||
if (execute == null)
|
||||
throw new ArgumentNullException ("execute");
|
||||
if (canExecute == null)
|
||||
throw new ArgumentNullException ("canExecute");
|
||||
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public void ChangeCanExecute()
|
||||
{
|
||||
var changed = CanExecuteChanged;
|
||||
if (changed != null)
|
||||
changed (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public bool CanExecute (object parameter)
|
||||
{
|
||||
return this.canExecute (parameter);
|
||||
}
|
||||
|
||||
public void Execute (object parameter)
|
||||
{
|
||||
this.execute (parameter);
|
||||
}
|
||||
|
||||
private readonly Action<object> execute;
|
||||
private readonly Func<object, bool> canExecute;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6597A270-F580-43DA-93EE-2B78473EECB3}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>GeolocationSample</RootNamespace>
|
||||
<AssemblyName>GeolocationSample</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>GeolocationSample_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<PackageCertificateThumbprint>B4698CA8814E001DD9CC5B7E78B487DE2EDD6B6F</PackageCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DelegatedCommand.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPageViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="GeolocationSample_TemporaryKey.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\Logo.png" />
|
||||
<Content Include="Assets\SmallLogo.png" />
|
||||
<Content Include="Assets\SplashScreen.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Common\StandardStyles.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Xamarin.Mobile\Xamarin.Mobile.csproj">
|
||||
<Project>{92076adc-fbd8-4f34-b01a-40d5fa369b8d}</Project>
|
||||
<Name>Xamarin.Mobile %28WindowsRT\Xamarin.Mobile%29</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -0,0 +1,74 @@
|
||||
<Page
|
||||
x:Class="GeolocationSample.MainPage"
|
||||
IsTabStop="false"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:GeolocationSample"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Style="{StaticResource LayoutRootStyle}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Text="Geolocation Sample" Style="{StaticResource HeaderTextStyle}" Margin="12,20,0,20" />
|
||||
|
||||
<Grid Grid.Row="1" Margin="12,0,12,0">
|
||||
<Grid.Resources>
|
||||
<Style TargetType="TextBlock" BasedOn="{StaticResource BaselineTextStyle}" />
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40*" />
|
||||
<ColumnDefinition Width="60*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Command="{Binding GetPosition}">Get Location</Button>
|
||||
<Button Command="{Binding ToggleListening}">Toggle Listening</Button>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0">Status:</TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Status}" />
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0">Time:</TextBlock>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CurrentPosition.Timestamp}" />
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0">Latitude:</TextBlock>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CurrentPosition.Latitude}" />
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0">Longitude:</TextBlock>
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding CurrentPosition.Longitude}" />
|
||||
|
||||
<TextBlock Grid.Row="5" Grid.Column="0">Accuracy:</TextBlock>
|
||||
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding CurrentPosition.Accuracy}" />
|
||||
|
||||
<TextBlock Grid.Row="6" Grid.Column="0">Heading:</TextBlock>
|
||||
<TextBlock Grid.Row="6" Grid.Column="1" Text="{Binding CurrentPosition.Heading}" />
|
||||
|
||||
<TextBlock Grid.Row="7" Grid.Column="0">Altitude:</TextBlock>
|
||||
<TextBlock Grid.Row="7" Grid.Column="1" Text="{Binding CurrentPosition.Altitude}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Grid.Column="0">Altitude Accuracy:</TextBlock>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Text="{Binding CurrentPosition.AltitudeAccuracy}" />
|
||||
|
||||
<TextBlock Grid.Row="9" Grid.Column="0">Speed:</TextBlock>
|
||||
<TextBlock Grid.Row="9" Grid.Column="1" Text="{Binding CurrentPosition.Speed}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||