public void TaggerSelectChange(object tagger, bool selected) { Tagger TaggerObject = (Tagger)tagger; if (selected == true) { if (CurrentSelected != null) { CurrentSelected.DeSelectTagger(); } CurrentSelected = TaggerObject; CurrentSelected.Focus(); CurrentSelected.PreviewKeyDown += new PreviewKeyDownEventHandler(CurrentSelected_PreviewKeyDown); } if (selected == false) { CurrentSelected = null; } }
private void CurrentSelected_PreviewKeyDown(object TaggerObject, PreviewKeyDownEventArgs e) { e.IsInputKey = true; Tagger SelectedObject = (Tagger)TaggerObject, SwappingObject; int AlphaIndex, BetaIndex; if (e.KeyCode == Keys.Left) { AlphaIndex = NameFinalPanel.Controls.GetChildIndex(CurrentSelected); BetaIndex = AlphaIndex - 1; if (AlphaIndex > 0) { SwappingObject = (Tagger)NameFinalPanel.Controls[BetaIndex]; NameFinalPanel.Controls.SetChildIndex(SelectedObject, BetaIndex); NameFinalPanel.Controls.SetChildIndex(SwappingObject, AlphaIndex); Tuple <int, int, string> TempTuple = FinalString[AlphaIndex]; FinalString[AlphaIndex] = FinalString[BetaIndex]; FinalString[BetaIndex] = TempTuple; } } if (e.KeyCode == Keys.Right) { AlphaIndex = NameFinalPanel.Controls.GetChildIndex(CurrentSelected); BetaIndex = AlphaIndex + 1; if (AlphaIndex < count - 1) { SwappingObject = (Tagger)NameFinalPanel.Controls[BetaIndex]; NameFinalPanel.Controls.SetChildIndex(SelectedObject, BetaIndex); NameFinalPanel.Controls.SetChildIndex(SwappingObject, AlphaIndex); Tuple <int, int, string> TempTuple = FinalString[AlphaIndex]; FinalString[AlphaIndex] = FinalString[BetaIndex]; FinalString[BetaIndex] = TempTuple; } } CurrentSelected.Focus(); }