#include "pch.h" #include "SingleKeyRemapControl.h" //Both static members are initialized to null HWND SingleKeyRemapControl::EditKeyboardWindowHandle = nullptr; KeyboardManagerState* SingleKeyRemapControl::keyboardManagerState = nullptr; // Initialized as new vector std::vector> SingleKeyRemapControl::singleKeyRemapBuffer; // Function to add a new row to the remap keys table. If the originalKey and newKey args are provided, then the displayed remap keys are set to those values. void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, const DWORD& originalKey, const DWORD& newKey) { // Parent element for the row Windows::UI::Xaml::Controls::StackPanel tableRow; tableRow.Background(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::LightGray() }); tableRow.Spacing(100); tableRow.Orientation(Windows::UI::Xaml::Controls::Orientation::Horizontal); // SingleKeyRemapControl for the original key. SingleKeyRemapControl originalRemapKeyControl(singleKeyRemapBuffer.size(), 0); tableRow.Children().Append(originalRemapKeyControl.getSingleKeyRemapControl()); // SingleKeyRemapControl for the new remap key. SingleKeyRemapControl newRemapKeyControl(singleKeyRemapBuffer.size(), 1); tableRow.Children().Append(newRemapKeyControl.getSingleKeyRemapControl()); // Set the key text if the two keys are not null (i.e. default args) if (originalKey != NULL && newKey != NULL) { singleKeyRemapBuffer.push_back(std::vector{ originalKey, newKey }); originalRemapKeyControl.singleKeyRemapText.Text(winrt::to_hstring(keyboardManagerState->keyboardMap.GetKeyName(originalKey).c_str())); newRemapKeyControl.singleKeyRemapText.Text(winrt::to_hstring(keyboardManagerState->keyboardMap.GetKeyName(newKey).c_str())); } else { // Initialize both keys to NULL singleKeyRemapBuffer.push_back(std::vector{ NULL, NULL }); } // Delete row button Windows::UI::Xaml::Controls::Button deleteRemapKeys; deleteRemapKeys.Background(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::LightGray() }); deleteRemapKeys.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Black() }); FontIcon deleteSymbol; deleteSymbol.FontFamily(Xaml::Media::FontFamily(L"Segoe MDL2 Assets")); deleteSymbol.Glyph(L"\xE74D"); deleteRemapKeys.Content(deleteSymbol); deleteRemapKeys.Click([&](IInspectable const& sender, RoutedEventArgs const&) { StackPanel currentRow = sender.as