public override void AddToTree(Shape s, bool allowAddOfSubpart)
 {
     if (RelatedDocumentTitleComponent.IsRelatedDocumentTitleContainer(s.Name))
     {
         RelatedDocumentTitleComponent com = new RelatedDocumentTitleComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (RelatedFileComponent.IsRelatedFileComponent(s.Name))
     {
         RelatedFileComponent com = new RelatedFileComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (RelatedUrlComponent.IsRelatedUrlComponent(s.Name))
     {
         RelatedUrlComponent com = new RelatedUrlComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
     else if (RelatedURLURLComponent.IsRelatedUrlUrlComponent(s.Name))
     {
         RelatedURLURLComponent com = new RelatedURLURLComponent(Page, s);
         if (com.Index == Index)
         {
             Children.Add(com);
         }
     }
 }
        public RelatedDocumentContainer(Page page, Shape containerShape) : base(page, false)
        {
            Shape = containerShape;
            Array        ident = containerShape.ContainerProperties.GetMemberShapes((int)VisContainerFlags.visContainerFlagsExcludeNested);
            List <Shape> shapes = (new List <int>((int[])ident)).Select(i => page.Shapes.ItemFromID[i]).ToList();
            string       name = null, path = null;
            bool         file       = false;
            Shape        titleShape = shapes.FirstOrDefault(shape => RelatedDocumentTitleComponent.IsRelatedDocumentTitleContainer(shape.Name));

            if (titleShape != null)
            {
                Children.Add(new RelatedDocumentTitleComponent(page, titleShape));
                name = titleShape.Text;
            }

            Shape fileShape = shapes.FirstOrDefault(shape => RelatedFileComponent.IsRelatedFileComponent(shape.Name));

            if (fileShape != null)
            {
                RelatedFileComponent relatedFileComponent = new RelatedFileComponent(page, fileShape);
                Children.Add(relatedFileComponent);
                path = relatedFileComponent.FilePath;
                file = true;
            }
            else
            {
                Shape urlShape = shapes.FirstOrDefault(shape => RelatedUrlComponent.IsRelatedUrlComponent(shape.Name));
                if (urlShape != null)
                {
                    Children.Add(new RelatedUrlComponent(page, urlShape));
                }

                Shape urlUrlShape = shapes.FirstOrDefault(shape => RelatedURLURLComponent.IsRelatedUrlUrlComponent(shape.Name));
                if (urlUrlShape != null)
                {
                    Children.Add(new RelatedURLURLComponent(page, urlUrlShape));
                    path = urlUrlShape.Text;
                }
            }

            if ((name != null) && (path != null))
            {
                RelatedDocument doc = new RelatedDocument(path, name, file, Id);
                if (Index <= Globals.RationallyAddIn.Model.Documents.Count)
                {
                    Globals.RationallyAddIn.Model.Documents.Insert(Index, doc);
                }
                else
                {
                    Globals.RationallyAddIn.Model.Documents.Add(doc);
                }
            }
            MarginTop    = Index == 0 ? 0.3 : 0.0;
            MarginBottom = 0;

            UsedSizingPolicy |= SizingPolicy.ExpandYIfNeeded;
        }
示例#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 (RelatedDocumentContainer.IsRelatedDocumentContainer(s.Name))
            {
                if (Children.All(c => c.Index != shapeComponent.Index)) //there is no container stub with this index
                {
                    RelatedDocumentContainer con = new RelatedDocumentContainer(Page, s);
                    Children.Insert(con.Index, con);
                }
                else
                {
                    //remove stub, insert s as the shape of the stub wrapper
                    RelatedDocumentStubContainer stub = (RelatedDocumentStubContainer)Children.First(c => c.Index == shapeComponent.Index);
                    Children.Remove(stub);
                    RelatedDocumentContainer con = new RelatedDocumentContainer(Page, s);
                    Children.Insert(con.Index, con);
                }
            }
            else
            {
                bool isDocumentChild = RelatedDocumentTitleComponent.IsRelatedDocumentTitleContainer(s.Name) || RelatedFileComponent.IsRelatedFileComponent(s.Name) || RelatedUrlComponent.IsRelatedUrlComponent(s.Name) || RelatedURLURLComponent.IsRelatedUrlUrlComponent(s.Name);

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