/// <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();
                }
            }
        }
        /// <summary>
        ///  Remove Lock Image
        /// </summary>
        /// <param name="b"></param>
        public void removeLockImage(PlayerButton b)
        {
            CustomPictureBox cpb = b.lockImage;

            if (cpb != null)
            {
                cpb.Visible = false;
                cpb         = null;
                //cpb.Dispose();
            }
            if (b.lockImage != null)
            {
                b.lockImage.Dispose();
            }
            //Console.WriteLine("Removed for " + b.SeatName + " Status: " + b.lockImage.IsDisposed); // Debug
        }
Exemple #3
0
        /// <summary>
        /// Set Similar images for buttons if necessary
        /// </summary>
        /// <param name="button">Which button should we attach similar nicks to?</param>
        /// <param name="similar">List of similar nicks</param>
        private void setSimilarNickImage(PlayerButton button, List <Note> similar)
        {
            // Create picture box with settings from GlobalSettings and Set location according to PlayerButton
            CustomPictureBox imageSimilar = new CustomPictureBox();

            imageSimilar.Image        = GlobalSettings.Images.questionImage;
            imageSimilar.Width        = GlobalSettings.Images.lockImage.Width;
            imageSimilar.Height       = GlobalSettings.Images.lockImage.Height;
            imageSimilar.Location     = new System.Drawing.Point(button.Location.X, button.Location.Y - imageSimilar.Width - 1);
            imageSimilar.Visible      = true;
            button.similarImage       = imageSimilar;
            imageSimilar.SimilarNicks = similar;
            imageSimilar.PlayerButton = button;
            imageSimilar.MouseDown   += new MouseEventHandler(PlayerButton.similarImage_Click);
            imageSimilar.SetParent(button.TableHandle);
        }
Exemple #4
0
        /// <summary>
        /// C# has a bug where tooltips for Buttons whicha re created during runtime will fail to show up
        /// Workaround is adding a transparent label on that button and attach the tooltip to that label
        /// If a Player has a note, we add a Note Icon to the left side of the button and implement the workaround for the tooltip
        /// </summary>
        /// <param name="button"></param>
        /// <param name="playername"></param>
        private void createToolTipAndNoteIcon(PlayerButton button, string playername)
        {
            string hasNote = NoteHandler.playerHasNote(playername);

            // check if note in note database
            if (hasNote == null || hasNote.Equals(""))
            {
                button.setNoteImage(false);
            }
            else
            {
                // if note-text was found, add note image to playerbutton
                button.setNoteImage(true);

                // clean up before adding new tooltip
                int controls = button.Controls.Count;
                if (controls > 0)
                {
                    foreach (Control c in button.Controls)
                    {
                        c.Dispose();
                    }
                }

                // Create workaround/dummy Label
                Label dummy = new Label {
                    Top = 3, Left = 3, Width = 20, Height = 20
                };
                dummy.BackColor = System.Drawing.Color.Transparent;
                dummy.ForeColor = System.Drawing.Color.Transparent;
                button.Controls.Add(dummy);

                // Set custom EventHandlers
                button.MouseHover += Button_MouseHover;
                button.MouseLeave += Button_MouseLeave;
            }
        }