/// <summary> /// Sets desired report accuracy. /// The desired accuracy is a global setting that affects all providers. /// </summary> public static void SetDesiredAccuracy(Guid reportType, DesiredAccuracy accuracy) { if (_location != null) { _location.SetDesiredAccuracy(ref reportType, accuracy); } }
/// <summary> /// Gets desired report accuracy. /// The desired accuracy is a global setting that affects all providers. /// </summary> public static DesiredAccuracy GetDesiredAccuracy(Guid reportType) { DesiredAccuracy da = DesiredAccuracy.Default; if (_location != null) { _location.GetDesiredAccuracy(ref reportType, out da); } return(da); }
public virtual extern HRESULT SetDesiredAccuracy([In] ref Guid reportType, [In] DesiredAccuracy pStatus);
/// <summary> /// Thread pool callback used to ensure location COM API is instantiated from /// multi-thread apartment, and register for location events. /// </summary> /// <param name="state"></param> private void CreateHandler(object state) { lock (this.InternalSyncObject) { try { m_location = new COMLocation(); } catch (COMException) { Utility.Trace("Failed to CoCreate ILocation COM object."); } if (null != m_location) { Utility.Trace("Done creating ILocation COM object"); // // Mapping to platform accuracy // GeoLocationAccuracy desiredAccuracy = (GeoLocationAccuracy)state; DesiredAccuracy accuracy = (desiredAccuracy == GeoLocationAccuracy.Low) ? DesiredAccuracy.DefaultAccuracy : DesiredAccuracy.HighAccuracy; Guid reportKey = LocationReportKey.LatLongReport; m_location.SetDesiredAccuracy(ref reportKey, accuracy); // // Always listen for latlong reports // if (m_location.RegisterForReport(this, ref reportKey, 0) == 0) { m_latLongRegistered = true; } // // Check the latlong status. If latlong reports are not supported, then register // for civic address reports. // m_location.GetReportStatus(ref reportKey, ref m_latLongStatus); if (ReportStatus.NotSupported == m_latLongStatus) { reportKey = LocationReportKey.CivicAddressReport; if (m_location.RegisterForReport(this, ref reportKey, 0) == 0) { m_civicAddrRegistered = true; m_location.GetReportStatus(ref reportKey, ref m_civicAddrStatus); } } // // set the current status to the available report type status // ReportStatus status = (ReportStatus.NotSupported != m_latLongStatus) ? m_latLongStatus : m_civicAddrStatus; m_curStatus = m_geoStatusMap[(int)status]; } Utility.DebugAssert(m_eventCreateDone != null, "m_eventCreateDone is null"); ManualResetEvent eventDone = m_eventCreateDone; if (eventDone != null) { eventDone.Set(); } } }
/// <summary> /// Thread pool callback used to ensure location COM API is instantiated from /// multi-thread apartment, and register for location events. /// </summary> /// <param name="state"></param> private void CreateHandler(object state) { lock (this.InternalSyncObject) { try { m_location = new COMLocation() as ILocation; } catch (COMException) { Utility.Trace("Failed to CoCreate ILocation COM object."); } if (null != m_location) { Utility.Trace("Successfully created ILocation COM object"); // // Mapping to platform accuracy // GeoPositionAccuracy desiredAccuracy = (GeoPositionAccuracy)state; DesiredAccuracy accuracy = (desiredAccuracy == GeoPositionAccuracy.Default) ? DesiredAccuracy.DefaultAccuracy : DesiredAccuracy.HighAccuracy; Guid reportKey = LocationReportKey.LatLongReport; m_location.SetDesiredAccuracy(ref reportKey, accuracy); // // Always listen for latlong reports // if (m_location.RegisterForReport(this, ref reportKey, 0) == 0) { m_latLongRegistered = true; } // // Check the latlong status. If latlong reports are not supported, then register // for civic address reports. // m_location.GetReportStatus(ref reportKey, ref m_latLongStatus); if (ReportStatus.NotSupported == m_latLongStatus) { reportKey = LocationReportKey.CivicAddressReport; if (m_location.RegisterForReport(this, ref reportKey, 0) == 0) { m_civicAddrRegistered = true; m_location.GetReportStatus(ref reportKey, ref m_civicAddrStatus); } } // // set the current status to the available report type status // ReportStatus status = (ReportStatus.NotSupported != m_latLongStatus) ? m_latLongStatus : m_civicAddrStatus; m_curStatus = m_geoStatusMap[(int)status]; ChangePermissionFromReportStatus(status); } else { m_curStatus = GeoPositionStatus.Disabled; } } }