示例#1
0
        public void Fkt_Test(object obj)
        {
            //if (obj is object[])
            //{
            //    var param = obj as object[];
            //    FieldContent[4] = param[0].ToString();
            //    OnNotifyPropertyChanged("FieldContent");
            //    TextContent = param[1].ToString();
            //    OnNotifyPropertyChanged("TextContent");
            //}
            //else
            //{
            //    string input = obj as String;
            //    char[] seperator = { '|' };
            //    string[] param = input.Split(seperator);
            //    FieldContent[4] = param[0].ToString();
            //    OnNotifyPropertyChanged("FieldContent");
            //    TextContent = param[1].ToString();
            //    OnNotifyPropertyChanged("TextContent");
            //}

            TextContent = CanExecute.ToString() + " " + GameInProgress.ToString();
            OnNotifyPropertyChanged("TextContent");
            OnNotifyPropertyChanged("FieldContent");
        }
        public FormatTemplateElement SetCanFormat([CanBeNull] CanExecute canFormat)
        {
            if (IsFrozen)
            {
                throw new InvalidOperationException("This object is Frozen");
            }

            CanFormat = canFormat;
            return(this);
        }
示例#3
0
        public LoginContent()
        {
            UserId.EnableValidation(() => UserId);
            Password.EnableValidation(() => Password);

            CanExecute.Bind(
                context => !string.IsNullOrEmpty(context.GetValueAt <string>(0)) && !string.IsNullOrEmpty(context.GetValueAt <string>(1)),
                UserId, Password
                );
        }
示例#4
0
 public FormatTemplateElement([NotNull] Delegate formatTemplate,
                              [CanBeNull] CanExecute canFormat,
                              [NotNull] Type inputTypes,
                              [CanBeNull] Type outputType,
                              [NotNull][ItemNotNull] MultiFormatterInfo[] argumentMeta)
 {
     Format     = formatTemplate ?? throw new ArgumentNullException(nameof(formatTemplate));
     CanFormat  = canFormat;
     InputTypes = inputTypes ?? throw new ArgumentNullException(nameof(inputTypes));
     OutputType = outputType ?? throw new ArgumentNullException(nameof(outputType));
     MetaData   = new MultiFormatterInfoCollection(argumentMeta ?? throw new ArgumentNullException(nameof(argumentMeta)));
     if (MetaData.Any(e => e == null))
     {
         throw new InvalidOperationException("You cannot use a Null value in the collection of MultiFormatterInfo");
     }
 }
示例#5
0
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        if (CanExecute.HasDelegate)
        {
            var ev = new CanExecuteEventArgs();
            await CanExecute.InvokeAsync(ev);

            _canExecute = ev.Result;
        }
        else
        {
            _canExecute = true;
        }
    }
示例#6
0
        public ButtonCellTestViewModel(IPageDialogService pageDialog)
        {
            CanExecute.Value = CanExecutes[0];

            Commands[0] = CanExecute.ToReactiveCommand();
            Commands[1] = CanExecute.ToReactiveCommand();

            CommandParameter.Value = Parameters[0];
            Command.Value          = Commands[0];

            Commands[0].Subscribe(async p =>
            {
                await pageDialog.DisplayAlertAsync("Command1", p?.ToString(), "OK");
            });

            Commands[1].Subscribe(async p =>
            {
                await pageDialog.DisplayAlertAsync("Command2", p?.ToString(), "OK");
            });
        }
        public LabelCellTestViewModel(INavigationService navigationService, IPageDialogService pageDialog)
        {
            BackgroundColor.Value = Color.White;
            PickerTitle.Value     = "Hoge";

            TimeFormat.Value = "t";
            Time.Value       = new TimeSpan(12, 0, 0);

            DateFormat.Value = DateFormats[0];
            TodayText.Value  = TodayTexts[0];
            Date.Value       = Dates[0];
            MaxDate.Value    = MaxDates[0];
            MinDate.Value    = MinDates[0];

            CanExecute.Value = CanExecutes[0];

            Commands[0] = CanExecute.ToReactiveCommand();
            Commands[1] = CanExecute.ToReactiveCommand();

            CommandParameter.Value = Parameters[0];
            Command.Value          = Commands[0];

            Commands[0].Subscribe(async p =>
            {
                await pageDialog.DisplayAlertAsync("Command1", p?.ToString(), "OK");
                await navigationService.NavigateAsync("ContentPage");
            });

            Commands[1].Subscribe(async p =>
            {
                await pageDialog.DisplayAlertAsync("Command2", p?.ToString(), "OK");
            });
            NumberSelectedCommand.Subscribe(async p =>
            {
                await pageDialog.DisplayAlertAsync("", p.ToString(), "OK");
            });
            TextSelectedCommand.Subscribe(async p => {
                await pageDialog.DisplayAlertAsync("", p?.ToString(), "OK");
            });
        }
示例#8
0
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        if (CanExecute.HasDelegate)
        {
            var ev = new CanExecuteEventArgs();
            await CanExecute.InvokeAsync(ev);

            _canExecute = ev.Result;
        }
        else
        {
            _canExecute = true;
            if (Screen != null)
            {
                var dws = Screen.GetDataWorkspace();
                if (dws != null)
                {
                    dws.SavedChanges += Dws_SavedChanges;
                }
            }
        }
    }
示例#9
0
 /// <summary>
 /// Raises the <see cref="CanExecute"/> event.
 /// </summary>
 private void RaiseCanExecute(DependencyObject element, ICommand command, Object parameters, CanExecuteRoutedEventData data) =>
 CanExecute?.Invoke(element, command, parameters, data);
