public override void AddToTree(Shape s, bool allowAddInChildren)
        {
            //make s into an rcomponent for access to wrapper
            VisioShape shapeComponent = new VisioShape(Page)
            {
                Shape = s
            };

            if (shapeComponent.Index == Index)
            {
                if (CheckBoxComponent.IsCheckBoxComponent(s.Name))
                {
                    if (Children.All(c => c.Index != shapeComponent.Index)) //there is no stub with this index
                    {
                        Children.Add(new CheckBoxComponent(Page, s));
                    }
                    else
                    {
                        //remove stub, insert s as new containers
                        CheckBoxStubComponent stub = (CheckBoxStubComponent)Children.First(c => c.Index == shapeComponent.Index);
                        Children.Remove(stub);
                        CheckBoxComponent con = new CheckBoxComponent(Page, s);
                        if (Children.Count < con.Index) //TODO implement index
                        {
                            Children.Add(con);
                        }
                        else
                        {
                            Children.Insert(con.Index, con);
                        }
                    }
                }
                else if (PlanningItemTextComponent.IsPlanningItemTextComponent(s.Name))
                {
                    PlanningItemTextComponent com = new PlanningItemTextComponent(Page, s);
                    if (com.Index == Index) //TODO implement index
                    {
                        Children.Add(com);
                    }
                }
                else
                {
                    if (CheckBoxStateComponent.IsCheckBoxStateComponent(s.Name) && Children.All(c => c.Index != shapeComponent.Index)) //if parent not exists
                    {
                        CheckBoxStubComponent stub = new CheckBoxStubComponent(Page, shapeComponent.Index);
                        Children.Insert(stub.Index, stub);
                        Children.ForEach(r => r.AddToTree(s, allowAddInChildren));
                    }
                    else
                    {
                        Children.ForEach(r => r.AddToTree(s, allowAddInChildren));
                    }
                }
            }
        }
        public PlanningItemComponent(Page page, Shape planningItem) : base(page, false)
        {
            Shape = planningItem;
            string name       = null;
            bool?  checkedBox = null;

            foreach (int shapeIdentifier in planningItem.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested))
            {
                Shape planningItemComponent = page.Shapes.ItemFromID[shapeIdentifier];
                if (CheckBoxComponent.IsCheckBoxComponent(planningItemComponent.Name))
                {
                    CheckBoxComponent cbComponent = new CheckBoxComponent(page, planningItemComponent);
                    Children.Add(cbComponent);
                    checkedBox = cbComponent.Checked;
                }

                if (PlanningItemTextComponent.IsPlanningItemTextComponent(planningItemComponent.Name))
                {
                    PlanningItemTextComponent itemContent = new PlanningItemTextComponent(page, planningItemComponent);
                    Children.Add(itemContent);
                    name = itemContent.Text;
                }
            }
            if ((name != null) && (checkedBox != null))
            {
                PlanningItem item = new PlanningItem(name, checkedBox.Value, Id);

                if (Index <= Globals.RationallyAddIn.Model.PlanningItems.Count)
                {
                    Globals.RationallyAddIn.Model.PlanningItems.Insert(Index, item);
                }
                else
                {
                    Globals.RationallyAddIn.Model.PlanningItems.Add(item);
                }
            }



            InitStyle();
        }
Exemplo n.º 3
0
        public override void AddToTree(Shape s, bool allowAddOfSubpart)
        {
            //make s into an rcomponent for access to wrapper
            VisioShape shapeComponent = new VisioShape(Page)
            {
                Shape = s
            };

            if (PlanningItemComponent.IsPlanningItem(s.Name))
            {
                if (Children.All(c => c.Index != shapeComponent.Index))     //there is no forcecontainer stub with this index
                {
                    Children.Add(new PlanningItemComponent(Page, s));
                }
                else
                {
                    //remove stub, insert s as new containers
                    PlanningStubItem stub = (PlanningStubItem)Children.First(c => c.Index == shapeComponent.Index);
                    Children.Remove(stub);
                    PlanningItemComponent con = new PlanningItemComponent(Page, s);
                    if (Children.Count < con.Index)
                    {
                        Children.Add(con);
                    }
                    else
                    {
                        Children.Insert(con.Index, con);
                    }
                }
            }
            else
            {
                bool isPlanningChild = CheckBoxComponent.IsCheckBoxComponent(s.Name) || PlanningItemTextComponent.IsPlanningItemTextComponent(s.Name);

                if (isPlanningChild && Children.All(c => c.Index != shapeComponent.Index))     //if parent not exists
                {
                    PlanningStubItem stub = new PlanningStubItem(Page, shapeComponent.Index);
                    Children.Insert(stub.Index, stub);
                    Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart));
                }
                else
                {
                    Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart));
                }
            }
        }