Ejemplo n.º 1
0
        private static void HideBar()
        {
            if (Fun.IsNotAutoHide())
            {
                return;
            }

            var taskbar = TaskbarHelper.InitTaskbar();

            if (taskbar.Handle != IntPtr.Zero)
            {
                taskbar.HideTaskbar();
            }
        }
Ejemplo n.º 2
0
        private static void Timer_Tick(object sender, EventArgs e)
        {
            if (UserSettings.AutoModeType != AutoModeType.Auto)
            {
                return;
            }

            // get taskbar every 1.25 second.
            if (_timerCount % 5 == 0)
            {
                // Make sure the taskbar has been automatically hidden, otherwise it will not work
                Fun.SetAutoHide();

                _taskbar = TaskbarHelper.InitTaskbar();

                // Some users will kill the explorer.exe under certain situation.
                // In this case, the taskbar cannot be found, just return and wait for the user to reopen the file explorer.
                if (_taskbar.Handle == IntPtr.Zero)
                {
                    Hooker.ReleaseHook();
                    return;
                }

                Hooker.SetHook(_taskbar.Handle);
            }

            switch (_taskbar.CheckIfMouseOver(NonMouseOverShowHandleSet))
            {
            case TaskbarBehavior.DoNothing:
                break;

            case TaskbarBehavior.Pending:
                if (UserSettings.ReduceTaskbarDisplay)
                {
                    CheckCurrentWindowReduceShowBar();
                }
                else
                {
                    CheckCurrentWindow();
                }

                break;

            case TaskbarBehavior.Show:
                    #if DEBUG
                Debug.WriteLine("Show the tasbkar because of Mouse Over.");
                    #endif

                _taskbar.ShowTaskar();
                break;
            }

            ++_timerCount;

            // clear cache and reset stable every 15 min.
            if (_timerCount <= 7200)
            {
                return;
            }

            _timerCount = 0;

            DesktopHandleSet.Clear();
            NonMouseOverShowHandleSet.Clear();
            NonDesktopShowHandleSet.Clear();
            NonForegroundShowHandleSet.Clear();
            Hooker.ResetHook();
        }
Ejemplo n.º 3
0
        private void ShowMenu()
        {
            var taskbar = TaskbarHelper.InitTaskbar();

            if (taskbar.Handle == IntPtr.Zero)
            {
                return;
            }

            switch (taskbar.Position)
            {
            case TaskbarPosition.Bottom:
                if (Cursor.Position.X + _contextMenuStrip.Width > Screen.PrimaryScreen.Bounds.Right)
                {
                    _contextMenuStrip.Show(
                        Screen.PrimaryScreen.Bounds.Right - _contextMenuStrip.Width - TrayTolerance,
                        taskbar.Rect.top - _contextMenuStrip.Height - TrayTolerance);
                }
                else
                {
                    _contextMenuStrip.Show(Cursor.Position.X - TrayTolerance,
                                           taskbar.Rect.top - _contextMenuStrip.Height - TrayTolerance);
                }
                break;

            case TaskbarPosition.Left:
                if (Cursor.Position.Y + _contextMenuStrip.Height > Screen.PrimaryScreen.Bounds.Bottom)
                {
                    _contextMenuStrip.Show(taskbar.Rect.right + TrayTolerance,
                                           Screen.PrimaryScreen.Bounds.Bottom
                                           - _contextMenuStrip.Height
                                           - TrayTolerance);
                }
                else
                {
                    _contextMenuStrip.Show(taskbar.Rect.right + TrayTolerance,
                                           Cursor.Position.Y - TrayTolerance);
                }
                break;

            case TaskbarPosition.Right:
                if (Cursor.Position.Y + _contextMenuStrip.Height > Screen.PrimaryScreen.Bounds.Bottom)
                {
                    _contextMenuStrip.Show(taskbar.Rect.left - TrayTolerance - _contextMenuStrip.Width,
                                           Screen.PrimaryScreen.Bounds.Bottom
                                           - _contextMenuStrip.Height
                                           - TrayTolerance);
                }
                else
                {
                    _contextMenuStrip.Show(taskbar.Rect.left - TrayTolerance - _contextMenuStrip.Width,
                                           Cursor.Position.Y - TrayTolerance);
                }
                break;

            case TaskbarPosition.Top:
                if (Cursor.Position.X + _contextMenuStrip.Width > Screen.PrimaryScreen.Bounds.Right)
                {
                    _contextMenuStrip.Show(
                        Screen.PrimaryScreen.Bounds.Right - _contextMenuStrip.Width - TrayTolerance,
                        taskbar.Rect.bottom + TrayTolerance);
                }
                else
                {
                    _contextMenuStrip.Show(Cursor.Position.X - TrayTolerance,
                                           taskbar.Rect.bottom + TrayTolerance);
                }
                break;
            }
        }