private void applyConfig_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         json.Devices[currentDev].TemplateLocation = Configuration.Keys.ToArray()[Templates.SelectedIndex];
         File.WriteAllText(Helper.PairedDevicesFile, PDSerialize.ToJson(json));
         MessageBox.Show("Applied!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         Helper.Error("Error", "Unable to apply configuration.");
     }
 }
 private void remDev_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to remove this device?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         try
         {
             json.Devices.RemoveAt(currentDev);
             File.WriteAllText(Helper.PairedDevicesFile, PDSerialize.ToJson(json));
             MessageBox.Show("Removed", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         catch (Exception)
         {
             Helper.Error("Error", "Unable to remove device.");
         }
     }
 }
Ejemplo n.º 3
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.");
     }
 }