当前位置: 首页>>代码示例>>C#>>正文


C# ProjectManager.IndexOf方法代码示例

本文整理汇总了C#中ProjectManager.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectManager.IndexOf方法的具体用法?C# ProjectManager.IndexOf怎么用?C# ProjectManager.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectManager的用法示例。


在下文中一共展示了ProjectManager.IndexOf方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SubGroupOrdering

        public void SubGroupOrdering()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();

            // create tasks in random order
            var a = new Task();
            var b = new Task();
            var c1 = new Task();
            var c2 = new Task();
            var d1 = new Task();
            var d2 = new Task();
            var d3 = new Task();
            var e1 = new Task();
            var e2 = new Task();
            var e3 = new Task();

            manager.Add(b);
            manager.Add(e1);
            manager.Add(a);
            manager.Add(e2);
            manager.Add(c1);
            manager.Add(d1);
            manager.Add(d2);
            manager.Add(e3);
            manager.Add(d3);
            manager.Add(c2);

            // setup: make sub groups
            manager.Group(a, b);
            manager.Group(b, c1);
            manager.Group(b, c2);
            manager.Group(c1, d1);
            manager.Group(c1, d2);
            manager.Group(c2, d3);
            manager.Group(d1, e1);
            manager.Group(d2, e2);
            manager.Group(d2, e3);

            // setup: make sub groups
            manager.Group(a, b);
            manager.Group(b, c1);
            manager.Group(b, c2);
            manager.Group(c1, d1);
            manager.Group(c1, d2);
            manager.Group(c2, d3);
            manager.Group(d1, e1);
            manager.Group(d2, e2);
            manager.Group(d2, e3);

            // test: check that order is correct
            Assert.IsTrue(manager.IndexOf(a) == 0, string.Format("Order a = {0} != {1}", manager.IndexOf(a), 0));
            Assert.IsTrue(manager.IndexOf(b) == 1, string.Format("Order a = {0} != {1}", manager.IndexOf(b), 1));
            Assert.IsTrue(manager.IndexOf(c1) == 2, string.Format("Order a = {0} != {1}", manager.IndexOf(c1), 2));
            Assert.IsTrue(manager.IndexOf(d1) == 3, string.Format("Order a = {0} != {1}", manager.IndexOf(d1), 3));
            Assert.IsTrue(manager.IndexOf(e1) == 4, string.Format("Order a = {0} != {1}", manager.IndexOf(d2), 4));
            Assert.IsTrue(manager.IndexOf(d2) == 5, string.Format("Order a = {0} != {1}", manager.IndexOf(d3), 5));
            Assert.IsTrue(manager.IndexOf(e2) == 6, string.Format("Order a = {0} != {1}", manager.IndexOf(e1), 6));
            Assert.IsTrue(manager.IndexOf(e3) == 7, string.Format("Order a = {0} != {1}", manager.IndexOf(e2), 7));
            Assert.IsTrue(manager.IndexOf(c2) == 8, string.Format("Order a = {0} != {1}", manager.IndexOf(e3), 8));
            Assert.IsTrue(manager.IndexOf(d3) == 9, string.Format("Order a = {0} != {1}", manager.IndexOf(a), 9));
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:61,代码来源:ProjectTest.cs

