public void Refresh(RefreshFor modify) { try { RefreshNumberRow(NumRowPanel, modify); RefreshQWERRow(QWERRowPanel, modify); RefreshASDFRow(ASDFRowPanel, modify); RefreshZXCVRow(ZXCVRowPanel, modify); RefreshSpaceRow(SpaceRowPanel, modify); //Speical Case for Special Keys if ((modify & RefreshFor.Font) == RefreshFor.Font) { Font smallFont = new Font(ButtonFont.FontFamily, ButtonFont.Size); foreach (KeyLocation loc in SpeicalKeys) { int index = loc.KeyIndex; if (index == -1) { index = loc.Panel.Controls.Count - 1; } loc.Panel.Controls[index].Font = smallFont; } } } catch (Exception e) { Debug.WriteLine(new StackTrace(e)); } }
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); } }
private void RefreshZXCVRow(FlowLayoutPanel panel, RefreshFor modify) { if (ZXCVRowScancodes.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 ((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 = ZXCVSize(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); } }