List <Task> SelectedTasks() { List <Task> result = new List <Task>(); int hr = VSConstants.S_OK; IVsTaskList2 taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; IVsEnumTaskItems enumerator = null; hr = taskList.EnumSelectedItems(out enumerator); Debug.Assert(hr == VSConstants.S_OK, "EnumSelectedItems did not return S_OK."); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { Task task = items[0] as Task; if (task != null) { result.Add(task); } } return(result); }
static public List <IVsTaskItem> TasksFromEnumerator(IVsEnumTaskItems enumerator) { List <IVsTaskItem> result = new List <IVsTaskItem>(); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { result.Add(items[0]); } return(result); }
private void IgnoreSelectedItems(bool ignore) { int hr = VSConstants.S_OK; IVsTaskList2 taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList2; IVsEnumTaskItems enumerator = null; hr = taskList.EnumSelectedItems(out enumerator); Debug.Assert(hr == VSConstants.S_OK, "EnumSelectedItems did not return S_OK."); IVsTaskItem[] items = new IVsTaskItem[] { null }; uint[] fetched = new uint[] { 0 }; for (enumerator.Reset(); enumerator.Next(1, items, fetched) == VSConstants.S_OK && fetched[0] == 1; /*nothing*/) { Task task = items[0] as Task; if (task != null) { task.Ignored = ignore; } } Refresh(); }