Exemple #1
0
        /// <summary>
        /// Implementing the Tooltip-Workaround found on StackOverflow
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_MouseHover(object sender, EventArgs e)
        {
            /*
             * Workaround found on StackOverflow since Button Tooltips are (still) buggy
             */
            Button button  = (Button)sender;
            string display = NoteHandler.getNote(button.Text).Text;
            Label  dummy   = (Label)button.Controls[0];

            tip.Show(display, dummy);
            tip.AutoPopDelay   = 0;
            tip.AutomaticDelay = 0;
            tip.ShowAlways     = true;
        }
        /// <summary>
        /// Only one notewindow per player should be opened, set to foreground if double open
        /// !!! Bug: Seems like western nicknames work fine but chinese dont !!!+
        ///
        /// Will get called from PlayerButton.Click
        ///
        /// </summary>
        /// <param name="playername"></param>
        /// <param name="tablename"></param>
        public FormNoteWindow(string playername, string tablename)
        {
            // Retrieve List of instances with the regex set to the playername
            EmulatorHandler doubleCheck = new EmulatorHandler(playername);
            List <IntPtr>   doubleList  = doubleCheck.getEmulatorList();

            if (doubleList.Count == 0) // No window for the same player found
            {
                // Create new NoteWindow
                initComponents();
                //Console.WriteLine("FormNoteWindow from PlayerButton.Click");  // Debug

                // Set Note from Loaded Notes
                this.note = NoteHandler.getNote(playername);

                table = tablename;

                // Check if note exists, if not: construct new from tabledata
                if (note.Name == null)
                {
                    constructNewNote(playername, tablename);
                }
                else
                {
                    loadValuesFromNote();
                }

                // Set Location of the Form within table boundaries and not somewhere else on the screen
                setAppearanceLocation(tablename);
                this.Show();
            }
            else   // Already one open => Set to foreground!
            {
                WinAPI.SetForegroundWindow(doubleList[0]);
            }
        }
Exemple #3
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());
        }