public DefaultTaskbarWindowService(IAppSettings settings)
        {
            _hookInstance = this;

            Settings        = settings;
            ActivePlacement = settings.Placement;

            // install a win event hook to track taskbar resize/movement
            hookDelegate = new WinEventHook.WinEventDelegate(WinEventProc);
            var winHook = WinEventHook.SetHook(WinEventHook.EVENT_OBJECT_LOCATIONCHANGE, hookDelegate);

            Application.ApplicationExit += (s, e) =>
            {
                if (winHook != IntPtr.Zero)
                {
                    WinEventHook.RemoveHook(winHook);
                    winHook = IntPtr.Zero;

                    foreach (var f in GetWindows())
                    {
                        f.Close();
                        f.RestoreTaskbar();
                    }
                }
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new taskbar window and adds it to the given taskbar
        /// </summary>
        /// <param name="targetTaskbar">The taskbar to add this window to</param>
        public TaskbarWindow(TaskbarRef targetTaskbar, TaskbarWindowPlacement placement, ITaskbarComponent component)
        {
            if (targetTaskbar == null)
            {
                throw new ArgumentNullException("targetTaskbar");
            }
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            Taskbar          = targetTaskbar;
            TaskbarComponent = component;
            Placement        = placement;

            TargetSize = TaskbarComponent.PreferredSize;

            FormBorderStyle = FormBorderStyle.None;

            // fix flickering
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);

            // since the window is a child of the taskbar, its
            // background becomes transparent automatically
            BackColor = Color.Black;

            // when the taskbar position or size changes
            // update this window's position/size accordingly
            Taskbar.PositionOrSizeChanged += Taskbar_PositionOrSizeChanged;

            // wire up component events
            component.RefreshRequested += Component_RefreshRequested;
        }
Ejemplo n.º 3
0
        public static string GetDisplayText(this TaskbarWindowPlacement p)
        {
            switch (p)
            {
            case TaskbarWindowPlacement.RightOfTaskButtons: return("Left of taskbar notifications icons");

            case TaskbarWindowPlacement.BetweenTrayAndClock: return("Between taskbar notification icons and clock");

            case TaskbarWindowPlacement.EndOfTaskbar: return("At the end of the task bar");

            default: return(p.ToString());
            }
        }
        public void RecreateAll()
        {
            taskbars = TaskbarUtils.ListTaskbars().ToList();

            ActivePlacement = Settings.Placement;

            // recreate all windows
            foreach (var w in windows)
            {
                w.RestoreTaskbar();
                w.Close();
            }

            windows.Clear();

            // add the component to each taskbar (primary and secondary)
            foreach (var taskbar in taskbars)
            {
                var f = new WeekWindow(taskbar, Settings, DialogService);
                f.Show();

                Register(f);
            }
        }