Example #1
0
        /// <summary>
        /// ctor
        /// </summary>
        public StepOfFoodConfirmViewModel()
        {
            this._workStepModel = WorkStepModel.GetInstance();

            this.ManipulateFoodModel = new ReactiveProperty <FoodModel>(this._workStepModel.ManipulateFood);

            this.CurrentWorkType = this._workStepModel.ObserveProperty(x => x.CurrentWorkStepsType).Select(x =>
            {
                switch (x)
                {
                case WorkType.Create:
                    return("登録");

                case WorkType.Update:
                    return("変更");

                case WorkType.Delete:
                    return("削除");

                case WorkType.Use:
                    return("使用済");

                case WorkType.None:
                case WorkType.StandBy:
                default:
                    //throw new InvalidOperationException("現在の作業では呼び出せません。");
                    return("----");
                }
            }).ToReactiveProperty();
        }
Example #2
0
        /// <summary>
        /// ctor
        /// </summary>
        public StepOfFoodNameViewModel()
        {
            this._workStepModel = WorkStepModel.GetInstance();

            this.Food = this._workStepModel.ToReactivePropertyAsSynchronized(
                x => x.ManipulateFood,
                convert => convert,
                convertBack => convertBack,
                ReactivePropertyMode.RaiseLatestValueOnSubscribe | ReactivePropertyMode.DistinctUntilChanged,
                false);
        }
        public StepOfFoodBoughtDateViewModel()
        {
            this._workStepModel = WorkStepModel.GetInstance();

            this.Food = this._workStepModel.ToReactivePropertyAsSynchronized(
                m => m.ManipulateFood,
                convert => convert,
                cb => cb,
                ReactivePropertyMode.DistinctUntilChanged | ReactivePropertyMode.RaiseLatestValueOnSubscribe,
                ignoreValidationErrorValue: false);
        }
Example #4
0
        /// <summary>
        /// ctor
        /// </summary>
        public StepOfFoodKindViewModel()
        {
            this._workstepModel = WorkStepModel.GetInstance();

            this.Food = this._workstepModel.ToReactivePropertyAsSynchronized(
                m => m.ManipulateFood,
                convert => convert,
                convertBack => convertBack,
                ReactivePropertyMode.DistinctUntilChanged | ReactivePropertyMode.RaiseLatestValueOnSubscribe,
                false);

            var ttt  = Enum.GetValues(typeof(FoodType));
            var list = new ObservableCollection <FoodType>();

            foreach (FoodType foodType in ttt)
            {
                list.Add(foodType);
            }

            this.FoodKinds = list;
        }
