コード例 #1
0
 private async Task ToggleLight(ButtonStateViewModel arg)
 {
     if (arg == null)
     {
         _panelService.StopLine(1, true)
         .ContinueWith(t =>
                       _panelService.StopLine(2, true));
         ButtonStates.Off();
     }
     else
     {
         arg.IsOn = !arg.IsOn;
         _panelService.SetLightState(arg.Row, arg.Column, arg.Color, arg.IsOn);
     }
 }
コード例 #2
0
        public MainPageViewModel(IPanelService panelService)
        {
            _panelService = panelService;
            _panelService.OperationComplete += _panelService_OperationComplete;

            _panelDeviceId  = "192.168.197.1:8800";
            _timeSinceStart = TimeSpan.Zero;
            _timer          = new Timer(new TimerCallback(_timer_tick), null, Timeout.Infinite, Timeout.Infinite);

            ConnectPanelCommand = new RelayCommand(async() => await ConnectPanel(), () => IsConnected || (!IsConnected && !String.IsNullOrWhiteSpace(PanelDeviceId)));
            SetTempoCommand     = new RelayCommand <object>(SetTempo);
            StartTempoCommand   = new RelayCommand(() => { TimeSinceStart = TimeSpan.Zero; _timer.Change(1000, 1000); _panelService.StartLine(0); }, () => !_panelService.IsLineRunning(0));
            StopTempoCommand    = new RelayCommand(() => { _timer.Change(Timeout.Infinite, Timeout.Infinite); _panelService.StopLine(0, true); }, () => _panelService.IsLineRunning(0));
            ToggleLightCommand  = new RelayCommand <ButtonStateViewModel>(async(args) => await ToggleLight(args));
            SelectColorCommand  = new RelayCommand <CustomPinchUpdatedEventArgs>(SelectColor);
            PanelOffCommand     = new RelayCommand(PanelOff);
            ModifyTempoCommand  = new RelayCommand <string>(ModifyTempo);
            PlayLine1Command    = new RelayCommand <string>(PlayLine1);
            PlayLine2Command    = new RelayCommand <string>(PlayLine2);
        }