Example #1
0
        /// <summary>
        /// Lock all Buttons for a single table
        /// </summary>
        public void lockAllButtons()
        {
            foreach (PlayerButton b in buttons)
            {
                if (b.Text != null)
                {
                    CustomPictureBox cpbOld = (CustomPictureBox)b.lockImage;
                    if (cpbOld == null) // dont attach two lock icons
                    {
                        CustomPictureBox imageLock = new CustomPictureBox();
                        imageLock.Image    = GlobalSettings.Images.lockImage;
                        imageLock.Width    = GlobalSettings.Images.lockImage.Width;
                        imageLock.Height   = GlobalSettings.Images.lockImage.Height;
                        imageLock.Location = new System.Drawing.Point(b.Location.X - imageLock.Width - 1, b.Location.Y);
                        imageLock.Visible  = true;
                        b.lockImage        = imageLock;
                        imageLock.SetParent(b.TableHandle);

                        PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)b.ContextMenuStrip;
                        if (pbcms == null)
                        {
                            continue;
                        }
                        // Reset toolstrip to "unlock" text
                        resetLockToolstrip("Unlock");
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Locks Single Button
        /// </summary>
        /// <param name="sender">should be ToolStripMenuItem</param>
        /// <param name="e"></param>
        private void LockButton_Click(object sender, EventArgs e)
        {
            if (sender is ToolStripMenuItem)
            {
                ToolStripMenuItem            tsi   = (ToolStripMenuItem)sender;
                PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)tsi.GetCurrentParent();

                // Set Caption correctly as it can also get changed by "LockAllButtons", etc
                string displayedText = tsi.Text;
                if (displayedText.Equals("Lock"))
                {
                    PlayerButtonContextMenuActions.lockSeat(pbcms.seatname, pbcms.tablename);
                    tsi.Text = "Unlock";
                }
                else
                {
                    PlayerButtonContextMenuActions.unlockSeat(pbcms.seatname, pbcms.tablename);
                    tsi.Text = "Lock";
                }
            }
            else
            {
                throw new Exception("Sender is no ToolStripMenuItem!");
            }
        }
Example #3
0
 /// <summary>
 /// Change Nickname by Avatar/Tags
 /// </summary>
 /// <param name="sender">should be ToolStripMenuItem</param>
 /// <param name="e"></param>
 private void changeNicknameByAvatar_Click(object sender, EventArgs e)
 {
     if (sender is ToolStripMenuItem)
     {
         ToolStripMenuItem            tsi   = (ToolStripMenuItem)sender;
         PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)tsi.GetCurrentParent();
         new FormChangeNickAvatar(pbcms.seatname, pbcms.tablename);
     }
     else
     {
         throw new Exception("Sender is no ToolStripMenuItem!");
     }
 }
Example #4
0
 /// <summary>
 /// Display Debug Table Data Form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DisplayDebugTableData_Click(object sender, EventArgs e)
 {
     if (sender is ToolStripMenuItem)
     {
         ToolStripMenuItem            tsi   = (ToolStripMenuItem)sender;
         PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)tsi.GetCurrentParent();
         PlayerButtonContextMenuActions.displayDebugTableData(pbcms.tablename);
     }
     else
     {
         throw new Exception("Sender is no ToolStripMenuItem!");
     }
 }
Example #5
0
 /// <summary>
 /// Remove Single Button
 /// </summary>
 /// <param name="sender">should be ToolStripMenuItem</param>
 /// <param name="e"></param>
 private void RemoveButton_Click(object sender, EventArgs e)
 {
     if (sender is ToolStripMenuItem)
     {
         ToolStripMenuItem            tsi   = (ToolStripMenuItem)sender;
         PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)tsi.GetCurrentParent();
         PlayerButtonContextMenuActions.removeSeatFromTable(pbcms.seatname, pbcms.tablename);
     }
     else
     {
         throw new Exception("Sender is no ToolStripMenuItem!");
     }
 }
