Exemplo n.º 1
0
 public bool Contains(IBindingKey key)
 {
     lock (this)
     {
         return(_bindingMap.ContainsKey(key));
     }
 }
Exemplo n.º 2
0
        public object TryGetBinding(IBindingName name, IBindingKey key, object[] extras)
        {
            ValueBindingContext ret = null;
            object theValue         = null;

            if (GetBinding(name, out ret))
            {
                if (!ret.Get(key, this, out theValue, extras))
                {
                    theValue = null;
                }
            }

            if (theValue == null)
            {
                foreach (var fallback in m_fallbacks)
                {
                    theValue = fallback(name, key, extras);

                    if (theValue != null)
                    {
                        break;
                    }
                }
            }

            return(theValue);
        }
Exemplo n.º 3
0
        public IUnsafeValueBindingContext Bind(IBindingName name, IBindingKey key)
        {
            ValueBindingContext ret = null;

            GetBinding(name, true, out ret);
            return(ret.Unsafe(key));
        }
Exemplo n.º 4
0
        protected override void OnBindingChange(IBindingKey key)
        {
            base.OnBindingChange(key);

            if (Equals(key, ShowMenu))
            {
                ShowMenuInput = InputManager.Get(ShowMenu);
            }
        }
Exemplo n.º 5
0
        protected override void OnBindingChange(IBindingKey key)
        {
            base.OnBindingChange(key);

            if (Equals(key, Zoom))
            {
                Scroll = InputManager.Get(Zoom);
            }
        }
Exemplo n.º 6
0
        public object Get(IBindingName name, IBindingKey key, params object[] extras)
        {
            object ret = TryGetBinding(name, key, extras);

            if (ret == null)
            {
                throw new BindingNotFound(name, key);
            }
            return(ret);
        }
Exemplo n.º 7
0
        public T Get <T>(IBindingKey <T> key) where T : class, IInput
        {
            lock (this)
            {
                IInput binding;

                _bindingMap.TryGetValue(key, out binding);

                return(binding as T);
            }
        }
Exemplo n.º 8
0
        public override bool Equals(object obj)
        {
            IBindingKey other = obj as IBindingKey;

            if (other == null)
            {
                return(false);
            }

            return(other.Key.Equals(Key));
        }
Exemplo n.º 9
0
        public void CheckRequiremets(IBindingKey key, IBindingName name)
        {
            var req = BindingRequirements.Instance.With(name, key);

            foreach (var requiremet in m_requirements)
            {
                if (req.Equals(requiremet))
                {
                    throw new BindingSelfRequirement();
                }
            }
        }
Exemplo n.º 10
0
        bool TryGet <T> (IBindingName name, IBindingKey key, out T t, object[] extras)
        {
            object ret = TryGetBinding(name, key, extras);

            if (ret != null)
            {
                t = (T)ret;
                return(true);
            }

            t = default(T);
            return(false);
        }
Exemplo n.º 11
0
        protected override void OnBindingChange(IBindingKey key)
        {
            base.OnBindingChange(key);

            if (Equals(key, Yaw))
            {
                X = InputManager.Get(Yaw);
            }

            if (Equals(key, Pitch))
            {
                Y = InputManager.Get(Pitch);
            }
        }
Exemplo n.º 12
0
        public void Register <T>(IBindingKey <T> key, T input) where T : class, IInput
        {
            lock (this)
            {
                Deregister(key);

                _bindings.Add(key);
                _bindingMap.Add(key, input);
            }

            input.Initialize();

            _onBindingChange.OnNext(key);
        }
Exemplo n.º 13
0
        object TryGetBinding(IBindingName name, IBindingKey key, object[] extras)
        {
            ValueBindingContext ret = null;

            if (GetBinding(name, out ret))
            {
                object theValue = null;
                if (ret.Get(key, this, out theValue, extras))
                {
                    return(theValue);
                }
            }

            return(null);
        }
Exemplo n.º 14
0
        public void Deregister(IBindingKey key)
        {
            lock (this)
            {
                if (!_bindingMap.ContainsKey(key))
                {
                    return;
                }

                var existingInput = _bindingMap[key];

                existingInput.Dispose();

                _bindings.Remove(key);
                _bindingMap.Remove(key);
            }

            _onBindingChange.OnNext(key);
        }
Exemplo n.º 15
0
        protected override void OnBindingChange(IBindingKey key)
        {
            base.OnBindingChange(key);

            if (Equals(key, Horizontal))
            {
                X = InputManager.Get(Horizontal);
            }

            if (Equals(key, Vertical))
            {
                Y = InputManager.Get(Vertical);
            }

            if (Equals(key, HoldToRun))
            {
                Running = InputManager.Get(HoldToRun);
            }
        }
Exemplo n.º 16
0
        private void ProcessBindingChange(IBindingKey key)
        {
            if (!Bindings.Contains(key))
            {
                return;
            }

            lock (this)
            {
                var wasActive = Active;

                Deactivate();

                OnBindingChange(key);

                if (Valid && wasActive)
                {
                    Activate();
                }
            }
        }
Exemplo n.º 17
0
 protected virtual void OnBindingChange(IBindingKey key)
 {
 }
 public ObjectBindingRequirement(IBindingName name, IBindingKey key)
 {
     m_name = name;
     m_key  = key;
 }
 public IBindingRequirement With(IBindingName name, IBindingKey key)
 {
     return(new ObjectBindingRequirement(name, key));
 }
Exemplo n.º 20
0
 public void CheckRequiremets(IBindingKey key, IBindingName name)
 {
     m_adaptee.CheckRequiremets(key, name);
 }
 public IUnsafeValueBindingContext Bind(IBindingKey key)
 {
     return(m_adaptee.Bind(new BindingName(InnerBindingNames.Empty), key));
 }
 public IUnsafeValueBindingContext Unsafe(IBindingKey key)
 {
     return(new UnsafeValueBindindContextAdapter(key, this));
 }
 internal void To(IBindingKey key, IBinding biding)
 {
     biding.CheckRequiremets(key, Name);
     m_bindings[key] = biding;
 }
 object IUnsafeBindingContext.TryGet(IBindingName name, IBindingKey key, params object[] extras)
 {
     return(m_adaptee.TryGetBinding(name, key, extras));
 }
 public object Get(IBindingName name, IBindingKey key)
 {
     return(m_adaptee.Get(name, key));
 }
 public IUnsafeValueBindingContext Bind(IBindingName name, IBindingKey key)
 {
     return(m_adaptee.Bind(name, key));
 }
Exemplo n.º 27
0
 public UnsafeValueBindindContextAdapter(IBindingKey key, ValueBindingContext adaptee)
 {
     m_adaptee = adaptee;
     m_key     = key;
 }
Exemplo n.º 28
0
 public BindingNotFound(IBindingName bindingName, IBindingKey bindingKey) : base(string.Format("With {0}, {1}", bindingName, bindingKey))
 {
 }