Esempio n. 1
0
        public Button(ComponentId id, IButtonEndpoint endpoint, ITimerService timerService, ISettingsService settingsService)
            : base(id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }

            settingsService.CreateSettingsMonitor <ButtonSettings>(Id, s => Settings = s);

            SetState(ButtonStateId.Released);

            timerService.Tick += CheckForTimeout;

            endpoint.Pressed  += (s, e) => HandleInputStateChanged(ButtonStateId.Pressed);
            endpoint.Released += (s, e) => HandleInputStateChanged(ButtonStateId.Released);
        }
Esempio n. 2
0
        public Button(ComponentId id, IButtonEndpoint endpoint, ITimerService timerService, ISettingsService settingsService)
            : base(id)
        {
            if (id == null) throw new ArgumentNullException(nameof(id));
            if (endpoint == null) throw new ArgumentNullException(nameof(endpoint));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));

            settingsService.CreateSettingsMonitor<ButtonSettings>(Id, s => Settings = s);

            SetState(ButtonStateId.Released);

            timerService.Tick += CheckForTimeout;

            endpoint.Pressed += (s, e) => HandleInputStateChanged(ButtonStateId.Pressed);
            endpoint.Released += (s, e) => HandleInputStateChanged(ButtonStateId.Released);
        }
Esempio n. 3
0
        public Button(ComponentId id, IButtonEndpoint endpoint, IHomeAutomationTimer timer)
            : base(id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            _settings = new ButtonSettingsWrapper(Settings);

            SetState(ButtonStateId.Released);

            timer.Tick        += CheckForTimeout;
            endpoint.Pressed  += (s, e) => HandleInputStateChanged(ButtonStateId.Pressed);
            endpoint.Released += (s, e) => HandleInputStateChanged(ButtonStateId.Released);
        }
Esempio n. 4
0
        public async Task <IButtonEndpoint> CreateDemoButton(string caption)
        {
            IButtonEndpoint result = null;

            await Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal,
                () =>
            {
                var button     = new Button();
                button.Content = caption;

                var endpoint = new UIButtonButtonEndpoint(button);
                endpoint.Connect();

                DemoButtonStackPanel.Children.Add(button);

                result = endpoint;
            });

            return(result);
        }