[iOS7] Add new samples
|
@ -0,0 +1,42 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirLocate", "AirLocate\AirLocate.csproj", "{718D5D6E-871A-4A42-9867-3D1F0552B0F4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Release|iPhone = Release|iPhone
|
||||
Ad-Hoc|iPhone = Ad-Hoc|iPhone
|
||||
AppStore|iPhone = AppStore|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{718D5D6E-871A-4A42-9867-3D1F0552B0F4}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = AirLocate\AirLocate.csproj
|
||||
Policies = $0
|
||||
$0.TextStylePolicy = $1
|
||||
$1.inheritsSet = null
|
||||
$1.scope = text/x-csharp
|
||||
$0.CSharpFormattingPolicy = $2
|
||||
$2.ElseIfNewLinePlacement = SameLine
|
||||
$2.AfterDelegateDeclarationParameterComma = True
|
||||
$2.inheritsSet = Mono
|
||||
$2.inheritsScope = text/x-csharp
|
||||
$2.scope = text/x-csharp
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,134 @@
|
|||
<?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)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{718D5D6E-871A-4A42-9867-3D1F0552B0F4}</ProjectGuid>
|
||||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>AirLocate</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>AirLocation</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<IpaPackageName>
|
||||
</IpaPackageName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="monotouch" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="MenuViewController.cs" />
|
||||
<Compile Include="MenuViewController.designer.cs">
|
||||
<DependentUpon>MenuViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MonitoringViewController.cs" />
|
||||
<Compile Include="MonitoringViewController.designer.cs">
|
||||
<DependentUpon>MonitoringViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ConfigurationViewController.cs" />
|
||||
<Compile Include="ConfigurationViewController.designer.cs">
|
||||
<DependentUpon>ConfigurationViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Defaults.cs" />
|
||||
<Compile Include="RangingViewController.cs" />
|
||||
<Compile Include="RangingViewController.designer.cs">
|
||||
<DependentUpon>RangingViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CalibrationCalculator.cs" />
|
||||
<Compile Include="CalibrationEndViewController.cs" />
|
||||
<Compile Include="CalibrationBeginViewController.cs" />
|
||||
<Compile Include="UuidPickerView.cs" />
|
||||
<Compile Include="Helpers.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="MainStoryboard.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\Icon.png" />
|
||||
<BundleResource Include="Resources\Icon%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-72.png" />
|
||||
<BundleResource Include="Resources\Icon-Small.png" />
|
||||
<BundleResource Include="Resources\Icon-Small%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small-50.png" />
|
||||
<BundleResource Include="Resources\Default.png" />
|
||||
<BundleResource Include="Resources\Default%402x.png" />
|
||||
<BundleResource Include="Resources\Default-568h%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork" />
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork%402x" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
[Register ("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate {
|
||||
|
||||
CLLocationManager locationManager;
|
||||
|
||||
public override UIWindow Window {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override void FinishedLaunching (UIApplication application)
|
||||
{
|
||||
locationManager = new CLLocationManager ();
|
||||
|
||||
// A user can transition in or out of a region while the application is not running.
|
||||
// When this happens CoreLocation will launch the application momentarily, call this delegate method
|
||||
// and we will let the user know via a local notification.
|
||||
locationManager.DidDetermineState += (sender, e) => {
|
||||
string body = null;
|
||||
if (e.State == CLRegionState.Inside)
|
||||
body = "You're inside the region";
|
||||
else if (e.State == CLRegionState.Outside)
|
||||
body = "You're outside the region";
|
||||
|
||||
if (body != null) {
|
||||
var notification = new UILocalNotification () { AlertBody = body };
|
||||
|
||||
// If the application is in the foreground, it will get called back to ReceivedLocalNotification
|
||||
// If its not, iOS will display the notification to the user.
|
||||
UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void ReceivedLocalNotification (UIApplication application, UILocalNotification notification)
|
||||
{
|
||||
// If the application is in the foreground, we will notify the user of the region's state via an alert.
|
||||
new UIAlertView (notification.AlertBody, String.Empty, null, "OK", null).Show ();
|
||||
}
|
||||
|
||||
static void Main (string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public partial class CalibrationBeginViewController : UITableViewController {
|
||||
|
||||
List<CLBeacon> [] beacons;
|
||||
CLLocationManager locationManager;
|
||||
List<CLBeaconRegion> rangedRegions;
|
||||
bool inProgress;
|
||||
|
||||
CalibrationCalculator calculator;
|
||||
CalibrationEndViewController endViewController;
|
||||
UIProgressView progressBar;
|
||||
|
||||
public CalibrationBeginViewController (UITableViewStyle style) : base (style)
|
||||
{
|
||||
Unknowns = new List<CLBeacon> ();
|
||||
Immediates = new List<CLBeacon> ();
|
||||
Nears = new List<CLBeacon> ();
|
||||
Fars = new List<CLBeacon> ();
|
||||
beacons = new List<CLBeacon> [4] { Unknowns, Immediates, Nears, Fars };
|
||||
// This location manager will be used to display beacons available for calibration.
|
||||
locationManager = new CLLocationManager ();
|
||||
locationManager.DidRangeBeacons += HandleDidRangeBeacons;
|
||||
}
|
||||
|
||||
List<CLBeacon> Unknowns { get; set; }
|
||||
List<CLBeacon> Immediates { get; set; }
|
||||
List<CLBeacon> Nears { get; set; }
|
||||
List<CLBeacon> Fars { get; set; }
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
Title = "Calibration";
|
||||
|
||||
progressBar = new UIProgressView (UIProgressViewStyle.Default) {
|
||||
AutoresizingMask = UIViewAutoresizing.FlexibleMargins
|
||||
};
|
||||
|
||||
// Populate the regions for the beacons we're interested in calibrating.
|
||||
rangedRegions = new List<CLBeaconRegion> ();
|
||||
|
||||
foreach (NSUuid uuid in Defaults.SupportedProximityUuids) {
|
||||
var region = new CLBeaconRegion (uuid, uuid.AsString ());
|
||||
rangedRegions.Add (region);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ViewWillAppear (bool animated)
|
||||
{
|
||||
base.ViewWillAppear (animated);
|
||||
// Start ranging to show the beacons available for calibration.
|
||||
StartRangingAllRegions ();
|
||||
}
|
||||
|
||||
public override void ViewWillDisappear (bool animated)
|
||||
{
|
||||
// Cancel calibration (if it was started) and stop ranging when the view goes away.
|
||||
if(inProgress)
|
||||
calculator.CancelCalibration ();
|
||||
|
||||
StopRangingAllRegions ();
|
||||
base.ViewWillDisappear (animated);
|
||||
}
|
||||
|
||||
// empty section are not shown in TableView so we must exclude them
|
||||
int GetNonEmptySection (int section)
|
||||
{
|
||||
if (inProgress)
|
||||
section--;
|
||||
int current = 0;
|
||||
foreach (var group in beacons) {
|
||||
if (group.Count > 0) {
|
||||
if (section-- == 0)
|
||||
return current;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override int NumberOfSections (UITableView tableView)
|
||||
{
|
||||
// return Unknown + Immediate + Near + Far if any beacon in each
|
||||
int sections = 0;
|
||||
foreach (var group in beacons) {
|
||||
if (group.Count > 0)
|
||||
sections++;
|
||||
}
|
||||
if (inProgress)
|
||||
sections++;
|
||||
return sections;
|
||||
}
|
||||
|
||||
public override int RowsInSection (UITableView tableview, int section)
|
||||
{
|
||||
if (inProgress && (section == 0))
|
||||
return 1;
|
||||
return beacons [GetNonEmptySection (section)].Count;
|
||||
}
|
||||
|
||||
public override string TitleForHeader (UITableView tableView, int section)
|
||||
{
|
||||
// the first section has no title when the progress bar is shown
|
||||
if (((section == 0) && inProgress) || (NumberOfSections (tableView) == 0))
|
||||
return null;
|
||||
|
||||
return ((CLProximity) GetNonEmptySection (section)).ToString ();
|
||||
}
|
||||
|
||||
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
int i = indexPath.Section;
|
||||
string identifier = inProgress && i == 0 ? "ProgressCell" : "BeaconCell";
|
||||
|
||||
UITableViewCell cell = tableView.DequeueReusableCell (identifier);
|
||||
if (cell == null) {
|
||||
// Show the indicator that denotes calibration is in progress.
|
||||
if (identifier == "ProgressCell") {
|
||||
cell = new UITableViewCell (UITableViewCellStyle.Default, identifier) {
|
||||
SelectionStyle = UITableViewCellSelectionStyle.None
|
||||
};
|
||||
|
||||
progressBar.Center = new PointF (cell.Center.X, 17.0f);
|
||||
cell.ContentView.AddSubview (progressBar);
|
||||
|
||||
UILabel label = new UILabel (new RectangleF (0.0f, 0.0f, 300.0f, 15.0f)) {
|
||||
AutoresizingMask = UIViewAutoresizing.FlexibleMargins,
|
||||
BackgroundColor = UIColor.Clear,
|
||||
Center = new PointF (cell.Center.X, 30.0f),
|
||||
Font = UIFont.SystemFontOfSize (11.0f),
|
||||
Text = "Wave device side-to-side 1m away from beacon",
|
||||
TextAlignment = UITextAlignment.Center,
|
||||
TextColor = UIColor.DarkGray
|
||||
};
|
||||
cell.ContentView.AddSubview (label);
|
||||
} else {
|
||||
cell = new UITableViewCell (UITableViewCellStyle.Subtitle, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
if (identifier == "ProgressCell")
|
||||
return cell;
|
||||
|
||||
CLBeacon beacon = beacons [GetNonEmptySection (indexPath.Section)] [indexPath.Row];
|
||||
|
||||
cell.TextLabel.Text = beacon.ProximityUuid.AsString ();
|
||||
cell.TextLabel.Font = UIFont.SystemFontOfSize (20.0f);
|
||||
cell.DetailTextLabel.Text = String.Format ("Major: {0} Minor: {1} Acc: {2:0.00}m",
|
||||
beacon.Major, beacon.Minor, beacon.Accuracy);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
if (inProgress)
|
||||
return;
|
||||
|
||||
CLBeacon beacon = beacons [GetNonEmptySection (indexPath.Section)] [indexPath.Row];
|
||||
CLBeaconRegion region = Helpers.CreateRegion (beacon.ProximityUuid, beacon.Major, beacon.Minor);
|
||||
if (region == null)
|
||||
return;
|
||||
|
||||
// We can stop ranging to display beacons available for calibration.
|
||||
StopRangingAllRegions ();
|
||||
// And we'll start the calibration process.
|
||||
calculator = new CalibrationCalculator (region, CompletionHandler);
|
||||
calculator.PerformCalibration ((sender,e) => {
|
||||
progressBar.SetProgress (e.PercentComplete, true);
|
||||
});
|
||||
|
||||
progressBar.Progress = 0.0f;
|
||||
inProgress = true;
|
||||
TableView.ReloadData ();
|
||||
}
|
||||
|
||||
void CompletionHandler (object sender, CalibrationCompletedEventArgs e)
|
||||
{
|
||||
if (e.Error != null) {
|
||||
if (View.Window != null) {
|
||||
var message = e.Error.UserInfo [NSError.LocalizedDescriptionKey].ToString ();
|
||||
new UIAlertView ("Unable to calibrate device", message, null, "OK", null).Show ();
|
||||
StartRangingAllRegions ();
|
||||
}
|
||||
} else {
|
||||
endViewController = new CalibrationEndViewController (e.MeasurePower);
|
||||
NavigationController.PushViewController (endViewController, true);
|
||||
}
|
||||
|
||||
inProgress = false;
|
||||
calculator = null;
|
||||
TableView.ReloadData ();
|
||||
}
|
||||
|
||||
void StartRangingAllRegions ()
|
||||
{
|
||||
foreach (CLBeaconRegion region in rangedRegions)
|
||||
locationManager.StartRangingBeacons (region);
|
||||
}
|
||||
|
||||
void StopRangingAllRegions ()
|
||||
{
|
||||
foreach (CLBeaconRegion region in rangedRegions)
|
||||
locationManager.StopRangingBeacons (region);
|
||||
}
|
||||
|
||||
void HandleDidRangeBeacons (object sender, CLRegionBeaconsRangedEventArgs e)
|
||||
{
|
||||
Unknowns.Clear ();
|
||||
Immediates.Clear ();
|
||||
Nears.Clear ();
|
||||
Fars.Clear ();
|
||||
|
||||
foreach (CLBeacon beacon in e.Beacons) {
|
||||
switch (beacon.Proximity) {
|
||||
case CLProximity.Immediate:
|
||||
Immediates.Add (beacon);
|
||||
break;
|
||||
case CLProximity.Near:
|
||||
Nears.Add (beacon);
|
||||
break;
|
||||
case CLProximity.Far:
|
||||
Fars.Add (beacon);
|
||||
break;
|
||||
case CLProximity.Unknown:
|
||||
Unknowns.Add (beacon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TableView.ReloadData ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using MonoTouch.CoreFoundation;
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public class CalibrationCompletedEventArgs : EventArgs {
|
||||
|
||||
public int MeasurePower { get; set; }
|
||||
public NSError Error { get; set; }
|
||||
}
|
||||
|
||||
public class CalibrationProgressEventArgs : EventArgs {
|
||||
|
||||
public float PercentComplete { get; set; }
|
||||
}
|
||||
|
||||
public class CalibrationCancelledError : NSError {
|
||||
|
||||
static NSString ErrorDomain = new NSString (Defaults.Identifier);
|
||||
|
||||
public CalibrationCancelledError () :
|
||||
base (ErrorDomain, 2, new NSDictionary ("Calibration was cancelled", NSError.LocalizedDescriptionKey))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class CalibrationCalculator {
|
||||
|
||||
static NSString Rssi = new NSString ("rssi");
|
||||
|
||||
CLLocationManager locationManager;
|
||||
CLBeaconRegion region;
|
||||
bool isCalibrating;
|
||||
NSTimer timer;
|
||||
List<CLBeacon[]> rangedBeacons;
|
||||
float percentComplete;
|
||||
|
||||
public event EventHandler<CalibrationCompletedEventArgs> CalibrationCompletionHandler;
|
||||
public event EventHandler<CalibrationProgressEventArgs> ProgressHandler;
|
||||
|
||||
public CalibrationCalculator (CLBeaconRegion region, EventHandler<CalibrationCompletedEventArgs> handler)
|
||||
{
|
||||
this.region = region;
|
||||
rangedBeacons = new List<CLBeacon[]> ();
|
||||
CalibrationCompletionHandler = handler;
|
||||
|
||||
locationManager = new CLLocationManager ();
|
||||
locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
|
||||
rangedBeacons.Add (e.Beacons);
|
||||
var progress = ProgressHandler;
|
||||
if (progress != null) {
|
||||
DispatchQueue.MainQueue.DispatchAsync (delegate {
|
||||
percentComplete += 1.0f / 20.0f;
|
||||
progress (this, new CalibrationProgressEventArgs () { PercentComplete = percentComplete });
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void CancelCalibration ()
|
||||
{
|
||||
if (isCalibrating) {
|
||||
isCalibrating = false;
|
||||
timer.Fire ();
|
||||
}
|
||||
}
|
||||
|
||||
public void PerformCalibration (EventHandler<CalibrationProgressEventArgs> handler)
|
||||
{
|
||||
if (!isCalibrating) {
|
||||
isCalibrating = true;
|
||||
rangedBeacons.Clear ();
|
||||
percentComplete = 0.0f;
|
||||
|
||||
ProgressHandler = handler;
|
||||
|
||||
locationManager.StartRangingBeacons (region);
|
||||
timer = NSTimer.CreateTimer (20.0f, new NSAction (delegate {
|
||||
locationManager.StopRangingBeacons (region);
|
||||
|
||||
DispatchQueue.DefaultGlobalQueue.DispatchAsync (new NSAction (delegate {
|
||||
NSError error = null;
|
||||
List<CLBeacon> allBeacons = new List<CLBeacon> ();
|
||||
int measuredPower = 0;
|
||||
if (!isCalibrating) {
|
||||
error = new CalibrationCancelledError ();
|
||||
} else {
|
||||
foreach (CLBeacon[] beacons in rangedBeacons) {
|
||||
if (beacons.Length > 1) {
|
||||
error = new CalibrationCancelledError ();
|
||||
break;
|
||||
} else {
|
||||
allBeacons.AddRange (beacons);
|
||||
}
|
||||
}
|
||||
|
||||
if (allBeacons.Count == 0) {
|
||||
error = new CalibrationCancelledError ();
|
||||
} else {
|
||||
allBeacons.Sort (delegate (CLBeacon x, CLBeacon y) {
|
||||
return (x.ValueForKey (Rssi) as NSNumber).CompareTo (y.ValueForKey (Rssi));
|
||||
});
|
||||
float power = 0;
|
||||
int number = 0;
|
||||
int outlierPadding = (int) (allBeacons.Count * 0.1f);
|
||||
for (int k = outlierPadding; k < allBeacons.Count - (outlierPadding * 2); k++) {
|
||||
power += ((NSNumber) allBeacons[k].ValueForKey (Rssi)).FloatValue;
|
||||
number ++;
|
||||
}
|
||||
measuredPower = (int) power/number;
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.MainQueue.DispatchAsync (delegate {
|
||||
CalibrationCompletionHandler (this, new CalibrationCompletedEventArgs () {
|
||||
MeasurePower = measuredPower,
|
||||
Error = error
|
||||
});
|
||||
});
|
||||
|
||||
isCalibrating = false;
|
||||
rangedBeacons.Clear ();
|
||||
}));
|
||||
}));
|
||||
NSRunLoop.Current.AddTimer (timer, NSRunLoopMode.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public class CalibrationEndViewController : UIViewController {
|
||||
|
||||
int measured_power;
|
||||
|
||||
public CalibrationEndViewController (int measuredPower)
|
||||
{
|
||||
measured_power = measuredPower;
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
View.BackgroundColor = UIColor.White;
|
||||
|
||||
var measuredPowerLabel = new UILabel (new RectangleF (0, 0, View.Bounds.Width, View.Bounds.Height)) {
|
||||
AutoresizingMask = UIViewAutoresizing.FlexibleMargins,
|
||||
Font = UIFont.SystemFontOfSize (32.0f),
|
||||
TextAlignment = UITextAlignment.Center,
|
||||
Text = measured_power.ToString ()
|
||||
};
|
||||
View.AddSubview (measuredPowerLabel);
|
||||
|
||||
var doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done);
|
||||
doneButton.Clicked += (sender, e) => {
|
||||
NavigationController.PopViewControllerAnimated (true);
|
||||
};
|
||||
|
||||
NavigationItem.RightBarButtonItem = doneButton;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
using System;
|
||||
using MonoTouch.CoreBluetooth;
|
||||
using MonoTouch.CoreFoundation;
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
class PeripheralManagerDelegate : CBPeripheralManagerDelegate {
|
||||
|
||||
public override void StateUpdated (CBPeripheralManager peripheral)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ConfigurationViewController : UITableViewController {
|
||||
|
||||
bool enabled;
|
||||
NSUuid uuid;
|
||||
NSNumber major;
|
||||
NSNumber minor;
|
||||
NSNumber power;
|
||||
|
||||
CBPeripheralManager peripheralManager;
|
||||
NSNumberFormatter numberFormatter;
|
||||
UIBarButtonItem doneButton;
|
||||
UIBarButtonItem saveButton;
|
||||
|
||||
public ConfigurationViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
var peripheralDelegate = new PeripheralManagerDelegate ();
|
||||
peripheralManager = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue);
|
||||
numberFormatter = new NSNumberFormatter () {
|
||||
NumberStyle = NSNumberFormatterStyle.Decimal
|
||||
};
|
||||
uuid = Defaults.DefaultProximityUuid;
|
||||
power = Defaults.DefaultPower;
|
||||
}
|
||||
|
||||
public override void ViewWillAppear (bool animated)
|
||||
{
|
||||
enabled = enabledSwitch.On = peripheralManager.Advertising;
|
||||
base.ViewWillAppear (animated);
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
this.Title = "Configure";
|
||||
|
||||
enabledSwitch.ValueChanged += (sender, e) => {
|
||||
enabled = enabledSwitch.On;
|
||||
};
|
||||
|
||||
uuidTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
uuidTextField.InputView = new UuidPickerView (uuidTextField);
|
||||
uuidTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
uuidTextField.EditingDidEnd += (sender, e) => {
|
||||
uuid = new NSUuid (uuidTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
uuidTextField.Text = uuid.AsString ();
|
||||
|
||||
majorTextField.KeyboardType = UIKeyboardType.NumberPad;
|
||||
majorTextField.ReturnKeyType = UIReturnKeyType.Done;
|
||||
majorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
majorTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
majorTextField.EditingDidEnd += (sender, e) => {
|
||||
major = numberFormatter.NumberFromString (majorTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
|
||||
minorTextField.KeyboardType = UIKeyboardType.NumberPad;
|
||||
minorTextField.ReturnKeyType = UIReturnKeyType.Done;
|
||||
minorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
minorTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
minorTextField.EditingDidEnd += (sender, e) => {
|
||||
minor = numberFormatter.NumberFromString (minorTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
|
||||
measuredPowerTextField.KeyboardType = UIKeyboardType.NumberPad;
|
||||
measuredPowerTextField.ReturnKeyType = UIReturnKeyType.Done;
|
||||
measuredPowerTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
measuredPowerTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
measuredPowerTextField.EditingDidEnd += (sender, e) => {
|
||||
power = numberFormatter.NumberFromString (measuredPowerTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
|
||||
doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done, (sender, e) => {
|
||||
uuidTextField.ResignFirstResponder ();
|
||||
majorTextField.ResignFirstResponder ();
|
||||
minorTextField.ResignFirstResponder ();
|
||||
measuredPowerTextField.ResignFirstResponder ();
|
||||
TableView.ReloadData ();
|
||||
});
|
||||
|
||||
saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender, e) => {
|
||||
if (peripheralManager.State < CBPeripheralManagerState.PoweredOn) {
|
||||
new UIAlertView ("Bluetooth must be enabled", "To configure your device as a beacon", null, "OK", null).Show ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
CLBeaconRegion region = Helpers.CreateRegion (uuid, major, minor);
|
||||
if (region != null)
|
||||
peripheralManager.StartAdvertising (region.GetPeripheralData (power));
|
||||
} else {
|
||||
peripheralManager.StopAdvertising ();
|
||||
}
|
||||
|
||||
NavigationController.PopViewControllerAnimated (true);
|
||||
});
|
||||
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
}
|
||||
|
||||
// identical code share across all UITextField
|
||||
void HandleEditingDidBegin (object sender, EventArgs e)
|
||||
{
|
||||
NavigationItem.RightBarButtonItem = doneButton;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using MonoTouch.Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AirLocate
|
||||
{
|
||||
[Register ("ConfigurationViewController")]
|
||||
partial class ConfigurationViewController
|
||||
{
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UISwitch enabledSwitch { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField majorTextField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField measuredPowerTextField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField minorTextField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField uuidTextField { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (majorTextField != null) {
|
||||
majorTextField.Dispose ();
|
||||
majorTextField = null;
|
||||
}
|
||||
|
||||
if (minorTextField != null) {
|
||||
minorTextField.Dispose ();
|
||||
minorTextField = null;
|
||||
}
|
||||
|
||||
if (measuredPowerTextField != null) {
|
||||
measuredPowerTextField.Dispose ();
|
||||
measuredPowerTextField = null;
|
||||
}
|
||||
|
||||
if (enabledSwitch != null) {
|
||||
enabledSwitch.Dispose ();
|
||||
enabledSwitch = null;
|
||||
}
|
||||
|
||||
if (uuidTextField != null) {
|
||||
uuidTextField.Dispose ();
|
||||
uuidTextField = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public static class Defaults {
|
||||
|
||||
static NSUuid[] supportedProximityUuids;
|
||||
static NSNumber defaultPower;
|
||||
|
||||
static Defaults ()
|
||||
{
|
||||
supportedProximityUuids = new NSUuid [] {
|
||||
new NSUuid ("E2C56DB5-DFFB-48D2-B060-D0F5A71096E0"),
|
||||
new NSUuid ("5A4BCFCE-174E-4BAC-A814-092E77F6B7E5"),
|
||||
new NSUuid ("74278BDA-B644-4520-8F0C-720EAF059935")
|
||||
};
|
||||
defaultPower = new NSNumber (-59);
|
||||
}
|
||||
|
||||
static public string Identifier {
|
||||
get { return "com.apple.AirLocate"; }
|
||||
}
|
||||
|
||||
static public NSUuid DefaultProximityUuid {
|
||||
get { return supportedProximityUuids [0]; }
|
||||
}
|
||||
|
||||
static public IList<NSUuid> SupportedProximityUuids {
|
||||
get { return supportedProximityUuids; }
|
||||
}
|
||||
|
||||
static public NSNumber DefaultPower {
|
||||
get { return defaultPower; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public static class Helpers {
|
||||
|
||||
// create the CLBeaconRegion using the right contructor, returns null if input is invalid (no exceptions)
|
||||
public static CLBeaconRegion CreateRegion (NSUuid uuid, NSNumber major, NSNumber minor)
|
||||
{
|
||||
if (uuid == null)
|
||||
return null;
|
||||
if (minor == null) {
|
||||
if (major == null)
|
||||
return new CLBeaconRegion (uuid, Defaults.Identifier);
|
||||
else
|
||||
return new CLBeaconRegion (uuid, major.UInt16Value, Defaults.Identifier);
|
||||
} else if (major != null) {
|
||||
return new CLBeaconRegion (uuid, major.UInt16Value, minor.UInt16Value, Defaults.Identifier);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
</array>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>MainStoryboard</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>7.0</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.apple.AirLocate</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon</string>
|
||||
<string>Icon@2x</string>
|
||||
<string>Icon-72</string>
|
||||
<string>Icon-Small</string>
|
||||
<string>Icon-Small@2x</string>
|
||||
<string>Icon-Small-50</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,561 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4457.9" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="11">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3682.9"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="10">
|
||||
<objects>
|
||||
<navigationController definesPresentationContext="YES" id="11" sceneMemberID="viewController">
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="14">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="24" kind="relationship" relationship="rootViewController" id="1048"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="15" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-1068" y="-1114"/>
|
||||
</scene>
|
||||
<!--Menu View Controller - AirLocate-->
|
||||
<scene sceneID="23">
|
||||
<objects>
|
||||
<tableViewController id="24" customClass="MenuViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" allowsSelectionDuringEditing="YES" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="25">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="416"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<sections>
|
||||
<tableViewSection id="34">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="43" detailTextLabel="44" style="IBUITableViewCellStyleSubtitle" id="35">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Monitoring" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="43">
|
||||
<rect key="frame" x="15" y="2" width="90" height="22"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Monitor a beacon region" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="44">
|
||||
<rect key="frame" x="15" y="24" width="155" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="57" detailTextLabel="58" style="IBUITableViewCellStyleSubtitle" id="36">
|
||||
<rect key="frame" x="0.0" y="44" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Ranging" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="57">
|
||||
<rect key="frame" x="15" y="2" width="70" height="22"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Range beacons around you" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="58">
|
||||
<rect key="frame" x="15" y="24" width="174" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="81" detailTextLabel="82" style="IBUITableViewCellStyleSubtitle" id="37">
|
||||
<rect key="frame" x="0.0" y="88" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Calibration" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="81">
|
||||
<rect key="frame" x="15" y="2" width="91" height="22"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Calibrate the measured power for a beacon" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="82">
|
||||
<rect key="frame" x="15" y="24" width="270" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="150" detailTextLabel="151" style="IBUITableViewCellStyleSubtitle" id="147">
|
||||
<rect key="frame" x="0.0" y="132" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Configuration" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="150">
|
||||
<rect key="frame" x="15" y="2" width="113" height="22"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Configure this iOS device as a beacon" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="151">
|
||||
<rect key="frame" x="15" y="24" width="242" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="0.50196078431372548" green="0.50196078431372548" blue="0.50196078431372548" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="24" id="26"/>
|
||||
<outlet property="delegate" destination="24" id="27"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationItem key="navigationItem" title="AirLocate" id="188"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="29" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-533" y="-1104"/>
|
||||
</scene>
|
||||
<!--Monitoring View Controller - Monitor-->
|
||||
<scene sceneID="313">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="MonitoringViewController" id="314" customClass="MonitoringViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="569">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<sections>
|
||||
<tableViewSection headerTitle="REGION MONITORING" id="581">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="582">
|
||||
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<switch opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" on="YES" id="614">
|
||||
<rect key="frame" x="231" y="8" width="79" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</switch>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Enabled" lineBreakMode="tailTruncation" minimumFontSize="10" id="845">
|
||||
<rect key="frame" x="12" y="12" width="75" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="583">
|
||||
<rect key="frame" x="0.0" y="66" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="UUID" lineBreakMode="tailTruncation" minimumFontSize="10" id="858">
|
||||
<rect key="frame" x="13" y="12" width="45" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" id="903">
|
||||
<rect key="frame" x="96" y="7" width="217" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="584">
|
||||
<rect key="frame" x="0.0" y="110" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Major" lineBreakMode="tailTruncation" minimumFontSize="10" id="920">
|
||||
<rect key="frame" x="14" y="12" width="45" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" id="929">
|
||||
<rect key="frame" x="194" y="7" width="119" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="604">
|
||||
<rect key="frame" x="0.0" y="154" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Minor" lineBreakMode="tailTruncation" minimumFontSize="10" id="960">
|
||||
<rect key="frame" x="14" y="12" width="45" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" id="969">
|
||||
<rect key="frame" x="197" y="7" width="117" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1023">
|
||||
<rect key="frame" x="0.0" y="198" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<switch opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" on="YES" id="1024">
|
||||
<rect key="frame" x="231" y="8" width="79" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</switch>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Notify Entry" lineBreakMode="tailTruncation" minimumFontSize="10" id="1025">
|
||||
<rect key="frame" x="12" y="12" width="111" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1030">
|
||||
<rect key="frame" x="0.0" y="242" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<switch opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" on="YES" id="1031">
|
||||
<rect key="frame" x="231" y="8" width="79" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</switch>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Notify Exit" lineBreakMode="tailTruncation" minimumFontSize="10" id="1032">
|
||||
<rect key="frame" x="12" y="12" width="104" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1037">
|
||||
<rect key="frame" x="0.0" y="286" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<switch opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" on="YES" id="1038">
|
||||
<rect key="frame" x="231" y="8" width="79" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</switch>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Notify Entry Display" lineBreakMode="tailTruncation" minimumFontSize="10" id="1039">
|
||||
<rect key="frame" x="12" y="12" width="167" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
</tableView>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationItem key="navigationItem" title="Monitor" id="457"/>
|
||||
<connections>
|
||||
<outlet property="enabledSwitch" destination="614" id="name-outlet-614"/>
|
||||
<outlet property="majorTextField" destination="929" id="name-outlet-929"/>
|
||||
<outlet property="minorTextField" destination="969" id="name-outlet-969"/>
|
||||
<outlet property="notifyOnDisplaySwitch" destination="1038" id="name-outlet-1038"/>
|
||||
<outlet property="notifyOnEntrySwitch" destination="1024" id="name-outlet-1024"/>
|
||||
<outlet property="notifyOnExitSwitch" destination="1031" id="name-outlet-1031"/>
|
||||
<outlet property="uuidTextField" destination="903" id="name-outlet-903"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="319" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="60" y="-1549"/>
|
||||
</scene>
|
||||
<!--Configuration View Controller-->
|
||||
<scene sceneID="558">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="ConfigurationViewController" id="559" customClass="ConfigurationViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="560">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<sections>
|
||||
<tableViewSection headerTitle="CONFIGURE DEVICE" id="1108">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1109">
|
||||
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Enabled" lineBreakMode="tailTruncation" minimumFontSize="10" id="1125">
|
||||
<rect key="frame" x="14" y="12" width="79" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<switch opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" id="1159">
|
||||
<rect key="frame" x="241" y="8" width="79" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</switch>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1110">
|
||||
<rect key="frame" x="0.0" y="66" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="UUID" lineBreakMode="tailTruncation" minimumFontSize="10" id="1164">
|
||||
<rect key="frame" x="20" y="12" width="45" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="right" minimumFontSize="17" id="1507">
|
||||
<rect key="frame" x="97" y="7" width="218" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1111">
|
||||
<rect key="frame" x="0.0" y="110" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Major" lineBreakMode="tailTruncation" minimumFontSize="10" id="1207">
|
||||
<rect key="frame" x="20" y="12" width="45" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="right" minimumFontSize="17" id="1299">
|
||||
<rect key="frame" x="182" y="7" width="131" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1324">
|
||||
<rect key="frame" x="0.0" y="154" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Minor" lineBreakMode="tailTruncation" minimumFontSize="10" id="1325">
|
||||
<rect key="frame" x="20" y="12" width="45" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="right" minimumFontSize="17" id="1326">
|
||||
<rect key="frame" x="182" y="7" width="131" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="10" style="IBUITableViewCellStyleDefault" id="1351">
|
||||
<rect key="frame" x="0.0" y="198" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Measured Power" lineBreakMode="tailTruncation" minimumFontSize="10" id="1352">
|
||||
<rect key="frame" x="20" y="12" width="139" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="-59" borderStyle="roundedRect" textAlignment="right" minimumFontSize="17" id="1353">
|
||||
<rect key="frame" x="182" y="7" width="131" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="559" id="561"/>
|
||||
<outlet property="delegate" destination="559" id="562"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationItem key="navigationItem" id="Zo9-KN-ivx"/>
|
||||
<connections>
|
||||
<outlet property="enabledSwitch" destination="1159" id="name-outlet-1159"/>
|
||||
<outlet property="majorTextField" destination="1299" id="name-outlet-1299"/>
|
||||
<outlet property="measuredPowerTextField" destination="1353" id="name-outlet-1353"/>
|
||||
<outlet property="minorTextField" destination="1326" id="name-outlet-1326"/>
|
||||
<outlet property="uuidTextField" destination="1507" id="name-outlet-1507"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="564" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-18" y="-696"/>
|
||||
</scene>
|
||||
<!--Ranging View Controller-->
|
||||
<scene sceneID="1434">
|
||||
<objects>
|
||||
<tableViewController id="1435" customClass="RangingViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="1436">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="1439">
|
||||
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="1435" id="1437"/>
|
||||
<outlet property="delegate" destination="1435" id="1438"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="1440" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="639" y="-1365"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<classes>
|
||||
<class className="ConfigurationViewController" superclassName="UITableViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/ConfigurationViewController.h"/>
|
||||
<relationships>
|
||||
<relationship kind="outlet" name="enabledSwitch" candidateClass="UISwitch"/>
|
||||
<relationship kind="outlet" name="majorTextField" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="measuredPowerTextField" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="minorTextField" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="uuidTextField" candidateClass="UITextField"/>
|
||||
</relationships>
|
||||
</class>
|
||||
<class className="MenuViewController" superclassName="UITableViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/MenuViewController.h"/>
|
||||
</class>
|
||||
<class className="MonitoringViewController" superclassName="UITableViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/MonitoringViewController.h"/>
|
||||
<relationships>
|
||||
<relationship kind="outlet" name="enabledSwitch" candidateClass="UISwitch"/>
|
||||
<relationship kind="outlet" name="majorTextField" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="minorTextField" candidateClass="UITextField"/>
|
||||
<relationship kind="outlet" name="notifyOnDisplaySwitch" candidateClass="UISwitch"/>
|
||||
<relationship kind="outlet" name="notifyOnEntrySwitch" candidateClass="UISwitch"/>
|
||||
<relationship kind="outlet" name="notifyOnExitSwitch" candidateClass="UISwitch"/>
|
||||
<relationship kind="outlet" name="uuidTextField" candidateClass="UITextField"/>
|
||||
</relationships>
|
||||
</class>
|
||||
<class className="RangingViewController" superclassName="UITableViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/RangingViewController.h"/>
|
||||
</class>
|
||||
</classes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public partial class MenuViewController : UITableViewController {
|
||||
|
||||
UIViewController[] controllers = new UIViewController [4];
|
||||
|
||||
public MenuViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
controllers [0] = (UIViewController) Storyboard.InstantiateViewController ("MonitoringViewController");
|
||||
controllers [1] = new RangingViewController (UITableViewStyle.Plain);
|
||||
controllers [2] = new CalibrationBeginViewController (UITableViewStyle.Plain);
|
||||
controllers [3] = (UIViewController) Storyboard.InstantiateViewController ("ConfigurationViewController");
|
||||
}
|
||||
|
||||
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
NavigationController.PushViewController (controllers [indexPath.Row], true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using MonoTouch.Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AirLocate
|
||||
{
|
||||
[Register ("MenuViewController")]
|
||||
partial class MenuViewController
|
||||
{
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public partial class MonitoringViewController : UITableViewController {
|
||||
|
||||
bool enabled;
|
||||
NSUuid uuid;
|
||||
NSNumber major;
|
||||
NSNumber minor;
|
||||
bool notifyOnEntry;
|
||||
bool notifyOnExit;
|
||||
bool notifyOnDisplay;
|
||||
|
||||
CLLocationManager locationManger;
|
||||
NSNumberFormatter numberFormatter;
|
||||
UIBarButtonItem doneButton;
|
||||
UIBarButtonItem saveButton;
|
||||
|
||||
public MonitoringViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
locationManger = new CLLocationManager ();
|
||||
numberFormatter = new NSNumberFormatter () {
|
||||
NumberStyle = NSNumberFormatterStyle.Decimal
|
||||
};
|
||||
uuid = Defaults.DefaultProximityUuid;
|
||||
}
|
||||
|
||||
public override void ViewWillAppear (bool animated)
|
||||
{
|
||||
base.ViewWillAppear (animated);
|
||||
CLBeaconRegion region = (CLBeaconRegion) locationManger.MonitoredRegions.AnyObject;
|
||||
enabled = (region != null);
|
||||
if (enabled) {
|
||||
uuid = region.ProximityUuid;
|
||||
major = region.Major;
|
||||
minor = region.Minor;
|
||||
notifyOnEntry = region.NotifyOnEntry;
|
||||
notifyOnExit = region.NotifyOnExit;
|
||||
notifyOnDisplay = region.NotifyEntryStateOnDisplay;
|
||||
} else {
|
||||
uuid = Defaults.DefaultProximityUuid;
|
||||
major = minor = null;
|
||||
notifyOnEntry = true;
|
||||
notifyOnExit = true;
|
||||
notifyOnDisplay = false;
|
||||
}
|
||||
|
||||
majorTextField.Text = major == null ? String.Empty : major.Int32Value.ToString ();
|
||||
minorTextField.Text = minor == null ? String.Empty : minor.Int32Value.ToString ();
|
||||
|
||||
uuidTextField.Text = uuid.AsString ();
|
||||
enabledSwitch.On = enabled;
|
||||
notifyOnEntrySwitch.On = notifyOnEntry;
|
||||
notifyOnExitSwitch.On = notifyOnExit;
|
||||
notifyOnDisplaySwitch.On = notifyOnDisplay;
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
uuidTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
uuidTextField.InputView = new UuidPickerView (uuidTextField);
|
||||
uuidTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
uuidTextField.EditingDidEnd += (sender, e) => {
|
||||
uuid = new NSUuid (uuidTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
|
||||
majorTextField.KeyboardType = UIKeyboardType.NumberPad;
|
||||
majorTextField.ReturnKeyType = UIReturnKeyType.Done;
|
||||
majorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
majorTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
majorTextField.EditingDidEnd += (sender, e) => {
|
||||
major = numberFormatter.NumberFromString (majorTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
|
||||
minorTextField.KeyboardType = UIKeyboardType.NumberPad;
|
||||
minorTextField.ReturnKeyType = UIReturnKeyType.Done;
|
||||
minorTextField.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
minorTextField.EditingDidBegin += HandleEditingDidBegin;
|
||||
minorTextField.EditingDidEnd += (sender, e) => {
|
||||
minor = numberFormatter.NumberFromString (minorTextField.Text);
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
};
|
||||
|
||||
enabledSwitch.ValueChanged += (sender, e) => {
|
||||
enabled = enabledSwitch.On;
|
||||
};
|
||||
|
||||
notifyOnEntrySwitch.ValueChanged += (sender, e) => {
|
||||
notifyOnEntry = notifyOnEntrySwitch.On;
|
||||
};
|
||||
|
||||
notifyOnExitSwitch.ValueChanged += (sender, e) => {
|
||||
notifyOnExit = notifyOnExitSwitch.On;
|
||||
};
|
||||
|
||||
notifyOnDisplaySwitch.ValueChanged += (sender, e) => {
|
||||
notifyOnDisplay = notifyOnDisplaySwitch.On;
|
||||
};
|
||||
|
||||
doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done, (sender, e) => {
|
||||
uuidTextField.ResignFirstResponder ();
|
||||
majorTextField.ResignFirstResponder ();
|
||||
minorTextField.ResignFirstResponder ();
|
||||
TableView.ReloadData ();
|
||||
});
|
||||
|
||||
saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender, e) => {
|
||||
if (enabled) {
|
||||
var region = Helpers.CreateRegion (uuid, major, minor);
|
||||
if (region != null) {
|
||||
region.NotifyOnEntry = notifyOnEntry;
|
||||
region.NotifyOnExit = notifyOnExit;
|
||||
region.NotifyEntryStateOnDisplay = notifyOnDisplay;
|
||||
locationManger.StartMonitoring (region);
|
||||
}
|
||||
} else {
|
||||
var region = (CLBeaconRegion) locationManger.MonitoredRegions.AnyObject;
|
||||
if (region != null)
|
||||
locationManger.StopMonitoring (region);
|
||||
}
|
||||
NavigationController.PopViewControllerAnimated (true);
|
||||
});
|
||||
|
||||
NavigationItem.RightBarButtonItem = saveButton;
|
||||
}
|
||||
|
||||
// identical code share across all UITextField
|
||||
void HandleEditingDidBegin (object sender, EventArgs e)
|
||||
{
|
||||
NavigationItem.RightBarButtonItem = doneButton;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using MonoTouch.Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AirLocate
|
||||
{
|
||||
[Register ("MonitoringViewController")]
|
||||
partial class MonitoringViewController
|
||||
{
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UISwitch enabledSwitch { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField majorTextField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField minorTextField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UISwitch notifyOnDisplaySwitch { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UISwitch notifyOnEntrySwitch { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UISwitch notifyOnExitSwitch { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCodeAttribute ("iOS Designer", "1.0")]
|
||||
MonoTouch.UIKit.UITextField uuidTextField { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (enabledSwitch != null) {
|
||||
enabledSwitch.Dispose ();
|
||||
enabledSwitch = null;
|
||||
}
|
||||
|
||||
if (uuidTextField != null) {
|
||||
uuidTextField.Dispose ();
|
||||
uuidTextField = null;
|
||||
}
|
||||
|
||||
if (majorTextField != null) {
|
||||
majorTextField.Dispose ();
|
||||
majorTextField = null;
|
||||
}
|
||||
|
||||
if (minorTextField != null) {
|
||||
minorTextField.Dispose ();
|
||||
minorTextField = null;
|
||||
}
|
||||
|
||||
if (notifyOnEntrySwitch != null) {
|
||||
notifyOnEntrySwitch.Dispose ();
|
||||
notifyOnEntrySwitch = null;
|
||||
}
|
||||
|
||||
if (notifyOnExitSwitch != null) {
|
||||
notifyOnExitSwitch.Dispose ();
|
||||
notifyOnExitSwitch = null;
|
||||
}
|
||||
|
||||
if (notifyOnDisplaySwitch != null) {
|
||||
notifyOnDisplaySwitch.Dispose ();
|
||||
notifyOnDisplaySwitch = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using MonoTouch.CoreLocation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public partial class RangingViewController : UITableViewController {
|
||||
|
||||
List<CLBeacon> [] beacons;
|
||||
CLLocationManager locationManager;
|
||||
List<CLBeaconRegion> rangedRegions;
|
||||
|
||||
public RangingViewController (UITableViewStyle style) : base (style)
|
||||
{
|
||||
Unknowns = new List<CLBeacon> ();
|
||||
Immediates = new List<CLBeacon> ();
|
||||
Nears = new List<CLBeacon> ();
|
||||
Fars = new List<CLBeacon> ();
|
||||
beacons = new List<CLBeacon> [4] { Unknowns, Immediates, Nears, Fars };
|
||||
|
||||
locationManager = new CLLocationManager ();
|
||||
locationManager.DidRangeBeacons += HandleDidRangeBeacons;
|
||||
}
|
||||
|
||||
List<CLBeacon> Unknowns { get; set; }
|
||||
List<CLBeacon> Immediates { get; set; }
|
||||
List<CLBeacon> Nears { get; set; }
|
||||
List<CLBeacon> Fars { get; set; }
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
Title = "Ranging";
|
||||
|
||||
// Populate the regions we will range once.
|
||||
rangedRegions = new List<CLBeaconRegion> ();
|
||||
|
||||
foreach (NSUuid uuid in Defaults.SupportedProximityUuids) {
|
||||
CLBeaconRegion region = new CLBeaconRegion (uuid, uuid.AsString ());
|
||||
rangedRegions.Add (region);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ViewWillAppear (bool animated)
|
||||
{
|
||||
base.ViewWillAppear (animated);
|
||||
// Start ranging when the view appears.
|
||||
foreach (CLBeaconRegion region in rangedRegions)
|
||||
locationManager.StartRangingBeacons (region);
|
||||
}
|
||||
|
||||
public override void ViewWillDisappear (bool animated)
|
||||
{
|
||||
base.ViewWillDisappear (animated);
|
||||
foreach (CLBeaconRegion region in rangedRegions)
|
||||
locationManager.StopRangingBeacons (region);
|
||||
}
|
||||
|
||||
public override int NumberOfSections (UITableView tableView)
|
||||
{
|
||||
// skip empty groups
|
||||
int sections = 0;
|
||||
foreach (var group in beacons) {
|
||||
if (group.Count > 0)
|
||||
sections++;
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
// empty section are not shown in TableView so we must exclude them
|
||||
int GetNonEmptySection (int section)
|
||||
{
|
||||
int current = 0;
|
||||
foreach (var group in beacons) {
|
||||
if (group.Count > 0) {
|
||||
if (section-- == 0)
|
||||
return current;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override int RowsInSection (UITableView tableview, int section)
|
||||
{
|
||||
return beacons [GetNonEmptySection (section)].Count;
|
||||
}
|
||||
|
||||
public override string TitleForHeader (UITableView tableView, int section)
|
||||
{
|
||||
if (NumberOfSections (tableView) == 0)
|
||||
return null;
|
||||
|
||||
return ((CLProximity) GetNonEmptySection (section)).ToString ();
|
||||
}
|
||||
|
||||
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
UITableViewCell cell = tableView.DequeueReusableCell ("Cell");
|
||||
if (cell == null) {
|
||||
cell = new UITableViewCell (UITableViewCellStyle.Subtitle, "Cell");
|
||||
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
|
||||
}
|
||||
|
||||
// Display the UUID, major, minor and accuracy for each beacon.
|
||||
CLBeacon beacon = beacons [GetNonEmptySection (indexPath.Section)] [indexPath.Row];
|
||||
|
||||
cell.TextLabel.Text = beacon.ProximityUuid.AsString ();
|
||||
cell.DetailTextLabel.Text = String.Format ("Major: {0} Minor: {1} Acc: {2:0.00}m",
|
||||
beacon.Major, beacon.Minor, beacon.Accuracy);
|
||||
return cell;
|
||||
}
|
||||
|
||||
void HandleDidRangeBeacons (object sender, CLRegionBeaconsRangedEventArgs e)
|
||||
{
|
||||
Unknowns.Clear ();
|
||||
Immediates.Clear ();
|
||||
Nears.Clear ();
|
||||
Fars.Clear ();
|
||||
|
||||
foreach (CLBeacon beacon in e.Beacons) {
|
||||
switch (beacon.Proximity) {
|
||||
case CLProximity.Immediate:
|
||||
Immediates.Add (beacon);
|
||||
break;
|
||||
case CLProximity.Near:
|
||||
Nears.Add (beacon);
|
||||
break;
|
||||
case CLProximity.Far:
|
||||
Fars.Add (beacon);
|
||||
break;
|
||||
case CLProximity.Unknown:
|
||||
Unknowns.Add (beacon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TableView.ReloadData ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using MonoTouch.Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace AirLocate
|
||||
{
|
||||
[Register ("RangingViewController")]
|
||||
partial class RangingViewController
|
||||
{
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 12 KiB |
После Ширина: | Высота: | Размер: 5.2 KiB |
После Ширина: | Высота: | Размер: 12 KiB |
После Ширина: | Высота: | Размер: 6.6 KiB |
После Ширина: | Высота: | Размер: 4.2 KiB |
После Ширина: | Высота: | Размер: 2.0 KiB |
После Ширина: | Высота: | Размер: 5.2 KiB |
После Ширина: | Высота: | Размер: 5.1 KiB |
После Ширина: | Высота: | Размер: 14 KiB |
После Ширина: | Высота: | Размер: 106 KiB |
После Ширина: | Высота: | Размер: 273 KiB |
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace AirLocate {
|
||||
|
||||
public class UuidPickerView : UIPickerView {
|
||||
|
||||
public UuidPickerView (UITextField uuidTextField)
|
||||
{
|
||||
AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
|
||||
ShowSelectionIndicator = true;
|
||||
Model = new UuidPickerViewModel (uuidTextField);
|
||||
}
|
||||
|
||||
class UuidPickerViewModel : UIPickerViewModel {
|
||||
|
||||
UITextField field;
|
||||
|
||||
public UuidPickerViewModel (UITextField uuidTextField)
|
||||
{
|
||||
field = uuidTextField;
|
||||
}
|
||||
|
||||
public override void Selected (UIPickerView picker, int row, int component)
|
||||
{
|
||||
field.Text = Defaults.SupportedProximityUuids [row].AsString ();
|
||||
}
|
||||
|
||||
public override int GetRowsInComponent (UIPickerView picker, int component)
|
||||
{
|
||||
return Defaults.SupportedProximityUuids.Count;
|
||||
}
|
||||
|
||||
public override int GetComponentCount (UIPickerView picker)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override string GetTitle (UIPickerView picker, int row, int component)
|
||||
{
|
||||
return Defaults.SupportedProximityUuids [row].AsString ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<SampleMetadata>
|
||||
<ID>e91d2f94-88c4-441d-acd2-d7ee8d7d294c</ID>
|
||||
<IsFullApplication>false</IsFullApplication>
|
||||
<Level>Intermediate</Level>
|
||||
<Tags>iOS7, Bluetooth</Tags>
|
||||
<LicenseRequirement>Starter</LicenseRequirement>
|
||||
</SampleMetadata>
|
|
@ -0,0 +1,45 @@
|
|||
AirLocate
|
||||
================
|
||||
AirLocate shows how to use `CLLocationManager` to monitor and range `CLBeaconRegion`.
|
||||
The code also provides an example of how you can calibrate and configure an iOS device as a beacon with CoreBluetooth.
|
||||
|
||||
You can configure an iOS device as a beacon as follows:
|
||||
|
||||
1) Obtain two iOS devices equipped with Bluetooth LE. One will be a target device, one will be a remote (calibration) device.
|
||||
|
||||
2) Load and launch this app on both devices.
|
||||
|
||||
3) Turn the target device into a beacon by selecting Configuration and turning on the Enabled switch.
|
||||
|
||||
4) Take the calibration device and move one meter away from the target device.
|
||||
|
||||
5) On the calibration device start the calibration process by selecting Calibration.
|
||||
|
||||
6) Choose the target device from the table view.
|
||||
|
||||
7) The calibration process will start. You should wave the calibration device from side-to-side while this process is running.
|
||||
|
||||
8) When the calibration process is done, it will show a calibrated RSSI value on the screen.
|
||||
|
||||
9) On the target device, go back to the Configuration screen and enter this value under Measured Power.
|
||||
|
||||
Note: The calibration process is optional, but recommended as it will fine-tune ranging for your environment.
|
||||
You can configure an iOS device as a beacon without calibrating it by not specifying a measured power.
|
||||
If a measured power is not specified, CoreLocation default to a pre-determined value.
|
||||
|
||||
Once you've setup your target device as a beacon, you can use this app to demo beacon ranging and monitoring.
|
||||
To demo ranging, select Ranging from the remote device. `RangingViewController` ranges a set of `CLBeaconRegion`.
|
||||
To demo monitoring, select Monitoring from the remote device. `MonitoringViewController` allows you to configure a `CLBeaconRegion` to monitor.
|
||||
|
||||
|
||||
|
||||
This sample is the Xamarin.iOS version of Apple's iOS7 Sample -- AirLocate.
|
||||
|
||||
Here is the link to the Apple's Sample:
|
||||
https://developer.apple.com/downloads/index.action?name=WWDC%202013#
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
Bo Pang
|
После Ширина: | Высота: | Размер: 168 KiB |
После Ширина: | Высота: | Размер: 212 KiB |
После Ширина: | Высота: | Размер: 171 KiB |
|
@ -0,0 +1,41 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ButtonTapper3000", "ButtonTapper3000\ButtonTapper3000.csproj", "{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Release|iPhone = Release|iPhone
|
||||
Ad-Hoc|iPhone = Ad-Hoc|iPhone
|
||||
AppStore|iPhone = AppStore|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = ButtonTapper3000\ButtonTapper3000.csproj
|
||||
Policies = $0
|
||||
$0.TextStylePolicy = $1
|
||||
$1.inheritsSet = Mono
|
||||
$1.inheritsScope = text/plain
|
||||
$1.scope = text/x-csharp
|
||||
$0.CSharpFormattingPolicy = $2
|
||||
$2.inheritsSet = Mono
|
||||
$2.inheritsScope = text/x-csharp
|
||||
$2.scope = text/x-csharp
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.GameKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
[Register ("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate {
|
||||
|
||||
public ViewController ViewController { get; private set; }
|
||||
public override UIWindow Window { get; set; }
|
||||
|
||||
public static AppDelegate Shared {
|
||||
get {
|
||||
return (AppDelegate) UIApplication.SharedApplication.Delegate;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
|
||||
{
|
||||
Window = new UIWindow (UIScreen.MainScreen.Bounds);
|
||||
ViewController = new ViewController ();
|
||||
|
||||
var navigationController = new UINavigationController (ViewController) {
|
||||
NavigationBarHidden = true
|
||||
};
|
||||
|
||||
GKLocalPlayer.LocalPlayer.AuthenticateHandler = (viewController, error) => {
|
||||
if (error != null) {
|
||||
Console.WriteLine ("Error while trying to authenticate local player: " + error.Description);
|
||||
return;
|
||||
}
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated || (viewController == null))
|
||||
return;
|
||||
navigationController.PresentViewController (viewController, true, null);
|
||||
};
|
||||
|
||||
Window.RootViewController = navigationController;
|
||||
Window.MakeKeyAndVisible ();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Main (string[] args)
|
||||
{
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
<?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)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D0493837-812B-4A0F-9A0C-D0E3F5FF9B95}</ProjectGuid>
|
||||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ButtonTapper3000</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>ButtonTapper3000</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<IpaPackageName>
|
||||
</IpaPackageName>
|
||||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="monotouch" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
<Folder Include="Resources\Images\" />
|
||||
<Folder Include="Scenes\" />
|
||||
<Folder Include="Model\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="Scenes\MainMenu.cs" />
|
||||
<Compile Include="Scenes\BasicScene.cs" />
|
||||
<Compile Include="Scenes\GameSetupMenu.cs" />
|
||||
<Compile Include="Scenes\StatsScreen.cs" />
|
||||
<Compile Include="Scenes\MainGame.cs" />
|
||||
<Compile Include="Model\GameInfo.cs" />
|
||||
<Compile Include="Scenes\ResultsScreen.cs" />
|
||||
<Compile Include="ViewController.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\Default-Portrait~ipad.png" />
|
||||
<BundleResource Include="Resources\Default-Portrait%402x~ipad.png" />
|
||||
<BundleResource Include="Resources\Default-Landscape~ipad.png" />
|
||||
<BundleResource Include="Resources\Default-Landscape%402x~ipad.png" />
|
||||
<BundleResource Include="Resources\Images\Podium.png" />
|
||||
<BundleResource Include="Resources\Images\Podium%402x.png" />
|
||||
<BundleResource Include="Resources\Images\DefaultPlayerPhoto.png" />
|
||||
<BundleResource Include="Resources\Images\DefaultPlayerPhoto%402x.png" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="iTunesArtwork" />
|
||||
<ITunesArtwork Include="iTunesArtwork%402x" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-60%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-40%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Contents.json" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
|
||||
<string>$(TeamIdentifierPrefix)con.example.apple.sample.gamekitsamplewwdc2013</string>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)con.example.apple.sample.gamekitsamplewwdc2013</string>
|
||||
</array>
|
||||
<key>com.apple.developer.ubiquity-container-identifiers</key>
|
||||
<array>
|
||||
<string>$(TeamIdentifierPrefix)con.example.apple.sample.gamekitsamplewwdc2013</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.example.xamarin.sample.gamekitsamplewwdc2013</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>7.0</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>ButtonTapper3000</string>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.0.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Resources/Images.xcassets/AppIcons.appiconset</string>
|
||||
<key>XSLaunchImageAssets</key>
|
||||
<string>Resources/Images.xcassets/LaunchImage.launchimage</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using MonoTouch.GameKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public enum GameMode {
|
||||
Easy,
|
||||
Hard,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum GameTime {
|
||||
Fifteen = 0,
|
||||
Thirty,
|
||||
FourtyFive,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum GameTypePlayed {
|
||||
Invalid = -0x0001,
|
||||
Easy15 = 0x0001,
|
||||
Hard15 = 0x0002,
|
||||
Easy30 = 0x0004,
|
||||
Hard30 = 0x0008,
|
||||
Easy45 = 0x0010,
|
||||
Hard45 = 0x0020,
|
||||
All = 0x003F
|
||||
}
|
||||
|
||||
public static class GameInfo {
|
||||
|
||||
public static GameMode GameMode;
|
||||
|
||||
static GameTime gameTime;
|
||||
public static GameTime GameTime {
|
||||
get { return gameTime; }
|
||||
set {
|
||||
gameTime = value;
|
||||
CurrentTicks = GameTimeInSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CurrentTaps;
|
||||
public static GKChallenge Challenge;
|
||||
public static GKLeaderboardSet CurrentSet;
|
||||
public static GKLeaderboard CurrentLeaderBoard;
|
||||
public static int[] GameTimes;
|
||||
public static int CurrentTicks;
|
||||
|
||||
static GameInfo ()
|
||||
{
|
||||
GameMode = GameMode.Easy;
|
||||
GameTimes = new [] { 15, 30, 45 };
|
||||
GameTime = GameTime.Fifteen;
|
||||
CurrentTaps = 0;
|
||||
CurrentTicks = GameTimes [(int)GameTime];
|
||||
}
|
||||
|
||||
public static int GameTimeInSeconds {
|
||||
get {
|
||||
return GameTimes [(int)GameTime];
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetGame ()
|
||||
{
|
||||
CurrentTaps = 0;
|
||||
Challenge = null;
|
||||
CurrentTicks = GameTimes [(int)GameTime];
|
||||
}
|
||||
}
|
||||
}
|
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Default-Landscape@2x~ipad.png
Normal file
После Ширина: | Высота: | Размер: 61 KiB |
После Ширина: | Высота: | Размер: 18 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Default-Portrait@2x~ipad.png
Normal file
После Ширина: | Высота: | Размер: 60 KiB |
После Ширина: | Высота: | Размер: 19 KiB |
|
@ -0,0 +1 @@
|
|||
{"images":[{"idiom":"iphone","filename":"Icon.png","size":"57x57","scale":"1x"},{"idiom":"iphone","filename":"Icon@2x.png","size":"57x57","scale":"2x"},{"idiom":"iphone","filename":"Icon-60@2x.png","size":"60x60","scale":"2x"},{"idiom":"iphone","filename":"Icon-Small.png","size":"29x29","scale":"1x"},{"idiom":"iphone","filename":"Icon-Small@2x.png","size":"29x29","scale":"2x"},{"idiom":"iphone","filename":"Icon-Small-40@2x.png","size":"40x40","scale":"2x"}],"info":{"version":1,"author":"xcode"}}
|
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/AppIcons.appiconset/Icon-60@2x.png
Normal file
После Ширина: | Высота: | Размер: 15 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/AppIcons.appiconset/Icon-Small-40@2x.png
Normal file
После Ширина: | Высота: | Размер: 8.6 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/AppIcons.appiconset/Icon-Small.png
Normal file
После Ширина: | Высота: | Размер: 2.0 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/AppIcons.appiconset/Icon-Small@2x.png
Normal file
После Ширина: | Высота: | Размер: 5.2 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/AppIcons.appiconset/Icon.png
Normal file
После Ширина: | Высота: | Размер: 5.1 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/AppIcons.appiconset/Icon@2x.png
Normal file
После Ширина: | Высота: | Размер: 14 KiB |
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"idiom": "iphone",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default.png",
|
||||
"size": "320x480",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"idiom": "iphone",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default@2x.png",
|
||||
"size": "320x480",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"idiom": "iphone",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default-568h@2x.png",
|
||||
"size": "320x568",
|
||||
"subtype": "retina4",
|
||||
"scale": "2x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png
Normal file
После Ширина: | Высота: | Размер: 12 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/LaunchImage.launchimage/Default.png
Normal file
После Ширина: | Высота: | Размер: 5.2 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images.xcassets/LaunchImage.launchimage/Default@2x.png
Normal file
После Ширина: | Высота: | Размер: 12 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images/DefaultPlayerPhoto.png
Normal file
После Ширина: | Высота: | Размер: 5.7 KiB |
Двоичные данные
ButtonTapper3000/ButtonTapper3000/Resources/Images/DefaultPlayerPhoto@2x.png
Normal file
После Ширина: | Высота: | Размер: 8.0 KiB |
После Ширина: | Высота: | Размер: 4.8 KiB |
После Ширина: | Высота: | Размер: 6.4 KiB |
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class BasicScene : SKScene {
|
||||
|
||||
protected UIColor SelectedColor { get; private set; }
|
||||
protected UIColor UnselectedColor { get; private set; }
|
||||
protected UIColor ButtonColor { get; private set; }
|
||||
protected UIColor InfoColor { get; private set; }
|
||||
|
||||
protected float FrameMidX { get; private set; }
|
||||
protected float FrameMidY { get; private set; }
|
||||
|
||||
SKTransition transition;
|
||||
|
||||
public BasicScene (SizeF size) : base (size)
|
||||
{
|
||||
ScaleMode = SKSceneScaleMode.AspectFill;
|
||||
|
||||
BackgroundColor = UIColor.FromRGBA (0.15f, 0.15f, 0.3f, 1f);
|
||||
|
||||
UnselectedColor = UIColor.FromRGBA (0f, 0.5f, 0.5f, 1f);
|
||||
SelectedColor = UIColor.FromRGBA (0.5f, 1f, 0.99f, 1f);
|
||||
|
||||
ButtonColor = UIColor.FromRGBA (1f, 1f, 0f, 1f);
|
||||
InfoColor = UIColor.FromRGBA (1f, 1f, 1f, 1f);
|
||||
|
||||
FrameMidX = Frame.GetMidX ();
|
||||
FrameMidY = Frame.GetMidY ();
|
||||
|
||||
transition = SKTransition.MoveInWithDirection (SKTransitionDirection.Up, 0.5);
|
||||
}
|
||||
|
||||
public void PresentScene (BasicScene scene)
|
||||
{
|
||||
View.PresentScene (scene, transition);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class GameSetupMenu : BasicScene {
|
||||
|
||||
SKLabelNode [] timeLabels;
|
||||
SKLabelNode [] modeLabels;
|
||||
SKLabelNode startButton;
|
||||
SKLabelNode backButton;
|
||||
|
||||
public GameSetupMenu (SizeF size) : base (size)
|
||||
{
|
||||
SKLabelNode timeLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Time",
|
||||
FontSize = 24,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 70)
|
||||
};
|
||||
|
||||
SKLabelNode time15Button = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "15",
|
||||
FontSize = 14,
|
||||
FontColor = UnselectedColor,
|
||||
Position = new PointF (FrameMidX - 40, FrameMidY + 40)
|
||||
};
|
||||
SKLabelNode time30Button = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "30",
|
||||
FontSize = 14,
|
||||
FontColor = UnselectedColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 40)
|
||||
};
|
||||
SKLabelNode time45Button = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "45",
|
||||
FontSize = 14,
|
||||
FontColor = UnselectedColor,
|
||||
Position = new PointF (FrameMidX + 40, FrameMidY + 40)
|
||||
};
|
||||
timeLabels = new SKLabelNode[] { time15Button, time30Button, time45Button };
|
||||
|
||||
SKLabelNode modeLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Mode",
|
||||
FontSize = 24,
|
||||
Position = new PointF (FrameMidX, FrameMidY)
|
||||
};
|
||||
SKLabelNode modeEasyButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Easy",
|
||||
FontSize = 14,
|
||||
FontColor = UnselectedColor,
|
||||
Position = new PointF (FrameMidX - 40, FrameMidY - 40)
|
||||
};
|
||||
SKLabelNode modeHardButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Hard",
|
||||
FontSize = 14,
|
||||
FontColor = UnselectedColor,
|
||||
Position = new PointF (FrameMidX + 40, FrameMidY - 40)
|
||||
};
|
||||
modeLabels = new [] { modeEasyButton, modeHardButton };
|
||||
|
||||
startButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Start!",
|
||||
FontSize = 30,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 100)
|
||||
};
|
||||
backButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Back",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 200)
|
||||
};
|
||||
|
||||
timeLabels [(int)GameInfo.GameTime].FontColor = SelectedColor;
|
||||
modeLabels [(int)GameInfo.GameMode].FontColor = SelectedColor;
|
||||
|
||||
GameInfo.ResetGame ();
|
||||
|
||||
AddChild (timeLabel);
|
||||
foreach (var button in timeLabels)
|
||||
AddChild (button);
|
||||
|
||||
AddChild (modeLabel);
|
||||
foreach (var button in modeLabels)
|
||||
AddChild (button);
|
||||
|
||||
AddChild (startButton);
|
||||
AddChild (backButton);
|
||||
}
|
||||
|
||||
void SelectTime (int time)
|
||||
{
|
||||
timeLabels [(int)GameInfo.GameTime].FontColor = UnselectedColor;
|
||||
GameInfo.GameTime = (GameTime)time;
|
||||
timeLabels [time].FontColor = SelectedColor;
|
||||
}
|
||||
|
||||
void SelectMode (int mode)
|
||||
{
|
||||
modeLabels [(int)GameInfo.GameMode].FontColor = UnselectedColor;
|
||||
GameInfo.GameMode = (GameMode)mode;
|
||||
modeLabels [mode].FontColor = SelectedColor;
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
|
||||
for (int i = 0; i < (int)GameTime.Max; i++) {
|
||||
if (timeLabels [i].ContainsPoint (location)) {
|
||||
SelectTime (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)GameMode.Max; i++) {
|
||||
if (modeLabels [i].ContainsPoint (location)) {
|
||||
SelectMode (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (startButton.ContainsPoint (location)) {
|
||||
PresentScene (new MainGame (View.Bounds.Size));
|
||||
} else if (backButton.ContainsPoint (location)) {
|
||||
PresentScene (new MainMenu (View.Bounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update (double currentTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using MonoTouch.CoreText;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.GameKit;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class MainGame : BasicScene {
|
||||
|
||||
public const string Prefix = "com.xamarin.sample.gamekitsamplewwdc2013.";
|
||||
const string TapOnceId = Prefix + "taponce";
|
||||
const string PlayHardId = Prefix + "playhardmode";
|
||||
const string PlayAllId = Prefix + "playallgametypes";
|
||||
const string AverageTapTimeId = Prefix + "averagetaptime";
|
||||
const string Tap100Id = Prefix + "tapahundred";
|
||||
const string Tap1000Id = Prefix + "tapathousand";
|
||||
|
||||
SKLabelNode button;
|
||||
SKLabelNode timerLabel;
|
||||
SKLabelNode clicksLabel;
|
||||
NSTimer gameTimer;
|
||||
NSTimer tickTimer;
|
||||
|
||||
Random rand;
|
||||
|
||||
public MainGame (SizeF size) : base (size)
|
||||
{
|
||||
rand = new Random ();
|
||||
|
||||
GameInfo.CurrentTaps = 0;
|
||||
|
||||
gameTimer = NSTimer.CreateScheduledTimer (GameInfo.GameTimeInSeconds, async delegate {
|
||||
await TimerDone ();
|
||||
});
|
||||
|
||||
tickTimer = NSTimer.CreateRepeatingScheduledTimer (1.0, async delegate {
|
||||
GameInfo.CurrentTicks --;
|
||||
if (GameInfo.CurrentTicks < 0) {
|
||||
GameInfo.CurrentTicks = 0;
|
||||
await TimerDone ();
|
||||
}
|
||||
});
|
||||
|
||||
button = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Tap Me!",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY)
|
||||
};
|
||||
|
||||
clicksLabel = new SKLabelNode ("AvenirNext-Bold") {
|
||||
Text = GameInfo.CurrentTaps.ToString (),
|
||||
FontSize = 45,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 120)
|
||||
};
|
||||
|
||||
timerLabel = new SKLabelNode ("HelveticaNeue-CondensedBlack") {
|
||||
Text = GameInfo.CurrentTicks.ToString (),
|
||||
FontSize = 45,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 120)
|
||||
};
|
||||
|
||||
AddChild (button);
|
||||
AddChild (clicksLabel);
|
||||
AddChild (timerLabel);
|
||||
}
|
||||
|
||||
public override async void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
var location = (touch as UITouch).LocationInNode (this);
|
||||
|
||||
if (button.ContainsPoint (location)) {
|
||||
GameInfo.CurrentTaps ++;
|
||||
|
||||
if (GameInfo.GameMode == GameMode.Hard) {
|
||||
int x = rand.Next (100) - 50;
|
||||
int y = rand.Next (100) - 50;
|
||||
button.Position = new PointF (FrameMidX + x, FrameMidY + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated) {
|
||||
var tapOnceAchievement = new GKAchievement (TapOnceId, GKLocalPlayer.LocalPlayer.PlayerID) {
|
||||
PercentComplete = 100
|
||||
};
|
||||
await GKAchievement.ReportAchievementsAsync (new [] { tapOnceAchievement }, null);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update (double currentTime)
|
||||
{
|
||||
clicksLabel.Text = GameInfo.CurrentTaps.ToString ();
|
||||
timerLabel.Text = GameInfo.CurrentTicks.ToString ();
|
||||
}
|
||||
|
||||
async Task TimerDone ()
|
||||
{
|
||||
tickTimer.Invalidate ();
|
||||
await ReportScore ();
|
||||
PresentScene (new ResultsScreen (View.Bounds.Size));
|
||||
}
|
||||
|
||||
async Task ReportScore ()
|
||||
{
|
||||
string leaderboardIdentifier = null;
|
||||
string gameTypeString = null;
|
||||
GameTypePlayed gameType = GameTypePlayed.Invalid;
|
||||
|
||||
if (GameInfo.GameTime == GameTime.Fifteen) {
|
||||
if (GameInfo.GameMode == GameMode.Easy) {
|
||||
gameTypeString = "15secondseasymode";
|
||||
gameType = GameTypePlayed.Easy15;
|
||||
} else if (GameInfo.GameMode == GameMode.Hard) {
|
||||
gameTypeString = "15secondshardmode";
|
||||
gameType = GameTypePlayed.Hard15;
|
||||
}
|
||||
} else if (GameInfo.GameTime == GameTime.Thirty) {
|
||||
if (GameInfo.GameMode == GameMode.Easy) {
|
||||
gameTypeString = "30secondseasymode";
|
||||
gameType = GameTypePlayed.Easy30;
|
||||
} else if (GameInfo.GameMode == GameMode.Hard) {
|
||||
gameTypeString = "30secondshardmode";
|
||||
gameType = GameTypePlayed.Hard30;
|
||||
}
|
||||
} else if (GameInfo.GameTime == GameTime.FourtyFive) {
|
||||
if (GameInfo.GameMode == GameMode.Easy) {
|
||||
gameTypeString = "45secondseasymode";
|
||||
gameType = GameTypePlayed.Easy45;
|
||||
} else if (GameInfo.GameMode == GameMode.Hard) {
|
||||
gameTypeString = "45secondshardmode";
|
||||
gameType = GameTypePlayed.Hard45;
|
||||
}
|
||||
}
|
||||
|
||||
if (gameTypeString != null)
|
||||
leaderboardIdentifier = Prefix + gameTypeString;
|
||||
|
||||
if (leaderboardIdentifier != null) {
|
||||
GKScore score = new GKScore (leaderboardIdentifier) {
|
||||
Value = GameInfo.CurrentTaps,
|
||||
Context = 0
|
||||
};
|
||||
var challenges = GameInfo.Challenge == null ? null : new [] { GameInfo.Challenge };
|
||||
await GKScore.ReportScoresAsync (new [] { score }, challenges);
|
||||
}
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated) {
|
||||
if (GameInfo.GameMode == GameMode.Hard) {
|
||||
var playhard = new GKAchievement (PlayHardId, GKLocalPlayer.LocalPlayer.PlayerID) {
|
||||
PercentComplete = 100
|
||||
};
|
||||
await GKAchievement.ReportAchievementsAsync (new [] { playhard });
|
||||
}
|
||||
|
||||
int playedGameTypesBitField;
|
||||
using (NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults) {
|
||||
playedGameTypesBitField = defaults.IntForKey ("playedGameTypes") | (int) gameType;
|
||||
defaults.SetInt (playedGameTypesBitField, "playedGameTypes");
|
||||
defaults.Synchronize ();
|
||||
}
|
||||
|
||||
int numTypesPlayed = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if ((playedGameTypesBitField & 0x01) != 0)
|
||||
numTypesPlayed++;
|
||||
playedGameTypesBitField >>= 1;
|
||||
}
|
||||
|
||||
GKAchievement playAllModesAchievement = new GKAchievement (PlayAllId) {
|
||||
PercentComplete = numTypesPlayed / 6.0 * 100.0
|
||||
};
|
||||
await GKAchievement.ReportAchievementsAsync (new [] { playAllModesAchievement });
|
||||
|
||||
await UpdateCurrentTapsLeaderboardAndTapAchievements ();
|
||||
}
|
||||
}
|
||||
|
||||
async Task UpdateCurrentTapsLeaderboardAndTapAchievements ()
|
||||
{
|
||||
GKLeaderboard averageTapLeaderboard = new GKLeaderboard (new [] { GKLocalPlayer.LocalPlayer.PlayerID }) {
|
||||
Identifier = AverageTapTimeId
|
||||
};
|
||||
var scores = await averageTapLeaderboard.LoadScoresAsync ();
|
||||
|
||||
GKScore currentScore;
|
||||
GKScore newScore = new GKScore (AverageTapTimeId);
|
||||
|
||||
if (scores != null && scores.Length > 1) {
|
||||
currentScore = scores [0];
|
||||
int oldTaps = (int)currentScore.Context;
|
||||
int oldTime = (int)currentScore.Value * oldTaps;
|
||||
|
||||
int newTime = oldTime + GameInfo.GameTimeInSeconds * 100;
|
||||
int newTaps = oldTaps + GameInfo.CurrentTaps;
|
||||
|
||||
newScore.Value = newTime / newTaps;
|
||||
newScore.Context = (ulong)newTaps;
|
||||
} else {
|
||||
newScore.Value = GameInfo.GameTimeInSeconds / Math.Max (GameInfo.CurrentTaps, 1) * 100;
|
||||
newScore.Context = (ulong)GameInfo.CurrentTaps;
|
||||
}
|
||||
|
||||
GKAchievement playAHundred = new GKAchievement (Tap100Id, GKLocalPlayer.LocalPlayer.PlayerID) {
|
||||
PercentComplete = (float) newScore.Context / 100f * 100f
|
||||
};
|
||||
|
||||
GKAchievement playAThousand = new GKAchievement (Tap1000Id, GKLocalPlayer.LocalPlayer.PlayerID) {
|
||||
PercentComplete = (float) newScore.Context / 1000f * 100f
|
||||
};
|
||||
|
||||
await GKAchievement.ReportAchievementsAsync (new [] { playAHundred, playAThousand });
|
||||
|
||||
await GKScore.ReportScoresAsync (new [] { newScore });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.GameKit;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class MainMenu : BasicScene {
|
||||
|
||||
SKLabelNode startButton;
|
||||
SKLabelNode gameCenterButton;
|
||||
SKLabelNode gameStatsButton;
|
||||
SKLabelNode playChallengeButton;
|
||||
SKLabelNode challengeFriendsButton;
|
||||
|
||||
public MainMenu (SizeF size) : base (size)
|
||||
{
|
||||
var title = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Button Tapper",
|
||||
FontSize = 30f,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 60)
|
||||
};
|
||||
|
||||
startButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Start Game",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY)
|
||||
};
|
||||
|
||||
gameCenterButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Game Center",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 60)
|
||||
};
|
||||
|
||||
gameStatsButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Game Stats",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 120)
|
||||
};
|
||||
|
||||
challengeFriendsButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Challenge Friends",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 180)
|
||||
};
|
||||
|
||||
playChallengeButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Play Challenge",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 240)
|
||||
};
|
||||
|
||||
SetupChallenge ();
|
||||
|
||||
AddChild (title);
|
||||
AddChild (startButton);
|
||||
AddChild (gameCenterButton);
|
||||
AddChild (gameStatsButton);
|
||||
AddChild (challengeFriendsButton);
|
||||
AddChild (playChallengeButton);
|
||||
}
|
||||
|
||||
async void SetupChallenge ()
|
||||
{
|
||||
playChallengeButton.Hidden = true;
|
||||
if (!GKLocalPlayer.LocalPlayer.Authenticated)
|
||||
return;
|
||||
|
||||
var challenges = await GKChallenge.LoadReceivedChallengesAsync ();
|
||||
if (challenges != null) {
|
||||
foreach (var challenge in challenges) {
|
||||
var c = challenge as GKScoreChallenge;
|
||||
if (c != null) {
|
||||
SelectChallenge (c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var listener = new PlayerListener ();
|
||||
listener.DidReceiveChallengeAction = (player, challenge) => {
|
||||
if (player == GKLocalPlayer.LocalPlayer) {
|
||||
var c = challenge as GKScoreChallenge;
|
||||
if (c != null)
|
||||
SelectChallenge (c);
|
||||
}
|
||||
};
|
||||
GKLocalPlayer.LocalPlayer.RegisterListener (listener);
|
||||
}
|
||||
|
||||
void SelectChallenge (GKScoreChallenge challenge)
|
||||
{
|
||||
string leaderboardID = challenge.Score.LeaderboardIdentifier;
|
||||
string[] substrings = leaderboardID.Split ('.');
|
||||
string leaderboardSubstring = substrings [substrings.Length - 1];
|
||||
string timeString = leaderboardSubstring.Substring (0, 9);
|
||||
string modeString = leaderboardSubstring.Substring (9);
|
||||
|
||||
switch (timeString) {
|
||||
case "15seconds":
|
||||
GameInfo.GameTime = GameTime.Fifteen;
|
||||
break;
|
||||
case "30seconds":
|
||||
GameInfo.GameTime = GameTime.Thirty;
|
||||
break;
|
||||
case ("45seconds"):
|
||||
GameInfo.GameTime = GameTime.FourtyFive;
|
||||
break;
|
||||
default:
|
||||
GameInfo.GameTime = GameTime.Max;
|
||||
break;
|
||||
}
|
||||
|
||||
GameInfo.GameMode = modeString == "hardmode" ? GameMode.Hard : GameMode.Easy;
|
||||
GameInfo.Challenge = challenge;
|
||||
|
||||
playChallengeButton.Hidden = false;
|
||||
}
|
||||
|
||||
void ShowGameCenter ()
|
||||
{
|
||||
GKGameCenterViewController controller = new GKGameCenterViewController ();
|
||||
controller.Finished += (object sender, EventArgs e) => {
|
||||
controller.DismissViewController (true, null);
|
||||
};
|
||||
AppDelegate.Shared.ViewController.PresentViewController (controller, true, null);
|
||||
}
|
||||
|
||||
async void ChallengeFriends ()
|
||||
{
|
||||
if (!GKLocalPlayer.LocalPlayer.Authenticated) {
|
||||
new UIAlertView ("Player not logged in", "Must be logged into Game Center to challenge friends",
|
||||
null, "Okay", null).Show ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Friends == null)
|
||||
await GKLocalPlayer.LocalPlayer.LoadFriendsAsync ();
|
||||
|
||||
GKScore score = new GKScore () {
|
||||
LeaderboardIdentifier = MainGame.Prefix + "15secondseasymode",
|
||||
Context = (ulong)GameTypePlayed.Easy15,
|
||||
Value = 10
|
||||
};
|
||||
|
||||
UIViewController challengeController = score.ChallengeComposeController (
|
||||
GKLocalPlayer.LocalPlayer.Friends, "Beat it!",
|
||||
delegate (UIViewController composeController, bool didIssueChallenge, string[] sentPlayerIDs) {
|
||||
AppDelegate.Shared.ViewController.DismissViewController (true, null);
|
||||
}
|
||||
);
|
||||
AppDelegate.Shared.ViewController.PresentViewController (challengeController, true, null);
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
if (startButton.Frame.Contains (location)) {
|
||||
PresentScene (new GameSetupMenu (View.Bounds.Size));
|
||||
} else if (gameCenterButton.Frame.Contains (location)) {
|
||||
ShowGameCenter ();
|
||||
} else if (gameStatsButton.Frame.Contains (location)) {
|
||||
PresentScene (new StatsScreen (View.Bounds.Size));
|
||||
} else if (challengeFriendsButton.Frame.Contains (location)) {
|
||||
ChallengeFriends ();
|
||||
} else if (playChallengeButton.Frame.Contains (location)) {
|
||||
PresentScene (new MainGame (View.Bounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerListener : GKLocalPlayerListener
|
||||
{
|
||||
public Action<GKPlayer, GKChallenge> DidReceiveChallengeAction;
|
||||
|
||||
public override void DidReceiveChallenge (GKPlayer player, GKChallenge challenge)
|
||||
{
|
||||
var action = DidReceiveChallengeAction;
|
||||
if (action != null)
|
||||
action (player, challenge);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class ResultsScreen : BasicScene {
|
||||
|
||||
SKLabelNode doneButton;
|
||||
|
||||
public ResultsScreen (SizeF size) : base (size)
|
||||
{
|
||||
var timeLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Time: " + GameInfo.GameTimeInSeconds,
|
||||
FontSize = 24,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 120)
|
||||
};
|
||||
var modeLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Mode: " + GameInfo.GameMode,
|
||||
FontSize = 24,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 60)
|
||||
};
|
||||
var scoreLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Score: " + GameInfo.CurrentTaps,
|
||||
FontSize = 30,
|
||||
Position = new PointF (FrameMidX, FrameMidY)
|
||||
};
|
||||
doneButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Done",
|
||||
FontSize = 24,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 90)
|
||||
};
|
||||
AddChild (timeLabel);
|
||||
AddChild (modeLabel);
|
||||
AddChild (scoreLabel);
|
||||
AddChild (doneButton);
|
||||
}
|
||||
|
||||
public override void TouchesBegan (MonoTouch.Foundation.NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
if (doneButton.ContainsPoint (location))
|
||||
PresentScene (new MainMenu (View.Bounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,389 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.GameKit;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class StatsScreen : BasicScene {
|
||||
|
||||
SKLabelNode leaderboardsButton;
|
||||
SKLabelNode achievementsButton;
|
||||
SKLabelNode backButton;
|
||||
|
||||
public StatsScreen (SizeF size) : base (size)
|
||||
{
|
||||
BackgroundColor = UIColor.FromRGBA (0.15f, 0.15f, 0.3f, 1f);
|
||||
|
||||
var title = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Stats",
|
||||
FontSize = 30,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 60)
|
||||
};
|
||||
|
||||
leaderboardsButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Leaderboards",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY)
|
||||
};
|
||||
|
||||
achievementsButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Achievements",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 60)
|
||||
};
|
||||
|
||||
backButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Back",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 200)
|
||||
};
|
||||
|
||||
AddChild (title);
|
||||
AddChild (leaderboardsButton);
|
||||
AddChild (achievementsButton);
|
||||
AddChild (backButton);
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
var location = (touch as UITouch).LocationInNode (this);
|
||||
|
||||
if (leaderboardsButton.ContainsPoint (location)) {
|
||||
PresentScene (new LeaderboardSetsScreen (View.Bounds.Size));
|
||||
} else if (achievementsButton.ContainsPoint (location)) {
|
||||
PresentScene (new AchievementsScreen (View.Bounds.Size));
|
||||
} else if (backButton.ContainsPoint (location)) {
|
||||
PresentScene (new MainMenu (View.Bounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AchievementsScreen : BasicScene {
|
||||
|
||||
SKLabelNode backButton;
|
||||
|
||||
public AchievementsScreen (SizeF size) : base (size)
|
||||
{
|
||||
var title = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Achievements",
|
||||
FontSize = 30,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 200)
|
||||
};
|
||||
|
||||
backButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Back",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 200)
|
||||
};
|
||||
|
||||
var incompleteLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Incomplete",
|
||||
FontSize = 18,
|
||||
Position = new PointF (FrameMidX + 75, FrameMidY + 150)
|
||||
};
|
||||
|
||||
var completeLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Complete",
|
||||
FontSize = 18,
|
||||
Position = new PointF (FrameMidX - 75, FrameMidY + 150)
|
||||
};
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated)
|
||||
GKAchievementDescription.LoadAchievementDescriptions (LoadAchievementInfo);
|
||||
|
||||
AddChild (title);
|
||||
AddChild (incompleteLabel);
|
||||
AddChild (completeLabel);
|
||||
AddChild (backButton);
|
||||
}
|
||||
|
||||
void LoadAchievementInfo (GKAchievementDescription[] descriptions, NSError error)
|
||||
{
|
||||
if (descriptions == null)
|
||||
return;
|
||||
|
||||
GKAchievement.LoadAchievements (delegate (GKAchievement[] achievements, NSError err) {
|
||||
int completeOffset = 0;
|
||||
int incompleteOffset = 0;
|
||||
|
||||
foreach (var description in descriptions) {
|
||||
bool completed = false;
|
||||
foreach (var achievement in achievements) {
|
||||
if (description.Identifier == achievement.Identifier)
|
||||
completed |= achievement.Completed;
|
||||
}
|
||||
|
||||
int xOffset = completed ? -75 : 75;
|
||||
int yOffset = completed ? completeOffset : incompleteOffset;
|
||||
|
||||
var achievementLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = description.Title,
|
||||
FontSize = 10,
|
||||
Position = new PointF (FrameMidX + xOffset, FrameMidY + 50 + yOffset + 25)
|
||||
};
|
||||
AddChild (achievementLabel);
|
||||
|
||||
description.LoadImage (delegate (UIImage image, NSError imageError) {
|
||||
if (image == null)
|
||||
image = UIImage.FromFile ("Images/DefaultPlayerPhoto.png");
|
||||
var sprite = SKSpriteNode.FromTexture (SKTexture.FromImage (image), new SizeF (32, 32));
|
||||
sprite.Position = new PointF (FrameMidX + xOffset, FrameMidY + 50 + yOffset + 50);
|
||||
AddChild (sprite);
|
||||
});
|
||||
|
||||
if (completed)
|
||||
completeOffset -= 50;
|
||||
else
|
||||
incompleteOffset -= 50;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
if (backButton.ContainsPoint (location))
|
||||
PresentScene (new StatsScreen (new SizeF (View.Bounds.Size)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LeaderboardSetsScreen : BasicScene {
|
||||
SKLabelNode backButton;
|
||||
GKLeaderboardSet[] leaderboardSets;
|
||||
List<SKLabelNode> leaderboardSetButtons;
|
||||
|
||||
public LeaderboardSetsScreen (SizeF size) : base (size)
|
||||
{
|
||||
leaderboardSetButtons = new List<SKLabelNode> ();
|
||||
|
||||
SKLabelNode title = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Leaderboards Sets",
|
||||
FontSize = 30,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 200)
|
||||
};
|
||||
|
||||
backButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Back",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 200)
|
||||
};
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated)
|
||||
GKLeaderboardSet.LoadLeaderboardSets (LoadLeaderboardSets);
|
||||
|
||||
AddChild (title);
|
||||
AddChild (backButton);
|
||||
}
|
||||
|
||||
void LoadLeaderboardSets (GKLeaderboardSet[] leaderboardSets, NSError error)
|
||||
{
|
||||
this.leaderboardSets = leaderboardSets;
|
||||
if (leaderboardSets == null)
|
||||
return;
|
||||
|
||||
int offset = 0;
|
||||
foreach (var leaderboardSet in leaderboardSets) {
|
||||
var leaderboardSetButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = leaderboardSet.Title,
|
||||
FontSize = 18,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 125 - offset)
|
||||
};
|
||||
offset += 50;
|
||||
|
||||
AddChild (leaderboardSetButton);
|
||||
leaderboardSetButtons.Add (leaderboardSetButton);
|
||||
}
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
|
||||
if (backButton.ContainsPoint (location)) {
|
||||
PresentScene (new StatsScreen (View.Bounds.Size));
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < leaderboardSetButtons.Count; i++) {
|
||||
var button = leaderboardSetButtons [i];
|
||||
|
||||
if (button.ContainsPoint (location)) {
|
||||
GameInfo.CurrentSet = leaderboardSets [i];
|
||||
PresentScene (new LeaderboardsScreen (View.Bounds.Size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LeaderboardsScreen : BasicScene {
|
||||
|
||||
SKLabelNode backButton;
|
||||
GKLeaderboard [] leaderboards;
|
||||
List<SKLabelNode> leaderboardButtons;
|
||||
|
||||
public LeaderboardsScreen (SizeF size) : base (size)
|
||||
{
|
||||
leaderboardButtons = new List<SKLabelNode> ();
|
||||
|
||||
var title = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Leaderboards",
|
||||
FontSize = 30,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 200)
|
||||
};
|
||||
|
||||
backButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Back",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 200)
|
||||
};
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated)
|
||||
GameInfo.CurrentSet.LoadLeaderboards (LoadLeaderboard);
|
||||
|
||||
AddChild (title);
|
||||
AddChild (backButton);
|
||||
}
|
||||
|
||||
void LoadLeaderboard (GKLeaderboard[] leaderboards, NSError error)
|
||||
{
|
||||
this.leaderboards = leaderboards;
|
||||
int offset = 0;
|
||||
foreach (var leaderboard in leaderboards) {
|
||||
SKLabelNode leaderboardButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = leaderboard.Title,
|
||||
FontSize = 18,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 125 - offset)
|
||||
};
|
||||
offset += 50;
|
||||
|
||||
AddChild (leaderboardButton);
|
||||
leaderboardButtons.Add (leaderboardButton);
|
||||
}
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
|
||||
if (backButton.ContainsPoint (location)) {
|
||||
PresentScene (new StatsScreen (View.Bounds.Size));
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < leaderboardButtons.Count; i++) {
|
||||
var button = leaderboardButtons [i];
|
||||
|
||||
if (button.ContainsPoint (location)) {
|
||||
GameInfo.CurrentLeaderBoard = leaderboards [i];
|
||||
PresentScene (new LeaderboardScoresScreen (View.Bounds.Size));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LeaderboardScoresScreen : BasicScene {
|
||||
|
||||
SKLabelNode backButton;
|
||||
|
||||
public LeaderboardScoresScreen (SizeF size) : base (size)
|
||||
{
|
||||
SKLabelNode title = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = GameInfo.CurrentLeaderBoard.Title,
|
||||
FontSize = 14,
|
||||
Position = new PointF (FrameMidX, FrameMidY + 200)
|
||||
};
|
||||
|
||||
var podiumSprite = SKSpriteNode.FromTexture (SKTexture.FromImageNamed ("Images/Podium.png"));
|
||||
podiumSprite.Position = new PointF (FrameMidX, FrameMidY + 50);
|
||||
|
||||
backButton = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = "Back",
|
||||
FontSize = 18,
|
||||
FontColor = ButtonColor,
|
||||
Position = new PointF (FrameMidX, FrameMidY - 200)
|
||||
};
|
||||
|
||||
if (GKLocalPlayer.LocalPlayer.Authenticated)
|
||||
LoadLeaderboardScoresInfo (GameInfo.CurrentLeaderBoard);
|
||||
|
||||
AddChild (title);
|
||||
AddChild (backButton);
|
||||
AddChild (podiumSprite);
|
||||
}
|
||||
|
||||
void DisplayScore (GKScore score, int rank, GKPlayer player)
|
||||
{
|
||||
PointF[] podiumPositions = new PointF[] {
|
||||
new PointF (0, 100),
|
||||
new PointF (-84, 75),
|
||||
new PointF (84, 50)
|
||||
};
|
||||
|
||||
PointF currentPoint = podiumPositions [rank];
|
||||
|
||||
SKLabelNode scoreLabel = new SKLabelNode ("GillSans-Bold") {
|
||||
Text = score.FormattedValue,
|
||||
FontSize = 14,
|
||||
Position = new PointF (FrameMidX + currentPoint.X, FrameMidY + currentPoint.Y - 32)
|
||||
};
|
||||
|
||||
player.LoadPhoto (GKPhotoSize.Small, delegate (UIImage photo, NSError error) {
|
||||
if (photo == null)
|
||||
photo = UIImage.FromFile ("Images/DefaultPlayerPhoto.png");
|
||||
var image = SKSpriteNode.FromTexture (SKTexture.FromImage (photo), new SizeF (32, 32));
|
||||
image.Position = new PointF (FrameMidX + currentPoint.X, FrameMidY + currentPoint.Y + 16);
|
||||
AddChild (image);
|
||||
});
|
||||
|
||||
AddChild (scoreLabel);
|
||||
}
|
||||
|
||||
async Task LoadLeaderboardScoresInfo (GKLeaderboard leaderboard)
|
||||
{
|
||||
leaderboard.Range = new NSRange (1, 3);
|
||||
leaderboard.TimeScope = GKLeaderboardTimeScope.AllTime;
|
||||
leaderboard.PlayerScope = GKLeaderboardPlayerScope.Global;
|
||||
var scores = await leaderboard.LoadScoresAsync ();
|
||||
|
||||
string [] identifiers = new string [scores.Length];
|
||||
int n = 0;
|
||||
foreach (var score in scores)
|
||||
identifiers [n++] = score.Player;
|
||||
|
||||
GKPlayer.LoadPlayersForIdentifiers (identifiers, delegate (GKPlayer[] players, NSError error) {
|
||||
for (int i = 0; i < scores.Length; i++)
|
||||
DisplayScore (scores [i], i, players [i]);
|
||||
});
|
||||
}
|
||||
|
||||
public override void TouchesBegan (NSSet touches, UIEvent evt)
|
||||
{
|
||||
foreach (var touch in touches) {
|
||||
PointF location = (touch as UITouch).LocationInNode (this);
|
||||
if (backButton.ContainsPoint (location))
|
||||
PresentScene (new LeaderboardsScreen (View.Bounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using MonoTouch.SpriteKit;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace ButtonTapper3000 {
|
||||
|
||||
public class ViewController : UIViewController {
|
||||
|
||||
public override void LoadView ()
|
||||
{
|
||||
View = new SKView ();
|
||||
}
|
||||
|
||||
public override void ViewWillAppear (bool animated)
|
||||
{
|
||||
(View as SKView).PresentScene (new MainMenu (View.Bounds.Size));
|
||||
}
|
||||
|
||||
public override bool ShouldAutorotate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()
|
||||
{
|
||||
return UIInterfaceOrientationMask.Portrait;
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 106 KiB |
После Ширина: | Высота: | Размер: 273 KiB |
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<SampleMetadata>
|
||||
<ID>666b31e5-356a-4c27-9d03-1b754a516ecf</ID>
|
||||
<IsFullApplication>false</IsFullApplication>
|
||||
<Level>Intermediate</Level>
|
||||
<Tags>Games</Tags>
|
||||
<LicenseRequirement>Indie</LicenseRequirement>
|
||||
</SampleMetadata>
|
|
@ -0,0 +1,11 @@
|
|||
ButtonTapper3000
|
||||
================
|
||||
Demonstrates the use of the new GameKit APIs introduced in iOS 7 for Achievements and Leaderboards.
|
||||
|
||||
The app lets the user play a simple tapping game, choosing from two difficulty levels and 3 time limits. There is a leaderboard for each combination of difficulty level and time limit, as well as one for Average Tap Time.
|
||||
|
||||
There are achievements for playing on hard mode, playing all difficulty levels, and playing tapping once, a hundred times, and a thousand times in a single game.
|
||||
|
||||
Authors
|
||||
-------
|
||||
Timothy Risi
|
После Ширина: | Высота: | Размер: 40 KiB |
После Ширина: | Высота: | Размер: 33 KiB |
После Ширина: | Высота: | Размер: 24 KiB |
После Ширина: | Высота: | Размер: 33 KiB |
|
@ -0,0 +1,32 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollectionViewTransition", "CollectionViewTransition\CollectionViewTransition.csproj", "{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Release|iPhone = Release|iPhone
|
||||
Ad-Hoc|iPhone = Ad-Hoc|iPhone
|
||||
AppStore|iPhone = AppStore|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = CollectionViewTransition\CollectionViewTransition.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.CoreAnimation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLCollectionViewCell : UICollectionViewCell {
|
||||
|
||||
public static readonly NSString Key = new NSString ("APLCollectionViewCell");
|
||||
|
||||
[Export ("initWithFrame:")]
|
||||
public APLCollectionViewCell (RectangleF frame) : base (frame)
|
||||
{
|
||||
BackgroundColor = UIColor.Cyan;
|
||||
ImageView = new UIImageView (Bounds);
|
||||
ImageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
|
||||
ImageView.ContentMode = UIViewContentMode.ScaleAspectFill;
|
||||
ImageView.Layer.BorderWidth = 3.0f;
|
||||
ImageView.ClipsToBounds = true;
|
||||
ImageView.Layer.BorderColor = UIColor.White.CGColor;
|
||||
ImageView.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
|
||||
ContentView.AddSubview (ImageView);
|
||||
}
|
||||
|
||||
public UIImageView ImageView { get; private set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
//#define NO_IMAGES
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLCollectionViewController : UICollectionViewController {
|
||||
|
||||
public const int MAX_COUNT = 20;
|
||||
|
||||
public APLCollectionViewController (UICollectionViewLayout layout) : base (layout)
|
||||
{
|
||||
CollectionView.RegisterClassForCell (typeof (APLCollectionViewCell), APLCollectionViewCell.Key);
|
||||
}
|
||||
|
||||
public override int NumberOfSections (UICollectionView collectionView)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override int GetItemsCount (UICollectionView collectionView, int section)
|
||||
{
|
||||
return MAX_COUNT;
|
||||
}
|
||||
|
||||
public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath)
|
||||
{
|
||||
var cell = collectionView.DequeueReusableCell (APLCollectionViewCell.Key, indexPath) as APLCollectionViewCell;
|
||||
#if NO_IMAGES
|
||||
float hue = indexPath.Item / (float) MAX_COUNT;
|
||||
UIColor cellColor = UIColor.FromHSB (hue, 1.0f, 1.0f);
|
||||
cell.ContentView.BackgroundColor = cellColor;
|
||||
#else
|
||||
cell.ImageView.Image = UIImage.FromFile ("Images/sa" + indexPath.Item + ".jpg");
|
||||
#endif
|
||||
return cell;
|
||||
}
|
||||
|
||||
public override UICollectionViewTransitionLayout TransitionLayout (UICollectionView collectionView, UICollectionViewLayout fromLayout, UICollectionViewLayout toLayout)
|
||||
{
|
||||
return new APLTransitionLayout (fromLayout, toLayout);
|
||||
}
|
||||
|
||||
public virtual UICollectionViewController NextViewControllerAtPoint (PointF p)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLGridCollectionViewController : APLCollectionViewController {
|
||||
|
||||
public APLGridCollectionViewController (UICollectionViewLayout layout) : base (layout)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLStackCollectionViewController : APLCollectionViewController {
|
||||
|
||||
public APLStackCollectionViewController (UICollectionViewLayout layout) : base (layout)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ItemSelected (UICollectionView collectionView, NSIndexPath indexPath)
|
||||
{
|
||||
NavigationController.PushViewController (NextViewControllerAtPoint (PointF.Empty), true);
|
||||
}
|
||||
|
||||
public override UICollectionViewController NextViewControllerAtPoint (PointF p)
|
||||
{
|
||||
UICollectionViewFlowLayout grid = new UICollectionViewFlowLayout () {
|
||||
ItemSize = new SizeF (75.0f, 75.0f),
|
||||
SectionInset = new UIEdgeInsets (10.0f, 10.0f, 10.0f, 10.0f)
|
||||
};
|
||||
return new APLGridCollectionViewController (grid) {
|
||||
Title = "Grid Layout",
|
||||
UseLayoutToLayoutNavigationTransitions = true
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLStackLayout : UICollectionViewLayout {
|
||||
|
||||
const int stackCount = 5;
|
||||
List<float> angles;
|
||||
List<UICollectionViewLayoutAttributes> attributesArray;
|
||||
|
||||
public APLStackLayout ()
|
||||
{
|
||||
angles = new List<float> (stackCount * 10);
|
||||
}
|
||||
|
||||
public override void PrepareLayout ()
|
||||
{
|
||||
SizeF size = CollectionView.Bounds.Size;
|
||||
PointF center = new PointF (size.Width / 2.0f, size.Height / 2.0f);
|
||||
|
||||
int itemCount = CollectionView.NumberOfItemsInSection (0);
|
||||
|
||||
if (attributesArray == null)
|
||||
attributesArray = new List<UICollectionViewLayoutAttributes> (itemCount);
|
||||
|
||||
angles.Clear ();
|
||||
|
||||
float maxAngle = (float) (1 / Math.PI / 3.0f);
|
||||
float minAngle = -maxAngle;
|
||||
float diff = maxAngle - minAngle;
|
||||
|
||||
angles.Add (0);
|
||||
for (int i = 1; i < stackCount * 10; i++) {
|
||||
int hash = (int) (i * 2654435761 % 2 ^ 32);
|
||||
hash = (int)(hash * 2654435761 % 2 ^ 32);
|
||||
|
||||
float currentAngle = (float) ((hash % 1000) / 1000.0 * diff) + minAngle;
|
||||
angles.Add (currentAngle);
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
int angleIndex = i % (stackCount * 10);
|
||||
float angle = angles [angleIndex];
|
||||
var path = NSIndexPath.FromItemSection (i, 0);
|
||||
UICollectionViewLayoutAttributes attributes = UICollectionViewLayoutAttributes.CreateForCell (path);
|
||||
attributes.Size = new SizeF (150, 200);
|
||||
attributes.Center = center;
|
||||
attributes.Transform = CGAffineTransform.MakeRotation (angle);
|
||||
attributes.Alpha = (i > stackCount) ? 0.0f : 1.0f;
|
||||
attributes.ZIndex = (itemCount - i);
|
||||
attributesArray.Add (attributes);
|
||||
}
|
||||
}
|
||||
|
||||
public override void InvalidateLayout ()
|
||||
{
|
||||
attributesArray.Clear ();
|
||||
attributesArray = null;
|
||||
}
|
||||
|
||||
public override SizeF CollectionViewContentSize {
|
||||
get { return CollectionView.Bounds.Size; }
|
||||
}
|
||||
|
||||
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
||||
{
|
||||
return attributesArray [indexPath.Item];
|
||||
}
|
||||
|
||||
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (RectangleF rect)
|
||||
{
|
||||
return attributesArray.ToArray ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLTransitionController : UIViewControllerInteractiveTransitioning, IUIViewControllerAnimatedTransitioning {
|
||||
|
||||
APLTransitionLayout transitionLayout;
|
||||
UICollectionView collectionView;
|
||||
UINavigationController navigationController;
|
||||
IUIViewControllerContextTransitioning context;
|
||||
float initialPinchDistance;
|
||||
PointF initialPinchPoint;
|
||||
|
||||
public APLTransitionController (UICollectionView view, UINavigationController controller)
|
||||
{
|
||||
collectionView = view;
|
||||
collectionView.AddGestureRecognizer (new UIPinchGestureRecognizer (HandlePinch));
|
||||
navigationController = controller;
|
||||
}
|
||||
|
||||
public bool HasActiveInteraction { get; private set; }
|
||||
|
||||
public UINavigationControllerOperation NavigationOperation { get; set; }
|
||||
|
||||
void InteractionBegan (PointF point)
|
||||
{
|
||||
UIViewController viewController = ((APLCollectionViewController)navigationController.TopViewController).NextViewControllerAtPoint (point);
|
||||
if (viewController != null) {
|
||||
navigationController.PushViewController (viewController, true);
|
||||
} else {
|
||||
navigationController.PopViewControllerAnimated (true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StartInteractiveTransition (IUIViewControllerContextTransitioning transitionContext)
|
||||
{
|
||||
context = transitionContext;
|
||||
var fromVC = (UICollectionViewController) context.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
|
||||
var toVC = (UICollectionViewController) context.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
|
||||
transitionLayout = (APLTransitionLayout) fromVC.CollectionView.StartInteractiveTransition (toVC.Layout,
|
||||
delegate (bool finished, bool completed) {
|
||||
context.CompleteTransition (completed);
|
||||
collectionView.WeakDelegate = completed ? toVC : fromVC;
|
||||
transitionLayout = null;
|
||||
context = null;
|
||||
HasActiveInteraction = false;
|
||||
});
|
||||
}
|
||||
|
||||
void Update (float progress, UIOffset offset)
|
||||
{
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
if ((progress != transitionLayout.TransitionProgress) || (offset != transitionLayout.Offset)) {
|
||||
transitionLayout.SetOffset (offset);
|
||||
transitionLayout.SetTransitionProgress (progress);
|
||||
transitionLayout.InvalidateLayout ();
|
||||
context.UpdateInteractiveTransition (progress);
|
||||
}
|
||||
}
|
||||
|
||||
void EndInteraction (bool success)
|
||||
{
|
||||
if (context == null) {
|
||||
HasActiveInteraction = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (success && (transitionLayout.TransitionProgress > 0.5f)) {
|
||||
collectionView.FinishInteractiveTransition ();
|
||||
context.FinishInteractiveTransition ();
|
||||
} else {
|
||||
collectionView.CancelInteractiveTransition ();
|
||||
context.CancelInteractiveTransition ();
|
||||
}
|
||||
}
|
||||
|
||||
public void HandlePinch (UIPinchGestureRecognizer sender)
|
||||
{
|
||||
if (sender.NumberOfTouches < 2)
|
||||
return;
|
||||
|
||||
PointF point1 = sender.LocationOfTouch (0, sender.View);
|
||||
PointF point2 = sender.LocationOfTouch (1, sender.View);
|
||||
float distance = (float) Math.Sqrt ((point1.X - point2.X) * (point1.X - point2.X) +
|
||||
(point1.Y - point2.Y) * (point1.Y - point2.Y));
|
||||
PointF point = sender.LocationInView (sender.View);
|
||||
|
||||
if (sender.State == UIGestureRecognizerState.Began) {
|
||||
if (HasActiveInteraction)
|
||||
return;
|
||||
|
||||
initialPinchDistance = distance;
|
||||
initialPinchPoint = point;
|
||||
HasActiveInteraction = true;
|
||||
InteractionBegan (point);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasActiveInteraction)
|
||||
return;
|
||||
|
||||
switch (sender.State) {
|
||||
case UIGestureRecognizerState.Changed:
|
||||
float offsetX = point.X - initialPinchPoint.X;
|
||||
float offsetY = point.Y - initialPinchPoint.Y;
|
||||
float distanceDelta = distance - initialPinchDistance;
|
||||
|
||||
if (NavigationOperation == UINavigationControllerOperation.Pop)
|
||||
distanceDelta = -distanceDelta;
|
||||
|
||||
SizeF size = collectionView.Bounds.Size;
|
||||
float dimension = (float)Math.Sqrt (size.Width * size.Width + size.Height * size.Height);
|
||||
float progress = (float) Math.Max (Math.Min (distanceDelta / dimension, 1.0), 0.0);
|
||||
Update (progress, new UIOffset (offsetX, offsetY));
|
||||
break;
|
||||
case UIGestureRecognizerState.Ended:
|
||||
EndInteraction (true);
|
||||
break;
|
||||
case UIGestureRecognizerState.Cancelled:
|
||||
EndInteraction (false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
|
||||
{
|
||||
}
|
||||
|
||||
public double TransitionDuration (IUIViewControllerContextTransitioning transitionContext)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
public class APLTransitionLayout : UICollectionViewTransitionLayout {
|
||||
|
||||
public APLTransitionLayout(UICollectionViewLayout currentLayout, UICollectionViewLayout newLayout) :
|
||||
base (currentLayout, newLayout)
|
||||
{
|
||||
}
|
||||
|
||||
public UIOffset Offset { get; private set; }
|
||||
|
||||
public void SetTransitionProgress (float transitionProgress)
|
||||
{
|
||||
base.TransitionProgress = transitionProgress;
|
||||
float offsetH = GetValueForAnimatedKey ("offsetH");
|
||||
float offsetV = GetValueForAnimatedKey ("offsetV");
|
||||
Offset = new UIOffset (offsetH, offsetV);
|
||||
}
|
||||
|
||||
public void SetOffset (UIOffset offset)
|
||||
{
|
||||
UpdateValue (offset.Horizontal, "offsetH");
|
||||
UpdateValue (offset.Vertical, "offsetV");
|
||||
Offset = offset;
|
||||
}
|
||||
|
||||
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (RectangleF rect)
|
||||
{
|
||||
UICollectionViewLayoutAttributes[] attributes = base.LayoutAttributesForElementsInRect (rect);
|
||||
foreach (var attribute in attributes) {
|
||||
PointF center = attribute.Center;
|
||||
attribute.Center = new PointF (center.X + Offset.Horizontal, center.Y + Offset.Vertical);
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
||||
{
|
||||
UICollectionViewLayoutAttributes attributes = base.LayoutAttributesForItem (indexPath);
|
||||
PointF center = attributes.Center;
|
||||
attributes.Center = new PointF (center.X + Offset.Horizontal, center.Y + Offset.Vertical);
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace CollectionViewTransition {
|
||||
|
||||
[Register ("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate {
|
||||
|
||||
public override UIWindow Window {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override void FinishedLaunching (UIApplication application)
|
||||
{
|
||||
Window = new UIWindow (UIScreen.MainScreen.Bounds);
|
||||
APLStackLayout stackLayout = new APLStackLayout ();
|
||||
var cvc = new APLStackCollectionViewController (stackLayout) {
|
||||
Title = "Stack Layout"
|
||||
};
|
||||
var navigationController = new UINavigationController (cvc);
|
||||
navigationController.NavigationBar.Translucent = false;
|
||||
|
||||
var transitionController = new APLTransitionController (cvc.CollectionView, navigationController);
|
||||
navigationController.Delegate = new NavigationControllerDelegate (transitionController);
|
||||
|
||||
Window.RootViewController = navigationController;
|
||||
Window.MakeKeyAndVisible ();
|
||||
}
|
||||
|
||||
public class NavigationControllerDelegate : UINavigationControllerDelegate
|
||||
{
|
||||
APLTransitionController transitionController;
|
||||
|
||||
public NavigationControllerDelegate (APLTransitionController controller)
|
||||
{
|
||||
transitionController = controller;
|
||||
}
|
||||
|
||||
public override IUIViewControllerInteractiveTransitioning GetInteractionControllerForAnimationController (UINavigationController navigationController, IUIViewControllerAnimatedTransitioning animationController)
|
||||
{
|
||||
if (animationController == transitionController)
|
||||
return transitionController;
|
||||
return null;
|
||||
}
|
||||
|
||||
public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation (UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
|
||||
{
|
||||
if (!fromViewController.GetType ().IsSubclassOf (typeof(UICollectionViewController)))
|
||||
return null;
|
||||
if (!toViewController.GetType ().IsSubclassOf (typeof (UICollectionViewController)))
|
||||
return null;
|
||||
if (!transitionController.HasActiveInteraction)
|
||||
return null;
|
||||
|
||||
transitionController.NavigationOperation = operation;
|
||||
return transitionController;
|
||||
}
|
||||
}
|
||||
|
||||
static void Main (string[] args)
|
||||
{
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
<?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)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D58FCF19-13C2-49DF-B24B-F5D4E277D62B}</ProjectGuid>
|
||||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>CollectionViewTransition</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>CollectionViewTransition</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<IpaPackageName>
|
||||
</IpaPackageName>
|
||||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="monotouch" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
<Folder Include="Images\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="APLCollectionViewCell.cs" />
|
||||
<Compile Include="APLGridCollectionViewController.cs" />
|
||||
<Compile Include="APLStackCollectionViewController.cs" />
|
||||
<Compile Include="APLStackLayout.cs" />
|
||||
<Compile Include="APLTransitionLayout.cs" />
|
||||
<Compile Include="APLCollectionViewController.cs" />
|
||||
<Compile Include="APLTransitionController.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Images\sa0.jpg" />
|
||||
<BundleResource Include="Images\sa1.jpg" />
|
||||
<BundleResource Include="Images\sa10.jpg" />
|
||||
<BundleResource Include="Images\sa11.jpg" />
|
||||
<BundleResource Include="Images\sa12.jpg" />
|
||||
<BundleResource Include="Images\sa13.jpg" />
|
||||
<BundleResource Include="Images\sa14.jpg" />
|
||||
<BundleResource Include="Images\sa15.jpg" />
|
||||
<BundleResource Include="Images\sa16.jpg" />
|
||||
<BundleResource Include="Images\sa17.jpg" />
|
||||
<BundleResource Include="Images\sa18.jpg" />
|
||||
<BundleResource Include="Images\sa19.jpg" />
|
||||
<BundleResource Include="Images\sa2.jpg" />
|
||||
<BundleResource Include="Images\sa20.jpg" />
|
||||
<BundleResource Include="Images\sa21.jpg" />
|
||||
<BundleResource Include="Images\sa22.jpg" />
|
||||
<BundleResource Include="Images\sa23.jpg" />
|
||||
<BundleResource Include="Images\sa24.jpg" />
|
||||
<BundleResource Include="Images\sa25.jpg" />
|
||||
<BundleResource Include="Images\sa26.jpg" />
|
||||
<BundleResource Include="Images\sa27.jpg" />
|
||||
<BundleResource Include="Images\sa28.jpg" />
|
||||
<BundleResource Include="Images\sa29.jpg" />
|
||||
<BundleResource Include="Images\sa3.jpg" />
|
||||
<BundleResource Include="Images\sa30.jpg" />
|
||||
<BundleResource Include="Images\sa31.jpg" />
|
||||
<BundleResource Include="Images\sa32.jpg" />
|
||||
<BundleResource Include="Images\sa33.jpg" />
|
||||
<BundleResource Include="Images\sa34.jpg" />
|
||||
<BundleResource Include="Images\sa35.jpg" />
|
||||
<BundleResource Include="Images\sa36.jpg" />
|
||||
<BundleResource Include="Images\sa37.jpg" />
|
||||
<BundleResource Include="Images\sa38.jpg" />
|
||||
<BundleResource Include="Images\sa4.jpg" />
|
||||
<BundleResource Include="Images\sa5.jpg" />
|
||||
<BundleResource Include="Images\sa6.jpg" />
|
||||
<BundleResource Include="Images\sa7.jpg" />
|
||||
<BundleResource Include="Images\sa8.jpg" />
|
||||
<BundleResource Include="Images\sa9.jpg" />
|
||||
<BundleResource Include="Resources\Default-568h%402x.png" />
|
||||
<BundleResource Include="Resources\Default%402x.png" />
|
||||
<BundleResource Include="Resources\Default.png" />
|
||||
<BundleResource Include="Resources\iTunesArtwork.png" />
|
||||
<BundleResource Include="Resources\iTunesArtwork%402x.png" />
|
||||
<BundleResource Include="Resources\Icon.png" />
|
||||
<BundleResource Include="Resources\Icon%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small.png" />
|
||||
<BundleResource Include="Resources\Icon-Small%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-60%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small-40%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork" />
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork%402x" />
|
||||
</ItemGroup>
|
||||
</Project>
|
После Ширина: | Высота: | Размер: 25 KiB |
После Ширина: | Высота: | Размер: 22 KiB |
После Ширина: | Высота: | Размер: 26 KiB |
После Ширина: | Высота: | Размер: 24 KiB |
После Ширина: | Высота: | Размер: 27 KiB |
После Ширина: | Высота: | Размер: 29 KiB |
После Ширина: | Высота: | Размер: 28 KiB |
После Ширина: | Высота: | Размер: 28 KiB |
После Ширина: | Высота: | Размер: 28 KiB |
После Ширина: | Высота: | Размер: 29 KiB |
После Ширина: | Высота: | Размер: 18 KiB |
После Ширина: | Высота: | Размер: 28 KiB |
После Ширина: | Высота: | Размер: 20 KiB |
После Ширина: | Высота: | Размер: 32 KiB |