Example #1
0
        private static void Main()
        {
            // Use a mutex to ensure single instance
            using (new Mutex(true, "{959d3545-aa5c-42a8-a327-6e2c079daa94}", out var createNew))
            {
                if (createNew)
                {
                    // Start a tray instead of a WinForm to reduce memory usage
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    var main = new MainController();
                    Application.AddMessageFilter(new MsgFilter(main));
                    Application.Run(main);
                }

                // Show the settings window if an instance already exists
                var process = Process.GetProcessesByName(Application.ProductName)
                              .FirstOrDefault(_ => _.Threads[0].Id != Process.GetCurrentProcess().Threads[0].Id);
                if (process is null)
                {
                    return;
                }

                InvokeMethods.BringOutSettingsWindow(process.Threads[0].Id);
            }
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            var isLight = InvokeMethods.IsLightTheme();

            ForeColor = ForeColor = isLight ? Color.Black : Color.White;
            FlatAppearance.MouseOverBackColor     =
                FlatAppearance.MouseDownBackColor = isLight ? Color.White : Color.FromArgb(65, 65, 65);
        }
Example #3
0
        private void SetAutoModeTypeIcon()
        {
            var islight = InvokeMethods.IsLightTheme();

            switch (_coreInvoker.UserSettings.ModeType)
            {
            case AutoModeType.Disable:
                stopButton.Image            = islight ? Resources.Pause_Black : Resources.Pause_White;
                WhitelistButton.Image       =
                    BlacklistButton.Image   =
                        foreButton.Image    =
                            apiButton.Image =
                                Resources.Empty;
                break;

            case AutoModeType.AutoHideApiMode:
                apiButton.Image              = islight ? Resources.Run_Black : Resources.Run_White;
                WhitelistButton.Image        =
                    BlacklistButton.Image    =
                        foreButton.Image     =
                            stopButton.Image =
                                Resources.Empty;
                break;

            case AutoModeType.ForegroundMode:
                foreButton.Image             = islight ? Resources.Run_Black : Resources.Run_White;
                WhitelistButton.Image        =
                    BlacklistButton.Image    =
                        apiButton.Image      =
                            stopButton.Image =
                                Resources.Empty;
                break;

            case AutoModeType.BlacklistMode:
                BlacklistButton.Image        = islight ? Resources.Run_Black : Resources.Run_White;
                WhitelistButton.Image        =
                    apiButton.Image          =
                        foreButton.Image     =
                            stopButton.Image =
                                Resources.Empty;
                break;

            case AutoModeType.WhitelistMode:
                WhitelistButton.Image        = islight ? Resources.Run_Black : Resources.Run_White;
                apiButton.Image              =
                    BlacklistButton.Image    =
                        foreButton.Image     =
                            stopButton.Image =
                                Resources.Empty;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #4
0
        private void ChangeTheme()
        {
            var islight = InvokeMethods.IsLightTheme();

            BackColor = islight ? ViewColor.DarkBackColor : ViewColor.LightBackColor;
            ForeColor = islight ? Color.Black : Color.White;

            settingsButton.Image = islight ? Resources.Setting_Black : Resources.Setting_White;

            SetAutoModeTypeIcon();
        }
Example #5
0
        private void ChangeTheme()
        {
            Icon = _coreInvoker.GetIcon();

            var islight = InvokeMethods.IsLightTheme();

            BackColor = islight ? Color.FromArgb(238, 238, 238) : Color.FromArgb(43, 43, 43);
            ForeColor = islight ? Color.Black : Color.White;

            // todo
        }
Example #6
0
        private void ChangeTheme()
        {
            var islight = InvokeMethods.IsLightTheme();

            BackColor = islight ? Color.FromArgb(238, 238, 238) : Color.FromArgb(43, 43, 43);
            ForeColor = islight ? Color.Black : Color.White;

            settingsButton.Image = islight ? Resources.Setting_Black : Resources.Setting_White;

            SetAutoModeTypeIcon();
        }
        public bool TryConvert(object from, Type toType, object conversionHint, out object result)
        {
            if (from is IconStyle style)
            {
                switch (style)
                {
                case IconStyle.Black:
                    result = Resources.Logo_Black;
                    return(true);

                case IconStyle.Blue:
                    result = Resources.Logo_Blue;
                    return(true);

                case IconStyle.Pink:
                    result = Resources.Logo_Pink;
                    return(true);

                case IconStyle.White:
                    result = Resources.Logo_White;
                    return(true);

                case IconStyle.Auto:
                    result = InvokeMethods.IsLightTheme()
                            ? Resources.Logo_Black
                            : Resources.Logo_White;
                    return(true);

                default:
                    result = Resources.Logo_Blue;
                    return(false);
                }
            }

            result = Resources.Logo_Blue;
            return(false);
        }
        private void LoadEvent()
        {
            checkBoxIsAutoHide0.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.ResetState.IsAutoHide == checkBoxIsAutoHide0.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.ResetState.IsAutoHide = checkBoxIsAutoHide0.Checked;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxIsAutoHide1.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.ReadyState.IsAutoHide == checkBoxIsAutoHide1.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.ReadyState.IsAutoHide = checkBoxIsAutoHide1.Checked;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxIsAutoHide2.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.TargetState.IsAutoHide == checkBoxIsAutoHide2.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.TargetState.IsAutoHide = checkBoxIsAutoHide2.Checked;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxHideTaskbar0.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.ResetState.HideTaskbarCompletely == checkBoxHideTaskbar0.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.ResetState.HideTaskbarCompletely = checkBoxHideTaskbar0.Checked;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxHideTaskbar1.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.ReadyState.HideTaskbarCompletely == checkBoxHideTaskbar1.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.ReadyState.HideTaskbarCompletely = checkBoxHideTaskbar1.Checked;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxHideTaskbar2.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.TargetState.HideTaskbarCompletely == checkBoxHideTaskbar2.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.TargetState.HideTaskbarCompletely = checkBoxHideTaskbar2.Checked;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxIconSize0.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.ResetState.IconSize == Constant.IconSmall ==
                    checkBoxIconSize0.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.ResetState.IconSize =
                    checkBoxIconSize0.Checked ? Constant.IconSmall : Constant.IconLarge;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxIconSize1.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.ReadyState.IconSize == Constant.IconSmall ==
                    checkBoxIconSize1.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.ReadyState.IconSize =
                    checkBoxIconSize1.Checked ? Constant.IconSmall : Constant.IconLarge;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxIconSize2.CheckedChanged += (s, e) =>
            {
                if (_coreInvoker.UserSettings.TargetState.IconSize == Constant.IconSmall ==
                    checkBoxIconSize2.Checked)
                {
                    return;
                }

                _coreInvoker.UserSettings.TargetState.IconSize =
                    checkBoxIconSize2.Checked ? Constant.IconSmall : Constant.IconLarge;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonDisable0.CheckedChanged += (s, e) =>
            {
                if (!radioButtonDisable0.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.ResetState.TransparentMode == TransparentModeType.Disable)
                {
                    return;
                }

                _coreInvoker.UserSettings.ResetState.TransparentMode = TransparentModeType.Disable;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonDisable1.CheckedChanged += (s, e) =>
            {
                if (!radioButtonDisable1.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.ReadyState.TransparentMode == TransparentModeType.Disable)
                {
                    return;
                }

                _coreInvoker.UserSettings.ReadyState.TransparentMode = TransparentModeType.Disable;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonDisable2.CheckedChanged += (s, e) =>
            {
                if (!radioButtonDisable2.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.TargetState.TransparentMode == TransparentModeType.Disable)
                {
                    return;
                }

                _coreInvoker.UserSettings.TargetState.TransparentMode = TransparentModeType.Disable;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonTransparent0.CheckedChanged += (s, e) =>
            {
                if (!radioButtonTransparent0.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.ResetState.TransparentMode == TransparentModeType.Transparent)
                {
                    return;
                }

                _coreInvoker.UserSettings.ResetState.TransparentMode = TransparentModeType.Transparent;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonTransparent1.CheckedChanged += (s, e) =>
            {
                if (!radioButtonTransparent1.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.ReadyState.TransparentMode == TransparentModeType.Transparent)
                {
                    return;
                }

                _coreInvoker.UserSettings.ReadyState.TransparentMode = TransparentModeType.Transparent;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonTransparent2.CheckedChanged += (s, e) =>
            {
                if (!radioButtonTransparent2.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.TargetState.TransparentMode == TransparentModeType.Transparent)
                {
                    return;
                }

                _coreInvoker.UserSettings.TargetState.TransparentMode = TransparentModeType.Transparent;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonBlur0.CheckedChanged += (s, e) =>
            {
                if (!radioButtonBlur0.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.ResetState.TransparentMode == TransparentModeType.Blur)
                {
                    return;
                }

                _coreInvoker.UserSettings.ResetState.TransparentMode = TransparentModeType.Blur;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonBlur1.CheckedChanged += (s, e) =>
            {
                if (!radioButtonBlur1.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.ReadyState.TransparentMode == TransparentModeType.Blur)
                {
                    return;
                }

                _coreInvoker.UserSettings.ReadyState.TransparentMode = TransparentModeType.Blur;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            radioButtonBlur2.CheckedChanged += (s, e) =>
            {
                if (!radioButtonBlur2.Checked)
                {
                    return;
                }

                if (_coreInvoker.UserSettings.TargetState.TransparentMode == TransparentModeType.Blur)
                {
                    return;
                }

                _coreInvoker.UserSettings.TargetState.TransparentMode = TransparentModeType.Blur;
                _coreInvoker.SaveUserSettings();
                _coreInvoker.ModeSwitch.LoadSetting();
            };

            checkBoxTaskbarAnimation.CheckStateChanged += (s, e) =>
            {
                if (checkBoxTaskbarAnimation.Checked == InvokeMethods.GetTaskbarAnimation())
                {
                    return;
                }

                InvokeMethods.ChangeTaskbarAnimation();
            };
        }
        private void LoadSettings()
        {
            checkBoxIsAutoHide0.Checked  = _coreInvoker.UserSettings.ResetState.IsAutoHide;
            checkBoxHideTaskbar0.Checked = _coreInvoker.UserSettings.ResetState.HideTaskbarCompletely;
            checkBoxIconSize0.Checked    = _coreInvoker.UserSettings.ResetState.IconSize == Constant.IconSmall;

            switch (_coreInvoker.UserSettings.ResetState.TransparentMode)
            {
            case TransparentModeType.Disable:
                radioButtonDisable0.Checked = true;
                break;

            case TransparentModeType.Transparent:
                radioButtonTransparent0.Checked = true;
                break;

            case TransparentModeType.Blur:
                radioButtonBlur0.Checked = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }


            checkBoxIsAutoHide1.Checked  = _coreInvoker.UserSettings.ReadyState.IsAutoHide;
            checkBoxHideTaskbar1.Checked = _coreInvoker.UserSettings.ReadyState.HideTaskbarCompletely;
            checkBoxIconSize1.Checked    = _coreInvoker.UserSettings.ReadyState.IconSize == Constant.IconSmall;

            switch (_coreInvoker.UserSettings.ReadyState.TransparentMode)
            {
            case TransparentModeType.Disable:
                radioButtonDisable1.Checked = true;
                break;

            case TransparentModeType.Transparent:
                radioButtonTransparent1.Checked = true;
                break;

            case TransparentModeType.Blur:
                radioButtonBlur1.Checked = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            checkBoxIsAutoHide2.Checked  = _coreInvoker.UserSettings.TargetState.IsAutoHide;
            checkBoxHideTaskbar2.Checked = _coreInvoker.UserSettings.TargetState.HideTaskbarCompletely;
            checkBoxIconSize2.Checked    = _coreInvoker.UserSettings.TargetState.IconSize == Constant.IconSmall;

            switch (_coreInvoker.UserSettings.TargetState.TransparentMode)
            {
            case TransparentModeType.Disable:
                radioButtonDisable2.Checked = true;
                break;

            case TransparentModeType.Transparent:
                radioButtonTransparent2.Checked = true;
                break;

            case TransparentModeType.Blur:
                radioButtonBlur2.Checked = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            checkBoxTaskbarAnimation.Checked = InvokeMethods.GetTaskbarAnimation();
        }
Example #10
0
 public void SaveUserSettings()
 {
     InvokeMethods.SaveUserSettings(UserSettings);
     _cultureResource.LanguageChange();
 }
Example #11
0
 public void ReloadSetting() => UserSettings = InvokeMethods.GetUserSettings();
Example #12
0
 private void ResetState()
 => InvokeMethods.ResetAutoModeState(_coreInvoker.UserSettings);
Example #13
0
 public void SaveUserSettings() => InvokeMethods.SaveUserSettings(UserSettings);
Example #14
0
 public async void ReloadSetting()
 => UserSettings = await InvokeMethods.GetUserSettings();
Example #15
0
 private void Exit_Click(object sender, EventArgs e)
 {
     InvokeMethods.SaveUserConfig();
     Application.Exit();
 }