private void rulesList_SelectedIndexChanged(object sender, EventArgs e) { if (rulesList.SelectedIndex != -1) { MyRow mr = rulesList.SelectedItem as MyRow; preview.Text = pairs[mr.irCode].keyCode; } }
private void removeRule_Click(object sender, EventArgs e) { if (rulesList.SelectedIndex != -1) { if (rulesList.SelectedItem is MyRow) { MyRow mr = rulesList.SelectedItem as MyRow; pairs.Remove(mr.irCode); rulesList.Items.RemoveAt(rulesList.SelectedIndex); } } }
void updateRulesList() { rulesList.Items.Clear(); foreach (var item in pairs) { string temp = $"{item.Key} : {item.Value}"; temp = String.Format("{0,-8}|{1,-2:X2}|{2}", item.Value.lable, item.Key, item.Value.keyCode); // 25 | CTRL+A MyRow mr = new MyRow(); mr.irCode = item.Key; mr.str = temp; rulesList.Items.Add(mr); } }
private void editRule_Click(object sender, EventArgs e) { if (rulesList.SelectedIndex != -1) { if (rulesList.SelectedItem is MyRow) { MyRow mr = rulesList.SelectedItem as MyRow; IRCode.Text = mr.irCode.ToString("x"); keyCode.Text = pairs[mr.irCode].keyCode; lable.Text = pairs[mr.irCode].lable; rulesList.Items.RemoveAt(rulesList.SelectedIndex); pairs.Remove(mr.irCode); } } }