コード例 #1
0
 void OnCollectionChanged(TaskCollection collection, CollectionChangedEventArgs e)
 {
     if (e.Element is TaskCollection)
     {
         if (e.Removed)
         {
             if (0 == _collection.Count(x => x is TaskCollection))
             {
                 _empty = true;
                 base.OnPropertyChanged("IsEmpty");
             }
         }
         else
         {
             if (_expanded)
             {
                 this.Add(new CollectionTreeViewModel(e.Element as TaskCollection, _repository, _dialog));
             }
             if (_empty)
             {
                 _empty = false;
                 base.OnPropertyChanged("IsEmpty");
             }
         }
     }
 }
コード例 #2
0
ファイル: TaskViewModel.cs プロジェクト: radtek/Octopus
        public void InsertTask()
        {
            OctopusLib.Task newTask = new OctopusLib.Task
            {
                Name                 = string.Format("New Task {0}", TaskCollection.Count() + 1),
                IsEnabled            = true,
                TaskActionCollection = new ObservableCollectionEx <OctopusLib.TaskAction>(),
                Machines             = new ObservableCollectionEx <Machine>(),
                Sequence             = 0,
            };
            this.SelectedRow = newTask;
            this.TaskCollection.Add(newTask);

            IsModified = true;
            Message    = "New task be added.";
        }
コード例 #3
0
 public CollectionTreeViewModel(TaskCollection taskCollection, TaskRepository repository, IDialogService dialogService)
 {
     if (null == "taskCollection")
     {
         throw new ArgumentNullException("taskCollection");
     }
     if (null == repository)
     {
         throw new ArgumentNullException("repository");
     }
     if (null == dialogService)
     {
         throw new ArgumentNullException("dialogService");
     }
     _dialog     = dialogService;
     _expanded   = false;
     _repository = repository;
     _collection = taskCollection;
     _collection.CollectionChanged += this.OnCollectionChanged;
     _collection.ParentChanged     += this.OnParentChanged;
     _repository.RepositoryChanged += this.OnRepositoryChanged;
     _empty = 0 == _collection.Count(x => x is TaskCollection);
 }
コード例 #4
0
 private void TraversalTaskList()
 {
     Task.Run(async() =>
     {
         while (true)
         {
             if (TaskCollection.Count() == 0)
             {
                 NullTaskNoteVisibility = Visibility.Visible;
                 return;
             }
             NullTaskNoteVisibility = Visibility.Collapsed;
             TaskCollection         = new ObservableCollection <TaskItem <bool> >(TaskCollection.Where(x => x.TaskStatus != TaskStatusEnum.Completed));
             if (TaskCollection.FirstOrDefault(x => x.TaskStatus == TaskStatusEnum.InProgress) != null)
             {
                 continue;
             }
             else
             {
                 await Task.Run(async() =>
                 {
                     var task = TaskCollection.FirstOrDefault(t => t.TaskStatus == TaskStatusEnum.Ready || t.TaskStatus == TaskStatusEnum.Hangup);
                     if (task != null)
                     {
                         if (task.TaskStatus == TaskStatusEnum.Hangup)
                         {
                             task.TaskCancellationTokenSource = new CancellationTokenSource();
                         }
                         task.TaskInstance = TaskExcuteHandler.Invoke(task, task.TaskCancellationTokenSource.Token);
                         await task.TaskInstance;
                     }
                 });
             }
             await Task.Delay(1000);
         }
     });
 }
コード例 #5
0
 public void it_should_have_the_correct_amount_of_tasks()
 {
     Assert.Equal(2, _tasks.Count( ));
 }