Exemplo n.º 1
0
        private async void RefreshDeviceList()
        {
            // Wait in case you recently added a device via this app
            await Task.Delay(500);

            // Read json file and add to list
            try
            {
                Log.Information("Reading information from PairedDevices.json");
                jsonFile = PairedDevicesJson.FromJson(File.ReadAllText(Helper.PairedDevicesFile));
                deviceListBind.Clear();
                Devices.Items.Clear();
                foreach (var i in jsonFile.Devices)
                {
                    Log.Information($"Adding {i.DeviceName} to the list.");
                    deviceListBind.Add(new DeviceListModel {
                        DeviceName = i.DeviceName, ImageSource = new Uri((i.DeviceType == "Bluetooth") ? "pack://application:,,,/Assets/bluetooth.png" : "pack://application:,,,/Assets/usb.png")
                    });
                    Devices.Items.Add(new DeviceListModel {
                        DeviceName = i.DeviceName, ImageSource = new Uri((i.DeviceType == "Bluetooth") ? "pack://application:,,,/Assets/bluetooth.png" : "pack://application:,,,/Assets/usb.png")
                    });
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "An error has occured trying to refresh device list.");
                Helper.Error("Error", "Unable to read PairedDevices.json. Please make sure you have not modified it. If this error still persists, try running as administrator or contact the developer.");
                deviceListBind.Clear();
                Devices.Items.Clear();
            }
        }
Exemplo n.º 2
0
 public static string ToJson(this PairedDevicesJson self)
 {
     return(JsonConvert.SerializeObject(self, AirPodsUI.Configurator.PDConverter.Settings));
 }