Example #6
0
 /// <summary>
 /// Change Nickname manually
 /// </summary>
 /// <param name="sender">should be ToolStripMenuItem</param>
 /// <param name="e"></param>
 private void changeNicknameManually_Click(object sender, EventArgs e)
 {
     /*
      *  Whats need to change?
      *  1. nickname in SeatData --> via tabledata
      *  2. text in PlayerButton --> via PlayerButtonHandler
      */
     if (sender is ToolStripMenuItem)
     {
         ToolStripMenuItem            tsi   = (ToolStripMenuItem)sender;
         PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)tsi.GetCurrentParent();
         PlayerButtonContextMenuActions.renameSeat(pbcms.seatname, pbcms.tablename);
     }
     else
     {
         throw new Exception("Sender is no ToolStripMenuItem!");
     }
 }
        /// <summary>
        /// pass information through to context menu
        /// --> necessary for adjusting nickname and avatars, locking & removing buttons
        /// </summary>
        /// <param name="nickname">nickname</param>
        /// <param name="seat">seatname</param>
        /// <param name="tableName">tablename</param>
        /// <param name="locked">locked or not?</param>
        public void SetPlayerNameContextMenu(string nickname, string seat, string tableName, bool locked)
        {
            PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)ContextMenuStrip;

            pbcms.playername = nickname;
            pbcms.seatname   = seat;
            pbcms.tablename  = tableName;

            if (locked)
            {
                foreach (ToolStripMenuItem tsmi in pbcms.Items)
                {
                    if (tsmi.Text.Equals("Lock"))
                    {
                        tsmi.Text = "Unlock";
                    }
                }
            }
        }
Example #8
0
 /// <summary>
 /// Reset PlayerButton context-menu to "text" if ScanButton context-menu "Remove Locks"/"Lock All" has been used before
 /// </summary>
 /// <param name="text"></param>
 public void resetLockToolstrip(String text)
 {
     foreach (PlayerButton b in buttons)
     {
         PlayerButtonContextMenuStrip newPBCMS = (PlayerButtonContextMenuStrip)b.ContextMenuStrip;
         if (newPBCMS == null)
         {
             // Happens with empty seats if there are no buttons created at all but buttons has those positions still in
             continue;
         }
         foreach (ToolStripMenuItem tsmi in newPBCMS.Items)
         {
             if (tsmi.Text.ToLower().Contains("lock"))
             {
                 tsmi.Text = text;
             }
         }
     }
 }
        /// <summary>
        /// Open Note Window on Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PlayerButton_Click(object sender, EventArgs e)
        {
            PlayerButtonContextMenuStrip pbcms = (PlayerButtonContextMenuStrip)this.ContextMenuStrip;

            new FormNoteWindow(pbcms.playername, pbcms.tablename);
        }
Example #10
0
        // Paint every button new from scratch
        private List <PlayerButton> paintButtons(Dictionary <string, PlayerButton> template, TableData tableData, bool force) // force = true enables repainting of buttons which are locked
        {
            foreach (PlayerButton button in buttonTemplate.Values)
            {
                if (!force)                                      // if repainting is not forced, skip locked seats, otherwise force repaint for all buttons (necessary for completely new tables f.e.)
                {
                    if (tableData.isSeatLocked(button.SeatName)) // only (re)paint unlocked seats
                    {
                        continue;
                    }
                }

                string playername = tableData.getNickname(button.SeatName);
                if (playername == null)
                {
                    continue;                                       // skip empty/open seats
                }
                if (GlobalSettings.ButtonSettings.HideEmptyButtons) // Show Empty Buttons? yes/no
                {
                    try
                    {
                        if (playername.Equals(""))
                        {
                            table.removeSeat(button.SeatName);
                            continue;
                        }
                    } catch (Exception ex) { Console.WriteLine("HideEmptyButtons: \n" + ex.ToString()); }
                }

                // Create ContextMenuStrip for playerbutton and initialize with necessary information
                PlayerButtonContextMenuStrip pbcms = new PlayerButtonContextMenuStrip();
                button.ContextMenuStrip = pbcms;
                button.Text             = playername;
                button.BackColor        = System.Drawing.Color.FromName(NoteHandler.getNote(playername).getColor());
                button.SetPlayerNameContextMenu(playername, button.SeatName, tableData.tablename, tableData.isSeatLocked(button.SeatName));
                button.SetParent(tableData.tablePointer);
                button.Visible = true;

                /*
                 * Create ToolTip & NoteIcon if there are notes
                 */
                createToolTipAndNoteIcon(button, playername);

                /*
                 * Check for alternate spellings in playernames ==> Levenshtein!
                 */
                if (tableData.isSeatLocked(button.SeatName))
                {
                    continue;                                                                     // Makes no sense to update this for locked buttons [would popup icon if other player gets renamed]
                }
                if (playername.Length > GlobalSettings.Notes.PlayernameMinLengthForDistanceCheck) // Only check for playernames with 3+ characters
                {
                    List <Note> similarNicks = NoteHandler.findSimilarNicknames(playername, GlobalSettings.Notes.LevenshteinMaxDistance);
                    if (similarNicks.Count > 0) // Players with similar nicks have notes already
                    {
                        setSimilarNickImage(button, similarNicks);
                    }
                }
            }
            return(buttonTemplate.Values.ToList());
        }