Ejemplo n.º 1
0
 public override void ViewAppearing()
 {
     base.ViewAppearing();
     _topNavigationViewModelService.Show(new TopNavigationViewModel.PrepareModel()
     {
         Title             = (string.IsNullOrWhiteSpace(Id.Value) ? "Add" : "Update") + " song",
         HomeIconType      = Enums.TopNavigationViewIconType.Back,
         HomeIconCommand   = new MvxCommand(async() => await _navigationService.Close(this)),
         ActionIconType    = Enums.TopNavigationViewIconType.Done,
         ActionIconCommand = new MvxCommand <string>((query) => ChangeCommand.Execute(null)),
     }
                                         );
     _bottomNavigationViewModelService.CheckItem(Enums.BottomNavigationViewCheckedItemType.None);
 }
Ejemplo n.º 2
0
        public void RunStep()
        {
            try
            {
                var currentSlideName = _slider.Cells.FirstOrDefault(z => z.IsActive == true).Value;
                if (_executableAlphabetCell == null)
                {
                    _executableAlphabetCell = _alphabetCells.FirstOrDefault(x =>
                                                                            x.Name == currentSlideName);
                    _executableAlphabetCell.IsExecute    = true;
                    _executableAlphabetCell.CurrentState = _executableAlphabetCell.States.FirstOrDefault(x => x.Name == "Q1");
                }
                _changeCommand._cells = _alphabetCells;
                if (!_changeCommand.IsValid(currentSlideName))
                {
                    throw new CannotExecuteException("На каретке имеется символ вне алфавита!", currentSlideName);
                }
                if (_executableAlphabetCell.CurrentState.Action == null)
                {
                    throw new CannotExecuteException("Ожидалось действие!",
                                                     $"Элемент алфавита: {_executableAlphabetCell.Name}\nСостояние: {_executableAlphabetCell.CurrentState.Name}");
                }
                var actionText = _executableAlphabetCell.CurrentState.Action;
                if (actionText == "end")
                {
                    _executableAlphabetCell = null;
                    IsEnd = true;
                }
                else
                {
                    SlideControl slideController = _slider.Controller;

                    _changeCommand.Execute(_executableAlphabetCell, _alphabetCells, _slider);

                    _moveCommand.Execute(_executableAlphabetCell, _slider);

                    _setStateCommand.Execute(ref _executableAlphabetCell, _alphabetCells, _slider);
                }
            }
            catch (CannotExecuteException ex)
            {
                MessageBox.Show(ex.WrongActionText, $"{ex.Message}, вызвано {ex.TargetSite}");
            }
        }
        public AddCommandPageViewModel(INavigationService navigationService)
        {
            Navigation        = navigationService;
            EffectOn          = true;
            EffectColor       = Color.FromHex("#FFFF00");
            IsExecutedCommand = false;
            IsExecutedLong    = false;
            EnableRipple      = true;
            TestParam         = "Hoge";
            TestLongParam     = "LongHoge";

            EnableSound    = true;
            SyncCanExecute = true;

            ToggleCanExecute.Subscribe(_ => {
                CanExecute.Value = !CanExecute.Value;
            });

            IDisposable subCommand = null;

            ChangeCommand.Subscribe(_ => {
                if (EffectCommand != null)
                {
                    subCommand?.Dispose();
                    EffectCommand = null;
                }
                else
                {
                    EffectCommand = CanExecute.ToReactiveCommand();
                    subCommand    = EffectCommand.Subscribe(ExecCommand);
                }
                OnPropertyChanged(() => this.EffectCommand);
            });

            ChangeCommand.Execute();

            IDisposable subLongCommand = null;

            ChangeLongCommand.Subscribe(_ => {
                if (LongCommand != null)
                {
                    subLongCommand.Dispose();
                    LongCommand = null;
                }
                else
                {
                    LongCommand    = CanExecute.ToReactiveCommand();
                    subLongCommand = LongCommand.Subscribe(ExecLongCommand);
                }
                OnPropertyChanged(() => this.LongCommand);
            });

            ChangeLongCommand.Execute();



            CanExecuteNullToggle.Subscribe(_ => {
                if (CanExecuteCommand != null)
                {
                    CanExecuteCommand    = null;
                    CommandParameterText = "Command is null";
                }
                else
                {
                    CanExecuteCommand = CanExecute.ToAsyncReactiveCommand();
                    CanExecuteCommand.Subscribe(async x => {
                        CommandParameterText = "Done Command";
                        await Task.Delay(500);
                    });
                }
                OnPropertyChanged(() => CanExecuteCommand);
            });

            CanExecuteLongNullToggle.Subscribe(_ => {
                if (CanExecuteLongCommand != null)
                {
                    CanExecuteLongCommand = null;
                    CommandParameterText  = "LongCommand is null";
                }
                else
                {
                    CanExecuteLongCommand = CanExecuteLong.ToReactiveCommand();
                    CanExecuteLongCommand.Subscribe(async x => {
                        CommandParameterText = "Done Long Command";
                        await Task.Delay(500);
                    });
                }
                OnPropertyChanged(() => CanExecuteLongCommand);
            });

            CanExecuteNullToggle.Execute();
            CanExecuteLongNullToggle.Execute();
        }