private void BindMergeAction(PopupWindowShowAction pswAction) { IActionControlsSite site = Frame.Template as IActionControlsSite; IActionControlContainer container = GetTargetActionContainer(site, pswAction); if (container != null && container.FindActionControl(pswAction.Id) == null) { if (bAddAction) { // Action noch nicht da ISimpleActionControl actionControl = container.AddSimpleActionControl(pswAction.Id); actionControl.NativeControlDisposed += ActionControl_NativeControlDisposed; ActionBinding actionBinding = ActionBindingFactory.Instance.Create(pswAction, actionControl); if (!dictBinding.ContainsKey(pswAction)) { dictBinding.Add(pswAction, actionBinding); } } } if (container != null && container.FindActionControl(pswAction.Id) == null) { if (bAddAction) { if (!dictBinding.ContainsKey(pswAction)) { ISimpleActionControl actionControl = container.AddSimpleActionControl(pswAction.Id); actionControl.NativeControlDisposed += ActionControl_NativeControlDisposed; ActionBinding actionBinding = ActionBindingFactory.Instance.Create(pswAction, actionControl); dictBinding.Add(pswAction, actionBinding); } } } }
private static void CallActionEvent(string ActionName, InputEvent Mode) { Logger.Info(string.Format("{0} - {1}", ActionName, Mode.ToString())); ActionBinding AB = GetActionBinding(ActionName, Mode); AB?.Action?.Invoke(); }
private void CreateBindingList() { _actionBindings.Clear(); if (_selectedAction >= _normalActionCount) { return; } var inputAction = new InputAction { Action = _actions[_selectedAction], Player = _currentPlayer }; var keys = Core.KeyMappings.GetKeys(inputAction); foreach (Keys key in keys) { var newBinding = new ActionBinding { ControllerNumber = 0, Height = 45, Width = 230, Key = key }; _actionBindings.Add(newBinding); } for (int num = 1; num < 5; num++) { var buttons = Core.KeyMappings.GetButtons(inputAction, num); foreach (Buttons button in buttons) { var newBinding = new ActionBinding { ControllerNumber = num, Height = 45, Width = 230, Button = button }; _actionBindings.Add(newBinding); } } }
public Binding AddBinding <TOwner>(ActionDependencyProperty <TOwner> vProperty, IClassMethod vmProperty) where TOwner : IVisualElement { var result = new ActionBinding <TOwner>(this, vProperty, vmProperty); m_Bindings.Add(result); return(result); }
/// <summary> /// 确保只有一个 <see cref="FromBodyAttribute"/> /// </summary> private static void EnsureOneBodyParameter(ActionBinding actionBinding) { int willReadBodyCount = actionBinding.Parameters.Count(c => c.WillReadBody); if (willReadBodyCount > 1) { Array.ConvertAll(actionBinding.Parameters, input => new ErrorParameterBinding(input.ParameterDescriptor, "无法将多个参数绑定到请求的内容")); } }
private IEnumerator OperateStopAction(ActionBinding binding, float delay) { yield return(new WaitForSeconds(delay)); binding.Action.Stop(); if (binding.Times > 0) { binding.Times -= 1; } stopPendings.Remove(binding); }
public ActionBinding GetBinding(ActionDescriptor descriptor) { if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } ParameterDescriptor[] descriptors = descriptor.GetParameterDescriptors(); ParameterBinding[] bindings = Array.ConvertAll(descriptors, GetParameterBinding); ActionBinding binding = new ActionBinding(descriptor, bindings); EnsureOneBodyParameter(binding); return(binding); }
public static void RemoveBinding(string ActionName, Action Binding, InputEvent InputMode) { ActionBinding AB = GetActionBinding(ActionName, InputMode); if (AB != null) { AB.Action -= Binding; if (AB.Action == null) { ActionBindingEvents.Remove(AB); } } }
/// <summary> /// Initializes a new instance of the <see cref="BindingContext"/> class. /// </summary> /// <param name="binder">The binder.</param> /// <param name="action">The action.</param> internal BindingContext(ControllerBinder binder, ActionBinding action) { if (binder == null) { throw new ArgumentNullException("binder"); } if (action == null) { throw new ArgumentNullException("action"); } this.action = action; this.binder = binder; RegisterDefaultScopes(); }
public static void BindInput(string ActionName, Action Binding, InputEvent InputMode) { ActionBinding AB = GetActionBinding(ActionName, InputMode); if (AB != null) { AB.Action += Binding; } else { AB = new ActionBinding { Name = ActionName, Action = Binding, InputEvent = InputMode, }; ActionBindingEvents.Add(AB); } }
private void AddDefaultTargets(ActionBinding action) { WebControl activeControl = action.ControlInstance; if (activeControl != null) { cbTarget.Items.Add(new StandardTarget(activeControl, "this")); if (!string.IsNullOrEmpty(action.EventName)) { Type activeEvent = EventUtil.GetEventArgsType(activeControl, action.EventName); if (activeEvent != null) { cbTarget.Items.Add(new StandardTarget(activeEvent, "event")); } else { cbTarget.Items.Add(new StandardTarget("event")); } } } }
private bool EnsureEventName(Control control, ActionBinding binding) { if (string.IsNullOrEmpty(binding.EventName)) { binding.EventName = SelectDefaultEvent(control, binding.Parent); return !string.IsNullOrEmpty(binding.EventName); } return false; }
protected IBindingEditorViewModel(ActionBinding model, IDeviceControl?control) { Model = model; _control = control; }
private static void CallActionEvent(string ActionName, InputEvent Mode) { ActionBinding AB = GetActionBinding(ActionName, Mode); AB?.Action?.Invoke(); }