Example #1
0
        /// <summary>
        /// Refresh Player Buttons - Used after Deleting a Note and resetting defaults
        /// Especially needed when we delete from Note Window that was not open by Click from table,
        /// but from NoteBrowser or from Click on SimilarNickName-Icon
        /// </summary>
        /// <param name="tablename"></param>
        public static void refreshPlayerButtons(string tablename)
        {
            PlayerButtonHandler pbh = TableHandler.buttonInventory[tablename];
            TableData           td  = TableHandler.getTableDataFromTableName(tablename);

            pbh.updateButtons(td, true);
        }
        /// <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();
                }
            }
        }