#include "pch.h" #include "ShortcutControl.h" //Both static members are initialized to null HWND ShortcutControl::EditShortcutsWindowHandle = nullptr; KeyboardManagerState* ShortcutControl::keyboardManagerState = nullptr; // Initialized as new vector std::vector> ShortcutControl::shortcutRemapBuffer; // Function to add a new row to the shortcut table. If the originalKeys and newKeys args are provided, then the displayed shortcuts are set to those values. void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, Shortcut originalKeys, Shortcut newKeys) { // 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); // ShortcutControl for the original shortcut ShortcutControl originalSC(shortcutRemapBuffer.size(), 0); tableRow.Children().Append(originalSC.getShortcutControl()); // ShortcutControl for the new shortcut ShortcutControl newSC(shortcutRemapBuffer.size(), 1); tableRow.Children().Append(newSC.getShortcutControl()); // Set the shortcut text if the two vectors are not empty (i.e. default args) if (!originalKeys.IsEmpty() && !newKeys.IsEmpty()) { shortcutRemapBuffer.push_back(std::vector{ originalKeys, newKeys }); originalSC.shortcutText.Text(originalKeys.ToHstring(keyboardManagerState->keyboardMap)); newSC.shortcutText.Text(newKeys.ToHstring(keyboardManagerState->keyboardMap)); } else { // Initialize both shortcuts as empty shortcuts shortcutRemapBuffer.push_back(std::vector{ Shortcut(), Shortcut() }); } // Delete row button Windows::UI::Xaml::Controls::Button deleteShortcut; FontIcon deleteSymbol; deleteSymbol.FontFamily(Xaml::Media::FontFamily(L"Segoe MDL2 Assets")); deleteSymbol.Glyph(L"\xE74D"); deleteShortcut.Content(deleteSymbol); deleteShortcut.Click([&](IInspectable const& sender, RoutedEventArgs const&) { StackPanel currentRow = sender.as