Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/CarPlay/CPEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,51 @@ public enum CPListImageRowItemImageGridElementShape : long {
RoundedRect = 0,
Circle = 1,
}

[NoTV, NoMac, iOS (26, 4), MacCatalyst (26, 4)]
[Native]
public enum CPRerouteReason : long {
Unknown = 0,
MissedTurn,
Offline,
AlternateRoute,
WaypointModified,
Mandated,
}

[NoTV, NoMac, iOS (26, 4), MacCatalyst (26, 4)]
[Native]
public enum CPRouteSource : ulong {
Inactive = 0,
IOSUnchanged = 1,
IOSRouteModified = 2,
IOSRouteDestinationsModified = 3,
IOSDestinationsOnly = 4,
Vehicle = 5,
}

[NoTV, NoMac, iOS (26, 4), MacCatalyst (26, 4)]
[Native]
public enum CPImageOverlayAlignment : long {
Leading,
Center,
Trailing,
}

[NoTV, NoMac, iOS (26, 4), MacCatalyst (26, 4)]
[Native]
public enum CPPlaybackPresentation : long {
None = 0,
Audio,
Video,
}

[NoTV, NoMac, iOS (26, 4), MacCatalyst (26, 4)]
[Native]
public enum CPPlaybackAction : long {
None = 0,
Play,
Pause,
Replay,
}
}
24 changes: 24 additions & 0 deletions src/CarPlay/CPLocationCoordinate3D.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#nullable enable

using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace CarPlay {

[SupportedOSPlatform ("ios26.4")]
[SupportedOSPlatform ("maccatalyst26.4")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("macos")]
[StructLayout (LayoutKind.Sequential)]
public struct CPLocationCoordinate3D {
double latitude;
double longitude;
double altitude;

#if !COREBUILD
public double Latitude { get => latitude; set => latitude = value; }
public double Longitude { get => longitude; set => longitude = value; }
public double Altitude { get => altitude; set => altitude = value; }
#endif
}
}
54 changes: 54 additions & 0 deletions src/CarPlay/CPNavigationWaypoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#nullable enable

using System;
using Foundation;
using MapKit;

namespace CarPlay {

public partial class CPNavigationWaypoint {

public static unsafe CPNavigationWaypoint Create (CPLocationCoordinate3D centerPoint, NSMeasurement<NSUnitLength>? locationThreshold, string? name, string? address, CPLocationCoordinate3D []? entryPoints, NSTimeZone? timeZone)
{
if (entryPoints is null || entryPoints.Length == 0) {
var obj = new CPNavigationWaypoint (NSObjectFlag.Empty);
obj.InitializeHandle (obj._InitWithCenterPoint (centerPoint, locationThreshold, name, address, IntPtr.Zero, 0, timeZone));
return obj;
}

fixed (CPLocationCoordinate3D* first = entryPoints) {
var obj = new CPNavigationWaypoint (NSObjectFlag.Empty);
obj.InitializeHandle (obj._InitWithCenterPoint (centerPoint, locationThreshold, name, address, (IntPtr) first, (nuint) entryPoints.Length, timeZone));
return obj;
}
}

public static unsafe CPNavigationWaypoint Create (MKMapItem mapItem, NSMeasurement<NSUnitLength>? locationThreshold, CPLocationCoordinate3D []? entryPoints)
{
if (entryPoints is null || entryPoints.Length == 0) {
var obj = new CPNavigationWaypoint (NSObjectFlag.Empty);
obj.InitializeHandle (obj._InitWithMapItem (mapItem, locationThreshold, IntPtr.Zero, 0));
return obj;
}

fixed (CPLocationCoordinate3D* first = entryPoints) {
var obj = new CPNavigationWaypoint (NSObjectFlag.Empty);
obj.InitializeHandle (obj._InitWithMapItem (mapItem, locationThreshold, (IntPtr) first, (nuint) entryPoints.Length));
return obj;
}
}

public unsafe CPLocationCoordinate3D [] EntryPoints {
get {
nuint n = EntryPointsCount;
if (n == 0)
return [];
var source = (CPLocationCoordinate3D*) _EntryPoints;
var result = new CPLocationCoordinate3D [(int) n];
for (int i = 0; i < (int) n; i++)
result [i] = source [i];
return result;
}
}
}
}
34 changes: 34 additions & 0 deletions src/CarPlay/CPRouteSegment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#nullable enable

using System;

namespace CarPlay {

public partial class CPRouteSegment {

public static unsafe CPRouteSegment Create (CPNavigationWaypoint origin, CPNavigationWaypoint destination, CPManeuver [] maneuvers, CPLaneGuidance [] laneGuidances, CPManeuver [] currentManeuvers, CPLaneGuidance currentLaneGuidance, CPTravelEstimates tripTravelEstimates, CPTravelEstimates maneuverTravelEstimates, CPLocationCoordinate3D [] coordinates)
{
if (coordinates is null)
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (coordinates));
if (coordinates.Length == 0)
return new CPRouteSegment (origin, destination, maneuvers, laneGuidances, currentManeuvers, currentLaneGuidance, tripTravelEstimates, maneuverTravelEstimates, IntPtr.Zero, 0);

fixed (CPLocationCoordinate3D* first = coordinates) {
return new CPRouteSegment (origin, destination, maneuvers, laneGuidances, currentManeuvers, currentLaneGuidance, tripTravelEstimates, maneuverTravelEstimates, (IntPtr) first, (nint) coordinates.Length);
}
}

public unsafe CPLocationCoordinate3D [] Coordinates {
get {
nint n = CoordinatesCount;
if (n == 0)
return [];
var source = (CPLocationCoordinate3D*) _Coordinates;
var result = new CPLocationCoordinate3D [(int) n];
for (int i = 0; i < (int) n; i++)
result [i] = source [i];
return result;
}
}
}
}
Loading
Loading