示例#1
0
        /// <summary>
        /// ボタン〔編集〕押下処理
        /// </summary>
        private void EditButtonCommandExecute()
        {
            TodoTask clickedTask = null;

            foreach (var task in this.DataGridItemsSource)
            {
                if (task.IsSelected)
                {
                    clickedTask = task;
                }
            }

            var inputValueNotification = new InputValueNotification();

            inputValueNotification.RequestValue = clickedTask;
            this.PopupEditViewRequestTrigger.Raise(inputValueNotification);

            object returnValue = inputValueNotification.ReturnValue;

            if (returnValue is TodoTask)
            {
                TodoTask editedTask = (TodoTask)returnValue;
                if (string.IsNullOrEmpty(editedTask.ID))
                {
                    _dbAccessor_.TodoTaskInsert(editedTask);
                }
                else
                {
                    _dbAccessor_.TodoTaskUpdate(editedTask);
                }
            }

            this.SearchExecute();
        }
        /// <summary>
        /// ビューにバインドされている項目を初期化します
        /// </summary>
        private void InitializeBindings()
        {
            this.DueDate = new ReactiveProperty <DateTime?>();
            // 良い初期化方法があるはず
            this.DueDateHourItemsSource = new ReadOnlyCollection <string>(new List <string> {
                "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"
            });
            this.DueDateMinuteItemsSource = new ReadOnlyCollection <string>(new List <string> {
                "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"
            });
            this.DueDateHour   = new ReactiveProperty <string>();
            this.DueDateMinute = new ReactiveProperty <string>();
            this.Status        = new ReactiveProperty <bool>();
            this.Subject       = new ReactiveProperty <string>();

            this.UpdateCommand = new ReactiveCommand();
            this.CancelCommand = new ReactiveCommand();
            this.AddNewCommand = new ReactiveCommand();

            this.UpdateCommand.Subscribe(() =>
            {
                this.CollectEditControls(ref _editingTodoTask_);
                InputValueNotification inputValueNotification = (InputValueNotification)Notification;
                inputValueNotification.ReturnValue            = this._editingTodoTask_;

                // IInteractionRequestAware を継承しても FinishInteraction が null のままで使用することができないため、この方法を用いる
                // FinishInteraction();
                this.AssociatedWindow.Close();
                //
            });

            this.CancelCommand.Subscribe(() =>
            {
                this.AssociatedWindow.Close();
            });

            this.AddNewCommand.Subscribe(() =>
            {
                this.CollectEditControls(ref _editingTodoTask_);
                this._editingTodoTask_.ID = null;
                InputValueNotification inputValueNotification = (InputValueNotification)Notification;
                inputValueNotification.ReturnValue            = this._editingTodoTask_;
                this.AssociatedWindow.Close();
            });
        }