public Button(string id, IButtonAdapter adapter, ITimerService timerService, ISettingsService settingsService, IMessageBrokerService messageBroker, ILogService logService) : base(id) { if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } if (settingsService == null) { throw new ArgumentNullException(nameof(settingsService)); } _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _log = logService?.CreatePublisher(id) ?? throw new ArgumentNullException(nameof(logService)); settingsService.CreateSettingsMonitor <ButtonSettings>(this, s => Settings = s.NewSettings); _pressedLongTimeout = new Timeout(timerService); _pressedLongTimeout.Elapsed += (s, e) => { _messageBroker.Publish(Id, new ButtonPressedLongEvent()); }; adapter.StateChanged += UpdateState; _commandExecutor.Register <ResetCommand>(); _commandExecutor.Register <PressCommand>(c => PressInternal(c.Duration)); }
public Button(IButtonAdapter button, string name, string tooltip) { this.button = button; this.name = name; this.tooltipStr = tooltip; this.tooltip = GameObject.Find(tooltipStr + "/Tooltip").GetComponentInChildren<MeshRenderer>(); this.key = this.tempKey = Configuration.GetString("key:" + name.ToLower(), ""); }
public Button(IButtonAdapter button, string name, string tooltip) { this.button = button; this.name = name; this.tooltipStr = tooltip; this.tooltip = GameObject.Find(tooltipStr + "/Tooltip").GetComponentInChildren <MeshRenderer>(); this.key = this.tempKey = Configuration.GetString("key:" + name.ToLower(), ""); }
public Button(string id, IButtonAdapter adapter, ITimerService timerService, ISettingsService settingsService) : base(id) { if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); _pressedLongTimeout = new Timeout(timerService); _pressedLongTimeout.Elapsed += (s, e) => ((Trigger)PressedLongTrigger).Execute(); adapter.Pressed += (s, e) => ProcessChangedInputState(ButtonStateValue.Pressed); adapter.Released += (s, e) => ProcessChangedInputState(ButtonStateValue.Released); _commandExecutor.Register <ResetCommand>(); _commandExecutor.Register <PressCommand>(c => PressInternal(c.Duration)); }
public async Task <IButtonAdapter> CreateUIButtonAdapter(string caption) { IButtonAdapter result = null; await Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { var button = new Button { Content = caption }; var adapter = new UIButtonAdapter(button); adapter.Connect(); DemoButtonPanel.Children.Add(button); result = adapter; }); return(result); }