| 365 | } |
| 366 | |
| 367 | void MainPage::MainPivot_PivotItemLoaded(Pivot const&, PivotItemEventArgs const& args) |
| 368 | { |
| 369 | try { |
| 370 | if (args.Item().Header().as<hstring>() == L"Setting") { |
| 371 | const auto& netifs = Netif::EnumerateInterfaces(); |
| 372 | std::vector<IInspectable> boxed_netifs; |
| 373 | boxed_netifs.reserve(netifs.size()); |
| 374 | std::transform(netifs.begin(), netifs.end(), std::back_inserter(boxed_netifs), [](const auto& netif) -> auto { |
| 375 | return netif; |
| 376 | }); |
| 377 | NetifCombobox().ItemsSource(single_threaded_vector(std::move(boxed_netifs))); |
| 378 | |
| 379 | const auto& currentNetif = ApplicationData::Current().LocalSettings().Values().TryLookup(NETIF_SETTING_KEY).try_as<hstring>(); |
| 380 | if (currentNetif.has_value()) { |
| 381 | NetifCombobox().SelectedValue(box_value(currentNetif.value())); |
| 382 | } |
| 383 | else { |
| 384 | const auto it = std::find_if(netifs.begin(), netifs.end(), [](const auto& netif) -> bool { |
| 385 | return netif.Desc().size() > 0 && netif.Desc()[0] == L'★'; |
| 386 | }); |
| 387 | if (it != netifs.end()) { |
| 388 | NetifCombobox().SelectedItem(*it); |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | catch (...) |
| 394 | { |
| 395 | UI::NotifyException(L"Loading settings"); |
| 396 | } |
| 397 | } |
| 398 | void MainPage::NetifCombobox_SelectionChanged(IInspectable const&, SelectionChangedEventArgs const& e) |
| 399 | { |
| 400 | try { |