//------------------------------------------------------------------------------- // private void keyinputright_KeyDataChanging(object sender, KeyDataChangingEventArgs e) { var kir = (KeyInputRight)sender; if (e.PreviousKeyData == e.NewKeyData) { return; } // 変わってない var list = _dataListDic[kir.GroupID]; // 重複解除確認 bool prevDupCheck = false; if (kir.IsWarning) { int index = _duplicateDic[kir.GroupID].FindIndex(t => t.Item1 == e.PreviousKeyData); Debug.Assert(index >= 0); var tuple = _duplicateDic[kir.GroupID][index]; if (tuple.Item2.Value() == 2) { _duplicateDic[kir.GroupID].RemoveAt(index); prevDupCheck = true; } else { tuple.Item2.Decrement(); } } // 重複確認 uint numDup = 1; bool isThisDuplicated = false; if (e.NewKeyData == null) { return; } foreach (var item in list) { if (item.Item1 == kir) { continue; } if (prevDupCheck && item.Item1.Keydata == e.PreviousKeyData) { item.Item1.IsWarning = false; } else if (item.Item1.Keydata == e.NewKeyData) { item.Item1.IsWarning = true; isThisDuplicated = true; ++numDup; } } if (numDup == 2) { _duplicateDic[kir.GroupID].Add(new Tuple<KeyData, Counter>(e.NewKeyData, new Counter(2))); } else if (numDup > 2) { _duplicateDic[kir.GroupID].Find(t => t.Item1 == e.NewKeyData).Item2.Increment(); } kir.IsWarning = isThisDuplicated; }
//------------------------------------------------------------------------------- // private void btnEdit_Click(object sender, EventArgs e) { using (KeyEditForm frm = new KeyEditForm(Keydata)) { if (frm.ShowDialog() == DialogResult.OK) { var ce = new KeyDataChangingEventArgs(frm.KeyData, Keydata); if (KeyDataChanging != null) { KeyDataChanging(this, ce); } if (!ce.Cancel) { Keydata = frm.KeyData; SetLabelText(); } } } }