private void AddMapping() { // max out the mapping at 104 if (lvKeys.Items.Count >= 104) { MessageBox.Show("최대 매핑 가능 키 갯수는 104개입니다.\n\n기존 매핑을 삭제한뒤에 추가하세요.", ""); return; } // adding a new mapping, so prep the add dialog with all of the scancodes Dialog_KeyItem dlg = new Dialog_KeyItem(); dlg.m_hashKeys = m_hashKeys; // passed into this dialog so it can go out to the next IDictionaryEnumerator iDic = m_hashKeys.GetEnumerator(); while (iDic.MoveNext() == true) { string str = string.Format("{0} ({1})", iDic.Value, iDic.Key); dlg.lbFrom.Items.Add(str); dlg.lbTo.Items.Add(str); } // remove the null setting for "From" since you can never have a null key to map int nPos = 0; nPos = dlg.lbFrom.FindString("-- Turn Key Off (00_00)"); if (nPos > -1) { dlg.lbFrom.Items.RemoveAt(nPos); } // Now remove any of the keys that have already been mapped in the list (can't double up on from's) for (int i = 0; i < lvKeys.Items.Count; i++) { nPos = dlg.lbFrom.FindString(lvKeys.Items[i].Text); if (nPos > -1) { dlg.lbFrom.Items.RemoveAt(nPos); } } // let C# sort the lists dlg.lbFrom.Sorted = true; dlg.lbTo.Sorted = true; // UI stuff dlg.Text = "새 키 매핑"; dlg.lbFrom.SelectedIndex = 0; dlg.lbTo.SelectedIndex = 0; if (dlg.ShowDialog() == DialogResult.OK) { m_bDirty = true; // Add the list, as it's past inspection. ListViewItem lvI = lvKeys.Items.Add(dlg.lbFrom.Text); lvI.SubItems.Add(dlg.lbTo.Text); lvI.Selected = true; } lvKeys.Focus(); }
private void AddMapping() { // max out the mapping at 104 if (lvKeys.Items.Count >= 104) { MessageBox.Show("The maximum number of mappings SharpKeys supports is 16.\n\nPlease delete an existing mapping before adding a new one!", "SharpKeys"); return; } // adding a new mapping, so prep the add dialog with all of the scancodes Dialog_KeyItem dlg = new Dialog_KeyItem(m_hashKeys); // passed into this dialog so it can go out to the next dlg.FillListboxes(); dlg.DeleteNullMapping(); // Now remove any of the keys that have already been mapped in the list (can't double up on from's) for (int i = 0; i < lvKeys.Items.Count; i++) { int nPos = dlg.lbFrom.FindString(lvKeys.Items[i].Text); if (nPos > -1) { dlg.lbFrom.Items.RemoveAt(nPos); } } // let C# sort the lists dlg.lbFrom.Sorted = true; dlg.lbTo.Sorted = true; // UI stuff dlg.Text = "SharpKeys: Add New Key Mapping"; dlg.lbFrom.SelectedIndex = 0; dlg.lbTo.SelectedIndex = 0; if (dlg.ShowDialog() == DialogResult.OK) { m_bDirty = true; // Add the list, as it's past inspection. ListViewItem lvI = lvKeys.Items.Add(dlg.lbFrom.Text); lvI.SubItems.Add(dlg.lbTo.Text); lvI.Selected = true; } lvKeys.Focus(); }
private void EditMapping() { // make sure something was selecting if (lvKeys.SelectedItems.Count <= 0) { MessageBox.Show("Please select a mapping to edit!", "SharpKeys"); return; } // built the drop down lists no matter what Dialog_KeyItem dlg = new Dialog_KeyItem(m_hashKeys); // passed into this dialog so it can go out to the next dlg.FillListboxes(); dlg.DeleteNullMapping(); // remove any of the existing from key mappings however, leave in the one that has currently // been selected! int nPos; for (int i = 0; i < lvKeys.Items.Count; i++) { nPos = dlg.lbFrom.FindString(lvKeys.Items[i].Text); if ((nPos > -1) && (lvKeys.Items[i].Text != lvKeys.SelectedItems[0].Text)) { dlg.lbFrom.Items.RemoveAt(nPos); } } // Let C# sort the lists dlg.lbFrom.Sorted = true; dlg.lbTo.Sorted = true; // as it's an edit, set the drop down lists to the current From value nPos = dlg.lbFrom.FindString(lvKeys.SelectedItems[0].Text); if (nPos > -1) { dlg.lbFrom.SelectedIndex = nPos; } else { dlg.lbFrom.SelectedIndex = 0; } // as it's an edit, set the drop down lists to the current To value nPos = dlg.lbTo.FindString(lvKeys.SelectedItems[0].SubItems[1].Text); if (nPos > -1) { dlg.lbTo.SelectedIndex = nPos; } else { dlg.lbTo.SelectedIndex = 0; } dlg.Text = "SharpKeys: Edit Key Mapping"; if (dlg.ShowDialog() == DialogResult.OK) { m_bDirty = true; // update the select mapping item in the list view lvKeys.SelectedItems[0].Text = dlg.lbFrom.Text; lvKeys.SelectedItems[0].SubItems[1].Text = dlg.lbTo.Text; } lvKeys.Focus(); }
private void EditMapping() { // make sure something was selecting if (lvKeys.SelectedItems.Count <= 0) { MessageBox.Show("수정할 키를 선택하세요!", ""); return; } // built the drop down lists no matter what Dialog_KeyItem dlg = new Dialog_KeyItem(); dlg.m_hashKeys = m_hashKeys; // passed into this dialog so it can go out to the next IDictionaryEnumerator iDic = m_hashKeys.GetEnumerator(); while (iDic.MoveNext() == true) { string str = string.Format("{0} ({1})", iDic.Value, iDic.Key); dlg.lbFrom.Items.Add(str); dlg.lbTo.Items.Add(str); } // remove the null setting for "From" since you can never have a null key to map int nPos = 0; nPos = dlg.lbFrom.FindString("-- Turn Key Off (00_00)"); if (nPos > -1) { dlg.lbFrom.Items.RemoveAt(nPos); } // remove any of the existing from key mappings however, leave in the one that has currently // been selected! for (int i = 0; i < lvKeys.Items.Count; i++) { nPos = dlg.lbFrom.FindString(lvKeys.Items[i].Text); if ((nPos > -1) && (lvKeys.Items[i].Text != lvKeys.SelectedItems[0].Text)) { dlg.lbFrom.Items.RemoveAt(nPos); } } // Let C# sort the lists dlg.lbFrom.Sorted = true; dlg.lbTo.Sorted = true; // as it's an edit, set the drop down lists to the current From value nPos = dlg.lbFrom.FindString(lvKeys.SelectedItems[0].Text); if (nPos > -1) { dlg.lbFrom.SelectedIndex = nPos; } else { dlg.lbFrom.SelectedIndex = 0; } // as it's an edit, set the drop down lists to the current To value nPos = dlg.lbTo.FindString(lvKeys.SelectedItems[0].SubItems[1].Text); if (nPos > -1) { dlg.lbTo.SelectedIndex = nPos; } else { dlg.lbTo.SelectedIndex = 0; } dlg.Text = "키 매핑 수정"; if (dlg.ShowDialog() == DialogResult.OK) { m_bDirty = true; // update the select mapping item in the list view lvKeys.SelectedItems[0].Text = dlg.lbFrom.Text; lvKeys.SelectedItems[0].SubItems[1].Text = dlg.lbTo.Text; } lvKeys.Focus(); }