#include "pch.h" #include "ShortcutControl.h" #include "KeyDropDownControl.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(Grid& parent, std::vector>>& keyboardRemapControlObjects, Shortcut originalKeys, Shortcut newKeys) { // Create new ShortcutControl objects dynamically so that we does not get destructed std::vector> newrow; newrow.push_back(std::move(std::unique_ptr(new ShortcutControl(parent, 0)))); newrow.push_back(std::move(std::unique_ptr(new ShortcutControl(parent, 1)))); keyboardRemapControlObjects.push_back(std::move(newrow)); // Add to grid parent.RowDefinitions().Append(RowDefinition()); parent.SetColumn(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->getShortcutControl(), KeyboardManagerConstants::ShortcutTableOriginalColIndex); parent.SetRow(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->getShortcutControl(), parent.RowDefinitions().Size() - 1); parent.SetColumn(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getShortcutControl(), KeyboardManagerConstants::ShortcutTableNewColIndex); parent.SetRow(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getShortcutControl(), parent.RowDefinitions().Size() - 1); // ShortcutControl for the original shortcut parent.Children().Append(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->getShortcutControl()); // Arrow icon FontIcon arrowIcon; arrowIcon.FontFamily(Xaml::Media::FontFamily(L"Segoe MDL2 Assets")); arrowIcon.Glyph(L"\xE72A"); arrowIcon.VerticalAlignment(VerticalAlignment::Center); arrowIcon.HorizontalAlignment(HorizontalAlignment::Center); parent.SetColumn(arrowIcon, KeyboardManagerConstants::ShortcutTableArrowColIndex); parent.SetRow(arrowIcon, parent.RowDefinitions().Size() - 1); parent.Children().Append(arrowIcon); // ShortcutControl for the new shortcut parent.Children().Append(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->getShortcutControl()); // 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.Background(Media::SolidColorBrush(Colors::Transparent())); deleteShortcut.HorizontalAlignment(HorizontalAlignment::Center); deleteShortcut.Click([&](winrt::Windows::Foundation::IInspectable const& sender, RoutedEventArgs const&) { Button currentButton = sender.as