Outline Properties
Contents
[
Hide
Show
]Microsoft Project has an outline structure that let users get a quick overview of a project. Aspose.Tasks for C++ API supports this functionality and lets developers control the outline number - where the task appears in a hierarchy - and the outline level - which level of the hierarchy the task is in.
Working with Outline Properties
The Tsk class exposes the OutlineNumber and OutlineLevel properties for managing outlines associated with a class:
- OutlineNumber (string).
- OutlineLevel (integer).
Outlines in Microsoft Project
In Microsoft Project, outline number and outline level properties can be viewed on the Task Entry form by adding the columns:
- On the Insert menu, select columns.
- Add the OutlineNumber and OutlineLevel columns.
Getting Outline Properties in Aspose.Tasks
The following example shows how to get the outline level and outline number information about a task using Aspose.Tasks.
1// Read project from file stream
2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
3System::SharedPtr<System::IO::FileStream> fs = System::MakeObject<System::IO::FileStream>(dataDir + u"TaskOutlineProperties.mpp", System::IO::FileMode::Open);
4System::SharedPtr<Project> prj = System::MakeObject<Project>(fs);
5fs->Close();
6
7// Create a ChildTasksCollector instance
8System::SharedPtr<ChildTasksCollector> collector = System::MakeObject<ChildTasksCollector>();
9
10// Collect all the tasks from RootTask using TaskUtils
11TaskUtils::Apply(prj->get_RootTask(), collector, 0);
12
13// Parse through all the collected tasks
14
15{
16 auto tsk1_enumerator = (collector->get_Tasks())->GetEnumerator();
17 decltype(tsk1_enumerator->get_Current()) tsk1;
18 while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
19 {
20 System::Console::WriteLine(tsk1->Get(Tsk::Name()) + u" - Outline Level : " + tsk1->Get<int32_t>(Tsk::OutlineLevel()));
21 System::Console::WriteLine(tsk1->Get(Tsk::Name()) + u" - Outline Number : " + tsk1->Get(Tsk::OutlineNumber()));
22 }
23}