diff options
| author | Adonais Romero González <[email protected]> | 2024-05-06 16:21:31 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-06 16:21:31 -0700 |
| commit | a74a241c664c4e1d7c0838287b34076c19d9858a (patch) | |
| tree | 6ff7562612967b122acf8acf8a69c4dcfd5905db /general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp | |
| parent | def8e8e34ed2b7b1deb2fc9112ac4255f1a0f2ba (diff) | |
| parent | 15477ce52bbb6b42ca591ecdfb484cac089f89ab (diff) | |
Merge develop changes prior to upcoming WDK release (May 2024)
Diffstat (limited to 'general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp')
| -rw-r--r-- | general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp b/general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp deleted file mode 100644 index 24c12f68..00000000 --- a/general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp +++ /dev/null @@ -1,154 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "pch.h" -#include "MainPage.xaml.h" - -using namespace SDKTemplate; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Core; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; -using namespace Windows::UI::Xaml::Interop; - -// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 - -MainPage^ MainPage::Current = nullptr; - -MainPage::MainPage() -{ - InitializeComponent(); - SampleTitle->Text = FEATURE_NAME; - - // This is a static public property that allows downstream pages to get a handle to the MainPage instance - // in order to call methods that are in this class. - MainPage::Current = this; -} - -void MainPage::OnNavigatedTo(NavigationEventArgs^ e) -{ - // Populate the ListBox with the scenarios as defined in SampleConfiguration.cpp. - auto itemCollection = ref new Platform::Collections::Vector<Object^>(); - int i = 1; - for (auto const& s : MainPage::Current->scenarios) - { - // Create a textBlock to hold the content and apply the ListItemTextStyle from Styles.xaml - TextBlock^ textBlock = ref new TextBlock(); - ListBoxItem^ item = ref new ListBoxItem(); - auto style = App::Current->Resources->Lookup("ListItemTextStyle"); - - textBlock->Text = (i++).ToString() + ") " + s.Title; - textBlock->Style = safe_cast<Windows::UI::Xaml::Style ^>(style); - - item->Name = s.ClassName; - item->Content = textBlock; - itemCollection->Append(item); - } - - // Set the newly created itemCollection as the ListBox ItemSource. - ScenarioControl->ItemsSource = itemCollection; - int startingScenarioIndex; - - if (Window::Current->Bounds.Width < 640) - { - startingScenarioIndex = -1; - } - else - { - startingScenarioIndex = 0; - } - - ScenarioControl->SelectedIndex = startingScenarioIndex; - ScenarioControl->ScrollIntoView(ScenarioControl->SelectedItem); -} - - -void MainPage::ScenarioControl_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e) -{ - ListBox^ scenarioListBox = safe_cast<ListBox^>(sender); //as ListBox; - ListBoxItem^ item = dynamic_cast<ListBoxItem^>(scenarioListBox->SelectedItem); - if (item != nullptr) - { - // Clear the status block when changing scenarios - NotifyUser("", NotifyType::StatusMessage); - - // Navigate to the selected scenario. - TypeName scenarioType = { item->Name, TypeKind::Custom }; - ScenarioFrame->Navigate(scenarioType, this); - - if (Window::Current->Bounds.Width < 640) - { - Splitter->IsPaneOpen = false; - } - } -} - -void MainPage::NotifyUser(String^ strMessage, NotifyType type) -{ - if (Dispatcher->HasThreadAccess) - { - UpdateStatus(strMessage, type); - } - else - { - Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([strMessage, type, this]() - { - UpdateStatus(strMessage, type); - })); - } -} - -void MainPage::UpdateStatus(String^ strMessage, NotifyType type) -{ - switch (type) - { - case NotifyType::StatusMessage: - StatusBorder->Background = ref new SolidColorBrush(Windows::UI::Colors::Green); - break; - case NotifyType::ErrorMessage: - StatusBorder->Background = ref new SolidColorBrush(Windows::UI::Colors::Red); - break; - default: - break; - } - - StatusBlock->Text = strMessage; - - // Collapse the StatusBlock if it has no text to conserve real estate. - if (StatusBlock->Text != "") - { - StatusBorder->Visibility = Windows::UI::Xaml::Visibility::Visible; - StatusPanel->Visibility = Windows::UI::Xaml::Visibility::Visible; - } - else - { - StatusBorder->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - StatusPanel->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - } -} - -void MainPage::Footer_Click(Object^ sender, RoutedEventArgs^ e) -{ - auto uri = ref new Uri((String^)((HyperlinkButton^)sender)->Tag); - Windows::System::Launcher::LaunchUriAsync(uri); -} - -void MainPage::Button_Click(Object^ sender, RoutedEventArgs^ e) -{ - Splitter->IsPaneOpen = !Splitter->IsPaneOpen; -}
\ No newline at end of file |