示例2: GroupTaskLevelAndOrdering

        public void GroupTaskLevelAndOrdering()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();

            var zero = new Task() { Name = "zero" };
            var one = new Task() { Name = "one" };
            var two = new Task() { Name = "two" };
            var three = new Task() { Name = "three" };
            var four = new Task() { Name = "four" };
            var five = new Task() { Name = "five" };

            manager.Add(zero);
            manager.Add(one);
            manager.Add(two);
            manager.Add(three);
            manager.Add(four);
            manager.Add(five);

            // single level ordering
            Assert.IsTrue(manager.IndexOf(zero) == 0);
            Assert.IsTrue(manager.IndexOf(one) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);
            Assert.IsTrue(manager.IndexOf(three) == 3);
            Assert.IsTrue(manager.IndexOf(four) == 4);
            Assert.IsTrue(manager.IndexOf(five) == 5);
            Assert.IsTrue(manager.Tasks.Count() == 6);

            // two level ordering
            manager.Group(zero, two);
            manager.Group(zero, three);
            Assert.IsTrue(manager.IndexOf(zero) == 0);
            Assert.IsTrue(manager.IndexOf(two) == 1);
            Assert.IsTrue(manager.IndexOf(three) == 2);
            Assert.IsTrue(manager.IndexOf(one) == 3);
            Assert.IsTrue(manager.IndexOf(four) == 4);
            Assert.IsTrue(manager.IndexOf(five) == 5);
            Assert.IsTrue(manager.Tasks.Count() == 6);

            // three level ordering
            manager.Group(five, zero);
            Assert.IsTrue(manager.IndexOf(one) == 0);
            Assert.IsTrue(manager.IndexOf(four) == 1);
            Assert.IsTrue(manager.IndexOf(five) == 2, string.Format("Assert index == {0}; but index == {1}", 0, manager.IndexOf(five)));
            Assert.IsTrue(manager.IndexOf(zero) == 3);
            Assert.IsTrue(manager.IndexOf(two) == 4);
            Assert.IsTrue(manager.IndexOf(three) == 5);
            Assert.IsTrue(manager.Tasks.Count() == 6);

            // twin three level ordering
            manager.Group(four, one);
            Assert.IsTrue(manager.IndexOf(four) == 0);
            Assert.IsTrue(manager.IndexOf(one) == 1);
            Assert.IsTrue(manager.IndexOf(five) == 2, string.Format("Assert index == {0}; but index == {1}", 0, manager.IndexOf(five)));
            Assert.IsTrue(manager.IndexOf(zero) == 3);
            Assert.IsTrue(manager.IndexOf(two) == 4);
            Assert.IsTrue(manager.IndexOf(three) == 5);
            Assert.IsTrue(manager.Tasks.Count() == 6);

            // four level ordering
            manager.Group(two, four);
            Assert.IsTrue(manager.IndexOf(five) == 0, string.Format("Assert index == {0}; but index == {1}", 0, manager.IndexOf(five)));
            Assert.IsTrue(manager.IndexOf(zero) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);
            Assert.IsTrue(manager.IndexOf(four) == 3);
            Assert.IsTrue(manager.IndexOf(one) == 4);
            Assert.IsTrue(manager.IndexOf(three) == 5);
            Assert.IsTrue(manager.Tasks.Count() == 6, string.Format("{0} != {1}", 6, manager.Tasks.Count()));

            // check parents
            Assert.IsTrue(manager.ParentOf(zero).Equals(five));
            Assert.IsTrue(manager.ParentOf(one).Equals(four));
            Assert.IsTrue(manager.ParentOf(two).Equals(zero));
            Assert.IsTrue(manager.ParentOf(three).Equals(zero));
            Assert.IsTrue(manager.ParentOf(four).Equals(two));
            Assert.IsTrue(manager.ParentOf(five) == null);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:76,代码来源:ProjectTest.cs

示例3: MoveTasksAroundSingleLevel

        public void MoveTasksAroundSingleLevel()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();

            // create tasks
            var one = new Task() { Name = "one" };
            var two = new Task() { Name = "one" };
            var three = new Task() { Name = "one" };

            manager.Add(one);
            manager.Add(two);
            manager.Add(three);

            // get index of one
            Assert.IsTrue(manager.IndexOf(one) == 0);
            Assert.IsTrue(manager.IndexOf(two) == 1);
            Assert.IsTrue(manager.IndexOf(three) == 2);
            // move by 1 offset each time
            manager.Move(one, 1);
            Assert.IsTrue(manager.IndexOf(two) == 0, string.Format("{0} != {1}", 0, manager.IndexOf(two)));
            Assert.IsTrue(manager.IndexOf(one) == 1, string.Format("{0} != {1}", 1, manager.IndexOf(one)));
            Assert.IsTrue(manager.IndexOf(three) == 2, string.Format("{0} != {1}", 2, manager.IndexOf(three)));
            manager.Move(one, 1);
            Assert.IsTrue(manager.IndexOf(two) == 0);
            Assert.IsTrue(manager.IndexOf(three) == 1);
            Assert.IsTrue(manager.IndexOf(one) == 2);
            manager.Move(one, 1);
            Assert.IsTrue(manager.IndexOf(two) == 0);
            Assert.IsTrue(manager.IndexOf(three) == 1);
            Assert.IsTrue(manager.IndexOf(one) == 2);

            // move by 1 offset each time
            manager.Move(two, 1);
            Assert.IsTrue(manager.IndexOf(three) == 0);
            Assert.IsTrue(manager.IndexOf(two) == 1);
            Assert.IsTrue(manager.IndexOf(one) == 2);
            manager.Move(two, 1);
            Assert.IsTrue(manager.IndexOf(three) == 0);
            Assert.IsTrue(manager.IndexOf(one) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);
            manager.Move(two, 1);
            Assert.IsTrue(manager.IndexOf(three) == 0);
            Assert.IsTrue(manager.IndexOf(one) == 1, string.Format("{0} != {1}", 1, manager.IndexOf(one)));
            Assert.IsTrue(manager.IndexOf(two) == 2, string.Format("{0} != {1}", 2, manager.IndexOf(two)));

            // move by -1 offset each time
            manager.Move(two, -1);
            Assert.IsTrue(manager.IndexOf(three) == 0);
            Assert.IsTrue(manager.IndexOf(two) == 1);
            Assert.IsTrue(manager.IndexOf(one) == 2);
            manager.Move(two, -1);
            Assert.IsTrue(manager.IndexOf(two) == 0);
            Assert.IsTrue(manager.IndexOf(three) == 1);
            Assert.IsTrue(manager.IndexOf(one) == 2);
            manager.Move(two, -1);
            Assert.IsTrue(manager.IndexOf(two) == 0);
            Assert.IsTrue(manager.IndexOf(three) == 1);
            Assert.IsTrue(manager.IndexOf(one) == 2);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:59,代码来源:ProjectTest.cs

