Exemplo n.º 1
0
        private void CreateSpaceRow(FlowLayoutPanel currentFlow)
        {
            SoftKey b = null;

            currentFlow.Controls.Clear();

            Padding p = new Padding(2, 3, 2, 3);

            Size[] sizes = SpaceSize(currentFlow.Size);

            for (int i = 0; i < sizes.Length; i++)
            {
                b = CreateSoftKey() as SoftKey;
                switch (i)
                {
                case 0:
                case 2:
                case 4:
                case 5:
                    b.CheckAble = true;
                    break;
                }
                b.ScanCode = SpaceRowScancodes[i];
                currentFlow.Controls.Add(b);
            }
        }
Exemplo n.º 2
0
        private void CreateZXCVRow(FlowLayoutPanel currentFlow)
        {
            SoftKey b = null;

            currentFlow.Controls.Clear();

            Padding p = new Padding(2, 3, 2, 3);

            Size[] sizes = ZXCVSize(currentFlow.Size);

            for (int i = 0; i < sizes.Length; i++)
            {
                b = CreateSoftKey() as SoftKey;
                if (i == 0)
                {
                    b.CheckAble = true;
                }
                b.ScanCode = ZXCVRowScancodes[i];
                currentFlow.Controls.Add(b);
            }

            if (b != null)
            {
                b.CheckAble = true;
            }
        }
Exemplo n.º 3
0
 private void ChangeStyleForKey(SoftKey key)
 {
     if (IsSwitchKey(key.ScanCode))
     {
         SetStyleForKeyType(key, KeyType.SwitchKey);
     }
     else
     {
         SetStyleForKeyType(key, KeyType.Normal);
     }
 }
Exemplo n.º 4
0
        protected virtual void SimulateKeyPress(SoftKey key)
        {
            SendInput.SendSingleScanCode((ushort)key.ScanCode, NativeMethods.KEYEVENTF.KEYDOWN);

            if (key.IsChecked == false)
            {
                SendInput.SendSingleScanCode((ushort)key.ScanCode, NativeMethods.KEYEVENTF.KEYUP);
            }

            //ResetModifiersAsNeeded((int)key.VirutalKeyCodeValue);
            ResetModifiersAsNeeded((int)key.ScanCode);
        }
Exemplo n.º 5
0
 protected void SetCapsLockState(SoftKey key)
 {
     if ((NativeMethods.GetKeyState(NativeMethods.VK.CAPITAL) & 0x1) != 0x1)
     {
         SetStyleForKeyType(key, KeyType.Normal);
         CapsLock = false;
     }
     else
     {
         SetStyleForKeyType(key, KeyType.Toggled);
         CapsLock = true;
     }
 }
Exemplo n.º 6
0
        private void RefreshASDFRow(FlowLayoutPanel panel, RefreshFor modify)
        {
            if (ASDFRowScancodes.Length != panel.Controls.Count)
            {
                return;
            }

            if ((modify & RefreshFor.Label) == RefreshFor.Label)
            {
                for (int i = 0; i < panel.Controls.Count; i++)
                {
                    SoftKey key = panel.Controls[i] as SoftKey;
                    ChangeStyleForKey(key);
                    key.Text = GetDisplayStringFromVK(key.ScanCode);
                    if (key.ScanCode == 0x14)
                    {
                        SetCapsLockState(key);
                        continue;
                    }
                }
            }

            if ((modify & RefreshFor.Font) == RefreshFor.Font)
            {
                for (int i = 0; i < panel.Controls.Count; i++)
                {
                    panel.Controls[i].Font = ButtonFont;
                }
            }

            if ((modify & RefreshFor.Size) == RefreshFor.Size)
            {
                panel.SuspendLayout();

                Size[] sizes = ASDFSize(panel.Size);
                if (sizes.Length != panel.Controls.Count)
                {
                    return;
                }

                for (int i = 0; i < sizes.Length; i++)
                {
                    panel.Controls[i].Size = sizes[i];
                }

                panel.ResumeLayout();

                Control b = panel.Controls[panel.Controls.Count - 1];
                b.Width = panel.Width - b.Location.X - (buttonMargin.Left + buttonMargin.Right);
            }
        }
Exemplo n.º 7
0
        private void CreateASDFRow(FlowLayoutPanel currentFlow)
        {
            SoftKey b = null;

            currentFlow.Controls.Clear();

            Padding p = new Padding(2, 3, 2, 3);

            Size[] sizes = ASDFSize(currentFlow.Size);

            for (int i = 0; i < sizes.Length; i++)
            {
                b          = CreateSoftKey() as SoftKey;
                b.ScanCode = ASDFRowScancodes[i];
                currentFlow.Controls.Add(b);
            }
        }
Exemplo n.º 8
0
 protected virtual void SetStyleForKeyType(SoftKey key, KeyType keyType)
 {
     if ((keyType & KeyType.Toggled) == KeyType.Toggled)
     {
         key.NormalColor = new Color[] { Color.Orange, Color.OrangeRed };
         key.ForeColor   = Color.White;
     }
     else if ((keyType & KeyType.Normal) == KeyType.Normal)
     {
         key.NormalColor = new Color[] { Color.White, Color.LightGray };
         key.ForeColor   = Color.Black;
     }
     else if ((keyType & KeyType.SwitchKey) == KeyType.SwitchKey)
     {
         key.NormalColor = new Color[] { Color.FromArgb(177, 216, 250), Color.FromArgb(105, 180, 255) };
         key.ForeColor   = Color.Black;
     }
 }
Exemplo n.º 9
0
        private ButtonBase CreateSoftKey()
        {
            SoftKey b = new SoftKey();

            b.Margin = buttonMargin;

            b.UseMnemonic = false;

            b.BackColor = Color.Black;

            b.ParentHandle = this.Handle;

            b.BackColor = this.BackColor;

            b.MouseUp += new MouseEventHandler(SoftKey_MouseUp);

            return(b);
        }
Exemplo n.º 10
0
        void SoftKey_MouseUp(object sender, MouseEventArgs e)
        {
            SoftKey key = sender as SoftKey;

            if (SetForegroundWindow() == false)
            {
                tt.RemoveAll();
                tt.AutomaticDelay = 0;
                tt.Show("Move the cursor where you want to enter text", key);
            }

            SimulateKeyPress(key);

            if (key.ScanCode == 0x14)
            {
                SetCapsLockState(key);
            }
        }