Exemplo n.º 1
0
        public void SerialCreateDestroy()
        {
            using (NotificationAreaIcon notificationAreaIcon1 = new NotificationAreaIcon(Guid.NewGuid()))
            {
                Icon icon1 = new Icon(TEST_ICON);
                notificationAreaIcon1.Icon    = icon1.Handle;
                notificationAreaIcon1.ToolTip = $"This is test #1";
                notificationAreaIcon1.ShowIcon();

                using (NotificationAreaIcon notificationAreaIcon2 = new NotificationAreaIcon(Guid.NewGuid()))
                {
                    Icon icon2 = new Icon(TEST_ICON);
                    notificationAreaIcon1.Icon    = icon2.Handle;
                    notificationAreaIcon1.ToolTip = $"This is test #2";
                    notificationAreaIcon1.ShowIcon();

                    using (NotificationAreaIcon notificationAreaIcon3 = new NotificationAreaIcon(Guid.NewGuid()))
                    {
                        Icon icon3 = new Icon(TEST_ICON);
                        notificationAreaIcon1.Icon    = icon3.Handle;
                        notificationAreaIcon1.ToolTip = $"This is test #2";
                        notificationAreaIcon1.ShowIcon();
                        Thread.Sleep(500);
                    }
                    Thread.Sleep(500);
                }
                Thread.Sleep(500);
            }
        }
Exemplo n.º 2
0
        public void ParallelCreateDestroy()
        {
            int runCount = 100;

            Parallel.For(0, runCount, run =>
            {
                using (NotificationAreaIcon notificationAreaIcon = new NotificationAreaIcon(Guid.NewGuid()))
                {
                    Icon icon = new Icon(TEST_ICON);
                    notificationAreaIcon.Icon    = icon.Handle;
                    notificationAreaIcon.ToolTip = $"This is test #{run}";
                    notificationAreaIcon.ShowIcon();
                    Thread.Sleep(500);
                }
            });
        }
Exemplo n.º 3
0
        public void IconProperty()
        {
            using (NotificationAreaIcon notificationAreaIcon = new NotificationAreaIcon(Guid.NewGuid()))
            {
                Icon icon = new Icon(TEST_ICON);
                notificationAreaIcon.Icon    = icon.Handle;
                notificationAreaIcon.ToolTip = $"This is test";
                notificationAreaIcon.ShowIcon();
                Thread.Sleep(500);

                notificationAreaIcon.Icon = null;
                Thread.Sleep(500);

                icon = new Icon(TEST_ICON);
                notificationAreaIcon.Icon = null;
                Thread.Sleep(500);
            }
        }
Exemplo n.º 4
0
        public void ToolTipProperty()
        {
            using (NotificationAreaIcon notificationAreaIcon = new NotificationAreaIcon(Guid.NewGuid()))
            {
                Icon icon = new Icon(TEST_ICON);
                notificationAreaIcon.Icon    = icon.Handle;
                notificationAreaIcon.ToolTip = $"This is short tooltip";
                notificationAreaIcon.ShowIcon();
                Thread.Sleep(500);

                notificationAreaIcon.ToolTip = null;
                Thread.Sleep(500);

                notificationAreaIcon.ToolTip = String.Empty;
                Thread.Sleep(500);

                notificationAreaIcon.ToolTip = "This is a really long\nmulti-line tool-tip that is tool long to fit the tool tip property\n. This should be truncated and not cause an error.";
                Thread.Sleep(500);
            }
        }
Exemplo n.º 5
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            // Try to convert the Uid to a GUID, or create a new guid
            if (!Guid.TryParse(this.Uid, out _itemGuid))
            {
                _itemGuid = Guid.NewGuid();
            }

            // Create the Win32 Notification Area Icon
            _notifyIcon = new NotificationAreaIcon(_itemGuid)
            {
                ToolTip = this.ToolTip?.ToString(),
                Icon    = this._icon?.Handle
            };
            _notifyIcon.NotificationIconEventHandler += OnNotificationIconEvent;

            // Show the icon
            _notifyIcon.ShowIcon();
        }