示例4: MoveSingleTaskToCheckForOutOfBoundHandling

        public void MoveSingleTaskToCheckForOutOfBoundHandling()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();

            // create a task
            var first = new Task();
            manager.Add(first);
            Assert.IsTrue(manager.Tasks.Count() == 1);

            // get task index
            var index = manager.IndexOf(first);
            Assert.IsTrue(index == 0, string.Format("Task index should be {0}, but is {1}", 0, index));

            // move task by 0 offset
            manager.Move(first, 0);
            index = manager.IndexOf(first);
            Assert.IsTrue(index == 0);

            // move task by negative offset
            manager.Move(first, -1);
            index = manager.IndexOf(first);
            Assert.IsTrue(index == 0);

            // move task by count offset
            manager.Move(first, 1);
            index = manager.IndexOf(first);
            Assert.IsTrue(index == 0);

            // move task by positive offset more than count
            manager.Move(first, 2);
            index = manager.IndexOf(first);
            Assert.IsTrue(index == 0);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:33,代码来源:ProjectTest.cs

示例5: MovePartBecomeMoveSplitTask

        public void MovePartBecomeMoveSplitTask()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            var one = new Task();
            var two = new Task();
            var split = new Task();
            var part1 = new Task();
            var part2 = new Task();
            manager.Add(one);
            manager.Add(two);
            manager.Add(split);

            // setup: create split task
            manager.Split(split, part1, part2, 1);
            Assert.IsTrue(manager.IsSplit(split));
            Assert.IsTrue(manager.IsPart(part1));
            Assert.IsTrue(manager.IsPart(part2));
            Assert.IsTrue(manager.IndexOf(one) == 0);
            Assert.IsTrue(manager.IndexOf(two) == 1);
            Assert.IsTrue(manager.IndexOf(split) == 2);
            Assert.IsTrue(manager.IndexOf(part1) == -1);
            Assert.IsTrue(manager.IndexOf(part2) == -1);

            // test: move part and expect split task to move instead
            manager.Move(split, -1);
            Assert.IsTrue(manager.IndexOf(one) == 0);
            Assert.IsTrue(manager.IndexOf(split) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);

            // test: move again
            manager.Move(split, -1);
            Assert.IsTrue(manager.IndexOf(split) == 0);
            Assert.IsTrue(manager.IndexOf(one) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);

            // test: move again (no effect, reached the top)
            manager.Move(split, -1);
            Assert.IsTrue(manager.IndexOf(split) == 0);
            Assert.IsTrue(manager.IndexOf(one) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);

            // test: move down
            manager.Move(split, 1);
            Assert.IsTrue(manager.IndexOf(one) == 0);
            Assert.IsTrue(manager.IndexOf(split) == 1);
            Assert.IsTrue(manager.IndexOf(two) == 2);

            // test: move out of bounds
            manager.Move(split, 2);
            Assert.IsTrue(manager.IndexOf(one) == 0);
            Assert.IsTrue(manager.IndexOf(two) == 1);
            Assert.IsTrue(manager.IndexOf(split) == 2);
        }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:53,代码来源:ProjectTest.cs

示例6: MoveNonExistingTask

 public void MoveNonExistingTask()
 {
     IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
     var task = new Task();
     manager.Move(task, 1);
     Assert.IsTrue(manager.IndexOf(task) == -1);
 }
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:7,代码来源:ProjectTest.cs

