/// <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"); } } } }
/// <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(); } } }
/// <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 }
/// <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); }
/// <summary> /// Set LockImage for single seat /// </summary> /// <param name="seatName"></param> /// <param name="tablePointer"></param> public void setLockImage(string seatName, IntPtr tablePointer) { foreach (PlayerButton b in buttons) { if (b.SeatName.Equals(seatName)) { 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(tablePointer); break; } } }