public static void Init(ShadowsocksController controller) { _hotKeyManager = new HotKeyManager(); _hotKeyManager.KeyPressed += HotKeyManagerPressed; HotkeyCallbacks.InitInstance(controller); }
public static void InitInstance(ShadowsocksController controller) { if (Instance != null) { return; } Instance = new HotkeyCallbacks(controller); }
public static void InitInstance() { if (Instance != null) { return; } Instance = new HotkeyCallbacks(); }
public static void Destroy() { if (Instance == null) { return; } Instance = new HotkeyCallbacks(false); Instance = null; }
public static void InitInstance(ShadowsocksController controller, View.MenuViewController menu) { if (Instance != null) { return; } Instance = new HotkeyCallbacks(controller, menu); }
public static void Destroy() { if (_hotKeyManager != null) { _hotKeyManager.KeyPressed -= HotKeyManagerPressed; _hotKeyManager.Dispose(); _hotKeyManager = null; } HotkeyCallbacks.Destroy(); IshotKeyManagerRunning = false; }
public static void Init() { IshotKeyManagerRunning = true; if (_hotKeyManager == null) { _hotKeyManager = new HotKeyManager(); } _hotKeyManager.KeyPressed += HotKeyManagerPressed; HotkeyCallbacks.InitInstance(); }
public static void Init(ShadowsocksController controller, View.MenuViewController menu) { _hotKeyManager = new HotKeyManager(); _hotKeyManager.KeyPressed += HotKeyManagerPressed; HotkeyCallbacks.InitInstance(controller, menu); var keys = controller.GetConfigurationCopy()?.hotkey ?? new HotkeyConfig(); LoadConfiguration(keys); }
private static void LoadConfiguration(HotkeyConfig config) { foreach (var pi in config.GetType().GetProperties()) { var pv = pi.GetValue(config, null); if (pv is string str) { var hotkey = Str2HotKey(str); if (hotkey != null) { var callbackName = pi.Name + "Callback"; if (HotkeyCallbacks.GetCallback(callbackName) is HotKeyCallBackHandler callback) { if (IsCallbackExists(callback, out var prevHotKey)) { UnRegist(prevHotKey); } var regResult = Regist(hotkey, callback); Logging.Info($"Reg {str} to {pi.Name}{(regResult ? "Successful" : "Fail")}"); } } } } }