internal BaseRadio(RadioDevice device, Radios parent) { DeviceName = device.DeviceName; DisplayName = device.DisplayName; m_state = device.ActualState ? RadioState.On : RadioState.Off; m_parent = parent; }
internal void SetState(IRadio radio, RadioState newState) { lock (m_radios) { IntPtr pDeviceList = IntPtr.Zero; if (GetDeviceList(ref pDeviceList, 0) == -1) { throw new Exception("Failed to get device list"); } if (pDeviceList != IntPtr.Zero) { try { RadioDevice device; IntPtr next = pDeviceList; do { device = new RadioDevice(next, 0); if (device.RadioType == radio.RadioType) { ChangeRadioState(device.Pointer, newState, SaveAction.PreSave); // don't exit the loop - we need to free all name strings } next = device.Next; } while (next != IntPtr.Zero); } finally { FreeDeviceList(pDeviceList); } } } }
internal PhoneRadio(RadioDevice device, Radios parent) : base(device, parent) { }
internal BluetoothRadio(RadioDevice device, Radios parent) : base(device, parent) { }
internal WiFiRadio(RadioDevice device, Radios parent) : base(device, parent) { }
public void Refresh() { lock (m_radios) { IntPtr pDeviceList = IntPtr.Zero; try { if (GetDeviceList(ref pDeviceList, 0) == -1) { throw new Exception("Failed to get device list"); } } catch (MissingMethodException) { throw new PlatformNotSupportedException("Radios are only supported on Windows Mobile platforms, versions 5.0 and later"); } m_radios.Clear(); if (pDeviceList != IntPtr.Zero) { try { RadioDevice device; IntPtr next = pDeviceList; do { device = new RadioDevice(next, 0); IRadio radio = null; switch (device.RadioType) { case RadioType.Bluetooth: radio = new BluetoothRadio(device, this); break; case RadioType.Phone: radio = new PhoneRadio(device, this); break; case RadioType.WiFi: radio = new WiFiRadio(device, this); break; default: radio = new UnknownRadio(device, this); break; } if (radio != null) { m_radios.Add(radio); } next = device.Next; } while (next != IntPtr.Zero); } finally { FreeDeviceList(pDeviceList); } } } }
internal UnknownRadio(RadioDevice device, Radios parent) : base(device, parent) { }