Example #1
0
        public MainViewModel()
        {
            IsLoading = Visibility.Collapsed;
            NoDeletedItemsVisibility = Visibility.Collapsed;

            //初始化
            NewToDo             = new ToDo();
            CurrentUser         = new MyerListUser();
            MyToDos             = new ObservableCollection <ToDo>();
            DeletedToDos        = new ObservableCollection <ToDo>();
            CurrentDisplayToDos = MyToDos;
            IsInSortMode        = false;

            SelectedCate = 0;

            CateColor      = App.Current.Resources["DefaultColor"] as SolidColorBrush;
            CateColorLight = App.Current.Resources["DefaultColorLight"] as SolidColorBrush;
            CateColorDark  = App.Current.Resources["DefaultColorDark"] as SolidColorBrush;

            //设置当前页面为 To-Do
            SelectedIndex   = 0;
            TodoIconAlpha   = 1;
            DeleteIconAlpha = 0.3;
            Title           = ResourcesHelper.GetString("ToDoPivotItem");

            //按下Enter后
            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.EnterToAdd, act =>
            {
                if (!string.IsNullOrEmpty(NewToDo.Content))
                {
                    OkCommand.Execute(null);
                }
            });

            //完成ToDo
            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.CheckToDo, act =>
            {
                var id = act.Content;
                CheckCommand.Execute(id);
            });

            //删除To-Do
            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.DeleteToDo, act =>
            {
                var id = act.Content;
                DeleteCommand.Execute(id);
            });

            Messenger.Default.Register <GenericMessage <ToDo> >(this, MessengerTokens.ReaddToDo, act =>
            {
                this.NewToDo = act.Content;
                OkCommand.Execute(false);
            });

            Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.CompleteSort, async act =>
            {
                await UpdateOrder();
            });
        }
        public void Check_Execute_ReturnsNotFound()
        {
            _catapultEngine.Setup(e => e.GetJobInQueue()).ReturnsAsync(() => null);

            var console = new TestConsole(_output);
            var command = new CheckCommand(_catapultEngine.Object, console, (new Mock <ILogger <CheckCommand> >()).Object);
            var message = command.Execute();

            Assert.Equal("No job was found in queue.", message);
        }
        public void Check_Execute_ReturnsFoundButNotExecuted()
        {
            _catapultEngine.Setup(e => e.GetJobInQueue()).ReturnsAsync(() => new JobDto {
                ProjectId = 1, Code = "20180817.1"
            });

            var console = new TestConsole(_output, "n");
            var command = new CheckCommand(_catapultEngine.Object, console, (new Mock <ILogger <CheckCommand> >()).Object);
            var message = command.Execute();

            Assert.Equal("Job queue \"20180817.1\" has not been executed.", message);
        }
        private void RegisterMessenger()
        {
            //完成ToDo
            Messenger.Default.Register <GenericMessage <ToDo> >(this, MessengerTokens.CheckToDo, act =>
            {
                CheckCommand.Execute(act.Content);
            });

            //删除To-Do
            Messenger.Default.Register <GenericMessage <ToDo> >(this, MessengerTokens.DeleteToDo, act =>
            {
                DeleteCommand.Execute(act.Content);
            });
            //重新加入已经删除了的
            Messenger.Default.Register <GenericMessage <ToDo> >(this, MessengerTokens.ReAddToDo, act =>
            {
                this.EditedToDo = act.Content;
                OkCommand.Execute(false);
            });
        }
Example #5
0
		private void TapCheckBox_OnTapped(object sender, EventArgs e)
		{
			IsChecked = !IsChecked;
			CheckCommand?.Execute(IsChecked);
		}