示例7: MoveGroupsAround

        public void MoveGroupsAround()
        {
            IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
            // groups
            var group1 = new Task() { Name = "group1" };
            var group2 = new Task() { Name = "group2" };
            var group3 = new Task() { Name = "group3" };
            // group 1 tasks
            var g1t1 = new Task() { Name = "g1t1" };
            var g1t2 = new Task() { Name = "g1t2" };
            var g1t3 = new Task() { Name = "g1t3" };
            // group 2 tasks
            var g2t1 = new Task() { Name = "g2t1" };
            var g2t2 = new Task() { Name = "g2t2" };
            var g2t3 = new Task() { Name = "g2t3" };
            // group 3 tasks
            var g3t1 = new Task() { Name = "g3t1" };
            var g3t2 = new Task() { Name = "g3t2" };
            var g3t3 = new Task() { Name = "g3t3" };

            manager.Add(group1);
            manager.Add(group2);
            manager.Add(group3);
            manager.Add(g1t1);
            manager.Add(g1t2);
            manager.Add(g1t3);
            manager.Add(g2t1);
            manager.Add(g2t2);
            manager.Add(g2t3);
            manager.Add(g3t1);
            manager.Add(g3t2);
            manager.Add(g3t3);

            // make groups
            manager.Group(group1, g1t1);
            manager.Group(group1, g1t2);
            manager.Group(group1, g1t3);
            // make groups
            manager.Group(group2, g2t1);
            manager.Group(group2, g2t2);
            manager.Group(group2, g2t3);
            // make groups
            manager.Group(group3, g3t1);
            manager.Group(group3, g3t2);
            manager.Group(group3, g3t3);

            // confirm parents
            Assert.IsTrue(manager.ParentOf(group1) == null);
            Assert.IsTrue(manager.ParentOf(group2) == null);
            Assert.IsTrue(manager.ParentOf(group3) == null);
            Assert.IsTrue(manager.ParentOf(g1t1) == group1);
            Assert.IsTrue(manager.ParentOf(g1t2) == group1);
            Assert.IsTrue(manager.ParentOf(g1t3) == group1);
            Assert.IsTrue(manager.ParentOf(g2t1) == group2);
            Assert.IsTrue(manager.ParentOf(g2t2) == group2);
            Assert.IsTrue(manager.ParentOf(g2t3) == group2);
            Assert.IsTrue(manager.ParentOf(g3t1) == group3);
            Assert.IsTrue(manager.ParentOf(g3t2) == group3);
            Assert.IsTrue(manager.ParentOf(g3t3) == group3);

            // confirm order
            Assert.IsTrue(manager.IndexOf(group1) == 0);
            Assert.IsTrue(manager.IndexOf(g1t1) == 1);
            Assert.IsTrue(manager.IndexOf(g1t2) == 2);
            Assert.IsTrue(manager.IndexOf(g1t3) == 3);
            Assert.IsTrue(manager.IndexOf(group2) == 4);
            Assert.IsTrue(manager.IndexOf(g2t1) == 5);
            Assert.IsTrue(manager.IndexOf(g2t2) == 6);
            Assert.IsTrue(manager.IndexOf(g2t3) == 7);
            Assert.IsTrue(manager.IndexOf(group3) == 8);
            Assert.IsTrue(manager.IndexOf(g3t1) == 9);
            Assert.IsTrue(manager.IndexOf(g3t2) == 10);
            Assert.IsTrue(manager.IndexOf(g3t3) == 11);

            // move group under itself 1 (not allowed)
            manager.Move(group1, 1);
            Assert.IsTrue(manager.IndexOf(group1) == 0, string.Format("{0} != {1}", 0, manager.IndexOf(group1)));
            Assert.IsTrue(manager.IndexOf(g1t1) == 1);
            Assert.IsTrue(manager.IndexOf(g1t2) == 2);
            Assert.IsTrue(manager.IndexOf(g1t3) == 3);
            Assert.IsTrue(manager.IndexOf(group2) == 4);
            Assert.IsTrue(manager.IndexOf(g2t1) == 5);
            Assert.IsTrue(manager.IndexOf(g2t2) == 6);
            Assert.IsTrue(manager.IndexOf(g2t3) == 7);
            Assert.IsTrue(manager.IndexOf(group3) == 8);
            Assert.IsTrue(manager.IndexOf(g3t1) == 9);
            Assert.IsTrue(manager.IndexOf(g3t2) == 10);
            Assert.IsTrue(manager.IndexOf(g3t3) == 11);

            // move group under itself 2 (not allowed)
            manager.Move(group1, 2);
            Assert.IsTrue(manager.IndexOf(group1) == 0);
            Assert.IsTrue(manager.IndexOf(g1t1) == 1);
            Assert.IsTrue(manager.IndexOf(g1t2) == 2);
            Assert.IsTrue(manager.IndexOf(g1t3) == 3);
            Assert.IsTrue(manager.IndexOf(group2) == 4);
            Assert.IsTrue(manager.IndexOf(g2t1) == 5);
            Assert.IsTrue(manager.IndexOf(g2t2) == 6);
            Assert.IsTrue(manager.IndexOf(g2t3) == 7);
            Assert.IsTrue(manager.IndexOf(group3) == 8);
//.........这里部分代码省略.........
开发者ID:JackWangCUMT,项目名称:NetGanttControl,代码行数:101,代码来源:ProjectTest.cs


注:本文中的ProjectManager.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。