public ControlRegistration(Type type, object o, IControlType controlType, IViewType viewType)
 {
     Type        = type;
     Object      = o;
     ControlType = controlType;
     ViewType    = viewType;
 }
 private void ReturnControl(IControlType controlType)
 {
     if (_returned) return;
     _returned = true;
     _returnControl(controlType);
     Hide();
 }
		public ControlResolverMetadataBase(IControlType controlType)
        {
            this.controlType = controlType;
            this.attribute = controlType?.Type?.GetControlMarkupOptionsAttribute();

            this.properties = new Lazy<Dictionary<string, IPropertyDescriptor>>(() => {
                var result = new Dictionary<string, IPropertyDescriptor>(StringComparer.CurrentCultureIgnoreCase);
                LoadProperties(result);
                return result;
            });
        }
        public ControlResolverMetadataBase(IControlType controlType)
        {
            this.controlType = controlType;
            this.attribute   = controlType?.Type?.GetControlMarkupOptionsAttribute();

            this.properties = new Lazy <Dictionary <string, IPropertyDescriptor> >(() => {
                var result = new Dictionary <string, IPropertyDescriptor>(StringComparer.CurrentCultureIgnoreCase);
                LoadProperties(result);
                return(result);
            });
        }
Example #5
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.RegulatingCondEq == null))
     {
         IRegulatingCondEq regulatingCondEqCasted = item.As <IRegulatingCondEq>();
         if ((regulatingCondEqCasted != null))
         {
             this._parent.RegulatingCondEq = regulatingCondEqCasted;
             return;
         }
     }
     if ((this._parent.ControlType == null))
     {
         IControlType controlTypeCasted = item.As <IControlType>();
         if ((controlTypeCasted != null))
         {
             this._parent.ControlType = controlTypeCasted;
             return;
         }
     }
     if ((this._parent.Unit == null))
     {
         IUnit unitCasted = item.As <IUnit>();
         if ((unitCasted != null))
         {
             this._parent.Unit = unitCasted;
             return;
         }
     }
     if ((this._parent.RemoteControl == null))
     {
         IRemoteControl remoteControlCasted = item.As <IRemoteControl>();
         if ((remoteControlCasted != null))
         {
             this._parent.RemoteControl = remoteControlCasted;
             return;
         }
     }
 }
        public IDisposable RegisterControl <T>(object obj, IControlType controlType, IViewType viewType = null, bool bindImmediately = false) where T : IControlType
        {
            if (_registrations.ContainsKey(typeof(T)))
            {
                Debug.LogError($"control of type {(typeof(T)).Name} already registered");
                return(null);
            }

            _registrations[typeof(T)] = new ControlRegistration
            {
                Object      = obj,
                Type        = typeof(T),
                ControlType = controlType,
                ViewType    = viewType
            };

            if (bindImmediately)
            {
                BindControl(typeof(T));
            }

            return(new UnregisterControl <T>(_registrations, typeof(T)));
        }
Example #7
0
 /// <summary>
 /// Resolves the control metadata for specified type.
 /// </summary>
 public IControlResolverMetadata ResolveControl(IControlType controlType)
 {
     return(cachedMetadata.GetOrAdd(controlType, _ => BuildControlMetadata(controlType)));
 }
Example #8
0
 /// <summary>
 /// Gets the control metadata.
 /// </summary>
 public abstract IControlResolverMetadata BuildControlMetadata(IControlType type);
Example #9
0
 /// <summary>
 /// Gets the control metadata.
 /// </summary>
 public override IControlResolverMetadata BuildControlMetadata(IControlType type)
 {
     return(new ControlResolverMetadata((ControlType)type));
 }
Example #10
0
 /// <summary>
 /// Gets the control metadata.
 /// </summary>
 public override IControlResolverMetadata BuildControlMetadata(IControlType type)
 {
     return new ControlResolverMetadata((ControlType) type);
 }
Example #11
0
		/// <summary>
		/// Resolves the control metadata for specified type.
		/// </summary>
		public IControlResolverMetadata ResolveControl(IControlType controlType)
		{
			return cachedMetadata.GetOrAdd(controlType, _ => BuildControlMetadata(controlType));
		}
Example #12
0
		/// <summary>
		/// Gets the control metadata.
		/// </summary>
		public abstract IControlResolverMetadata BuildControlMetadata(IControlType type);
Example #13
0
 public void CopyFrom(PlayerControlsSettings other)
 {
     Thrust = other.Thrust;
     Left = other.Left;
     Right = other.Right;
     Fire1 = other.Fire1;
     Fire2 = other.Fire2;
     Extra = other.Extra;
 }
 private void TryReturnControl(IControlType controlType)
 {
     var control = controlType.GetControl();
     control.SetLocalState(Game.UIEngine.PreviousInputState, Game.UIEngine.InputState);
     if (control.Pulse) ReturnControl(controlType);
 }