/// <summary> /// Remove Similar Nick Image /// </summary> /// <param name="b"></param> public void removeSimilarNickImage(PlayerButton b) { CustomPictureBox cpb = b.similarImage; //b.similarImage = null; if (cpb != null) { cpb.Dispose(); } }
/// <summary> /// Handles actions when clicked on SimilarImage-Icon /// * RightClick => Removes Icon /// * Left Click => If there is only one similar nick, it will adjust the player from the button to the one from the similar icon /// If there are more than one => Open NoteWindows for all similar nicks! /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void similarImage_Click(object sender, MouseEventArgs e) { // LeftClick if (e.Button.Equals(MouseButtons.Left)) { if (sender is CustomPictureBox) { CustomPictureBox cbp = (CustomPictureBox)sender; PlayerButton pb = cbp.PlayerButton; List <Note> similar = cbp.SimilarNicks; IntPtr pointer = pb.TableHandle; TableData td = TableHandler.tableSessions[pointer]; // if only 1 similar nick, set player on this button to the similar player on LeftClick if (similar.Count.Equals(1)) { // Adjust TableData string seatname = td.getSeatname(pb.Text); td.setNickname(seatname, similar[0].Name); // Repaint Buttons PlayerButtonHandler pbh = TableHandler.buttonInventory[td.tablename]; pbh.updateButtons(td, true); cbp.Dispose(); } else { // if more than 1 similar nick, open NoteWindows for every of those nicks foreach (Note n in similar) { Console.WriteLine(n.Name); FormNoteWindow fnw = new FormNoteWindow(n, td.tablename); fnw.Show(); } } } } // RightClick else if (e.Button.Equals(MouseButtons.Right)) { if (sender is CustomPictureBox) { CustomPictureBox cbp = (CustomPictureBox)sender; cbp.Dispose(); } } }