示例#10
0
 public FormatTemplateElement SetCanFormat([CanBeNull] CanExecute canFormat)
 {
     CanFormat = canFormat;
     return(this);
 }
示例#11
0
 public InternalReactiveCommand(MonoBehaviour disposer)
 {
     CanExecute.Subscribe(_ => CanExecuteChanged?.Invoke(this, EventArgs.Empty)).AddTo(disposer);
 }
示例#12
0
 /// <inheritdoc/>
 protected override bool ICommandCanExecute(object parameter)
 {
     return(CanExecute.FirstAsync().Wait());
 }
示例#13
0
 public virtual bool OnCanExecute(TArgs args) => CanExecute?.Invoke(args) ?? true;
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="canDoAction">The delegate that defines if the command is enabled.</param>
 /// <param name="doAction">The delegate that defines the command action.</param>
 public DelegateCommand(CanExecute canDoAction, Execute doAction)
     : this(null, canDoAction, doAction)
 {
 }
示例#15
0
 public FormatTemplateElement([NotNull] Func <object, object, object> formatTemplate,
                              [CanBeNull] CanExecute canFormat, [NotNull] Type inputTypes,
                              [CanBeNull] Type outputType, [NotNull][ItemNotNull] MultiFormatterInfo[] argumentMeta)
     : this((Delegate)formatTemplate, canFormat, inputTypes, outputType, argumentMeta)
 {
 }
示例#16
0
 public PlanExecutionEvents OnCanExecute(bool canExecute)
 {
     CanExecute?.Invoke(this, new PlanCanExecuteUpdatedEventArgs(backupPlan, canExecute));
     return(this);
 }
示例#17
0
 public void RaiseCanExecute(object sender, CanExecuteEventArgs args)
 {
     CanExecute.NullableInvoke(sender, args);
 }
示例#18
0
 public IDisposable NonGenericSubscribe(Action <object> onNext)
 {
     return(CanExecute.Subscribe(obj => onNext.Invoke(obj)));
 }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="canDoAction">The delegate that defines if the command is enabled.</param>
 /// <param name="doAction">The delegate that defines the command action.</param>
 public DelegateCommand(CanExecute canDoAction, Execute doAction)
     : this(null, canDoAction, doAction)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CombinedReactiveCommand{TParam, TResult}"/> class.
        /// </summary>
        /// <param name="childCommands">The child commands which will be executed.</param>
        /// <param name="canExecute">A observable when the command can be executed.</param>
        /// <param name="outputScheduler">The scheduler where to dispatch the output from the command.</param>
        /// <exception cref="ArgumentNullException">Fires when required arguments are null.</exception>
        /// <exception cref="ArgumentException">Fires if the child commands container is empty.</exception>
        protected internal CombinedReactiveCommand(
            IEnumerable <ReactiveCommandBase <TParam, TResult> > childCommands,
            IObservable <bool> canExecute,
            IScheduler outputScheduler)
        {
            if (childCommands is null)
            {
                throw new ArgumentNullException(nameof(childCommands));
            }

            if (canExecute is null)
            {
                throw new ArgumentNullException(nameof(canExecute));
            }

            if (outputScheduler is null)
            {
                throw new ArgumentNullException(nameof(outputScheduler));
            }

            var childCommandsArray = childCommands.ToArray();

            if (childCommandsArray.Length == 0)
            {
                throw new ArgumentException("No child commands provided.", nameof(childCommands));
            }

            _exceptions = new ScheduledSubject <Exception>(outputScheduler, RxApp.DefaultExceptionHandler);

            var canChildrenExecute = childCommandsArray.Select(x => x.CanExecute)
                                     .CombineLatest()
                                     .Select(x => x.All(y => y));
            var combinedCanExecute = canExecute
                                     .Catch <bool, Exception>(ex =>
            {
                _exceptions.OnNext(ex);
                return(Observables.False);
            })
                                     .StartWith(false)
                                     .CombineLatest(canChildrenExecute, (ce, cce) => ce && cce)
                                     .DistinctUntilChanged()
                                     .Replay(1)
                                     .RefCount();

            _exceptionsSubscription = childCommandsArray.Select(x => x.ThrownExceptions)
                                      .Merge()
                                      .Subscribe(ex => _exceptions.OnNext(ex));

            _innerCommand = new ReactiveCommand <TParam, IList <TResult> >(
                param =>
                childCommandsArray
                .Select(x => x.Execute(param))
                .CombineLatest(),
                combinedCanExecute,
                outputScheduler);

            // we already handle exceptions on individual child commands above, but the same exception
            // will tick through innerCommand. Therefore, we need to ensure we ignore it or the default
            // handler will execute and the process will be torn down
            _innerCommand
            .ThrownExceptions
            .Subscribe();

            CanExecute.Subscribe(OnCanExecuteChanged);
        }
示例#21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="canDoAction">The can do action.</param>
 /// <param name="doAction">The do action.</param>
 public DelegateCommand(string name, CanExecute canDoAction, Execute doAction)
 {
     this.name = name;
     this.canDoAction = canDoAction;
     this.doAction = doAction;
 }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="canDoAction">The can do action.</param>
 /// <param name="doAction">The do action.</param>
 public DelegateCommand(string name, CanExecute canDoAction, Execute doAction)
 {
     this.name        = name;
     this.canDoAction = canDoAction;
     this.doAction    = doAction;
 }
        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();
        }