简体   繁体   English

Windows IoT Raspberry Pi 3 C#保存设备设置

[英]Windows IoT Raspberry Pi 3 C# Save Device Setting

I would like to know how to save my user config for my selected USB devices. 我想知道如何为所选的USB设备保存用户配置。 Whenever i restart the device it will load as i selected previously. 每当我重新启动设备时,它将按照我之前选择的方式加载。 is it advisable to save locally or in the usb storage? 是否建议将其保存在本地或USB存储中?

Does this app note Store and retrieve settings and other app data applicable as types of app data mentioned works with USB adapter? 此应用笔记是否存储和检索设置以及其他应用数据,因为上述应用数据类型适用于USB适配器?

选定的设备

Updated: 更新:

When I selected the USB adapter from the listbox, I set the respective selected device accordingly. 从列表框中选择USB适配器时,将相应地设置相应的所选设备。

        private void audioCaptureList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            recordPlayer.AudioDevice = captureDeviceList[audioCaptureList.SelectedIndex];
        }

        private void audioRenderList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            mediaPlayer.AudioDevice = renderDeviceList[audioRenderList.SelectedIndex];

        }

Your setting can be saved as Local app data . 您的设置可以另存为本地应用程序数据 These data will not change even you restart the device. 即使重新启动设备,这些数据也不会更改。 But note: the lifetime of the app data is tied to the lifetime of the app. 请注意: 应用程序数据的生命周期与应用程序的生命周期息息相关。 If the app is removed, all of the app data will be lost as a consequence . 如果删除该应用程序,则所有应用程序数据都将丢失

You can store and retrieve local app data like this: 您可以像这样存储和检索本地应用程序数据:

    Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

    private void StoreButton_Click(object sender, RoutedEventArgs e)
    {
        var selection = ConnectDevices.SelectedItems;
        var entry = (DeviceListEntry)selection[0];
        var device = entry.DeviceInformation;

        localSettings.Values["SelectedUsbDeviceId"] =  device.Id;
        localSettings.Values["SelectedUsbDeviceName"] = device.Name;
    }

    private void RetrieveButton_Click(object sender, RoutedEventArgs e)
    {
        Object deviceId = localSettings.Values["SelectedUsbDeviceId"];
        Object deviceName = localSettings.Values["SelectedUsbDeviceName"];
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM