2020-03-27 23:38:58 +08:00
# pragma once
2020-04-19 07:12:26 +08:00
# include "KeyDropDownControl.h"
2020-07-24 07:43:49 +08:00
# include <keyboardmanager/common/Shortcut.h>
2020-03-27 23:38:58 +08:00
2020-07-14 02:49:09 +08:00
class KeyboardManagerState ;
namespace winrt : : Windows : : UI : : Xaml
{
struct XamlRoot ;
namespace Controls
{
struct StackPanel ;
struct Grid ;
2020-09-19 08:12:37 +08:00
struct Button ;
2020-07-14 02:49:09 +08:00
}
}
2020-03-27 23:38:58 +08:00
class SingleKeyRemapControl
{
private :
// Button to type the remap key
2020-07-14 02:49:09 +08:00
winrt : : Windows : : Foundation : : IInspectable typeKey ;
2020-03-27 23:38:58 +08:00
// StackPanel to parent the above controls
2020-07-14 02:49:09 +08:00
winrt : : Windows : : Foundation : : IInspectable singleKeyRemapControlLayout ;
2020-03-27 23:38:58 +08:00
2020-07-24 07:43:49 +08:00
// Stack panel for the drop downs to display the selected shortcut for the hybrid case
winrt : : Windows : : Foundation : : IInspectable hybridDropDownStackPanel ;
2020-09-19 08:12:37 +08:00
// Function to set the accessible names for all the controls in a row
static void UpdateAccessibleNames ( StackPanel sourceColumn , StackPanel mappedToColumn , Button deleteButton , int rowIndex ) ;
2020-03-27 23:38:58 +08:00
public :
2020-07-24 07:43:49 +08:00
// Vector to store dynamically allocated KeyDropDownControl objects to avoid early destruction
std : : vector < std : : unique_ptr < KeyDropDownControl > > keyDropDownControlObjects ;
2020-03-27 23:38:58 +08:00
// Handle to the current Edit Keyboard Window
static HWND EditKeyboardWindowHandle ;
// Pointer to the keyboard manager state
static KeyboardManagerState * keyboardManagerState ;
2020-04-10 00:20:19 +08:00
// Stores the current list of remappings
2020-08-14 07:32:15 +08:00
static RemapBuffer singleKeyRemapBuffer ;
2020-03-27 23:38:58 +08:00
2020-07-14 02:49:09 +08:00
// constructor
2020-11-06 22:24:11 +08:00
SingleKeyRemapControl ( StackPanel table , StackPanel row , const int colIndex ) ;
2020-03-27 23:38:58 +08:00
// 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.
2020-11-06 22:24:11 +08:00
static void AddNewControlKeyRemapRow ( StackPanel & parent , std : : vector < std : : vector < std : : unique_ptr < SingleKeyRemapControl > > > & keyboardRemapControlObjects , const DWORD originalKey = NULL , const KeyShortcutUnion newKey = NULL ) ;
2020-03-27 23:38:58 +08:00
// Function to return the stack panel element of the SingleKeyRemapControl. This is the externally visible UI element which can be used to add it to other layouts
2020-07-14 02:49:09 +08:00
winrt : : Windows : : UI : : Xaml : : Controls : : StackPanel getSingleKeyRemapControl ( ) ;
2020-03-27 23:38:58 +08:00
// Function to create the detect remap keys UI window
2020-07-24 07:43:49 +08:00
void createDetectKeyWindow ( winrt : : Windows : : Foundation : : IInspectable const & sender , XamlRoot xamlRoot , KeyboardManagerState & keyboardManagerState ) ;
2020-03-27 23:38:58 +08:00
} ;