public override void FillContent()
        {
            ImagePart  imagePart = NewSlidePart.AddImagePart(ImagePartType.Emf, NewImageName + _imgId++);
            FileStream fs        = _diagram.DiagramToStream();

            imagePart.FeedData(fs);
            SwapPhoto(NewSlidePart, NewSlidePart.GetIdOfPart(imagePart));
            SetPlaceholder(NewSlidePart, "{title}", _diagram.Name);

            //cleanup:
            fs.Close();
            File.Delete(fs.Name);
        }
        public void InsertDiagramImage(IEADiagram diagram)
        {
            if (diagram.IsRelationshipView())
            {
                Paragraph     para          = _body.AppendChild(new Paragraph());
                Run           run           = para.AppendChild(new Run());
                RunProperties runProperties = getHeading2(run);
                run.AppendChild(new Text(++_diagmarCounter + ". Relationship View: " + diagram.Name));
                //_body.AppendChild(new Paragraph(new Run(new Text(++_diagmarCounter + ". Relationship Viewpoint"))));
            }
            else if (diagram.IsStakeholderInvolvementView())
            {
                Paragraph     para          = _body.AppendChild(new Paragraph());
                Run           run           = para.AppendChild(new Run());
                RunProperties runProperties = getHeading2(run);
                run.AppendChild(
                    new Text(++_diagmarCounter + ". Decision Stakeholder Involvement View: " + diagram.Name));
                //_body.AppendChild(new Paragraph(new Run(new Text(++_diagmarCounter + ". Decision Stakeholder Involvement Viewpoint"))));
            }
            else if (diagram.IsChronologicalView())
            {
                Paragraph     para          = _body.AppendChild(new Paragraph());
                Run           run           = para.AppendChild(new Run());
                RunProperties runProperties = getHeading2(run);
                run.AppendChild(new Text(++_diagmarCounter + ". Decision Chronological View: " + diagram.Name));
                //_body.AppendChild(new Paragraph(new Run(new Text(++_diagmarCounter + ". Decision Chronological Viewpoint"))));
            }
            else
            {
                return;
            }

            _body.AppendChild(new Paragraph(new Run(new Text())));

            ImagePart  imagePart = _mainPart.AddImagePart(ImagePartType.Emf);
            FileStream fs        = diagram.DiagramToStream();

            imagePart.FeedData(fs);

            Image image = Image.FromFile(fs.Name);

            AddImageToBody(_mainPart.GetIdOfPart(imagePart), Utils.GetImageSize(image));

            //cleanup:
            fs.Close();
            image.Dispose();
            File.Delete(fs.Name);
        }
Esempio n. 3
0
        public void EA_DiagramTests()
        {
            // Properties

            {
                IEADiagram diagram = _e.GetDecisionForcesDiagram();
                Assert.IsTrue(DateTime.Now > diagram.Created);
                Assert.IsTrue(EANativeType.Diagram == diagram.EANativeType);
                Assert.IsTrue("" != diagram.GUID);
                Assert.IsTrue(0 < diagram.ID);
                Assert.IsTrue("" != diagram.Metatype);
                Assert.IsTrue(DateTime.Now > diagram.Modified);
                Assert.IsTrue("" != diagram.Name);
                Assert.IsTrue("" == diagram.Notes);
                Assert.IsNotNull(diagram.ParentElement);
                Assert.IsNotNull(diagram.ParentPackage);
                Assert.IsTrue("" != diagram.Version);
            }

            // Operations

            {
                // IsForcesView / AddElement / Contains / OpenAndSelectElement / HideConnectors / RemoveElement
                IEAPackage package = _e.GetDecisionPackage();
                IEADiagram diagram = _e.GetDecisionForcesDiagram();
                IEAElement element = package.CreateElement("MyNote", "MyStereotype", "Note");
                package.RefreshElements();
                diagram.AddElement(element);
                Assert.IsTrue(diagram.Contains(element));
                diagram.OpenAndSelectElement(element);
                diagram.HideConnectors(new[]
                {
                    EAConstants.RelationAlternativeFor, EAConstants.RelationCausedBy,
                    EAConstants.RelationDependsOn,
                    EAConstants.RelationExcludedBy, EAConstants.RelationReplaces, EAConstants.RelationFollowedBy
                });
                diagram.RemoveElement(element);
                Assert.IsFalse(diagram.Contains(element));
                Assert.IsTrue(deleteElementFromPackage(package, element));
            }

            {
                // ShowInProjectView / DiagramToStream
                IEAPackage package = _e.GetDecisionPackage();
                IEADiagram diagram = _e.GetDecisionForcesDiagram();
                diagram.ShowInProjectView();
                FileStream fs = diagram.DiagramToStream();
                Assert.IsNotNull(fs);
                Assert.IsTrue(fs.Name.Contains(".emf"));
            }

            {
                // GetElements
                IEAPackage package           = _e.GetDecisionPackage();
                IEADiagram diagram           = _e.GetDecisionForcesDiagram();
                List <IEADiagramObject> objs = diagram.GetElements();
                Assert.IsNotNull(objs);
                Assert.IsTrue(0 < objs.Count);
            }

            /* TODO: adjust for Decision Architect MDG
             * {  // IsChronologicalView
             *  IEAPackage package = _e.GetDecisionPackage();
             *  IEADiagram diagram = _e.GetDecisionChronologicalDiagram();
             * }
             *
             * {  // IsRelationshipView
             *  IEAPackage package = _e.GetDecisionPackage();
             *  IEADiagram diagram = _e.GetDecisionRelationshipDiagram();
             * }
             *
             * {  // IsStakeholderInvolvementView
             *  IEAPackage package = _e.GetDecisionPackage();
             *  IEADiagram diagram = _e.GetDecisionStakeholderDiagram();
             * }
             */
        }