コード例 #1
0
ファイル: Keyboard.cs プロジェクト: stuartd/keymapper
        public KeyboardForm()
        {
            FormToolTip = new ToolTip();

            InitializeComponent();
            FormsManager.RegisterMainForm(this);

            if (DpiInfo.Dpi < 96)
            {
                menu.Height = (int)(menu.Height * (96F / DpiInfo.Dpi));
                // Menu will always show even is fonts are set to less than 100%
            }
            else if (DpiInfo.Dpi > 96)
            {
                menu.Height = (int)(menu.Height * (DpiInfo.Dpi / 96F));
            }

            LoadUserSettings();

            ResizeToAspect();

            if (DpiInfo.Dpi != 96)
            {
                PositionKeyboardCombo();
            }

            // This needs to be done after location and size of this form are fully determined.
            FormsManager.OpenChildForms();

            lastSize = Size;

            GetKeyboardData();

            // Create event handlers
            ResizeEnd += KeyboardFormResizeEnd;
            KeyboardListCombo.SelectedIndexChanged += KeyboardListSelectedIndexChanged;

            MappingsManager.MappingsChanged += OnMappingsChanged;
            UserColourSettingManager.ColoursChanged += OnColoursChanged;

            // Sniff for Caps/Num/Scroll lock keys being pressed while app doesn't have focus
            sniffer = new KeySniffer();
            sniffer.KeyPressed += ReceiveKeyPress;
            sniffer.ActivateHook();

            Redraw();
        }