private void _onOneOfTheRunSelected(object sender, ASTaskViewModel e) { SelectedRun = e; foreach (var t in Tasks) { if (t != e) { t.IsSelected = false; } } //OnProjectSelected(this); }
public ProjectViewModel(Project m) : this() { _model = m; _tasks = new ObservableCollection <ASTaskViewModel>(); foreach (var tsk in m.Tasks) { var newTask = new ASTaskViewModel(tsk); newTask.RunSelected += _onOneOfTheRunSelected; _tasks.Add(newTask); newTask.Parent = this; } }
public void AddANewTask(string newtaskName) { ASTask newTask = _model.CreatTaskDir(newtaskName); var newTaskViewModel = new ASTaskViewModel(newTask); newTaskViewModel.RunSelected += _onOneOfTheRunSelected; Tasks.Add(newTaskViewModel); newTaskViewModel.Parent = this; this.SelectedRun = newTaskViewModel; Tasks = new ObservableCollection <ASTaskViewModel>(Tasks); newTaskViewModel.IsSelected = true; }
private void _newTaskNameAccepted(object sender, ProjectViewModel e) { _addataskdialogbox.Close(); var newtaskName = ((AddTaskViewModel)sender).NewTaskName; //var TaskExistsFlag = false; ASTaskViewModel taskExist = null; foreach (var task in e.Tasks) { if (task.TaskName == newtaskName) { taskExist = task; //TaskExistsFlag = true; break; } } if (taskExist != null) { var taskCanRun = !taskExist.Model.FindRunGeneratedFile(); if (taskCanRun) { var rsp = MessageBox.Show("Task exists, do you want to overwrite it?", "Warning!", MessageBoxButton.YesNo); if (rsp == MessageBoxResult.Yes) { taskExist.IsSelected = true; } else { _showAddTaskPopupWindow(e); } } else { MessageBox.Show("Task exists, please give a new name!", "Error!", MessageBoxButton.OK); _showAddTaskPopupWindow(e); } } else { SelectedProject = e; e.AddANewTask(newtaskName); //_model.GenerateProjectTree(); //_setupProjectTree(); } }
public void DeleteATask(ASTaskViewModel e) { var dialogResult = MessageBox.Show("Are you sure you want to delete this task: " + e.TaskName + " ?", "Warning!", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { foreach (var task in _model.Tasks) { if (task.TaskName == e.TaskName) { _model.Tasks.Remove(task); _model.RemoveTaskDirRecursively(task.TaskPath); break; } } Tasks.Remove(e); } }
protected virtual void OnRunSelected(ASTaskViewModel e) { RunSelected?.Invoke(this, e); }