初始化

This commit is contained in:
xhm
2023-11-21 23:05:03 +08:00
commit 2455630dad
2252 changed files with 466529 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
namespace CPF.Mac.CoreLocation
{
public enum CLActivityType
{
Other = 1,
AutomotiveNavigation,
Fitness,
OtherNavigation
}
}

View File

@@ -0,0 +1,18 @@
using System;
namespace CPF.Mac.CoreLocation
{
public class CLAuthorizationChangedEventArgs : EventArgs
{
public CLAuthorizationStatus Status
{
get;
set;
}
public CLAuthorizationChangedEventArgs(CLAuthorizationStatus status)
{
Status = status;
}
}
}

View File

@@ -0,0 +1,10 @@
namespace CPF.Mac.CoreLocation
{
public enum CLAuthorizationStatus
{
NotDetermined,
Restricted,
Denied,
Authorized
}
}

View File

@@ -0,0 +1,13 @@
using System;
namespace CPF.Mac.CoreLocation
{
[Obsolete("Use CLAuthorizationChangedEventArgs")]
public class CLAuthroziationChangedEventArgs : CLAuthorizationChangedEventArgs
{
public CLAuthroziationChangedEventArgs(CLAuthorizationStatus status)
: base(status)
{
}
}
}

View File

@@ -0,0 +1,13 @@
namespace CPF.Mac.CoreLocation
{
public enum CLDeviceOrientation
{
Unknown,
Portrait,
PortraitUpsideDown,
LandscapeLeft,
LandscapeRight,
FaceUp,
FaceDown
}
}

View File

@@ -0,0 +1,27 @@
using CPF.Mac.ObjCRuntime;
namespace CPF.Mac.CoreLocation
{
public enum CLError
{
LocationUnknown,
Denied,
Network,
HeadingFailure,
[Since(4, 0)]
RegionMonitoringDenied,
[Since(4, 0)]
RegionMonitoringFailure,
[Since(4, 0)]
RegionMonitoringSetupDelayed,
RegionMonitoringResponseDelayed,
GeocodeFoundNoResult,
GeocodeFoundPartialResult,
GeocodeCanceled,
DeferredFailed,
DeferredNotUpdatingLocation,
DeferredAccuracyTooLow,
DeferredDistanceFiltered,
DeferredCanceled
}
}

View File

