Ejemplo n.º 1
0
        public TestMotionActivityViewModel(IMotionActivityManager manager, IDialogs dialogs)
        {
            var tm = manager as TestMotionActivityManager;

            this.IsGeneratingData = tm?.IsGeneratingTestData ?? false;
            this.ActivityType     = tm?.GeneratingActivityType ?? MotionActivityType.Automotive;
            this.Confidence       = tm?.GeneratingConfidence ?? MotionActivityConfidence.High;
            this.IntervalSeconds  = Convert.ToInt32(tm?.GeneratingInterval?.TotalSeconds ?? 10d);

            this.SelectActivityType = dialogs.PickEnumValueCommand <MotionActivityType>(
                "Select Activity Type",
                x => this.ActivityType = x
                );
            this.SelectConfidence = dialogs.PickEnumValueCommand <MotionActivityConfidence>(
                "Select Confidence",
                x => this.Confidence = x
                );

            this.Toggle = ReactiveCommand.Create(
                () =>
            {
                if (tm.IsGeneratingTestData)
                {
                    tm.StopGeneratingTestData();
                    this.IsGeneratingData = false;
                }
                else
                {
                    tm.StartGeneratingTestData(
                        this.ActivityType,
                        TimeSpan.FromSeconds(this.IntervalSeconds),
                        this.Confidence
                        );
                    this.IsGeneratingData = true;
                }
            },
                this.WhenAny(
                    x => x.IntervalSeconds,
                    (ts) =>
            {
                if (tm == null)
                {
                    return(false);
                }

                if (ts.GetValue() <= 0)
                {
                    return(false);
                }

                return(true);
            }
                    )
                );
        }
Ejemplo n.º 2
0
        public ChannelCreateViewModel(INavigationService navigator,
                                      INotificationManager manager,
                                      IDialogs dialogs)
        {
            this.Create = ReactiveCommand.CreateFromTask
                          (
                async() =>
            {
                await manager.AddChannel(this.ToChannel());
                await navigator.GoBack();
            },
                this.WhenAny(
                    x => x.Identifier,
                    x => x.Description,
                    (id, desc) =>
                    !id.GetValue().IsEmpty() &&
                    !desc.GetValue().IsEmpty()
                    )
                          );

            this.PickImportance = dialogs.PickEnumValueCommand <ChannelImportance>(
                "Importance",
                x => this.Importance = x.ToString()
                );

            this.PickActionType1 = dialogs.PickEnumValueCommand <ChannelActionType>(
                "Action Type",
                x => this.Action1ActionType = x.ToString(),
                this.WhenAny(
                    x => x.UseAction1,
                    x => x.GetValue()
                    )
                );
            this.PickActionType2 = dialogs.PickEnumValueCommand <ChannelActionType>(
                "Action Type",
                x => this.Action2ActionType = x.ToString(),
                this.WhenAny(
                    x => x.UseAction2,
                    x => x.GetValue()
                    )
                );
        }