示例#1
0
        public SystemTray()
        {
            bool isWin10 = System.Environment.OSVersion.Version.Major.ToString() == "10";

            #region Initialization
            ResourceCulture     resource = new ResourceCulture();
            System.Drawing.Font font     = new System.Drawing.Font("Segoe UI", 9F);
            about = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(about)),
                Font = font
            };
            smallIcon = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(smallIcon)),
                Font = font
            };
            animation = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(animation)),
                Font = font
            };
            auto_size = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(auto_size)),
                Font = font
            };
            auto_display = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(auto_display)),
                Font = font
            };
            exit = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(exit)),
                Font = font
            };
            contextMenuStrip = new ContextMenuStrip
            {
                Renderer = new Win10Renderer()
            };
            if (isWin10)
            {
                transparent = new ToolStripMenuItem
                {
                    Text = resource.GetString(nameof(transparent)),
                    Font = font
                };
                contextMenuStrip.Items.AddRange(new ToolStripItem[]
                {
                    about,
                    smallIcon,
                    animation,
                    transparent,
                    new ToolStripSeparator(),
                    auto_display,
                    auto_size,
                    new ToolStripSeparator(),
                    exit
                });

                timer.Interval = 15;
                timer.Tick    += (s, e) => Transparent();
            }
            else
            {
                contextMenuStrip.Items.AddRange(new ToolStripItem[]
                {
                    about,
                    smallIcon,
                    animation,
                    new ToolStripSeparator(),
                    auto_display,
                    auto_size,
                    new ToolStripSeparator(),
                    exit
                });
            }

            notifyIcon = new NotifyIcon
            {
                ContextMenuStrip = contextMenuStrip,
                Text             = "SmartTaskbar v1.1.8",
                Icon             = isWin10 ? Properties.Resources.logo_32 : Properties.Resources.logo_blue_32,
                Visible          = true
            };
            #endregion

            #region Load Event

            about.Click += (s, e) => System.Diagnostics.Process.Start(@"https://github.com/ChanpleCai/SmartTaskbar/releases");

            Properties.Settings.Default.PropertyChanged += (s, e) => Properties.Settings.Default.Save();

            transparent.Click += (s, e) => transparent.Checked = timer.Enabled = Properties.Settings.Default.Transparent = !transparent.Checked;

            smallIcon.Click += (s, e) =>
            {
                if (smallIcon.Checked)
                {
                    Properties.Settings.Default.IconSize = 0;
                    smallIcon.Checked = false;
                }
                else
                {
                    Properties.Settings.Default.IconSize = 1;
                    smallIcon.Checked = true;
                }
                SetIconSize(Properties.Settings.Default.IconSize);
            };

            animation.Click += (s, e) => animation.Checked = ChangeTaskbarAnimation();

            auto_size.Click += (s, e) =>
            {
                if (auto_size.Checked)
                {
                    switcher.Stop();
                    Properties.Settings.Default.TaskbarState = (int)AutoModeType.none;
                    smallIcon.Enabled = true;
                    auto_size.Checked = false;
                }
                else
                {
                    switcher.Start(AutoModeType.size);
                    Properties.Settings.Default.TaskbarState = (int)AutoModeType.size;
                    auto_size.Checked    = true;
                    auto_display.Checked = smallIcon.Enabled = false;
                }
            };

            auto_display.Click += (s, e) =>
            {
                if (auto_display.Checked)
                {
                    switcher.Stop();
                    Properties.Settings.Default.TaskbarState = (int)AutoModeType.none;
                    auto_display.Checked = false;
                }
                else
                {
                    switcher.Start(AutoModeType.display);
                    Properties.Settings.Default.TaskbarState = (int)AutoModeType.display;
                    auto_display.Checked = true;
                    auto_size.Checked    = false;
                }
                smallIcon.Enabled = true;
            };

            exit.Click += (s, e) =>
            {
                switcher.Stop();
                switcher.Reset();
                notifyIcon.Dispose();
                Application.Exit();
            };

            if (isWin10)
            {
                notifyIcon.MouseClick += (s, e) =>
                {
                    if (e.Button != MouseButtons.Right)
                    {
                        return;
                    }

                    switcher.Resume();

                    animation.Checked = GetTaskbarAnimation();

                    if (smallIcon.Enabled)
                    {
                        SetIconSize(Properties.Settings.Default.IconSize);
                    }

                    UpdataTaskbarHandle();
                };
            }
            else
            {
                notifyIcon.MouseClick += (s, e) =>
                {
                    if (e.Button != MouseButtons.Right)
                    {
                        return;
                    }

                    switcher.Resume();

                    animation.Checked = GetTaskbarAnimation();

                    if (smallIcon.Enabled)
                    {
                        SetIconSize(Properties.Settings.Default.IconSize);
                    }
                };
            }


            notifyIcon.MouseDoubleClick += (s, e) =>
            {
                smallIcon.Enabled = true;
                switcher.ChangeState();
                SetIconSize(Properties.Settings.Default.IconSize);
                auto_size.Checked = auto_display.Checked = false;
            };

            #endregion

            #region Load Settings

            switch ((AutoModeType)Properties.Settings.Default.TaskbarState)
            {
            case AutoModeType.display:
                auto_display.Checked = true;
                break;

            case AutoModeType.size:
                auto_size.Checked = true;
                smallIcon.Enabled = false;
                break;
            }

            if (Properties.Settings.Default.IconSize == 1)
            {
                smallIcon.Checked = true;
            }

            transparent.Checked = timer.Enabled = Properties.Settings.Default.Transparent;
            #endregion
        }
