Esempio n. 1
0
        public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            if (keyPath == Constants.KEY_HOTKEY_SCAN_SELECT)
            {
                if (_hotkeyBindings.ContainsKey(Constants.KEY_HOTKEY_SCAN_SELECT))
                {
                    _hotkeyManager.Unbind(_hotkeyBindings[Constants.KEY_HOTKEY_SCAN_SELECT]);
                    _hotkeyBindings.Remove(Constants.KEY_HOTKEY_SCAN_SELECT);
                }

                UpdateGlobalHotKey(Constants.KEY_HOTKEY_SCAN_SELECT, ofObject.ValueForKeyPath(keyPath), "onScanSelect");
            }
            else if (keyPath == Constants.KEY_HOTKEY_SCAN_CLICK)
            {
                if (_hotkeyBindings.ContainsKey(Constants.KEY_HOTKEY_SCAN_CLICK))
                {
                    _hotkeyManager.Unbind(_hotkeyBindings[Constants.KEY_HOTKEY_SCAN_CLICK]);
                    _hotkeyBindings.Remove(Constants.KEY_HOTKEY_SCAN_CLICK);
                }

                UpdateGlobalHotKey(Constants.KEY_HOTKEY_SCAN_CLICK, ofObject.ValueForKeyPath(keyPath), "onScanClick");
            }
            else
            {
                base.ObserveValue(keyPath, ofObject, change, context);
            }
        }
Esempio n. 2
0
        public void Invoke(NSObject target)
        {
            var resolvedTarget = KeyPath == null
                ? target
                : target.ValueForKeyPath(new NSString(KeyPath));

            Invocation.Invoke(resolvedTarget);
        }
        public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            if (keyPath == "values.globalPing")
            {
                var hotKeyCenter = PTHotKeyCenter.SharedCenter;
                var oldHotKey    = hotKeyCenter.HotKeyWithIdentifier(keyPath);
                if (oldHotKey != null)
                {
                    hotKeyCenter.UnregisterHotKey(oldHotKey);
                }

                var newShortcut = ofObject.ValueForKeyPath(keyPath) as NSDictionary;
                if (newShortcut != null)
                {
                    var newHotKey = PTHotKey.PTHotKey.HotKeyWithIdentifier(keyPath, newShortcut, this, new ObjCRuntime.Selector("ping"));
                    hotKeyCenter.RegisterHotKey(newHotKey);
                }
            }
            else
            {
                base.ObserveValue(keyPath, ofObject, change, context);
            }
        }