Пример #1
0
        public void GetIconForUnknownReturnsDifferentIconForDifferentColors()
        {
            using DynamicIcons icons = new DynamicIcons();
            Icon icon1 = icons.GetIconForUnknown(FG, BG);
            Icon icon2 = icons.GetIconForUnknown(Color.Black, Color.White);

            Assert.AreNotSame(icon1, icon2);
        }
Пример #2
0
        public void GetIconForUnknownReturnsSameIconForSameColors()
        {
            using DynamicIcons icons = new DynamicIcons();
            Icon icon1 = icons.GetIconForUnknown(FG, BG);
            Icon icon2 = icons.GetIconForUnknown(FG, BG);

            Assert.AreSame(icon1, icon2);
        }
Пример #3
0
        public void ResetClearsInternalCacheOfPreviouslyRenderedIcons()
        {
            using DynamicIcons icons = new DynamicIcons();
            Icon unknownIcon1 = icons.GetIconForUnknown(FG, BG);
            Icon numberIcon1  = icons.GetIconForNumber(42, FG, BG);

            icons.Reset();

            Icon unknownIcon2 = icons.GetIconForUnknown(FG, BG);
            Icon numberIcon2  = icons.GetIconForNumber(42, FG, BG);

            Assert.AreNotSame(unknownIcon1, unknownIcon2);
            Assert.AreNotSame(numberIcon1, numberIcon2);
        }
Пример #4
0
        public void GetIconForUnknownReturnsIconShowingSingleX()
        {
            using DynamicIcons icons = new DynamicIcons();
            Icon icon = icons.GetIconForUnknown(FG, BG);

            Assert.AreEqual(16, icon.Width);
            Assert.AreEqual(16, icon.Height);
            AssertIconHasPixels(new ushort[16]
            {
                0x0000, 0x0420, 0x0420, 0x0240, 0x0240, 0x0180, 0x0180, 0x0180,
                0x0180, 0x0180, 0x0240, 0x0240, 0x0420, 0x0420, 0x0000, 0x0000
            },
                                icon);
        }
Пример #5
0
        private void UpdateSystemTrayIcon(int players, int maxPlayers)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(delegate { UpdateSystemTrayIcon(players, maxPlayers); }));
            }
            else
            {
                Color foreground = settings.TrayIconForeground;
                Color background = settings.TrayIconBackground;
                if (ShouldNotify(players))
                {
                    logger.Debug("Playing beep sound because player count crossed threshold");
                    SystemSounds.Beep.Play();
                }

                if (CrossedThreshold(players))
                {
                    foreground = settings.TrayIconAlertForeground;
                    background = settings.TrayIconAlertBackground;
                }

                lastIconUpdatePlayers    = players;
                lastIconUpdateMaxPlayers = maxPlayers;

                this.miniLabel.ForeColor = foreground;
                this.miniLabel.BackColor = background;

                if (players >= 0)
                {
                    UpdateSystemTrayIcon(
                        dynamicIcons.GetIconForNumber((uint)players, foreground, background),
                        $"{players}/{maxPlayers}");
                    this.miniLabel.Text = players.ToString();
                }
                else
                {
                    UpdateSystemTrayIcon(
                        dynamicIcons.GetIconForUnknown(foreground, background), "?");
                    this.miniLabel.Text = "X";
                }
            }
        }