Beispiel #1
0
        public MainContextMenu(UserConfigEngine <MainViewModel> userConfigEngine,
                               CultureResource cultureResource)
        {
            InitializeComponent();

            _userConfigEngine = userConfigEngine;
            _cultureResource  = cultureResource;
            _mainSettingForm  =
                new Lazy <MainSettingForm>(() => new MainSettingForm(_userConfigEngine, cultureResource),
                                           LazyThreadSafetyMode.ExecutionAndPublication);

            VisibleChanged += (s, e) =>
            {
                if (Visible)
                {
                    Activate();
                }
            };
            Activated += (s, e) =>
            {
                ThemeUpdate();
                SetPosition();
            };
            Deactivate += (s, e) => Hide();

            #region Initialization

            exitMenuButton.Text   = _cultureResource.GetText("TrayExit");
            exitMenuButton.Image  = IconResources.Empty;
            exitMenuButton.Click += (s, e) => Application.Exit();

            stopButton.Text   = _cultureResource.GetText("TrayStop");
            stopButton.Click += (s, e) => { SetAutoModeType(AutoModeType.Disable); };

            AllowlistButton.Text   = _cultureResource.GetText("TrayAllowlistMode");
            AllowlistButton.Click += (s, e) => { SetAutoModeType(AutoModeType.AllowlistMode); };

            BlockListButton.Text   = _cultureResource.GetText("TrayBlockListMode");
            BlockListButton.Click += (s, e) => { SetAutoModeType(AutoModeType.BlockListMode); };

            foreButton.Text   = _cultureResource.GetText("TrayAutoMode2");
            foreButton.Click += (s, e) => { SetAutoModeType(AutoModeType.ForegroundMode); };

            apiButton.Text   = _cultureResource.GetText("TrayAutoMode1");
            apiButton.Click += (s, e) => { SetAutoModeType(AutoModeType.AutoHideApiMode); };

            settingsButton.Text   = _cultureResource.GetText("TraySettings");
            settingsButton.Click += (s, e) => { _mainSettingForm.Value.Show(); };

            aboutButton.Text                 = _cultureResource.GetText("TrayAbout");
            aboutButton.Image                = IconResources.Empty;
            aboutButton.Click               += (s, e)
                                        => _ = Launcher.LaunchUriAsync(new Uri("https://github.com/ChanpleCai/SmartTaskbar/releases"));

            #endregion
        }
Beispiel #2
0
 private void UpdateText()
 {
     exitMenuButton.Text  = _cultureResource.GetText("TrayExit");
     stopButton.Text      = _cultureResource.GetText("TrayStop");
     AllowlistButton.Text = _cultureResource.GetText("TrayAllowlistMode");
     BlockListButton.Text = _cultureResource.GetText("TrayBlockListMode");
     foreButton.Text      = _cultureResource.GetText("TrayAutoMode2");
     apiButton.Text       = _cultureResource.GetText("TrayAutoMode1");
     settingsButton.Text  = _cultureResource.GetText("TraySettings");
     aboutButton.Text     = _cultureResource.GetText("TrayAbout");
 }
Beispiel #3
0
 public string GetText(string name) => _cultureResource.GetText(name);