@@ -0,0 +1,327 @@
using CPF.Mac.Foundation;
using CPF.Mac.ObjCRuntime;
using System;
using System.ComponentModel;
namespace CPF.Mac.CoreLocation
{
[Register("CLLocation", true)]
public class CLLocation : NSObject
{
public static readonly double AccuracyBest;
public static readonly double AccuracyNearestTenMeters;
public static readonly double AccuracyHundredMeters;
public static readonly double AccuracyKilometer;
public static readonly double AccuracyThreeKilometers;
public static readonly double AccurracyBestForNavigation;
private static readonly IntPtr selCoordinateHandle;
private static readonly IntPtr selAltitudeHandle;
private static readonly IntPtr selHorizontalAccuracyHandle;
private static readonly IntPtr selVerticalAccuracyHandle;
private static readonly IntPtr selCourseHandle;
private static readonly IntPtr selSpeedHandle;
private static readonly IntPtr selTimestampHandle;
private static readonly IntPtr selInitWithLatitudeLongitude_Handle;
private static readonly IntPtr selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyTimestamp_Handle;
private static readonly IntPtr selDescriptionHandle;
private static readonly IntPtr selGetDistanceFrom_Handle;
private static readonly IntPtr selDistanceFromLocation_Handle;
private static readonly IntPtr selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyCourseSpeedTimestamp_Handle;
private static readonly IntPtr class_ptr;
private object __mt_Timestamp_var;
private static NSString _ErrorUserInfoAlternateRegionKey;
public override IntPtr ClassHandle => class_ptr;
public virtual CLLocationCoordinate2D Coordinate
{
[Export("coordinate")]
get
{
if (IsDirectBinding)
{
return Messaging.CLLocationCoordinate2D_objc_msgSend(base.Handle, selCoordinateHandle);
}
return Messaging.CLLocationCoordinate2D_objc_msgSendSuper(base.SuperHandle, selCoordinateHandle);
}
}
public virtual double Altitude
{
[Export("altitude")]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selAltitudeHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selAltitudeHandle);
}
}
public virtual double HorizontalAccuracy
{
[Export("horizontalAccuracy")]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selHorizontalAccuracyHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selHorizontalAccuracyHandle);
}
}
public virtual double VerticalAccuracy
{
[Export("verticalAccuracy")]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selVerticalAccuracyHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selVerticalAccuracyHandle);
}
}
public virtual double Course
{
[Export("course")]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selCourseHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selCourseHandle);
}
}
public virtual double Speed
{
[Export("speed")]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selSpeedHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selSpeedHandle);
}
}
public virtual NSDate Timestamp
{
[Export("timestamp")]
get
{
return (NSDate)(__mt_Timestamp_var = ((!IsDirectBinding) ? ((NSDate)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selTimestampHandle))) : ((NSDate)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selTimestampHandle)))));
}
}
[Field("kCLErrorUserInfoAlternateRegionKey", "CoreLocation")]
[MountainLion]
public static NSString ErrorUserInfoAlternateRegionKey
{
[MountainLion]
get
{
if (_ErrorUserInfoAlternateRegionKey == null)
{
_ErrorUserInfoAlternateRegionKey = Dlfcn.GetStringConstant(Libraries.CoreLocation.Handle, "kCLErrorUserInfoAlternateRegionKey");
}
return _ErrorUserInfoAlternateRegionKey;
}
}
static CLLocation()
{
selCoordinateHandle = Selector.GetHandle("coordinate");
selAltitudeHandle = Selector.GetHandle("altitude");
selHorizontalAccuracyHandle = Selector.GetHandle("horizontalAccuracy");
selVerticalAccuracyHandle = Selector.GetHandle("verticalAccuracy");
selCourseHandle = Selector.GetHandle("course");
selSpeedHandle = Selector.GetHandle("speed");
selTimestampHandle = Selector.GetHandle("timestamp");
selInitWithLatitudeLongitude_Handle = Selector.GetHandle("initWithLatitude:longitude:");
selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyTimestamp_Handle = Selector.GetHandle("initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:");
selDescriptionHandle = Selector.GetHandle("description");
selGetDistanceFrom_Handle = Selector.GetHandle("getDistanceFrom:");
selDistanceFromLocation_Handle = Selector.GetHandle("distanceFromLocation:");
selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyCourseSpeedTimestamp_Handle = Selector.GetHandle("initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp:");
class_ptr = Class.GetHandle("CLLocation");
IntPtr handle = Libraries.CoreLocation.Handle;
if (!(handle == IntPtr.Zero))
{
AccurracyBestForNavigation = Dlfcn.GetDouble(handle, "kCLLocationAccuracyBestForNavigation");
AccuracyBest = Dlfcn.GetDouble(handle, "kCLLocationAccuracyBest");
AccuracyNearestTenMeters = Dlfcn.GetDouble(handle, "kCLLocationAccuracyNearestTenMeters");
AccuracyHundredMeters = Dlfcn.GetDouble(handle, "kCLLocationAccuracyHundredMeters");
AccuracyKilometer = Dlfcn.GetDouble(handle, "kCLLocationAccuracyKilometer");
AccuracyThreeKilometers = Dlfcn.GetDouble(handle, "kCLLocationAccuracyThreeKilometers");
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Export("init")]
public CLLocation()
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend(base.Handle, Selector.Init);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, Selector.Init);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Export("initWithCoder:")]
public CLLocation(NSCoder coder)
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend_IntPtr(base.Handle, Selector.InitWithCoder, coder.Handle);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(base.SuperHandle, Selector.InitWithCoder, coder.Handle);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public CLLocation(NSObjectFlag t)
: base(t)
{
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public CLLocation(IntPtr handle)
: base(handle)
{
}
[Export("initWithLatitude:longitude:")]
public CLLocation(double latitude, double longitude)
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend_Double_Double(base.Handle, selInitWithLatitudeLongitude_Handle, latitude, longitude);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper_Double_Double(base.SuperHandle, selInitWithLatitudeLongitude_Handle, latitude, longitude);
}
}
[Export("initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:")]
public CLLocation(CLLocationCoordinate2D coordinate, double altitude, double hAccuracy, double vAccuracy, NSDate timestamp)
: base(NSObjectFlag.Empty)
{
if (timestamp == null)
{
throw new ArgumentNullException("timestamp");
}
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend_CLLocationCoordinate2D_Double_Double_Double_IntPtr(base.Handle, selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyTimestamp_Handle, coordinate, altitude, hAccuracy, vAccuracy, timestamp.Handle);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper_CLLocationCoordinate2D_Double_Double_Double_IntPtr(base.SuperHandle, selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyTimestamp_Handle, coordinate, altitude, hAccuracy, vAccuracy, timestamp.Handle);
}
}
[Export("description")]
public new virtual string Description()
{
if (IsDirectBinding)
{
return NSString.FromHandle(Messaging.IntPtr_objc_msgSend(base.Handle, selDescriptionHandle));
}
return NSString.FromHandle(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selDescriptionHandle));
}
[Export("getDistanceFrom:")]
[Obsolete("Replaced by DistanceFrom", false)]
public virtual double Distancefrom(CLLocation location)
{
if (location == null)
{
throw new ArgumentNullException("location");
}
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend_IntPtr(base.Handle, selGetDistanceFrom_Handle, location.Handle);
}
return Messaging.Double_objc_msgSendSuper_IntPtr(base.SuperHandle, selGetDistanceFrom_Handle, location.Handle);
}
[Export("distanceFromLocation:")]
public virtual double DistanceFrom(CLLocation location)
{
if (location == null)
{
throw new ArgumentNullException("location");
}
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend_IntPtr(base.Handle, selDistanceFromLocation_Handle, location.Handle);
}
return Messaging.Double_objc_msgSendSuper_IntPtr(base.SuperHandle, selDistanceFromLocation_Handle, location.Handle);
}
[Export("initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp:")]
public CLLocation(CLLocationCoordinate2D coordinate, double altitude, double hAccuracy, double vAccuracy, double course, double speed, NSDate timestamp)
: base(NSObjectFlag.Empty)
{
if (timestamp == null)
{
throw new ArgumentNullException("timestamp");
}
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend_CLLocationCoordinate2D_Double_Double_Double_Double_Double_IntPtr(base.Handle, selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyCourseSpeedTimestamp_Handle, coordinate, altitude, hAccuracy, vAccuracy, course, speed, timestamp.Handle);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper_CLLocationCoordinate2D_Double_Double_Double_Double_Double_IntPtr(base.SuperHandle, selInitWithCoordinateAltitudeHorizontalAccuracyVerticalAccuracyCourseSpeedTimestamp_Handle, coordinate, altitude, hAccuracy, vAccuracy, course, speed, timestamp.Handle);
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (base.Handle == IntPtr.Zero)
{
__mt_Timestamp_var = null;
}
}
}
}

