Esempio n. 1
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();
        }
Esempio n. 2
0
        public SystemTray()
        {
            _engine = new Engine(_container);

            #region Initialization

            var resource = new ResourceCulture();
            var font     = new Font("Segoe UI", 10.5F);
            _about = new ToolStripMenuItem
            {
                Text = resource.GetString(LangName.About),
                Font = font
            };
            _animation = new ToolStripMenuItem
            {
                Text = resource.GetString(LangName.Animation),
                Font = font
            };
            _reduceTaskbarDisplay = new ToolStripMenuItem
            {
                Text = resource.GetString(LangName.ReduceTaskbarDisplay),
                Font = font
            };
            _autoMode = new ToolStripMenuItem
            {
                Text = resource.GetString(LangName.Auto),
                Font = font
            };
            _showTaskbarWhenExit = new ToolStripMenuItem
            {
                Text = resource.GetString(LangName.ShowBarOnExit),
                Font = font
            };
            _exit = new ToolStripMenuItem
            {
                Text = resource.GetString(LangName.Exit),
                Font = font
            };
            _contextMenuStrip = new ContextMenuStrip
            {
                Renderer = new Win10Renderer()
            };

            _contextMenuStrip.Items.AddRange(new ToolStripItem[]
            {
                _about,
                _animation,
                new ToolStripSeparator(),
                _reduceTaskbarDisplay,
                _autoMode,
                new ToolStripSeparator(),
                _showTaskbarWhenExit,
                _exit
            });

            _notifyIcon = new NotifyIcon(_container)
            {
                Text    = @"SmartTaskbar v1.4.5",
                Icon    = Fun.IsLightTheme() ? Resources.Logo_Black : Resources.Logo_White,
                Visible = true
            };

            #endregion

            #region Load Event

            _about.Click += AboutOnClick;

            _animation.Click += AnimationOnClick;

            _reduceTaskbarDisplay.Click += ReduceTaskbarDisplayOnClick;

            _autoMode.Click += AutoModeOnClick;

            _showTaskbarWhenExit.Click += ShowTaskbarWhenExitOnClick;

            _exit.Click += ExitOnClick;

            _notifyIcon.MouseClick += NotifyIconOnMouseClick;

            _notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick;

            Fun.UiSettings.ColorValuesChanged += UISettingsOnColorValuesChanged;

            #endregion
        }
Esempio n. 3
0
 private void AnimationOnClick(object s, EventArgs e)
 => _animation.Checked = Fun.ChangeTaskbarAnimation();
Esempio n. 4
0
 private void UISettingsOnColorValuesChanged(UISettings sender, object args)
 => _notifyIcon.Icon = Fun.IsLightTheme() ? Resources.Logo_Black : Resources.Logo_White;