Beispiel #1
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 (StakeholderContainer.IsStakeholderContainer(s.Name))
            {
                if (Children.All(c => c.Index != shapeComponent.Index)) //there is no stakeholder stub with this index
                {
                    Children.Add(new StakeholderContainer(Page, s));
                }
                else
                {
                    //remove stub, insert s as new containers
                    StakeholderStubContainer stub = (StakeholderStubContainer)Children.First(c => c.Index == shapeComponent.Index);
                    Children.Remove(stub);
                    StakeholderContainer con = new StakeholderContainer(Page, s);
                    if (Children.Count < con.Index)
                    {
                        Children.Add(con);
                    }
                    else
                    {
                        Children.Insert(con.Index, con);
                    }
                }
            }
            else
            {
                bool isStakeholderChild = StakeholderNameComponent.IsStakeholderName(s.Name) || StakeholderRoleComponent.IsStakeholderRole(s.Name);

                if (isStakeholderChild && Children.All(c => c.Index != shapeComponent.Index)) //if parent not exists
                {
                    StakeholderStubContainer stub = new StakeholderStubContainer(Page, shapeComponent.Index);
                    Children.Insert(stub.Index, stub);
                    Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart));
                }
                else
                {
                    Children.ForEach(r => r.AddToTree(s, allowAddOfSubpart));
                }
            }
        }
 public override void AddToTree(Shape s, bool allowAddInChildren)
 {
     if (StakeholderNameComponent.IsStakeholderName(s.Name))
     {
         StakeholderNameComponent com = new StakeholderNameComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (StakeholderRoleComponent.IsStakeholderRole(s.Name))
     {
         StakeholderRoleComponent com = new StakeholderRoleComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
 }
        public StakeholderContainer(Page page, Shape stakeholder) : base(page, false)
        {
            Shape = stakeholder;
            string name = null;
            string role = null;

            foreach (int shapeIdentifier in stakeholder.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested))
            {
                Shape stakeholderComponent = page.Shapes.ItemFromID[shapeIdentifier];
                if (StakeholderNameComponent.IsStakeholderName(stakeholderComponent.Name))
                {
                    StakeholderNameComponent comp = new StakeholderNameComponent(page, stakeholderComponent);
                    Children.Add(comp);
                    name = comp.Text;
                }
                else if (StakeholderRoleComponent.IsStakeholderRole(stakeholderComponent.Name))
                {
                    StakeholderRoleComponent comp = new StakeholderRoleComponent(page, stakeholderComponent);
                    Children.Add(comp);
                    role = comp.Text;
                }
            }

            if ((name != null) && (role != null))
            {
                Stakeholder newStakeholder = new Stakeholder(name, role, Id);

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

            InitStyle();
        }