View File

@@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
namespace CPF.Mac.CoreLocation
{
public struct CLLocationCoordinate2D
{
public double Latitude;
public double Longitude;
public CLLocationCoordinate2D(double latitude, double longitude)
{
Latitude = latitude;
Longitude = longitude;
}
[DllImport("/System/Library/Frameworks/CoreLocation.framework/CoreLocation")]
private static extern int CLLocationCoordinate2DIsValid(CLLocationCoordinate2D cord);
public bool IsValid()
{
return CLLocationCoordinate2DIsValid(this) != 0;
}
}
}

View File

@@ -0,0 +1,451 @@
using CPF.Mac.Foundation;
using CPF.Mac.ObjCRuntime;
using System;
using System.ComponentModel;
namespace CPF.Mac.CoreLocation
{
[Register("CLLocationManager", true)]
public class CLLocationManager : NSObject
{
[Register]
private sealed class _CLLocationManagerDelegate : CLLocationManagerDelegate
{
internal EventHandler<CLLocationUpdatedEventArgs> updatedLocation;
internal CLLocationManagerEventArgs shouldDisplayHeadingCalibration;
internal EventHandler<NSErrorEventArgs> failed;
internal EventHandler<CLAuthorizationChangedEventArgs> authorizationChanged;
internal EventHandler<CLLocationsUpdatedEventArgs> locationsUpdated;
internal EventHandler locationUpdatesPaused;
internal EventHandler locationUpdatesResumed;
internal EventHandler<NSErrorEventArgs> deferredUpdatesFinished;
[Preserve(Conditional = true)]
public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
EventHandler<CLLocationUpdatedEventArgs> eventHandler = updatedLocation;
if (eventHandler != null)
{
CLLocationUpdatedEventArgs e = new CLLocationUpdatedEventArgs(newLocation, oldLocation);
eventHandler(manager, e);
}
}
[Preserve(Conditional = true)]
public override bool ShouldDisplayHeadingCalibration(CLLocationManager manager)
{
return shouldDisplayHeadingCalibration?.Invoke(manager) ?? true;
}
[Preserve(Conditional = true)]
public override void Failed(CLLocationManager manager, NSError error)
{
EventHandler<NSErrorEventArgs> eventHandler = failed;
if (eventHandler != null)
{
NSErrorEventArgs e = new NSErrorEventArgs(error);
eventHandler(manager, e);
}
}
[Preserve(Conditional = true)]
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status)
{
EventHandler<CLAuthorizationChangedEventArgs> eventHandler = authorizationChanged;
if (eventHandler != null)
{
CLAuthorizationChangedEventArgs e = new CLAuthorizationChangedEventArgs(status);
eventHandler(manager, e);
}
}
[Preserve(Conditional = true)]
public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations)
{
EventHandler<CLLocationsUpdatedEventArgs> eventHandler = locationsUpdated;
if (eventHandler != null)
{
CLLocationsUpdatedEventArgs e = new CLLocationsUpdatedEventArgs(locations);
eventHandler(manager, e);
}
}
[Preserve(Conditional = true)]
public override void LocationUpdatesPaused(CLLocationManager manager)
{
locationUpdatesPaused?.Invoke(manager, EventArgs.Empty);
}
[Preserve(Conditional = true)]
public override void LocationUpdatesResumed(CLLocationManager manager)
{
locationUpdatesResumed?.Invoke(manager, EventArgs.Empty);
}
[Preserve(Conditional = true)]
public override void DeferredUpdatesFinished(CLLocationManager manager, NSError error)
{
EventHandler<NSErrorEventArgs> eventHandler = deferredUpdatesFinished;
if (eventHandler != null)
{
NSErrorEventArgs e = new NSErrorEventArgs(error);
eventHandler(manager, e);
}
}
}
private const bool use_static_variants = true;
private static readonly IntPtr selDelegateHandle = Selector.GetHandle("delegate");
private static readonly IntPtr selSetDelegate_Handle = Selector.GetHandle("setDelegate:");
private static readonly IntPtr selLocationServicesEnabledHandle = Selector.GetHandle("locationServicesEnabled");
private static readonly IntPtr selDistanceFilterHandle = Selector.GetHandle("distanceFilter");
private static readonly IntPtr selSetDistanceFilter_Handle = Selector.GetHandle("setDistanceFilter:");
private static readonly IntPtr selDesiredAccuracyHandle = Selector.GetHandle("desiredAccuracy");
private static readonly IntPtr selSetDesiredAccuracy_Handle = Selector.GetHandle("setDesiredAccuracy:");
private static readonly IntPtr selLocationHandle = Selector.GetHandle("location");
private static readonly IntPtr selStartUpdatingLocationHandle = Selector.GetHandle("startUpdatingLocation");
private static readonly IntPtr selStopUpdatingLocationHandle = Selector.GetHandle("stopUpdatingLocation");
private static readonly IntPtr class_ptr = Class.GetHandle("CLLocationManager");
private object __mt_WeakDelegate_var;
private object __mt_Location_var;
public static bool LocationServicesEnabled => _LocationServicesEnabledStatic;
public override IntPtr ClassHandle => class_ptr;
public CLLocationManagerDelegate Delegate
{
get
{
return WeakDelegate as CLLocationManagerDelegate;
}
set
{
WeakDelegate = value;
}
}
public virtual NSObject WeakDelegate
{
[Export("delegate", ArgumentSemantic.Assign)]
get
{
return (NSObject)(__mt_WeakDelegate_var = ((!IsDirectBinding) ? Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selDelegateHandle)) : Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selDelegateHandle))));
}
[Export("setDelegate:", ArgumentSemantic.Assign)]
set
{
if (IsDirectBinding)
{
Messaging.void_objc_msgSend_IntPtr(base.Handle, selSetDelegate_Handle, value?.Handle ?? IntPtr.Zero);
}
else
{
Messaging.void_objc_msgSendSuper_IntPtr(base.SuperHandle, selSetDelegate_Handle, value?.Handle ?? IntPtr.Zero);
}
__mt_WeakDelegate_var = value;
}
}
internal virtual bool _LocationServicesEnabledInstance
{
[Export("locationServicesEnabled")]
get
{
if (IsDirectBinding)
{
return Messaging.bool_objc_msgSend(base.Handle, selLocationServicesEnabledHandle);
}
return Messaging.bool_objc_msgSendSuper(base.SuperHandle, selLocationServicesEnabledHandle);
}
}
public virtual double DistanceFilter
{
[Export("distanceFilter", ArgumentSemantic.Assign)]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selDistanceFilterHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selDistanceFilterHandle);
}
[Export("setDistanceFilter:", ArgumentSemantic.Assign)]
set
{
if (IsDirectBinding)
{
Messaging.void_objc_msgSend_Double(base.Handle, selSetDistanceFilter_Handle, value);
}
else
{
Messaging.void_objc_msgSendSuper_Double(base.SuperHandle, selSetDistanceFilter_Handle, value);
}
}
}
public virtual double DesiredAccuracy
{
[Export("desiredAccuracy", ArgumentSemantic.Assign)]
get
{
if (IsDirectBinding)
{
return Messaging.Double_objc_msgSend(base.Handle, selDesiredAccuracyHandle);
}
return Messaging.Double_objc_msgSendSuper(base.SuperHandle, selDesiredAccuracyHandle);
}
[Export("setDesiredAccuracy:", ArgumentSemantic.Assign)]
set
{
if (IsDirectBinding)
{
Messaging.void_objc_msgSend_Double(base.Handle, selSetDesiredAccuracy_Handle, value);
}
else
{
Messaging.void_objc_msgSendSuper_Double(base.SuperHandle, selSetDesiredAccuracy_Handle, value);
}
}
}
public virtual CLLocation Location
{
[Export("location")]
get
{
return (CLLocation)(__mt_Location_var = ((!IsDirectBinding) ? ((CLLocation)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, selLocationHandle))) : ((CLLocation)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(base.Handle, selLocationHandle)))));
}
}
[Since(4, 0)]
internal static bool _LocationServicesEnabledStatic
{
[Export("locationServicesEnabled")]
get
{
return Messaging.bool_objc_msgSend(class_ptr, selLocationServicesEnabledHandle);
}
}
public CLLocationManagerEventArgs ShouldDisplayHeadingCalibration
{
get
{
return EnsureCLLocationManagerDelegate().shouldDisplayHeadingCalibration;
}
set
{
EnsureCLLocationManagerDelegate().shouldDisplayHeadingCalibration = value;
}
}
[Obsolete("Deprecated in iOS 6.0", false)]
public event EventHandler<CLLocationUpdatedEventArgs> UpdatedLocation
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.updatedLocation = (EventHandler<CLLocationUpdatedEventArgs>)System.Delegate.Combine(cLLocationManagerDelegate.updatedLocation, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.updatedLocation = (EventHandler<CLLocationUpdatedEventArgs>)System.Delegate.Remove(cLLocationManagerDelegate.updatedLocation, value);
}
}
public event EventHandler<NSErrorEventArgs> Failed
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.failed = (EventHandler<NSErrorEventArgs>)System.Delegate.Combine(cLLocationManagerDelegate.failed, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.failed = (EventHandler<NSErrorEventArgs>)System.Delegate.Remove(cLLocationManagerDelegate.failed, value);
}
}
public event EventHandler<CLAuthorizationChangedEventArgs> AuthorizationChanged
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.authorizationChanged = (EventHandler<CLAuthorizationChangedEventArgs>)System.Delegate.Combine(cLLocationManagerDelegate.authorizationChanged, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.authorizationChanged = (EventHandler<CLAuthorizationChangedEventArgs>)System.Delegate.Remove(cLLocationManagerDelegate.authorizationChanged, value);
}
}
public event EventHandler<CLLocationsUpdatedEventArgs> LocationsUpdated
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.locationsUpdated = (EventHandler<CLLocationsUpdatedEventArgs>)System.Delegate.Combine(cLLocationManagerDelegate.locationsUpdated, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.locationsUpdated = (EventHandler<CLLocationsUpdatedEventArgs>)System.Delegate.Remove(cLLocationManagerDelegate.locationsUpdated, value);
}
}
public event EventHandler LocationUpdatesPaused
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.locationUpdatesPaused = (EventHandler)System.Delegate.Combine(cLLocationManagerDelegate.locationUpdatesPaused, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.locationUpdatesPaused = (EventHandler)System.Delegate.Remove(cLLocationManagerDelegate.locationUpdatesPaused, value);
}
}
public event EventHandler LocationUpdatesResumed
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.locationUpdatesResumed = (EventHandler)System.Delegate.Combine(cLLocationManagerDelegate.locationUpdatesResumed, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.locationUpdatesResumed = (EventHandler)System.Delegate.Remove(cLLocationManagerDelegate.locationUpdatesResumed, value);
}
}
public event EventHandler<NSErrorEventArgs> DeferredUpdatesFinished
{
add
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.deferredUpdatesFinished = (EventHandler<NSErrorEventArgs>)System.Delegate.Combine(cLLocationManagerDelegate.deferredUpdatesFinished, value);
}
remove
{
_CLLocationManagerDelegate cLLocationManagerDelegate = EnsureCLLocationManagerDelegate();
cLLocationManagerDelegate.deferredUpdatesFinished = (EventHandler<NSErrorEventArgs>)System.Delegate.Remove(cLLocationManagerDelegate.deferredUpdatesFinished, value);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Export("init")]
public CLLocationManager()
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend(base.Handle, Selector.Init);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, Selector.Init);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Export("initWithCoder:")]
public CLLocationManager(NSCoder coder)
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend_IntPtr(base.Handle, Selector.InitWithCoder, coder.Handle);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(base.SuperHandle, Selector.InitWithCoder, coder.Handle);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public CLLocationManager(NSObjectFlag t)
: base(t)
{
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public CLLocationManager(IntPtr handle)
: base(handle)
{
}
[Export("startUpdatingLocation")]
public virtual void StartUpdatingLocation()
{
if (IsDirectBinding)
{
Messaging.void_objc_msgSend(base.Handle, selStartUpdatingLocationHandle);
}
else
{
Messaging.void_objc_msgSendSuper(base.SuperHandle, selStartUpdatingLocationHandle);
}
}
[Export("stopUpdatingLocation")]
public virtual void StopUpdatingLocation()
{
if (IsDirectBinding)
{
Messaging.void_objc_msgSend(base.Handle, selStopUpdatingLocationHandle);
}
else
{
Messaging.void_objc_msgSendSuper(base.SuperHandle, selStopUpdatingLocationHandle);
}
}
private _CLLocationManagerDelegate EnsureCLLocationManagerDelegate()
{
NSObject nSObject = WeakDelegate;
if (nSObject == null || !(nSObject is _CLLocationManagerDelegate))
{
nSObject = (WeakDelegate = new _CLLocationManagerDelegate());
}
return (_CLLocationManagerDelegate)nSObject;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (base.Handle == IntPtr.Zero)
{
__mt_WeakDelegate_var = null;
__mt_Location_var = null;
}
}
}
}

