簡體   English   中英

Windows IoT Raspberry Pi 3 C#保存設備設置

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

我想知道如何為所選的USB設備保存用戶配置。 每當我重新啟動設備時,它將按照我之前選擇的方式加載。 是否建議將其保存在本地或USB存儲中?

此應用筆記是否存儲和檢索設置以及其他應用數據,因為上述應用數據類型適用於USB適配器?

選定的設備

更新:

從列表框中選擇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];

        }

您的設置可以另存為本地應用程序數據 即使重新啟動設備,這些數據也不會更改。 請注意: 應用程序數據的生命周期與應用程序的生命周期息息相關。 如果刪除該應用程序,則所有應用程序數據都將丟失

您可以像這樣存儲和檢索本地應用程序數據:

    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