private void GetLocation(NSObject context) { location = context as CLLocation; if (location == null) { location = LocationHelper.GetLocationForCity(City.SanFrancisco); } }
#region Using using System; using CoreLocation; using Foundation; using WatchKit; #endregion namespace HelloWatchKit.WatchExtension { public partial class CityGeolocationController : WKInterfaceController { private CLLocation location; public CityGeolocationController(IntPtr handle) : base(handle) { } public override void Awake(NSObject context) { base.Awake(context); GetLocation(context); } public override void WillActivate() { LabelLat.SetText(location.Coordinate.Latitude.ToString()); LabelLng.SetText(location.Coordinate.Longitude.ToString()); } private void GetLocation(NSObject context) { location = context as CLLocation; if (location == null) { location = LocationHelper.GetLocationForCity( City.SanFrancisco); } } } }
private void DisplayCityGeolocationController(City city) { var location = LocationHelper.GetLocationForCity(city); PushController("CityGeolocationController", location); }
partial void SanFranciscoItem_Tapped() { DisplayCityGeolocationController(City.SanFrancisco); } private void DisplayCityGeolocationController(City city) { var location = LocationHelper.GetLocationForCity(city); PushController("CityGeolocationController", location); } #endregion #region Helpers private void DisplayInfo(string eventName) { Debug.WriteLine($"{this.Class.Name}, view event: {eventName} "); } #endregion } }