本文整理汇总了C#中ProjectManager.Relate方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectManager.Relate方法的具体用法?C# ProjectManager.Relate怎么用?C# ProjectManager.Relate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectManager
的用法示例。
在下文中一共展示了ProjectManager.Relate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdjustDependantScheduleOnRelate
public void AdjustDependantScheduleOnRelate()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task() { Name = "one" };
var two = new Task() { Name = "two" };
manager.Add(one);
manager.Add(two);
// setup: make 2 independant tasks
manager.SetStart(one, 10);
manager.SetDuration(one, 6);
manager.SetStart(two, 10);
manager.SetDuration(two, 10);
Assert.IsTrue(one.Start == 10);
Assert.IsTrue(one.End == 16);
Assert.IsTrue(two.Start == 10);
Assert.IsTrue(two.End == 20);
// test: relate one and two; one before two
manager.Relate(one, two);
Assert.IsTrue(one.Start == 10);
Assert.IsTrue(one.End == 16);
Assert.IsTrue(two.Start == 17);
Assert.IsTrue(two.End == 27);
}
示例2: RemoveExistingRelation
public void RemoveExistingRelation()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
// test: remove relation
manager.Unrelate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 0);
}
示例3: RemoveAllDependantsRelation
public void RemoveAllDependantsRelation()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
var four = new Task();
manager.Add(one);
manager.Add(two);
manager.Add(three);
manager.Add(four);
// setup: create a relationship
manager.Relate(four, one);
manager.Relate(one, two);
manager.Relate(one, three);
Assert.IsTrue(manager.DependantsOf(one).Contains(three));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(three).Contains(one));
Assert.IsTrue(manager.DependantsOf(four).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(one).Contains(four));
// test: remove dependants
manager.Unrelate(one);
Assert.IsTrue(manager.DependantsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(three).Count() == 0);
Assert.IsTrue(manager.DependantsOf(four).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(one).Contains(four));
}
示例4: CannotStartPartBeforeSplitTaskPrecedentStart
public void CannotStartPartBeforeSplitTaskPrecedentStart()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var split = new Task();
var part1 = new Task();
var part2 = new Task();
var precedent = new Task();
manager.Add(split);
manager.Add(precedent);
// setup: create a split task with precendent
manager.SetStart(precedent, 5);
manager.SetDuration(precedent, 5);
manager.SetStart(split, 15);
manager.SetDuration(split, 5);
manager.Relate(precedent, split);
manager.Split(split, part1, part2, 2);
Assert.IsTrue(manager.PrecedentsOf(split).Contains(precedent));
Assert.IsTrue(manager.PartsOf(split).Contains(part1));
Assert.IsTrue(manager.PartsOf(split).Contains(part2));
Assert.IsTrue(precedent.End == 10);
Assert.IsTrue(split.Start == 15);
Assert.IsTrue(part1.Start == 15);
// test: move part1 start before precendent start
manager.SetStart(part1, 8);
Assert.IsTrue(manager.PrecedentsOf(split).Contains(precedent));
Assert.IsTrue(manager.PartsOf(split).Contains(part1));
Assert.IsTrue(manager.PartsOf(split).Contains(part2));
Assert.IsTrue(part1.Start == 11);
Assert.IsTrue(split.Start == 11);
}
示例5: GroupCannotBeRelated
public void GroupCannotBeRelated()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group = new Task();
var member = new Task();
var one = new Task();
manager.Add(group);
manager.Add(member);
manager.Add(one);
// setup: make a group
manager.Group(group, member);
Assert.IsTrue(manager.IsGroup(group));
Assert.IsTrue(manager.IsMember(member));
Assert.IsTrue(!manager.HasRelations(one));
// test: relate a task and a group (not allowed)
manager.Relate(group, one);
Assert.IsTrue(manager.IsGroup(group));
Assert.IsTrue(manager.IsMember(member));
Assert.IsTrue(!manager.HasRelations(group));
Assert.IsTrue(!manager.HasRelations(one));
// test: relate a task and a group, now in another order (not allowed)
manager.Relate(one, group);
Assert.IsTrue(manager.IsGroup(group));
Assert.IsTrue(manager.IsMember(member));
Assert.IsTrue(!manager.HasRelations(group));
Assert.IsTrue(!manager.HasRelations(one));
}
示例6: CreateRelationWithUnknownTasks
public void CreateRelationWithUnknownTasks()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
// test: non-added dependant (no effect)
manager.Relate(one, two);
Assert.IsTrue(manager.HasRelations(one) == false);
Assert.IsTrue(manager.HasRelations(two) == false);
// test: non-added precedent (no effect)
manager.Relate(two, one);
Assert.IsTrue(manager.HasRelations(one) == false);
Assert.IsTrue(manager.HasRelations(two) == false);
}
示例7: CreateRelationThatAlreadyExist
public void CreateRelationThatAlreadyExist()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
// test: re-create the relationship (no effect)
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
}
示例8: Create3LevelRelations
public void Create3LevelRelations()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
manager.Add(one);
manager.Add(two);
manager.Add(three);
// setup: one before two before three
manager.Relate(one, two);
manager.Relate(two, three);
// test: check enumerations are established
Assert.IsTrue(manager.DependantsOf(one).Count() == 2);
Assert.IsTrue(manager.DependantsOf(two).Count() == 1);
Assert.IsTrue(manager.DependantsOf(three).Count() == 0);
Assert.IsTrue(manager.DirectDependantsOf(one).Count() == 1);
Assert.IsTrue(manager.DirectDependantsOf(two).Count() == 1);
Assert.IsTrue(manager.DirectDependantsOf(three).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 1, string.Format("expected {0} != {1}", 1, manager.PrecedentsOf(two).Count()));
Assert.IsTrue(manager.PrecedentsOf(three).Count() == 2);
Assert.IsTrue(manager.DirectPrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.DirectPrecedentsOf(two).Count() == 1);
Assert.IsTrue(manager.DirectPrecedentsOf(three).Count() == 1);
}
示例9: RelateBeforePrecedentEndsLate
public void RelateBeforePrecedentEndsLate()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task() { Name = "one" };
var two = new Task() { Name = "two" };
manager.Add(one);
manager.Add(two);
// setup: set task parameters and set relation
manager.Relate(one, two);
manager.SetStart(one, 10);
manager.SetDuration(one, 5);
manager.SetStart(two, 18);
manager.SetDuration(two, 12);
Assert.IsTrue(one.Start == 10);
Assert.IsTrue(one.End == 15);
Assert.IsTrue(one.Slack == 2, string.Format("Expected {0} != {1}", 2, one.Slack));
Assert.IsTrue(two.Start == 18);
Assert.IsTrue(two.End == 30);
Assert.IsTrue(two.Slack == 0);
}
示例10: PrecendentPushingDependantLater
public void PrecendentPushingDependantLater()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task() { Name = "one" };
var two = new Task() { Name = "two" };
manager.Add(one);
manager.Add(two);
// setup: set task parameters and set relation
manager.Relate(one, two);
manager.SetStart(one, 10);
manager.SetDuration(one, 5);
manager.SetStart(two, 18);
manager.SetDuration(two, 12);
Assert.IsTrue(one.Start == 10);
Assert.IsTrue(one.End == 15);
Assert.IsTrue(one.Slack == 2, string.Format("Expected {0} != {1}", 2, one.Slack));
Assert.IsTrue(two.Start == 18);
Assert.IsTrue(two.End == 30);
Assert.IsTrue(two.Slack == 0);
// test: set one end date further than two start date
manager.SetStart(one, 15);
Assert.IsTrue(one.Start == 15);
Assert.IsTrue(one.End == 20);
Assert.IsTrue(one.Slack == 0, string.Format("Expected {0} != {1}", 1, one.Slack));
Assert.IsTrue(two.Start == 21);
Assert.IsTrue(two.End == 33, string.Format("Expected {0} != {1}", 33, two.End));
Assert.IsTrue(one.Slack == 0);
}
示例11: MovePartLaterThanDependantStart
public void MovePartLaterThanDependantStart()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var split = new Task();
var part1 = new Task();
var part2 = new Task();
var dependant = new Task();
manager.Add(split);
manager.Add(dependant);
// setup: create a dependant on the split task
manager.SetDuration(split, 20);
manager.SetDuration(dependant, 7);
manager.Split(split, part1, part2, 15);
manager.Relate(split, dependant);
Assert.IsTrue(dependant.Start == 22);
Assert.IsTrue(part2.End == 21);
Assert.IsTrue(split.End == 21);
// test: adjust part2 duration beyond dependant start
manager.SetEnd(part2, 25);
Assert.IsTrue(dependant.Start == 26);
Assert.IsTrue(part2.End == 25);
Assert.IsTrue(split.End == 25);
// test: adjust part2 start such that end beyond dependant start
manager.SetStart(part2, 30);
Assert.IsTrue(dependant.Start == 40);
Assert.IsTrue(part2.End == 39);
Assert.IsTrue(split.End == 39);
}
示例12: DependantRescheduledStartEarlierThanPrecedentEnd
public void DependantRescheduledStartEarlierThanPrecedentEnd()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: one before two
manager.Relate(one, two);
manager.SetStart(one, 5);
manager.SetEnd(one, 10);
manager.SetStart(two, 15);
manager.SetDuration(two, 25);
Assert.IsTrue(one.Start == 5);
Assert.IsTrue(one.Duration == 5);
Assert.IsTrue(two.Start == 15);
Assert.IsTrue(two.End == 40);
// test: reschedule two to start before end of one
manager.SetStart(two, 8);
Assert.IsTrue(one.Start == 5);
Assert.IsTrue(one.Duration == 5);
Assert.IsTrue(two.Start == 11);
Assert.IsTrue(two.Duration == 25);
Assert.IsTrue(two.End == 36);
}
示例13: CriticalPath
public void CriticalPath()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
var three = new Task();
var four = new Task();
var five = new Task();
var six = new Task();
var seven = new Task();
var eight = new Task();
var nine = new Task();
var group1 = new Task() { Name = "group1" };
var group2 = new Task() { Name = "group2" };
manager.Add(one);
manager.Add(two);
manager.Add(three);
manager.Add(four);
manager.Add(five);
manager.Add(six);
manager.Add(seven);
manager.Add(eight);
manager.Add(nine);
manager.Add(group1);
manager.Add(group2);
// setup: create some schedules and grouping, and confirm we laid it out correctly
manager.Relate(one, two);
manager.Relate(one, three);
manager.Relate(three, four);
manager.Relate(five, six);
manager.Relate(six, four);
manager.Relate(six, seven);
manager.Relate(six, eight);
manager.Relate(eight, nine);
manager.Group(group1, one);
manager.Group(group1, two);
manager.Group(group1, three);
manager.Group(group1, four);
manager.Group(group2, five);
manager.Group(group2, six);
manager.Group(group2, seven);
manager.Group(group2, eight);
manager.SetStart(one, 0); manager.SetEnd(one, 3);
manager.SetStart(two, 4); manager.SetEnd(two, 7);
manager.SetStart(three, 5); manager.SetEnd(three, 8);
manager.SetStart(four, 10); manager.SetEnd(four, 15);
manager.SetStart(five, 1); manager.SetEnd(five, 5);
manager.SetStart(six, 6); manager.SetEnd(six, 9);
manager.SetStart(seven, 12); manager.SetEnd(seven, 15);
manager.SetStart(eight, 11); manager.SetEnd(eight, 16);
manager.SetStart(nine, 17); manager.SetEnd(nine, 20);
Assert.IsTrue(one.Start == 0 && one.Duration == 3, string.Format("Expected ({0}, {1}) != ({2}, {3})", 0, 3, one.Start, one.Duration));
Assert.IsTrue(two.Start == 4 && two.Duration == 3);
Assert.IsTrue(three.Start == 5 && three.Duration == 3);
Assert.IsTrue(four.Start == 10 && four.Duration == 5);
Assert.IsTrue(five.Start == 1 && five.Duration == 4);
Assert.IsTrue(six.Start == 6 && six.Duration == 3);
Assert.IsTrue(seven.Start == 12 && seven.Duration == 3);
Assert.IsTrue(eight.Start == 11 && eight.Duration == 5);
Assert.IsTrue(nine.Start == 17 && nine.Duration == 3, string.Format("Expected ({0}, {1}) != ({2}, {3})", 17, 3, nine.Start, nine.Duration));
var iter_nine = manager.PrecedentsOf(nine).GetEnumerator(); // nine is critical in this setup
iter_nine.MoveNext(); Assert.IsTrue(iter_nine.Current.Equals(eight));
iter_nine.MoveNext(); Assert.IsTrue(iter_nine.Current.Equals(six));
iter_nine.MoveNext(); Assert.IsTrue(iter_nine.Current.Equals(five));
Assert.IsTrue(iter_nine.MoveNext() == false);
// test: change the critical path and see if it gets updated correctly
manager.SetStart(four, 17); // four now ends later than 9;
var critical_paths = manager.CriticalPaths; // should have 2 paths: 4 to 1; and 4 to 5;
Assert.IsTrue(critical_paths.Count() == 2, string.Format("Expected {0} != {1}", 2, critical_paths.Count()));
var critical_tasks = critical_paths.SelectMany(x => x);
Assert.IsTrue(critical_tasks.Distinct().Count() == 6, string.Format("Expected {0} != {1}", 5, critical_tasks.Distinct().Count())); // 4, 3, 1, 6, 5, group1
Assert.IsTrue(critical_tasks.Contains(four));
Assert.IsTrue(critical_tasks.Contains(three));
Assert.IsTrue(critical_tasks.Contains(one));
Assert.IsTrue(critical_tasks.Contains(six));
Assert.IsTrue(critical_tasks.Contains(five));
Assert.IsTrue(critical_tasks.Contains(group1));
}
示例14: CircularRelationLevel1
public void CircularRelationLevel1()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var one = new Task();
var two = new Task();
manager.Add(one);
manager.Add(two);
// setup: create a relationship
manager.Relate(one, two);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.DependantsOf(one).Count() == 1);
Assert.IsTrue(manager.PrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 1);
Assert.IsTrue(manager.DependantsOf(two).Count() == 0);
// test: cycle the relationship (no effect)
manager.Relate(two, one);
Assert.IsTrue(manager.DependantsOf(one).Contains(two));
Assert.IsTrue(manager.DependantsOf(one).Count() == 1);
Assert.IsTrue(manager.PrecedentsOf(one).Count() == 0);
Assert.IsTrue(manager.PrecedentsOf(two).Contains(one));
Assert.IsTrue(manager.PrecedentsOf(two).Count() == 1);
Assert.IsTrue(manager.DependantsOf(two).Count() == 0);
}
示例15: ExampleFull
/// <summary>
/// Example starts here
/// </summary>
public ExampleFull()
{
InitializeComponent();
// Create a Project and some Tasks
_mManager = new ProjectManager();
var work = new MyTask(_mManager) { Name = "Prepare for Work" };
var wake = new MyTask(_mManager) { Name = "Wake Up" };
var teeth = new MyTask(_mManager) { Name = "Brush Teeth" };
var shower = new MyTask(_mManager) { Name = "Shower" };
var clothes = new MyTask(_mManager) { Name = "Change into New Clothes" };
var hair = new MyTask(_mManager) { Name = "Blow My Hair" };
var pack = new MyTask(_mManager) { Name = "Pack the Suitcase" };
_mManager.Add(work);
_mManager.Add(wake);
_mManager.Add(teeth);
_mManager.Add(shower);
_mManager.Add(clothes);
_mManager.Add(hair);
_mManager.Add(pack);
// Create another 1000 tasks for stress testing
Random rand = new Random();
for (int i = 0; i < 1000; i++)
{
var task = new MyTask(_mManager) { Name = string.Format("New Task {0}", i.ToString()) };
_mManager.Add(task);
_mManager.SetStart(task, rand.Next(300));
_mManager.SetDuration(task, rand.Next(50));
}
// Set task durations, e.g. using ProjectManager methods
_mManager.SetDuration(wake, 3);
_mManager.SetDuration(teeth, 5);
_mManager.SetDuration(shower, 7);
_mManager.SetDuration(clothes, 4);
_mManager.SetDuration(hair, 3);
_mManager.SetDuration(pack, 5);
// demostrate splitting a task
_mManager.Split(pack, new MyTask(_mManager), new MyTask(_mManager), 2);
// Set task complete status, e.g. using newly created properties
wake.Complete = 0.9f;
teeth.Complete = 0.5f;
shower.Complete = 0.4f;
// Give the Tasks some organisation, setting group and precedents
_mManager.Group(work, wake);
_mManager.Group(work, teeth);
_mManager.Group(work, shower);
_mManager.Group(work, clothes);
_mManager.Group(work, hair);
_mManager.Group(work, pack);
_mManager.Relate(wake, teeth);
_mManager.Relate(wake, shower);
_mManager.Relate(shower, clothes);
_mManager.Relate(shower, hair);
_mManager.Relate(hair, pack);
_mManager.Relate(clothes, pack);
// Create and assign Resources.
// MyResource is just custom user class. The API can accept any object as resource.
var jake = new MyResource() { Name = "Jake" };
var peter = new MyResource() { Name = "Peter" };
var john = new MyResource() { Name = "John" };
var lucas = new MyResource() { Name = "Lucas" };
var james = new MyResource() { Name = "James" };
var mary = new MyResource() { Name = "Mary" };
// Add some resources
_mManager.Assign(wake, jake);
_mManager.Assign(wake, peter);
_mManager.Assign(wake, john);
_mManager.Assign(teeth, jake);
_mManager.Assign(teeth, james);
_mManager.Assign(pack, james);
_mManager.Assign(pack, lucas);
_mManager.Assign(shower, mary);
_mManager.Assign(shower, lucas);
_mManager.Assign(shower, john);
// Initialize the Chart with our ProjectManager and CreateTaskDelegate
_mChart.Init(_mManager);
_mChart.CreateTaskDelegate = delegate() { return new MyTask(_mManager); };
// Attach event listeners for events we are interested in
_mChart.TaskMouseOver += new EventHandler<TaskMouseEventArgs>(_mChart_TaskMouseOver);
_mChart.TaskMouseOut += new EventHandler<TaskMouseEventArgs>(_mChart_TaskMouseOut);
_mChart.TaskSelected += new EventHandler<TaskMouseEventArgs>(_mChart_TaskSelected);
_mChart.PaintOverlay += _mOverlay.ChartOverlayPainter;
_mChart.AllowTaskDragDrop = true;
// set some tooltips to show the resources in each task
_mChart.SetToolTip(wake, string.Join(", ", _mManager.ResourcesOf(wake).Select(x => (x as MyResource).Name)));
_mChart.SetToolTip(teeth, string.Join(", ", _mManager.ResourcesOf(teeth).Select(x => (x as MyResource).Name)));
_mChart.SetToolTip(pack, string.Join(", ", _mManager.ResourcesOf(pack).Select(x => (x as MyResource).Name)));
//.........这里部分代码省略.........