示例#2
0
        public SystemTray()
        {
            #region Load Auto-Mode
            //Turn on Auto-Mode as soon as possible
            if (Properties.Settings.Default.TaskbarState.Equals(nameof(auto)))
            {
                switcher.Start();
            }

            #endregion

            #region Initialization
            ResourceCulture     resource = new ResourceCulture();
            System.Drawing.Font font     = new System.Drawing.Font("Segoe UI", 10F);
            about = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(about)),
                Font = font
            };
            animation = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(animation)),
                Font = font
            };
            auto = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(auto)),
                Name = nameof(auto),
                Font = font
            };
            show = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(show)),
                Name = nameof(show),
                Font = font
            };
            hide = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(hide)),
                Name = nameof(hide),
                Font = font
            };
            exit = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(exit)),
                Font = font
            };
            contextMenuStrip = new ContextMenuStrip
            {
                Renderer = new Win10Renderer()
            };
            contextMenuStrip.Items.AddRange(new ToolStripItem[]
            {
                about,
                animation,
                new ToolStripSeparator(),
                auto,
                show,
                hide,
                new ToolStripSeparator(),
                exit
            });
            notifyIcon = new NotifyIcon
            {
                ContextMenuStrip = contextMenuStrip,
                Text             = "SmartTaskbar v1.1.7",
                Icon             = System.Environment.OSVersion.Version.Major.ToString() == "10" ? Properties.Resources.logo_32 : Properties.Resources.logo_blue_32,
                Visible          = true
            };
            #endregion

            #region Load Event

            about.Click += (s, e) => System.Diagnostics.Process.Start(@"https://github.com/ChanpleCai/SmartTaskbar/releases");

            animation.Click += (s, e) => animation.Checked = switcher.AnimationSwitcher();

            auto.Click += (s, e) =>
            {
                if (auto.Checked)
                {
                    return;
                }
                switcher.Start();
                RadioChecked(ref auto);
            };

            show.Click += (s, e) =>
            {
                if (show.Checked)
                {
                    return;
                }
                switcher.Show();
                RadioChecked(ref show);
            };

            hide.Click += (s, e) =>
            {
                if (hide.Checked)
                {
                    return;
                }
                switcher.Hide();
                RadioChecked(ref hide);
            };

            exit.Click += (s, e) =>
            {
                switcher.Stop();
                notifyIcon.Dispose();
                Application.Exit();
            };

            notifyIcon.MouseClick += (s, e) =>
            {
                if (e.Button != MouseButtons.Right)
                {
                    return;
                }

                switch (Properties.Settings.Default.TaskbarState)
                {
                case "auto":
                    switcher.Resume();
                    break;

                case "hide":
                    if (!switcher.IsHide())
                    {
                        RadioChecked(ref show);
                    }
                    break;

                default:
                    if (switcher.IsHide())
                    {
                        RadioChecked(ref hide);
                    }
                    break;
                }
                animation.Checked = switcher.IsAnimationEnable();
            };

            notifyIcon.MouseDoubleClick += (s, e) =>
            {
                if (switcher.IsHide())
                {
                    switcher.Show();
                    RadioChecked(ref show);
                }
                else
                {
                    switcher.Hide();
                    RadioChecked(ref hide);
                }
            };

            #endregion

            #region Load Check State

            switch (Properties.Settings.Default.TaskbarState)
            {
            case "auto":
                auto.Checked = true;
                break;

            case "hide":
                hide.Checked = true;
                break;

            default:
                show.Checked = true;
                break;
            }

            #endregion
        }