View File

@@ -0,0 +1,103 @@
using CPF.Mac.Foundation;
using CPF.Mac.ObjCRuntime;
using System;
using System.ComponentModel;
namespace CPF.Mac.CoreLocation
{
[Register("CLLocationManagerDelegate", false)]
[Model]
public class CLLocationManagerDelegate : NSObject
{
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Export("init")]
public CLLocationManagerDelegate()
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend(base.Handle, Selector.Init);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper(base.SuperHandle, Selector.Init);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Export("initWithCoder:")]
public CLLocationManagerDelegate(NSCoder coder)
: base(NSObjectFlag.Empty)
{
if (IsDirectBinding)
{
base.Handle = Messaging.IntPtr_objc_msgSend_IntPtr(base.Handle, Selector.InitWithCoder, coder.Handle);
}
else
{
base.Handle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(base.SuperHandle, Selector.InitWithCoder, coder.Handle);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public CLLocationManagerDelegate(NSObjectFlag t)
: base(t)
{
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public CLLocationManagerDelegate(IntPtr handle)
: base(handle)
{
}
[Export("locationManager:didUpdateToLocation:fromLocation:")]
[Obsolete("Deprecated in iOS 6.0", false)]
public virtual void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManagerShouldDisplayHeadingCalibration:")]
public virtual bool ShouldDisplayHeadingCalibration(CLLocationManager manager)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManager:didFailWithError:")]
public virtual void Failed(CLLocationManager manager, NSError error)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManager:didChangeAuthorizationStatus:")]
public virtual void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManager:didUpdateLocations:")]
public virtual void LocationsUpdated(CLLocationManager manager, CLLocation[] locations)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManagerDidPauseLocationUpdates:")]
public virtual void LocationUpdatesPaused(CLLocationManager manager)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManagerDidResumeLocationUpdates:")]
public virtual void LocationUpdatesResumed(CLLocationManager manager)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
[Export("locationManager:didFinishDeferredUpdatesWithError:")]
public virtual void DeferredUpdatesFinished(CLLocationManager manager, NSError error)
{
throw new You_Should_Not_Call_base_In_This_Method();
}
}
}

View File

@@ -0,0 +1,4 @@
namespace CPF.Mac.CoreLocation
{
public delegate bool CLLocationManagerEventArgs(CLLocationManager manager);
}

View File

@@ -0,0 +1,25 @@
using System;
namespace CPF.Mac.CoreLocation
{
public class CLLocationUpdatedEventArgs : EventArgs
{
public CLLocation NewLocation
{
get;
set;
}
public CLLocation OldLocation
{
get;
set;
}
public CLLocationUpdatedEventArgs(CLLocation newLocation, CLLocation oldLocation)
{
NewLocation = newLocation;
OldLocation = oldLocation;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
namespace CPF.Mac.CoreLocation
{
public class CLLocationsUpdatedEventArgs : EventArgs
{
public CLLocation[] Locations
{
get;
set;
}
public CLLocationsUpdatedEventArgs(CLLocation[] locations)
{
Locations = locations;
}
}
}