Example #1
0
        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 InitInstance(ShadowsocksController controller)
        {
            if (Instance != null)
            {
                return;
            }

            Instance = new HotkeyCallbacks(controller);
        }
 public static void Destroy()
 {
     if (Instance == null)
     {
         return;
     }
     Instance = new HotkeyCallbacks(false);
     Instance = null;
 }
Example #6
0
        public static void InitInstance(ShadowsocksController controller, View.MenuViewController menu)
        {
            if (Instance != null)
            {
                return;
            }

            Instance = new HotkeyCallbacks(controller, menu);
        }
Example #7
0
 public static void Destroy()
 {
     if (_hotKeyManager != null)
     {
         _hotKeyManager.KeyPressed -= HotKeyManagerPressed;
         _hotKeyManager.Dispose();
         _hotKeyManager = null;
     }
     HotkeyCallbacks.Destroy();
     IshotKeyManagerRunning = false;
 }
Example #8
0
        public static void Init()
        {
            IshotKeyManagerRunning = true;
            if (_hotKeyManager == null)
            {
                _hotKeyManager = new HotKeyManager();
            }
            _hotKeyManager.KeyPressed += HotKeyManagerPressed;

            HotkeyCallbacks.InitInstance();
        }
Example #9
0
        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);
        }
Example #10
0
 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")}");
                 }
             }
         }
     }
 }