public static void UnbindHotkey(this IHotkeyManager m, Hotkey hotkey) { if (m is HotkeyManager manager && manager.ActionHotkeys.ContainsKey(hotkey)) { manager.ActionHotkeys.Remove(hotkey); } }
public static Hotkey BindHotkey(this IHotkeyManager m, string hotkeyString, Action action, bool isOneTime = false) { Hotkey hotkey = new Hotkey(hotkeyString, isOneTime); m.Bind(hotkey, action); return(hotkey); }
public void Dispose() { _configManager.RemovePropertyChangeListener(ConfigManager_Update); _hotkeyManager.UnregisterHotkey(_hotkeyId); _configManager = null; _hotkeyManager = null; _chatManager = null; }
public ConfigHotkeyUpdater(string hotkeyid, string hotkeyName, IConfigManager configManager, string configKey, IHotkeyManager hotkeyManager, IChatManager chatManager) { _hotkeyId = hotkeyid ?? throw new ArgumentNullException(nameof(hotkeyid)); _configKey = configKey ?? throw new ArgumentNullException(nameof(configKey)); _hotkeyName = hotkeyName ?? throw new ArgumentNullException(nameof(hotkeyName)); _configManager = configManager ?? throw new ArgumentNullException(nameof(configManager)); _hotkeyManager = hotkeyManager ?? throw new ArgumentNullException(nameof(hotkeyManager)); _chatManager = chatManager ?? throw new ArgumentNullException(nameof(chatManager)); _hotkeyManager.RegisterHotkey(_hotkeyId, Hotkey_Action); _configManager.AddPropertyChangeListener(_configKey, true, true, ConfigManager_Update); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel" /> class. /// </summary> public MainWindowViewModel() { Main = DIResolver.Get <MainControlViewModel>(); MainVisible = true; MainOpacity = 1; ConflictSolver = DIResolver.Get <MainConflictSolverControlViewModel>(); writingStateOperationHandler = DIResolver.Get <WritingStateOperationHandler>(); overlayProgressHandler = DIResolver.Get <OverlayProgressHandler>(); hotkeyManager = DIResolver.Get <IHotkeyManager>(); if (!StaticResources.IsVerifyingContainer) { BindOverlay(); } }
private void SetUpKeyBinds(IHotkeyManager hotkeys) { hotkeys.Bind(_settings.GetItem <string>(DumpSceneBasicSettingsKey), () => { DumpBasic(); } ); hotkeys.Bind(_settings.GetItem <string>(DumpSceneDetailedSettingsKey), () => { DumpDetailed(); } ); }
public UserActionHandler( IMetaPubSub metaMessenger, IActiveDevice activeDevice, InputLogin inputLogin, InputPassword inputPassword, InputOtp inputOtp, ISettingsManager <ApplicationSettings> appSettingsManager, IHotkeyManager hotkeyManager, IWindowsManager windowsManager, ILog log) : base(nameof(UserActionHandler), log) { _metaMessenger = metaMessenger; _activeDevice = activeDevice; _inputLogin = inputLogin; _inputPassword = inputPassword; _inputOtp = inputOtp; _appSettingsManager = appSettingsManager; _hotkeyManager = hotkeyManager; _windowsManager = windowsManager; _metaMessenger.Subscribe <HotkeyPressedMessage>(HotkeyPressedMessageHandler); _metaMessenger.Subscribe <ButtonPressedMessage>(ButtonPressedMessageHandler); }
public HotkeySettingsViewModel(IHotkeyManager globalHotkeyManager) { this.GlobalHotkeyManager = globalHotkeyManager; }
private void UpdateHotkeyService(bool useLowLevelHotkey) { HotkeyManager = useLowLevelHotkey ? new LowLevelHotkeyManager() : (IHotkeyManager) new ApiHotkeyManager(); }
protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); InitializeDIContainer(); // Init settings ApplicationSettings settings = null; ISettingsManager <ApplicationSettings> appSettingsManager = Container.Resolve <ISettingsManager <ApplicationSettings> >(); try { var appSettingsDirectory = Path.GetDirectoryName(appSettingsManager.SettingsFilePath); if (!Directory.Exists(appSettingsDirectory)) { Directory.CreateDirectory(appSettingsDirectory); } settings = await appSettingsManager.LoadSettingsAsync().ConfigureAwait(true); // Init localization var culture = new CultureInfo(settings.SelectedUiLanguage); TranslationSource.Instance.CurrentCulture = culture; Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } catch (Exception exp) { var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("Unexpected Error 1 in App.Application_Startup()"); sb.AppendLine($" Message:{exp.Message}"); sb.AppendLine($"StackTrace:{exp.StackTrace}"); sb.AppendLine(); _log.WriteLine(sb.ToString(), LogErrorSeverity.Error); } // Due to implementation constraints, taskbar icon must be instantiated as late as possible Container.RegisterInstance(FindResource("TaskbarIcon") as TaskbarIcon, new ContainerControlledLifetimeManager()); Container.Resolve <ITaskbarIconManager>(); _log.WriteLine("Resolve DI container"); _startupHelper = Container.Resolve <IStartupHelper>(); _workstationManager = Container.Resolve <IWorkstationManager>(); _metaMessenger = Container.Resolve <IMetaPubSub>(); _metaMessenger.Subscribe <ConnectedToServerEvent>(OnConnectedToServer); _serviceWatchdog = Container.Resolve <IServiceWatchdog>(); _serviceWatchdog.Start(); _deviceManager = Container.Resolve <IDeviceManager>(); _userActionHandler = Container.Resolve <UserActionHandler>(); _hotkeyManager = Container.Resolve <IHotkeyManager>(); _hotkeyManager.Enabled = true; _buttonManager = Container.Resolve <IButtonManager>(); _buttonManager.Enabled = true; _messageWindow = Container.Resolve <MessageWindow>(); Container.Resolve <IProximityLockManager>(); Container.Resolve <IVaultLowBatteryMonitor>(); SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; // This will create an instance of password manager view model and allow handling of "Add new account" user action // It is required for subscribtion of PasswordManagerViewModel to the "AddAccountForApp" message // Note: PasswordManagerViewModel is not required for simplified UI Container.Resolve <PasswordManagerViewModel>(); // Public Suffix list loading and updating may take some time (more than 8000 entries) // Better to load it before its required (for main domain extraction) await Task.Run(URLHelper.PreloadPublicSuffixAsync); // Handle first launch if (settings.IsFirstLaunch) { OnFirstLaunch(); settings.IsFirstLaunch = false; appSettingsManager.SaveSettings(settings); } _windowsManager = Container.Resolve <IWindowsManager>(); await _windowsManager.InitializeMainWindowAsync(); await _metaMessenger.TryConnectToServer("HideezServicePipe"); }