public HotKeyVisualItem(HotKeyItem HotKey = null) { InitializeComponent(); if (HotKey != null) { InputKeyString(HotKey); } }
private void OnTextBoxKeyDown(object sender, KeyEventArgs e) { TextBox textBox = (TextBox)sender; int i = (int)textBox.Tag; HotKeyItem item = m_hotKeyItems[i]; m_newHotKeyOptions.keys[i] = e.KeyData; UpdateOptions(); UpdateBottomsEnabling(); VerifyValidness(); }
private HotKeyItem GetHotKeyItem(GLOBAL_HOT_KEY_TYPE type) { if (!hot_keys.TryGetValue(type, out var cur)) { hot_keys[type] = cur = new HotKeyItem { setting = new HotKeySetting { key = Key.None } } } ; return(cur); }
public void InputKeyString(HotKeyItem HotKey) { switch (HotKey.ModifiersValue) { case 1: HotKeysString = "Alt+" + HotKey.KeyValue.ToString(); ModifiersValue = HotKey.ModifiersValue; KeyValue = HotKey.KeyValue; this.Available = true; break; case 2: HotKeysString = "Ctrl+" + HotKey.KeyValue.ToString(); ModifiersValue = HotKey.ModifiersValue; KeyValue = HotKey.KeyValue; this.Available = true; break; case 3: HotKeysString = "Ctrl+Alt+" + HotKey.KeyValue.ToString(); ModifiersValue = HotKey.ModifiersValue; KeyValue = HotKey.KeyValue; this.Available = true; break; case 4: HotKeysString = "Shift+" + HotKey.KeyValue.ToString(); ModifiersValue = HotKey.ModifiersValue; KeyValue = HotKey.KeyValue; this.Available = true; break; case 6: HotKeysString = "Ctrl+Shift+" + HotKey.KeyValue.ToString(); ModifiersValue = HotKey.ModifiersValue; KeyValue = HotKey.KeyValue; this.Available = true; break; case 8: HotKeysString = "Shift+" + HotKey.KeyValue.ToString(); ModifiersValue = HotKey.ModifiersValue; KeyValue = HotKey.KeyValue; this.Available = true; break; default: break; } }
private void PopulateHotkeys() { Dictionary <string, KeyCode> keys = HotKeyManager.Instance.GetHotKeys(); buttonKeyCodeTexts = new Dictionary <string, Text>(); foreach (string hotkey in keys.Keys) { GameObject newItem = Instantiate(hotKeySelectionPrefab); newItem.transform.SetParent(scrollViewContent, false); HotKeyItem item = newItem.GetComponentInChildren <HotKeyItem>(); item.SetItemText(hotkey); item.SetButtonText(keys[hotkey].ToString()); item.itemButton.onClick.AddListener(() => StartRebindFor(hotkey.ToString())); buttonKeyCodeTexts.Add(hotkey, item.GetButtonText()); } }
private void OnCheckBoxClick(object sender, EventArgs e) { CheckBox checkBox = (CheckBox)sender; int i = (int)checkBox.Tag; HotKeyItem item = m_hotKeyItems[i]; if (!item.ckeck.Checked) { m_newHotKeyOptions.keys[i] = Keys.None; } else { m_newHotKeyOptions.SetDefault((HotKeyOptions.Action)i); } UpdateOptions(); UpdateBottomsEnabling(); VerifyValidness(); }
private void InitializeComponents() { ClientSize = new System.Drawing.Size(420, 315); FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterScreen; ShowInTaskbar = false; MaximizeBox = false; MinimizeBox = false; Resources.Help.Bind(this, Resources.Help.HotKeys); m_toolTip = new ToolTip(); m_toolTip.ShowAlways = true; TableLayoutPanel mainTableLayoutPanel = InitFactory.Layout.Create(1, 2, 5); mainTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 80F)); mainTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); Controls.Add(mainTableLayoutPanel); TableLayoutPanel hotKeysTableLayoutPanel = InitFactory.Layout.Create(4, m_newHotKeyOptions.keys.Length, 5); hotKeysTableLayoutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset; hotKeysTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 8F)); hotKeysTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 66F)); hotKeysTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 6F)); hotKeysTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); mainTableLayoutPanel.Controls.Add(hotKeysTableLayoutPanel, 0, 0); m_hotKeyItems = new HotKeyItem[m_newHotKeyOptions.keys.Length]; for (int i = 0; i < m_hotKeyItems.Length; i++) { HotKeyItem item = new HotKeyItem(); item.icon = new PictureBox(); item.icon.Location = new System.Drawing.Point(0, 0); item.icon.Size = new System.Drawing.Size(20, 20); item.icon.SizeMode = PictureBoxSizeMode.Zoom; hotKeysTableLayoutPanel.Controls.Add(item.icon, 0, i); item.text = new Label(); item.text.Location = new System.Drawing.Point(0, 0); item.text.Dock = DockStyle.Fill; item.text.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; hotKeysTableLayoutPanel.Controls.Add(item.text, 1, i); item.ckeck = new CheckBox(); item.ckeck.Location = new System.Drawing.Point(0, 0); item.ckeck.Size = new System.Drawing.Size(20, 20); item.ckeck.Dock = DockStyle.Fill; item.ckeck.Tag = i; item.ckeck.Click += new EventHandler(OnCheckBoxClick); hotKeysTableLayoutPanel.Controls.Add(item.ckeck, 2, i); item.edit = new TextBox(); item.edit.Location = new System.Drawing.Point(0, 0); item.edit.Dock = DockStyle.Fill; item.edit.ReadOnly = true; item.edit.Multiline = false; item.edit.KeyDown += new KeyEventHandler(OnTextBoxKeyDown); item.edit.Tag = i; hotKeysTableLayoutPanel.Controls.Add(item.edit, 3, i); m_hotKeyItems[i] = item; } InitializeIcons(); TableLayoutPanel buttonsTableLayoutPanel = InitFactory.Layout.Create(4, 1); buttonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F)); buttonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); buttonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); buttonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F)); mainTableLayoutPanel.Controls.Add(buttonsTableLayoutPanel, 0, 1); m_okButton = new Button(); m_okButton.Click += new System.EventHandler(OnButtonClick); buttonsTableLayoutPanel.Controls.Add(m_okButton, 1, 0); m_cancelButton = new Button(); m_cancelButton.Click += new System.EventHandler(OnButtonClick); buttonsTableLayoutPanel.Controls.Add(m_cancelButton, 2, 0); m_setDefaultButton = new Button(); m_setDefaultButton.AutoSize = true; m_setDefaultButton.Click += new System.EventHandler(OnButtonClick); buttonsTableLayoutPanel.Controls.Add(m_setDefaultButton, 3, 0); }