示例#3
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
        }
示例#4
0
        public SystemTray()
        {
            #region Initialization

            var resource = new ResourceCulture();
            var font     = new Font("Segoe UI", 9F);
            about = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(about)),
                Font = font
            };
            smallIcon = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(smallIcon)),
                Font = font
            };
            animation = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(animation)),
                Font = font
            };
            auto_size = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(auto_size)),
                Font = font
            };
            auto_display = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(auto_display)),
                Font = font
            };
            exit = new ToolStripMenuItem
            {
                Text = resource.GetString(nameof(exit)),
                Font = font
            };
            contextMenuStrip = new ContextMenuStrip
            {
                Renderer = new Win10Renderer()
            };

            contextMenuStrip.Items.AddRange(new ToolStripItem[]
            {
                about,
                smallIcon,
                animation,
                new ToolStripSeparator(),
                auto_display,
                auto_size,
                new ToolStripSeparator(),
                exit
            });

            notifyIcon = new NotifyIcon
            {
                ContextMenuStrip = contextMenuStrip,
                Text             = @"SmartTaskbar v1.1.9",
                Icon             = IsWin10 ? Resources.logo_32 : Resources.logo_blue_32,
                Visible          = true
            };

            #endregion

            #region Load Event

            about.Click += (s, e) => Process.Start(@"https://github.com/ChanpleCai/SmartTaskbar/releases");

            Settings.Default.PropertyChanged += (s, e) =>
            {
                Settings.Default.Save();
                switch ((AutoModeType)Settings.Default.TaskbarState)
                {
                case AutoModeType.Display:
                    auto_display.Checked = true;
                    auto_size.Checked    = false;
                    ChangeDisplayState();
                    break;

                case AutoModeType.Size:
                    auto_display.Checked = false;
                    auto_size.Checked    = true;
                    ChangeIconSize();
                    Show();
                    break;

                case AutoModeType.None:
                    auto_display.Checked = auto_size.Checked = false;
                    break;
                }
            };

            smallIcon.Click += (s, e) => SetIconSize(smallIcon.Checked ? BigIcon : SmallIcon);

            animation.Click += (s, e) => animation.Checked = ChangeTaskbarAnimation();

            auto_size.Click += (s, e) => Settings.Default.TaskbarState = auto_size.Checked ? (int)AutoModeType.None : (int)AutoModeType.Size;

            auto_display.Click += (s, e) => Settings.Default.TaskbarState = auto_display.Checked ? (int)AutoModeType.None : (int)AutoModeType.Display;

            exit.Click += (s, e) =>
            {
                notifierLauncher.Dispose();
                Reset();
                notifyIcon.Dispose();
                Application.Exit();
            };

            notifyIcon.MouseClick += (s, e) =>
            {
                if (e.Button != MouseButtons.Right)
                {
                    return;
                }

                notifierLauncher.Resume();

                animation.Checked = GetTaskbarAnimation();

                smallIcon.Checked = GetIconSize() == SmallIcon;
            };

            notifyIcon.MouseDoubleClick += (s, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    return;
                }

                Settings.Default.TaskbarState = (int)AutoModeType.None;
                if (IsHide())
                {
                    Show();
                }
                else
                {
                    Hide();
                }
            };

            #endregion

            #region Load Settings

            if (Settings.Default.TaskbarState == -1)
            {
                //Run the software for the first time
                Settings.Default.TaskbarState = (int)AutoModeType.Display;
            }
            else
            {
                switch ((AutoModeType)Settings.Default.TaskbarState)
                {
                case AutoModeType.Display:
                    auto_display.Checked = true;
                    auto_size.Checked    = false;
                    break;

                case AutoModeType.Size:
                    auto_display.Checked = false;
                    auto_size.Checked    = true;
                    break;

                case AutoModeType.None:
                    auto_display.Checked = auto_size.Checked = false;
                    break;
                }
                Reset();
            }

            #endregion
        }