Example #5
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="model"></param>
        public EditPageViewModel()
        {
            // FoodShelfModel関係
            this._foodShelfModel = FoodShelfModel.GetInstance();
            this.Foods           = this._foodShelfModel.FoodCollection
                                   .ToReadOnlyReactiveCollection(_foodShelfModel.FoodCollection.ToCollectionChanged(), System.Reactive.Concurrency.Scheduler.CurrentThread)
                                   .AddTo(this.Disposable);

            this._foodShelfModel.FoodCollection.CollectionChangedAsObservable().Subscribe(x =>
            {
                switch (x.Action)
                {
                // 食材追加時
                case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                    foreach (FoodModel food in x.NewItems)
                    {
                        food.PropertyChanged += this.Afood_PropertyChanged;
                    }
                    break;

                // 食材削除時
                case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                    foreach (FoodModel food in x.OldItems)
                    {
                        food.PropertyChanged -= this.Afood_PropertyChanged;
                    }
                    break;

                // 食材置き換え時
                case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                    foreach (FoodModel food in x.OldItems)
                    {
                        food.PropertyChanged -= this.Afood_PropertyChanged;
                    }
                    foreach (FoodModel food in x.NewItems)
                    {
                        food.PropertyChanged += this.Afood_PropertyChanged;
                    }
                    break;

                // 食材移動時
                case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                    break;

                // 食材リセット時
                case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                    foreach (var food in this._foodShelfModel.FoodCollection)
                    {
                        food.PropertyChanged -= this.Afood_PropertyChanged;
                    }
                    break;

                default:
                    break;
                }
            });

            foreach (var afood in this._foodShelfModel.FoodCollection)
            {
                afood.PropertyChanged += this.Afood_PropertyChanged;
            }

            // WorkStepModel関係
            this._workStepModel = WorkStepModel.GetInstance();
            this.WorkSteps      = this._workStepModel.ObserveProperty(x => x.CurrentWorkSteps).ToReactiveProperty().AddTo(this.Disposable);

            // スタンバイモードでなければスタンバイモードに変更する
            if (this._workStepModel.CurrentWorkStepsType != WorkType.StandBy)
            {
                this._workStepModel.SetStandBy();
            }

            // 選択食材プロパティの購読
            //this.SelectedFood.Subscribe((_) =>
            //{
            //    this.IsSelectedFood.Value = this.SelectedFood?.Value != null;
            //});
            this.IsSelectedFood = this.SelectedFood.Select(x => x != null).ToReactiveProperty().AddTo(this.Disposable);

            // 現在の作業の種類プロパティの購読
            this.CurrentWorkStepsType = this._workStepModel.ObserveProperty(m => m.CurrentWorkStepsType).ToReactiveProperty().AddTo(this.Disposable);
            this.ButtonVisibility     = this.CurrentWorkStepsType.Select(x => x == WorkType.StandBy).ToReactiveProperty().AddTo(this.Disposable);
            this.WorkLoadVisibility   = this.CurrentWorkStepsType.Select(x => x != WorkType.StandBy).ToReactiveProperty().AddTo(this.Disposable);

            // 最後のステップ判定プロパティの購読
            this.IsLastStep = this._workStepModel.ObserveProperty(x => x.IsLastStep).ToReactiveProperty().AddTo(this.Disposable);

            this.NextContent = this.CurrentWorkStepsType.CombineLatest(this.IsLastStep, (currentWorkStepsType, isLastStep) =>
            {
                if (isLastStep == false)
                {
                    return("進む");
                }
                switch (currentWorkStepsType)
                {
                case WorkType.Create:
                    return("登録");

                case WorkType.Update:
                    return("変更");

                case WorkType.Delete:
                    return("削除");

                case WorkType.Use:
                    return("使用済");

                case WorkType.None:
                case WorkType.StandBy:
                default:
                    return("---");
                }
            }).ToReactiveProperty().AddTo(this.Disposable);

            // 登録コマンドの購読
            this.Send_NavigateRegister.Subscribe((x) =>
            {
                if (x is NavigationService navigation)
                {
                    this._workStepModel.NavigateAddWork(navigation);
                }
            });

            // 変更コマンドの購読
            this.Send_ModifyFood.Subscribe((x) =>
            {
                if (x is NavigationService navigation)
                {
                    if (this.SelectedFood.Value != null)
                    {
                        this._workStepModel.NavigateUpdateWork(this.SelectedFood.Value, navigation);
                    }
                }
            });

            // 削除コマンドの購読
            this.Send_RemoveFood.Subscribe((x) =>
            {
                if (x is NavigationService navigation)
                {
                    if (this.SelectedFood.Value != null)
                    {
                        this._workStepModel.NavigateDeleteWork(this.SelectedFood.Value, navigation);
                    }
                }
            });

            // 使用コマンドの購読
            this.Send_SetUsed.Subscribe((x) =>
            {
                if (x is NavigationService navigation)
                {
                    if (this.SelectedFood.Value != null)
                    {
                        this._workStepModel.NavigateUseWork(this.SelectedFood.Value, navigation);
                    }
                }
            });

            // 次へコマンドの購読
            this.Send_NextStep.Subscribe(async(navigationService) =>
            {
                if (navigationService is NavigationService navigation)
                {
                    await this._workStepModel.NextStepAsync(navigation);
                }
            });

            // 戻るコマンドの購読
            this.Send_PrevStep.Subscribe((namevigationService) =>
            {
                if (namevigationService is NavigationService navigation)
                {
                    this._workStepModel.PrevStep(navigation);
                }
            });
        }