Ejemplo n.º 1
0
        public MainNotifyIcon(UserConfigEngine <MainViewModel> userConfigEngine,
                              CultureResource cultureResource,
                              AutoModeWorker autoModeWorker,
                              TimeEngine timeEngine)
        {
            _container        = new Container();
            _userConfigEngine = userConfigEngine;
            _autoModeWorker   = autoModeWorker;
            _timeEngine       = timeEngine;

            _contextMenuLazy = new Lazy <MainContextMenu>(
                () => new MainContextMenu(userConfigEngine, cultureResource, autoModeWorker),
                LazyThreadSafetyMode.ExecutionAndPublication);

            #region Initialization

            _notifyIcon = new NotifyIcon(_container)
            {
                Text    = Constants.ApplicationName,
                Icon    = _userConfigEngine.ViewModel.Icon,
                Visible = true
            };

            _notifyIcon.MouseClick              += NotifyIcon_MouseClick;
            UIInfo.Settings.ColorValuesChanged  += Settings_ColorValuesChanged;
            SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;

            #endregion
        }
Ejemplo n.º 2
0
        public MainContextMenu(UserConfigEngine <MainViewModel> userConfigEngine,
                               CultureResource cultureResource,
                               AutoModeWorker autoModeWorker)
        {
            InitializeComponent();

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

            #region Events

            VisibleChanged += MainContextMenu_VisibleChanged;
            Activated      += MainContextMenu_Activated;
            Deactivate     += MainContextMenu_Deactivate;
            UIInfo.Settings.ColorValuesChanged += Settings_ColorValuesChanged;

            exitMenuButton.Click  += OnExitMenuButtonOnClick;
            stopButton.Click      += OnStopButtonOnClick;
            AllowlistButton.Click += OnAllowlistButtonOnClick;
            BlockListButton.Click += OnBlockListButtonOnClick;
            foreButton.Click      += OnForeButtonOnClick;
            apiButton.Click       += OnApiButtonOnClick;
            settingsButton.Click  += OnSettingsButtonOnClick;
            aboutButton.Click     += OnAboutButtonOnClick;

            #endregion

            #region Initialization

            UpdateTheme();
            UpdateText();

            aboutButton.Image    = IconResources.Empty;
            exitMenuButton.Image = IconResources.Empty;

            #endregion
        }