Пример #1
0
        /// <summary>
        /// Initializes the taskbar icon and registers a message listener
        /// in order to receive events from the taskbar area.
        /// </summary>
        public TaskBarIcon(Icon icon)
        {
            Icon = icon;

            // using dummy sink in design mode
            messageSink = new WindowMessageSink(NotifyIconVersion.Vista);

            // init icon data structure
            iconData             = NotifyIconData.CreateDefault(messageSink.MessageWindowHandle);
            iconData.IconHandle  = Icon?.Handle ?? IntPtr.Zero;
            iconData.ToolTipText = nameof(MangaReader);

            // create the taskbar icon
            CreateTaskbarIcon();

            // register event listeners
            messageSink.MouseEventReceived += OnMouseEvent;
            messageSink.TaskbarCreated     += OnTaskbarCreated;

            // register listener in order to get notified when the application closes
            if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime)
            {
                lifetime.Exit += OnExit;
            }
        }
Пример #2
0
        /// <summary>
        /// Inits the taskbar icon and registers a message listener
        /// in order to receive events from the taskbar area.
        /// </summary>
        public TaskbarIcon()
        {
            //using dummy sink in design mode
            this.messageSink = Util.IsDesignMode
                ? WindowMessageSink.CreateEmpty()
                : new WindowMessageSink(NotifyIconVersion.Vista);

            //init icon data structure
            this.iconData = NotifyIconData.CreateDefault(this.messageSink.MessageWindowHandle);

            //create the taskbar icon
            this.CreateTaskbarIcon();

            // register event listeners
            this.messageSink.MouseEventReceived        += this.OnMouseEvent;
            this.messageSink.TaskbarCreated            += this.OnTaskbarCreated;
            this.messageSink.ChangeToolTipStateRequest += this.OnToolTipChange;
            this.messageSink.BalloonToolTipChanged     += this.OnBalloonToolTipChanged;

            //init single click / balloon timers
            this.singleClickTimer  = new Timer(DoSingleClickAction);
            this.balloonCloseTimer = new Timer(CloseBalloonCallback);

            // register listener in order to get notified when the application closes
            if (Application.Current != null)
            {
                Application.Current.Exit += this.OnExit;
            }
        }
Пример #3
0
        public TaskbarIcon(IAppInfo appInfo, IHiddenWindowMessages messages)
        {
            lockObject = new object();

            taskbarRestartedMessageId = WinApi.RegisterWindowMessage("TaskbarCreated");

            messages.AddHook(WindowProc);
            messages.Disposed += Messages_Disposed;

            iconData = NotifyIconData.CreateDefault(messages.Handle);

            iconData.IconHandle = appInfo.Icon.Handle;

            Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Icon);

            // create the taskbar icon
            Show();
        }