public DeviceConfigPage(PairedDevicesJson json, int selectedIndex)
 {
     Log.Information("Loading window with " + json.Devices[selectedIndex].DeviceName);
     InitializeComponent();
     Configuration = new Dictionary <string, object>();
     this.json     = json;
     currentDev    = selectedIndex;
     refresh_Click(this, new RoutedEventArgs());
     DevName.Content = json.Devices[selectedIndex].DeviceName + " settings";
     Log.Information("Loaded window.");
 }
Ejemplo n.º 2
0
 private void ApplyUSB(object sender, RoutedEventArgs e)
 {
     Log.Information("Applying selected USB device.");
     try
     {
         USBDevice         SelectedDevice = USBDevices[usbDevices.SelectedIndex];
         PairedDevicesJson PairedDevices  = PairedDevicesJson.FromJson(File.ReadAllText(Helper.PairedDevicesFile));
         Log.Information("Got current devices.");
         PairedDevices.Devices.Add(new Device {
             DeviceAddress = SelectedDevice.DeviceID, DeviceName = usbName.Text, DeviceType = "USB", TemplateLocation = ""
         });
         File.WriteAllText(Helper.PairedDevicesFile, PDSerialize.ToJson(PairedDevices));
         Log.Information("Wrote to PairedDevices.json");
         MessageBox.Show("Done!", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception ex)
     {
         Log.Error(ex, "There was a error applying the USB device.");
         Helper.Error("Error", "There was a error writing to the PairedDevices.json file. Please contact the developer.");
     }
 }