예제 #1
0
        public void Handle(PapercutClientReadyEvent message)
        {
            if (_notification != null)
            {
                return;
            }

            // Set up the notification icon
            _notification = new NotifyIcon
            {
                Icon    = new Icon(_resourceLocator.GetResource("App.ico").Stream),
                Text    = "Papercut",
                Visible = true
            };

            _notification.Click +=
                (sender, args) => _publishEvent.Publish(new ShowMainWindowEvent());

            _notification.BalloonTipClicked +=
                (sender, args) =>
                _publishEvent.Publish(new ShowMainWindowEvent {
                SelectMostRecentMessage = true
            });

            var options = new MenuItem(
                "Options",
                (sender, args) => _publishEvent.Publish(new ShowOptionWindowEvent()))
            {
                DefaultItem = false,
            };

            var menuItems = new[]
            {
                new MenuItem(
                    "Show",
                    (sender, args) => _publishEvent.Publish(new ShowMainWindowEvent()))
                {
                    DefaultItem = true
                },
                options,
                new MenuItem(
                    "Exit",
                    (sender, args) => _publishEvent.Publish(new AppForceShutdownEvent()))
            };

            _notification.ContextMenu = new ContextMenu(menuItems);
        }
예제 #2
0
        void SetupNotification()
        {
            // Set up the notification icon
            _notification = new NotifyIcon
            {
                Icon    = new Icon(_resourceLocator.GetResource("App.ico").Stream),
                Text    = AppConstants.ApplicationName,
                Visible = true
            };

            _notification.Click +=
                (sender, args) => this._messageBus.Publish(new ShowMainWindowEvent());

            _notification.BalloonTipClicked +=
                (sender, args) =>
                this._messageBus.Publish(new ShowMainWindowEvent {
                SelectMostRecentMessage = true
            });

            var options = new MenuItem(
                "Options",
                (sender, args) => this._messageBus.Publish(new ShowOptionWindowEvent()))
            {
                DefaultItem = false,
            };

            var menuItems = new[]
            {
                new MenuItem(
                    "Show",
                    (sender, args) => this._messageBus.Publish(new ShowMainWindowEvent()))
                {
                    DefaultItem = true
                },
                options,
                new MenuItem(
                    "Exit",
                    (sender, args) => this._messageBus.Publish(new AppForceShutdownEvent()))
            };

            _notification.ContextMenu = new ContextMenu(menuItems);
        }